Link issue with clang and ARM EABI
Andrew Turner
andrew at fubar.geek.nz
Wed Feb 6 10:14:54 UTC 2013
Hello,
I've been updating clang to support ARM EABI on FreeBSD. The problem
I've found is libc & compiler-rt are dependent on each other.
The current link order for a static binary is to append -lgcc -lc -lgcc
to the end of the link command. The __aeabi_mem* are implemented by
calling their equivalent function in libc, for example __aeabi_memmove
calls the libc memmove.
The problem is clang can place calls to these __aeabi_mem* functions in
libc. If we are building a static program libc will call into the
second copy of libgcc which is then unable to find the required symbol.
This doesn't appear to be a problem for the run-time linker so shared
binaries work without changing the libraries linked against.
The attached patch fixes this by changing the link order to -lc -lgcc
-lc -lgcc. This means the program will use the symbol in the first copy
of libc which will call into the first libgcc and that calls into the
second libc.
Can anyone see any problems doing this? I would like to send it
upstream and commit it to our tree to help get ARM EABI clang builds
working.
(CC me, I'm not on the list)
Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_libc.diff
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20130206/78f01fc8/attachment.bin>
More information about the freebsd-toolchain
mailing list