Sign in Join

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

Mailing lists / fpc-pascal / 2007-12

cross compiling enigma

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Sam Liddicott

I'm modifying the lazarus packaging scripts to make building debs of lazarus, fpc and cross-fpc variants simpler than it is. (Cross is not simple right now)

I've read the buildfaq (thanks Marco) and various fpc build scripts but am still puzzled in this respect:

Why does:

$ cd fpc
$make clean all OS_TARGET=win32  FPC=/usr/bin/ppc386

make:
./compiler/ppc386.exe

I thought I was building a cross-compiler, not cross-compiling one - or is it a side effect of building the rtl etc?

(Not to mention utils/*exe)

also with the ubuntu mingw* packages installed,
$ make clean all OS_TARGET=win32 FPC=/usr/bin/ppc386 BINUTILSPREFIX=i586-mingw32msvc-

generates all these .exe files.

Am I doing the cross-compiler build wrong?
It dumps out: compiler/ppcross386
as well, which was used to build all the .exe

I'm puzzled, it seems like the fpc makefile had the wrong idea and built a cross compiler so it could build windows binaries which is not what I was actually trying to do.

Sam

Reply by email

Marco van de Voort
to Sam Liddicott
Show quoted text 17 lines
I'm modifying the lazarus packaging scripts to make building debs of lazarus, fpc and cross-fpc variants simpler than it is. (Cross is not simple right now) I've read the buildfaq (thanks Marco) and various fpc build scripts but am still puzzled in this respect: Why does: $ cd fpc $make clean all OS_TARGET=win32 FPC=/usr/bin/ppc386 make: ./compiler/ppc386.exe I thought I was building a cross-compiler, not cross-compiling one - or is it a side effect of building the rtl etc?

The thing you are missing (read buildfaq better :-) is that FPC doesn't have to be cross for platforms on the same architecture.

Reply by email

Sam Liddicott
to Marco van de Voort

* Marco van de Voort wrote, On 07/12/07 08:20:

Show quoted text 22 lines
> I'm modifying the lazarus packaging scripts to make building debs of > lazarus, fpc and cross-fpc variants simpler than it is. (Cross is not > simple right now) > > I've read the buildfaq (thanks Marco) and various fpc build scripts but > am still puzzled in this respect: > > Why does: > > $ cd fpc > $make clean all OS_TARGET=win32 FPC=/usr/bin/ppc386 > > make: > ./compiler/ppc386.exe > > I thought I was building a cross-compiler, not cross-compiling one - or > is it a side effect of building the rtl etc? > The thing you are missing (read buildfaq better :-) is that FPC doesn't have to be cross for platforms on the same architecture.

:-(
I used 386-win32 for testing the script because FPC-SVN won't compile for arm-wince - I'll try a ppc build for the test then.

So... because the makefile knew it was compiling for the same architecture it decided that I wasn't building an fpc cross compiler but cross building an fpc compiler? That's a bit unexpectedly clever...

Sam

Reply by email

Sam Liddicott
to Sam Liddicott
Sam Liddicott wrote 31 lines
* Marco van de Voort wrote, On 07/12/07 08:20: >> I'm modifying the lazarus packaging scripts to make building debs of >> lazarus, fpc and cross-fpc variants simpler than it is. (Cross is not >> simple right now) >> >> I've read the buildfaq (thanks Marco) and various fpc build scripts but >> am still puzzled in this respect: >> >> Why does: >> >> $ cd fpc >> $make clean all OS_TARGET=win32 FPC=/usr/bin/ppc386 >> >> make: >> ./compiler/ppc386.exe >> >> I thought I was building a cross-compiler, not cross-compiling one - or >> is it a side effect of building the rtl etc? >> > > The thing you are missing (read buildfaq better :-) is that FPC doesn't have > to be cross for platforms on the same architecture. > :-( I used 386-win32 for testing the script because FPC-SVN won't compile for arm-wince - I'll try a ppc build for the test then. So... because the makefile knew it was compiling for the same architecture it decided that I wasn't building an fpc cross compiler but cross building an fpc compiler? That's a bit unexpectedly clever...

So... this time:
$ make clean all CPU_TARGET=powerpc OS_TARGET=linux FPC=/usr/bin/ppc386 BINUTILSPREFIX=/usr/bin/powerpc-linux-gnu-

And, just like before, it has created a load of powerpc binaries:

$ file /tmp/fpc_patchdir/fpc_build/usr/bin/postw32 /tmp/fpc_patchdir/fpc_build/usr/bin/postw32: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, stripped

So I'm still puzzled that the recipe for creating a cross compiler is actually cross-compiling a compiler and cross-compiling the tools.

Of course, compiler/ppcrossppc was created, but it seems as a precursor to creating all the powerpc binaries.

So I still think I'm doing it wrong; was my make command line correct to produce an fpc instance that will cross-compile for powerpc-linux?

Sam

Reply by email

Sam Liddicott
to Sam Liddicott
Sam Liddicott wrote 52 lines
Sam Liddicott wrote: > * Marco van de Voort wrote, On 07/12/07 08:20: >>> I'm modifying the lazarus packaging scripts to make building debs of >>> lazarus, fpc and cross-fpc variants simpler than it is. (Cross is not >>> simple right now) >>> >>> I've read the buildfaq (thanks Marco) and various fpc build scripts but >>> am still puzzled in this respect: >>> >>> Why does: >>> >>> $ cd fpc >>> $make clean all OS_TARGET=win32 FPC=/usr/bin/ppc386 >>> >>> make: >>> ./compiler/ppc386.exe >>> >>> I thought I was building a cross-compiler, not cross-compiling one - or >>> is it a side effect of building the rtl etc? >>> >> >> The thing you are missing (read buildfaq better :-) is that FPC doesn't have >> to be cross for platforms on the same architecture. >> > > :-( > I used 386-win32 for testing the script because FPC-SVN won't compile > for arm-wince - I'll try a ppc build for the test then. > > So... because the makefile knew it was compiling for the same > architecture it decided that I wasn't building an fpc cross compiler > but cross building an fpc compiler? That's a bit unexpectedly clever... So... this time: $ make clean all CPU_TARGET=powerpc OS_TARGET=linux FPC=/usr/bin/ppc386 BINUTILSPREFIX=/usr/bin/powerpc-linux-gnu- And, just like before, it has created a load of powerpc binaries: $ file /tmp/fpc_patchdir/fpc_build/usr/bin/postw32 /tmp/fpc_patchdir/fpc_build/usr/bin/postw32: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, stripped So I'm still puzzled that the recipe for creating a cross compiler is actually cross-compiling a compiler and cross-compiling the tools. Of course, compiler/ppcrossppc was created, but it seems as a precursor to creating all the powerpc binaries. So I still think I'm doing it wrong; was my make command line correct to produce an fpc instance that will cross-compile for powerpc-linux?

I guess my mistake was in "make all", possibly a less encompassing target would be better :-) like make cycle or whatever.

Sam

Reply by email

Jonas Maebe
to Sam Liddicott: So... this time: $ make clean all CPU_TARGET=powerpc OS_TARGET=linux FPC=/usr/bin/ppc386…
Sam Liddicott wrote 15 lines
> So... because the makefile knew it was compiling for the same > architecture it decided that I wasn't building an fpc cross compiler > but cross building an fpc compiler? That's a bit unexpectedly > clever... So... this time: $ make clean all CPU_TARGET=powerpc OS_TARGET=linux FPC=/usr/bin/ ppc386 BINUTILSPREFIX=/usr/bin/powerpc-linux-gnu- And, just like before, it has created a load of powerpc binaries: $ file /≈/usr/bin/postw32 /tmp/fpc_patchdir/fpc_build/usr/bin/postw32: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, stripped

"make clean all" does not put anything in usr/bin, so you at least alo have done a "make install" afterwards.

Show quoted text 6 lines
So I'm still puzzled that the recipe for creating a cross compiler is actually cross-compiling a compiler and cross-compiling the tools. Of course, compiler/ppcrossppc was created, but it seems as a precursor to creating all the powerpc binaries.

It's a cross compiler, which is indeed necessary to create PowerPC binaries.

So I still think I'm doing it wrong; was my make command line correct to produce an fpc instance that will cross-compile for powerpc-linux?

Cross compilers are only intended as add-ons to a native compiler suite. If you do a plain install, the Makefiles assume you want to create a native install for the target platform (although currently this will only work consistently if both the source and target platform have the same endianess).

If you want to perform an add-on cross install (which will only install the cross compiler and units, but not the PowerPC-native compiler and utilities -- as the natively installed versions of those utilities will be used), do something like this:

make FPC=`pwd`/compiler/ppcrossppc INSTALL_PREFIX=/tmp/fpc_patchdir/ fpc_build/usr install CROSSINSTALL=1

(the CROSSINSTALL=1 may not even be necessary when you point FPC to the cross compiler, as the Makefile should detect that it's a cross compiler and set that variable itself)

Jonas

Reply by email

Sam Liddicott
to Jonas Maebe
Jonas Maebe wrote 18 lines
On 08 Dec 2007, at 19:26, Sam Liddicott wrote: >> So... because the makefile knew it was compiling for the same >> architecture it decided that I wasn't building an fpc cross compiler >> but cross building an fpc compiler? That's a bit unexpectedly clever... > So... this time: > $ make clean all CPU_TARGET=powerpc OS_TARGET=linux FPC=/usr/bin/ppc386 > BINUTILSPREFIX=/usr/bin/powerpc-linux-gnu- > > And, just like before, it has created a load of powerpc binaries: > > $ file /≈/usr/bin/postw32 > /tmp/fpc_patchdir/fpc_build/usr/bin/postw32: ELF 32-bit MSB executable, > PowerPC or cisco 4500, version 1 (SYSV), statically linked, stripped "make clean all" does not put anything in usr/bin, so you at least alo have done a "make install" afterwards.

Yes, I'm modifying lazarus's create_fpc_deb.sh so it can also create cross-compiler debs as well (this being simpler than fixing the scripts in cross_unix)

Show quoted text 10 lines
> So I'm still puzzled that the recipe for creating a cross compiler is > actually cross-compiling a compiler and cross-compiling the tools. > > Of course, compiler/ppcrossppc was created, but it seems as a precursor > to creating all the powerpc binaries. It's a cross compiler, which is indeed necessary to create PowerPC binaries.

yes... I was expecting ppcrossppc to be created, the rest was surprising me

Show quoted text 17 lines
> So I still think I'm doing it wrong; was my make command line correct to > produce an fpc instance that will cross-compile for powerpc-linux? Cross compilers are only intended as add-ons to a native compiler suite. If you do a plain install, the Makefiles assume you want to create a native install for the target platform (although currently this will only work consistently if both the source and target platform have the same endianess). If you want to perform an add-on cross install (which will only install the cross compiler and units, but not the PowerPC-native compiler and utilities -- as the natively installed versions of those utilities will be used), do something like this: make FPC=`pwd`/compiler/ppcrossppc INSTALL_PREFIX=/tmp/fpc_patchdir/fpc_build/usr install CROSSINSTALL=1

this was the required tip, thanks

(the CROSSINSTALL=1 may not even be necessary when you point FPC to the cross compiler, as the Makefile should detect that it's a cross compiler and set that variable itself)

It seems to be needed, and I think I have it working now, apart from adding stuff to /etc/fpc.cfg when the cross compiler package is installed.

I see that the old cross_unix crosswin32 stuff tries to add like this:

# add -FD and -XP entry for cross compiling
echo '# set binutils paths for crosscompiling # fpc_crosswin32' >> /etc/fpc.cfg
echo '#IFDEF FPC_CROSSCOMPILING # fpc_crosswin32' >> /etc/fpc.cfg
echo ' -XPfpc-i386-win32-' >> /etc/fpc.cfg
echo '#ENDIF # fpc_crosswin32' >> /etc/fpc.cfg
# end.

But that seems to presume there will be only one cross compiler installed; do you have any hints on what to add to fpc.cfg?

Thank

Sam

Reply by email