* * *

Author Topic: where is my cross compiler ? [SOLVED]  (Read 577 times)

lazer

  • New member
  • *
  • Posts: 25
where is my cross compiler ? [SOLVED]
« on: October 06, 2017, 05:46:01 pm »
As the central issue on my attempts to be able to cross compiler for win64 from linux64, my key issue seems to be that the cross-compiler isn't a cross-compiler at all.

I pulled current trunk fpc built installed to /usr to avoid complications with hacking /etc/fpc.cfg and then breaking the system installed fpc.

Code: Pascal  [Select]
  1. $make distclean
  2. $make clean all OS_TARGET=win64 CPU_TARGET=x86_64
  3. $make crossinstall  OS_TARGET=win64 CPU_TARGET=x86_64  INSTALL_PREFIX=/usr
  4.  
Then when I check the supposed cross-compiler it only supports linux target , which I did not ask for and does not support win64 target which I specified.
Code: Pascal  [Select]
  1. $ /usr/lib/fpc/3.1.1/ppcrossx64  -iTO
  2. linux
  3.  

This would seem to be a fairly simple build option. What am I doing wrong?

thx.
« Last Edit: October 11, 2017, 08:03:28 am by lazer »

Handoko

  • Hero Member
  • *****
  • Posts: 1644
  • My goal: build my own game engine using Lazarus
Re: where is my cross compiler ?
« Reply #1 on: October 06, 2017, 05:52:40 pm »
I am confused, I remember you previously want to cross compile from Windows but now from Linux. But that's okay, I don't know how doing cross compile from Windows but I know from Linux.

01. cd /usr/share/fpcsrc/3.0.2
02. sudo make clean all OS_TARGET=win32 CPU_TARGET=i386
03. sudo make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/usr
04. sudo ln -sf /usr/lib/fpc/3.0.2/ppcross386 /usr/bin/ppcross386

Note:
- Those steps above works for Linux to Win32, I never try to target Win64
- You need to change the "3.0.2" to the version you're using.

After doing the things above, you must rebuild your Lazarus:
Lazarus main menu > Tools > Configure Build Lazarus > Build

-edit-
Have you try this:
https://github.com/cpicanco/stimulus_control/blob/master/docs/compiling/cross_compiling.md
« Last Edit: October 06, 2017, 06:01:34 pm by Handoko »

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #2 on: October 06, 2017, 06:29:06 pm »
thanks for the reply.

I never was intending to build on Win. Some confusion there.
Code: Pascal  [Select]
  1. cd /usr/share/fpcsrc/3.0.4
  2. sudo make clean all OS_TARGET=win64 CPU_TARGET=x86_64
  3. sudo make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=/usr
  4. sudo ln -sf /usr/lib/fpc/3.0.4/ppcrossx64 /usr/bin/ppcrossx64
  5.  

Isn't that basically what I just posted above , it seems to be the same text I was going from ( at another URL ).
I have a fresh trunk svn not the debian src package.

I have found one issue, the Makefile is installing the 64 bit build ( Fed 26 on x86_64) files into /usr/lib not /usr/lib64 as with the distro 3.0.2 , so this does not match the paths in /etc/fpc/cfg.

I've moved them across so I now have :

Code: Pascal  [Select]
  1. $ls /usr/lib64/fpc
  2. 3.0.2  3.1.1
  3.  

but  ...

Code: Pascal  [Select]
  1. /usr/lib64/fpc/3.1.1/ppcrossx64 /back/coredata/hello.pas
  2. Free Pascal Compiler version 3.1.1 [2017/10/06] for x86_64
  3. Copyright (c) 1993-2017 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling /back/coredata/hello.pas
  6. Fatal: Can't find unit system used by Hello
  7. Fatal: Compilation aborted
  8.  

