[fpc-pascal] Cross compiling x86_64 on i386 Linux.

Bruce Tulloch bruce at causal.com
Wed May 30 01:48:34 CEST 2012


Hi Tony,

I use Debian as my Debian derived distro :-) I agree a minimal chroot
environment for each target is a good solution but it's predicated on
running a 64-bit kernel on the host (which I am trying to avoid so I can
use this setup on a 32-bit capable netbook).

Looks like I might have to abandon the idea (cross compiling for a
x86_64 target on a i386 host) and upgrade my mobile development platform
to something with an x86_64 capable CPU in it :-/

I'll see if Jonas has any more ideas.

Cheers, Bruce.


On 29/05/12 18:40, Tony Whyman wrote:
> Bruce,
> 
> If you are using a Debian derived distribution such as Ubuntu, you might
> find it easier to use debootstrap to create a 64 bit environment on your
> system and compile the program in that environment (see
> https://help.ubuntu.com/community/DebootstrapChroot for a guide). Then
> you can be sure that you have all the correct libraries in their
> standard paths, etc.
> 
> In my set up, I compile for both 64 bit and 32 bit targets on a 64 bit
> machine and have separate debootstrap (chroots) for each target
> environment rather than compile in the development environment. This
> ensures that the final compilation takes place in a known clean
> environment. I also have a chroot for a win32 cross compiler.
> 
> Once you have created the chroot for each target, all you need to do is
> to install the fpc debs in the appropriate environment (64 bit fpc for
> the 64 bit environment, 32 bit for the 32 bit environment), install any
> other libraries you need for the distribution repository and then
> compile the software in each chroot separately. The result will be
> executables built for each target and built in a clean environment. If
> you also want to generate distribution packages (debs), this is also the
> best way to go about it.
> 
> Regards
> 
> Tony Whyman
> MWA Software
> 
> 
> 
> 
> On 29/05/12 03:19, Bruce Tulloch wrote:
>> Closer, but not quite there yet...
>>
>> To get this going I've (sshfs) mounted a 64 bit system on /mnt/engels
>> and then attempted to cross-compile on the 32 bit system with:
>>
>>    fpc -MDelphi -Scgi -CX -O3 -OoUNCERTAIN -OoREGVAR \
>>    -Tlinux -Px86_64 -Xs -XX -va -l \
>>    -dLCL -dLCLgtk2 -XR/mnt/engels
>>
>> This compiles but fails at the linker:
>>
>>    Searching file /mnt/engels/usr/lib64/crtn.o... found
>>    Searching file /usr/local/opt/binutils/bin/x86_64-linux-ld... found
>>    Using util /usr/local/opt/binutils/bin/x86_64-linux-ld
>>    /usr/local/opt/binutils/bin/x86_64-linux-ld: skipping incompatible
>> /lib/libpthread.so.0 when searching for /lib/libpthread.so.0
>>    /usr/local/opt/binutils/bin/x86_64-linux-ld: cannot find
>> /lib/libpthread.so.0
>>    Error: Error while linking
>>    Fatal: There were 1 errors compiling module, stopping
>>
>> The linker
>>
>>   /usr/local/opt/binutils/bin/x86_64-linux-ld
>>
>> was created using (an appropriately modified)
>>
>>    fpcfixes_2.6/cross/buildcrossbinutils
>>
>> i.e. built to run on i386 and target x86_64
>>
>>    MYINTEL=i386
>>    TARGETS_X86_64="linux"
>>
>> and the pthread library is (presumably, given the -XR option)
>>
>>    /mnt/engels/lib/libpthread.so
>>
>> which file reports as
>>
>>    libpthread-2.11.3.so: ELF 64-bit LSB shared object, x86-64, version
>>    1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux
>>    2.6.18, not stripped
>>
>> How can I find out why x86_64-linux-ld reports it as incompatible?
>>
>> Many thanks, Bruce.
>>
>> On 05/28/12 23:02, Jonas Maebe wrote:
>>> On 28 May 2012, at 14:56, Bruce Tulloch wrote:
>>>
>>>> Am I correct to assume that if I drag in the x86_64 libraries I need
>>>> from another x86_64 system, put them in a local directory and then
>>>> reference then using the -XR option I can make this setup work?
>>> -XR is for pointing the compiler/linker to the top of a complete
>>> sysroot (i.e., a hierarchy with /lib, /usr/lib etc), not to a
>>> directory with just few handpicked libraries. For the latter, use the
>>> -Fl command line switch instead, possibly combined with -Xd (to
>>> prevent the compiler from passing the default system directories as
>>> search paths to the linker).
>>>
>>> And yes, that should indeed work fine.
>>>
>>>
>>> Jonas_______________________________________________
>>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list