[fpc-pascal] Cross-building on from Linux/i386 to Linux/x86-64

patspiper patspiper at gmail.com
Tue May 7 22:43:33 CEST 2013

On 07/05/13 21:01, Jonas Maebe wrote:
> On 07 May 2013, at 19:27, patspiper wrote:
>> It is the other way round. My OS is 32 bit Ubuntu and one of the targets is Linux/x86-64, so I assume you mean the 64 bit paths and not the 32 bit ones.
>> I tried setting CROSSOPT (CROSSOPT="-XR/usr/lib64 -Fl/usr/lib/gcc/i686-linux-gnu/4.7/64"), but the line that fails ("/usr/bin/ld: cannot find -lgcc") is:
>> /home/user1/Programs/fpc/fpsrc/exported/2.7.1/compiler/ppc fpmake.pp -n -Fu/home/user1/Programs/fpc/fpsrc/exported/2.7.1/packages/fpmkunit/units_bs/i386-linux -Fu/home/user1/Programs/fpc/fpsrc/exported/2.7.1/rtl/units/i386-linux -Xd -Xt -gl
>> None of the paths from CROSSOPT are mentioned in the above line.
> That is by design. fpmake runs on the host, not on the target. /home/user1/Programs/fpc/fpsrc/exported/2.7.1/compiler/ppc is a native compiler (so i386->i386 in your case). Options specific to compiling fpmake can be passed using FPMAKEOPT, so add FPMAKEOPT="-Fl/path/to/32bit/libgcc/directory" to your build invocation.

Shouldn't it be FPCMAKEOPT for compiling fpmake.pp? FPMAKEOPT seems to 
pass options to fpmake itself.

Cross compiling for Linux/x86_64 with 
FPCMAKEOPT="-Fl/usr/lib/gcc/i686-linux-gnu/4.7" went past the previous 
error point, but yet yielded another error:

./fpmake compile --localunitdir=.. --os=linux --cpu=x86_64 -o -Px86_64 
-o -XPx86_64-linux- -o -Xr -o -Ur -o -Xs -o -O2 -o -n -o 
-o -Cg -o -Xt -o -dx86_64 -o -dRELEASE 
-bu -sp -o -XX -o -CX
make[2]: *** [smart] Error 216
make[2]: Leaving directory 
make[1]: *** [packages_smart] Error 2
make[1]: Leaving directory `/home/user1/Programs/fpc/fpsrc/exported/2.7.1'
make: *** [build-stamp.x86_64-linux] Error 2

What could be causing this error?

Note: I used the following (part of a script) to build the cross 
compiler (the 1st one triggers the errors):
${MAKE} clean all OS_TARGET=${OS} CPU_TARGET=${CPU} OPT="-Xt" 
>   I also don't know where the "-Xd" comes from in the above compiler invocation. If you added that yourself, remove it again.

I inherited it from the buildcrosssnapshot script found in 
fpcbuild-2.6.2.zip, and never even thought about its effect.
> At most, you can add it to CROSSOPT, but never to OPT (since it tells FPC to not search the standard library paths and OPT is used for "native" compiles, so why would you want the compiler not to search the standard library paths when doing native compiles?). And you don't need it at all, not even in CROSSOPT, if you use -XR in CROSSOPT (or rather: you mustn't use it at all if you use -XR, since that will then prevent the compiler from searching the standard library paths under the alternative root).

I suppose the multiarch root path for Linux/x86_64 should be 
/usr/lib/i686-linux-gnu, but this directory does not exist even on 
Ubuntu 13.04. Any ideas?
>>>> http://bugs.freepascal.org/view.php?id=24372
>>> And does the linker not interpret that parameter correctly? Even if it doesn't, that does not appear to be a problem specific to cross building.
>> I tried to replace the include directive with the actual paths. No improvement. Either it is not needed by the cross building process
> It is most likely completely unrelated to what you are experiencing here.
Once I am able to rebuild the cross compilers, I'll restore the include 
directive and hence find out for sure.

Note: Are crossall, FPMAKEOPT, FPCMAKEOPT, etc.. mentioned in any fpc 
manual? I could not find them.

Thanks for your support!


More information about the fpc-pascal mailing list