Code: Pascal  [Select]
  1. $ls /usr/lib64/fpc/*/units      
  2. /usr/lib64/fpc/3.0.2/units:
  3. x86_64-linux
  4.  
  5. /usr/lib64/fpc/3.1.1/units:
  6. x86_64-win64
  7.  

Code: Pascal  [Select]
  1. $ls -ail  /usr/lib64/fpc/*/units/*/rtl/system*
  2. 1333486 -rw-r--r--. 1 root root  851472 Mar 27  2017 /usr/lib64/fpc/3.0.2/units/x86_64-linux/rtl/system.o
  3. 1333487 -rw-r--r--. 1 root root  873458 Mar 27  2017 /usr/lib64/fpc/3.0.2/units/x86_64-linux/rtl/system.ppu
  4.  946070 -rw-r--r--. 1 root root 1341962 Oct  6 16:53 /usr/lib64/fpc/3.1.1/units/x86_64-win64/rtl/system.o
  5.  945978 -rw-r--r--. 1 root root  886996 Oct  6 16:53 /usr/lib64/fpc/3.1.1/units/x86_64-win64/rtl/system.ppu
  6.  

3.0.2 can build my hello.pas , 3.1.1 can not , complaining about unit system .

Can you see the problem?

thx

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #3 on: October 06, 2017, 06:33:56 pm »
Code: Pascal  [Select]
  1. /usr/lib64/fpc/3.1.1/ppcrossx64 -iTO
  2. linux

I think I was mis-reading this as being part of the  problem. it is the pre-compiler so IS running on linux.

Handoko

  • Hero Member
  • *****
  • Posts: 1644
  • My goal: build my own game engine using Lazarus
Re: where is my cross compiler ?
« Reply #4 on: October 06, 2017, 06:45:04 pm »
You mention 3.1.1 and 3.0.2, do you install both them together on the same PC? I never use 2 versions together. If I want the other version then I will remove the current version first. And I remember I must restart my Linux or some buggy things may happen. After doing the cross compiling, I usually rebuild my Lazarus and compile the project using Lazarus, because some units may need to rebuilt to target to that platform. Manually compiling using Terminal (or Command Prompt) may work but it is easier using Lazarus.
« Last Edit: October 06, 2017, 06:47:17 pm by Handoko »

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #5 on: October 06, 2017, 06:56:30 pm »
OK , I've found the main error, I still needed to add target and processor options to the command line.
Code: Pascal  [Select]
  1.  
  2. /usr/lib64/fpc/3.1.1/ppcrossx64 -Twin64 -Px86_64 hello.pas
  3. Free Pascal Compiler version 3.1.1 [2017/10/06] for x86_64
  4. Copyright (c) 1993-2017 by Florian Klaempfl and others
  5. Target OS: Win64 for x64
  6.  

I now have a win64 exe file. :phew:

Do you know whether the "x64" covers all  64 CPU for the fpc compiler ?  I'm guessing it does, but not sure.

I may need some more fiddling to get laz to use the right one but I'm half way there.
« Last Edit: October 06, 2017, 06:58:21 pm by lazer »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7679
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: where is my cross compiler ?
« Reply #6 on: October 06, 2017, 07:19:38 pm »
Then when I check the supposed cross-compiler it only supports linux target , which I did not ask for and does not support win64 target which I specified.
-iTO doesn't list all targets, check with -i instead. Every single ppcXXX supports all OSes on that architecture. Remember this is only the compiler, rtl and packages are on the same requirement level but separated.
I have found one issue, the Makefile is installing the 64 bit build ( Fed 26 on x86_64) files into /usr/lib not /usr/lib64 as with the distro 3.0.2 , so this does not match the paths in /etc/fpc/cfg.
The distro packaged one is different then. If you build from source, it will always installs to /usr/lib. FPC directory structure is designed smart enough to install multiple cross compiler toolchain (including host one).
3.0.2 can build my hello.pas , 3.1.1 can not , complaining about unit system .
Call fpc with proper -T and -P (or only -T if you execute ppcXXX).
Do you know whether the "x64" covers all  64 CPU for the fpc compiler ?  I'm guessing it does, but not sure.
Yes, it does (back to my first answer).
« Last Edit: October 06, 2017, 07:21:37 pm by Leledumbo »

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #7 on: October 06, 2017, 08:08:37 pm »
Thanks, I have the two versions in /usr/lib64 now, see above.

That works for my hello.pas passing args -T and -P as you described, to fpc.  The fpc side seems sorted out now. I can use fpc from command line and the -P ensures it gets the right version.

My problem is now with lazarus which seems to be implicitly calling. fpc 3.0.2 with the correct options but there is no account of $fpcversion

when I change the project target in Lazarus I see it is doing essentially the right thing but not using my new build.

Code: Pascal  [Select]
  1. Info: (lazarus) Execute Title="Test: Compiling an empty file"
  2. Info: (lazarus) Working Directory="/tmp/"
  3. Info: (lazarus) Executable="/usr/bin/fpc"
  4. Info: (lazarus) Param[0]="-Twin64"
  5. Info: (lazarus) Param[1]="-Px86_64"
  6. Info: (lazarus) Param[2]="-MObjFPC"
  7. Info: (lazarus) Param[3]="-Scghi"
  8. Info: (lazarus) Param[4]="-O1"
  9.  

do you know how I can configure the project options to include fpc version and reach the right libs?

thx

Leledumbo

  • Hero Member
  • *****
  • Posts: 7679
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: where is my cross compiler ?
« Reply #8 on: October 06, 2017, 08:44:13 pm »
My problem is now with lazarus which seems to be implicitly calling. fpc 3.0.2 with the correct options but there is no account of $fpcversion
...
do you know how I can configure the project options to include fpc version and reach the right libs?
Did you symlink the ppcXXX to /usr/bin (ls -l to double check)? Essentially that's the way you change compiler version, fpc will call corresponding ppcXXX for given -P in directory where it resides.

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #9 on: October 06, 2017, 09:16:58 pm »
I did symlink but I forgot to update it when move it all to /usr/lib64. Good catch. Fixed.

when I hit the test btn in project options dlg I get this:
Code: Pascal  [Select]
  1. HINT: using config file /etc/fpc.cfg
  2. ERROR: compiled FPC unit not found: system.ppu
  3. ERROR: compiled FPC unit not found: objpas.ppu
  4. ERROR: compiled FPC unit not found: sysutils.ppu
  5. ERROR: compiled FPC unit not found: classes.ppu
  6. ERROR: compiled FPC unit not found: avl_tree.ppu
  7. ERROR: compiled FPC unit not found: zstream.ppu
  8.  

those files are present in /usr/lib64/fpc/3.1.1/units/x86_64-win64/rtl

console:
Code: Pascal  [Select]
  1. Info: (lazarus) Param[8]="-Fu/usr/lib64/lazarus/packager/registration/"
  2. Info: (lazarus) Param[9]="-FU/usr/lib64/lazarus/packager/units/x86_64-win64/"
  3. Info: (lazarus) Param[10]="fcllaz.pas"
  4. TIDEFPCParser.ImproveMsgUnitNotFound FindUnitInAllUsesSections failed due to syntax errors or system is not used in /usr/lib64/lazarus/packager/registration/fcllaz.pas
  5. Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 256"
  6. Error: (lazarus) [TMainIDE.DoBuildProject] PkgBoss.DoCompileProjectDependencies failed
  7.  
  8.  
Code: Pascal  [Select]
  1. cat /usr/lib64/lazarus/packager/units/x86_64-win64/*
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <CONFIG>
  4.   <Compiler Value="/usr/bin/fpc" Date="1490647422"/>
  5.   <Params Value=" -Twin64 -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -Fu/usr/lib64/lazarus/packager/registration/ -FU/usr/lib64/lazarus/packager/units/x86_64-win64/ fcllaz.pas"/>
  6.   <Complete Value="False" MainPPUExists="False"/>
  7. </CONFIG>
  8.  

The thing about not finding system unit was what I was seeing with the hello.pas before I got the libs under the same struction in /usr/lib64.

« Last Edit: October 06, 2017, 09:21:13 pm by lazer »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7679
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: where is my cross compiler ?
« Reply #10 on: October 07, 2017, 07:41:20 am »
when I hit the test btn in project options dlg I get this:
Can you still build thr project? If yes, then that test button handler code might need fixes. AFAIK, those messages don't come from the compiler.

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #11 on: October 07, 2017, 10:22:04 am »
No the project will only build for the local platfrom.

When I change TARGET_OS and attempt to build,  the message panel shows:
Code: Pascal  [Select]
  1. Compile package FCL 1.0.1: Exit code 256, Errors: 1
  2. Fatal: Cannot find system used by fcllaz of package FCL.

and I get this on the console:
Code: Pascal  [Select]
  1. TIDEFPCParser.ImproveMsgUnitNotFound FindUnitInAllUsesSections failed due to syntax errors or system is not used in /usr/lib64/lazarus/packager/registration/fcllaz.pas
  2. Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 256"
  3. Error: (lazarus) [TMainIDE.DoBuildProject] PkgBoss.DoCompileProjectDependencies failed
  4. [WARNING] invalid source position for vertical gradient
  5. [WARNING] invalid source position for vertical gradient
  6.  

Neither seems to be actual compiler output.

This seems to be the same problem I had with hello.pas when the libs were in the wrong place ( /usr/l.ib rather than /usr/lib64 as indicated in fpc.cfg ).

It seems odd that command line fpc now finds the correct cross compiler and the system.ppu for win64 but Lazarus does not. Each tree only has one platform's libraries, so this error suggests that it may not be calling the correct fpc version.

Is there any means of getting more direct output ? If I could run a command line it may give a direct indication of the problem.

thx

lazer

  • New member
  • *
  • Posts: 25
Re: where is my cross compiler ?
« Reply #12 on: October 10, 2017, 10:08:36 am »
OK, bottom line is that it seems Lazarus can not find the system libs if the cross-compiler is not the save version as the ppc native compiler. Neither can it sort it self out to build them as it is supposed to do when they are needed.

This means you need to build both ppc and ppcross and set the appropriate symlinks. You can then no long rebuild either because of the version lock on building fpc  >:(

Similarly if I wanted to build the distro ppcross to keep it in sync with the disto fpc I would need to go and find fpc 2.6 to build that !  It's all a bit a run around.

If Lazarus is to be able to cross compile without all this jiving around it needs to be able to cope with native fpc calling different versions of ppc and ppcross, which is what fpc will do in this situation. It currently seems to assume both are the same and goes looking in the wrong place for system.ppu and friends. It also does not build them when the cross TARGET is selected in the GUI, which is what it is advertised as being able to do.

I have now been able to create my win54 exe file but it took a LOT of time to find out what was happening and what was needed.

The resulting exe falls on its arse anyway, but that's another issue.

[EDIT]  Thanks to some help on the mailing list this now runs perfectly on win64. The key factor was to compiler with win32 gui , not gtk2.
« Last Edit: October 11, 2017, 08:03:12 am by lazer »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus