[fpc-devel] Cross compiling x86 on amd64, linking to crtbegin.o etc.

Sven Barth pascaldragon at googlemail.com
Wed Jul 11 17:43:52 CEST 2012

Am 11.07.2012 16:36, schrieb Konstantin:
> Hello!
> Free Pascal has been designed to run on several platforms on many
> architectures which is a neat feature. The executable name is chosen
> accordingly - ppc386, ppcx64 etc. to be able to have many at the same
> time on the same system. When building from source it automatically
> detects the platform on which it is running. Unfortunately, when
> building on amd64 you end up with the ppcx64 compiler which can not
> compile for x86 targets.
> I'm using Free Pascal on Gentoo so I created ebuilds (see Gentoo bug
> report here <https://bugs.gentoo.org/show_bug.cgi?id=322971>) to compile
> FPC on amd64 machines for x86 as well if desired. Currently this
> involves compiling everything twice and then install it together. This
> way the advantage of the CPU to be able to run code in 32 bit and 64 bit
> on the same system can be used.
> So first question, is there a better way instead of compiling everything
> twice? Maybe something can be reused?

I'm not used to Gentoo's ebuilds, so I'll tell you from FPC's normal 

if you do a "make all CPU_TARGET=i386" on a x86_64 Linux system then a 
x86_64 -> i386 cross compiler will be created with default system Linux 
and where the compiler binary will be called ppcross386 (instead of 
ppc386). [It works similar on Windows, other targets and other CPUs with 
the only exception that most non-i386 systems can not cross compile to 
i386, because of the missing Extended support; x86_64 on non-Windows can 
though] Only problem might be that the build process and/or the compiler 
does not find the correct binutils, so you might need to help it using 
"CROSSBINDIR=/opt/gcc32" {just an example}). The crosscompiled compiler 
(and its units) is then installed using "make crossinstall 
CPU_TARGET=i386 INSTALL_PREFIX=/whereever/you/want".


More information about the fpc-devel mailing list