Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-03

Cross compiling Linux to OS X

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

Hi all.

I recently update from fpc 3.0.0 to 3.0.4 (yes, a little late i know...) for our range of application. In order to simplify our build i have a VM with linux running on it and in there i had it setup to crosscompile fra Linux -> Win32/Win64/Linux32/Darwin-i386.

But after the upgrade I can no longer cross-compile the fpc sources to Darwin. I get a linking error that I suspect is related to an old version of binutil (see below for the complete message).

Now my question is if there is someone on the list that has a setup where you can successfully build fpc to cross compile from linux -> mac os x. The guide on the wiki is very outdated so there is not a lot of help to get from there. I can still use the build command below on the sources for 3.0.0, so the previous approach i had seems to still be working.

Best regards
Torsten.

=================== Output ======================

make distclean crossall crossinstall OPT="-O2 -XX -CX -Xs -Xd

-Fl/home/epidata/Apple/SDKs/MacOSX10.5.sdk/usr/lib" CPU_TARGET=i386 OS_TARGET=darwin BINUTILSPREFIX=i686-apple-darwin10- INSTALL_PREFIX=~/fpc FPMAKEOPT="-o -Aas-darwin"

.... lots of lines ...

/home/epidata/FreePascal/release_3_0_4/compiler/ppc fpmake.pp -n -Fu/home/epidata/FreePascal/release_3_0_4/packages/fpmkunit/units_bs/x86_64-linux -Fu/home/epidata/FreePascal/release_3_0_4/rtl/units/x86_64-linux -O2 -XX -CX -Xs -Xd -Fl/home/epidata/Apple/SDKs/MacOSX10.5.sdk/usr/lib /usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/bin/ld: /usr/lib/libc_nonshared.a(elf-init.oS): in function `__libc_csu_init':
(.text+0x2e): undefined reference to `_init'
fpmake.pp(47,1) Error: Error while linking
fpmake.pp(47,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted

Jonas Maebe
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote
> make distclean crossall crossinstall OPT="-O2 -XX -CX -Xs -Xd -Fl/home/epidata/Apple/SDKs/MacOSX10.5.sdk/usr/lib" CPU_TARGET=i386 OS_TARGET=darwin BINUTILSPREFIX=i686-apple-darwin10- INSTALL_PREFIX=~/fpc FPMAKEOPT="-o -Aas-darwin"

It surprises me this works with FPC 3.0, as cross-compilation-specific options should be passed via CROSSOPT instead of OPT.

Anyway, the non-hacky way to specify a cross-compilation sysroot is with -XR instead of -Xd -Fl.

So try this instead:

make distclean crossall crossinstall OPT="-O2 -XX -CX -Xs" CROSSOPT="-XR/home/epidata/Apple/SDKs/MacOSX10.5.sdk -Aas-darwin" CPU_TARGET=i386 OS_TARGET=darwin BINUTILSPREFIX=i686-apple-darwin10- INSTALL_PREFIX=~/fpc

If you split the make invocations into one per command, you can also add -j 4 FPMAKEOPT="-T 4" for "crossall" to significantly speed up the process.

Jonas