Sign in Join

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

Mailing lists / fpc-pascal / 2008-10

Smartlinking while cross compiling

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Brad Campbell

G'day all,

I'm cross compiling from i386-linux to i386-darwin/powerpc-darwin/i386-win32. I can't seem to create smartlinkable libraries for anything other than i386-linux and so all my cross compiled files are suddenly huge by comparison.

I thought I had this working. Everything is compiled with -CX -XX, but I only have .a files in my i386-linux directory, and my -va compile logs from the other architectures all say..

unit STRUTILS can't be smart linked, switching to static linking [7.082] Searching file /opt/cross/lib/fpc/2.2.3/units/powerpc-darwin/rtl/strutils.o... found

I have No idea what I've changed (if anything), so I thought I'd ask if it were possible to even make it work.

I'll include the script I use to create my cross compilers just in case. I can compile for all the platforms with these compilers, and also compile lazarus against them.

I *thought* I had smartlinking working for non-linux, but on closer inspection it appears not to be.

#!/bin/bash
set -e
make distclean
make all install INSTALL_PREFIX=/opt/cross OPT="-gl -XX -CX"

make distclean
FPC=ppc386 make crossall crossinstall CPU_TARGET=i386 OS_TARGET=darwin CROSSBINDIR=/opt/cross/bin BINUTILSPREFIX=i386-darwin- INSTALL_PREFIX=/opt/cross OPT="-gl -XX -CX -Xd -Fl/opt/cross/MacOSX10.4u.sdk/usr/lib"

make distclean
FPC=ppc386 make crossall crossinstall CPU_TARGET=powerpc OS_TARGET=darwin CROSSBINDIR=/opt/cross/bin BINUTILSPREFIX=powerpc-darwin- INSTALL_PREFIX=/opt/cross OPT="-gl -XX -CX -Xd -Fl/opt/cross/MacOSX10.4u.sdk/usr/lib"

make distclean
FPC=ppc386 make crossall crossinstall CPU_TARGET=i386 OS_TARGET=win32 CROSSBINDIR=/opt/cross/bin BINUTILSPREFIX=i386-mingw- INSTALL_PREFIX=/opt/cross OPT="-gl -XX -CX"

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.
Brad Campbell
to Brad Campbell
Brad Campbell wrote
G'day all, I'm cross compiling from i386-linux to

Yet again I fail to provide any useful information. This is using the svn FIXES_2_2 Branch as of the 1/10/2008.

I'm trying trunk now to see if I'm doing something dumb.

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.
Jonas Maebe
to Brad Campbell: I'm cross compiling from i386-linux to i386-darwin/powerpc-darwin/i386-win32. I can't…
Brad Campbell wrote 13 lines
I'm cross compiling from i386-linux to i386-darwin/powerpc-darwin/ i386-win32. I can't seem to create smartlinkable libraries for anything other than i386-linux and so all my cross compiled files are suddenly huge by comparison. I thought I had this working. Everything is compiled with -CX -XX, but I only have .a files in my i386-linux directory, and my -va compile logs from the other architectures all say.. unit STRUTILS can't be smart linked, switching to static linking [7.082] Searching file /opt/cross/lib/fpc/2.2.3/units/powerpc-darwin/ rtl/strutils.o... found

Smart linking does not happen using .a files on Darwin. Smart linking is performed by the Darwin linker (as of the one included with Xcode 1.5 and higher) using the plain .o files. All that needs to be done is to add ".subsections_via_symbols" at the end of an assembler file (which FPC does when you use -CX) and pass -dead_strip to the linker when linking (which FPC does when you use -XX).

Please file a bug to have this warning only shown for Darwin in case a unit has been compiled without -CX.

I have no idea why it wouldn't work if you cross-compile, since as explained it's just a matter of having a single line in the assembler files and passing a parameter to the linker.

Jonas

Brad Campbell
to Jonas Maebe
Jonas Maebe wrote 29 lines
On 08 Oct 2008, at 09:15, Brad Campbell wrote: > I'm cross compiling from i386-linux to > i386-darwin/powerpc-darwin/i386-win32. I can't seem to create > smartlinkable libraries for anything other than i386-linux and so all > my cross compiled files are suddenly huge by comparison. > > I thought I had this working. Everything is compiled with -CX -XX, but > I only have .a files in my i386-linux directory, and my -va compile > logs from the other architectures all say.. > > unit STRUTILS can't be smart linked, switching to static linking > [7.082] Searching file > /opt/cross/lib/fpc/2.2.3/units/powerpc-darwin/rtl/strutils.o... found Smart linking does not happen using .a files on Darwin. Smart linking is performed by the Darwin linker (as of the one included with Xcode 1.5 and higher) using the plain .o files. All that needs to be done is to add ".subsections_via_symbols" at the end of an assembler file (which FPC does when you use -CX) and pass -dead_strip to the linker when linking (which FPC does when you use -XX). Please file a bug to have this warning only shown for Darwin in case a unit has been compiled without -CX. I have no idea why it wouldn't work if you cross-compile, since as explained it's just a matter of having a single line in the assembler files and passing a parameter to the linker.

I've looked at it further, and whilst it tells me it's not smartlinking, filesize says otherwise. This is native on a G4, but cross compiling shows the same results.

macppc:~ user$ fpc -Xs test -va | grep "smart link" macppc:~ user$ ls -la test
-rwxr-xr-x 1 user user 240252 Oct 8 12:48 test macppc:~ user$ fpc -XX -Xs test -va | grep "smart link" [0.293] unit HELLO can't be smart linked, switching to static linking [0.293] unit SYSTEM can't be smart linked, switching to static linking macppc:~ user$ ls -la test
-rwxr-xr-x 1 user user 107840 Oct 8 12:48 test macppc:~ user$ fpc
Free Pascal Compiler version 2.2.3 [2008/06/14] for powerpc Copyright (c) 1993-2008 by Florian Klaempfl
/usr/local/bin/ppcppc [options] <inputfile> [options]

This was a snapshot I downloaded some time back. My cross compiler exhibits the same behaviour.

So it appears that while the compiler complains and states it's going to static link, it looks like it's smartlinking in any case.

I will file a bug as you requested. Thanks for the input yet again :)

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.