[llvm-commits] [llvm] r96569 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ unittests/Makefile.unittest

Xerxes Ranby xerxes at zafena.se
Thu Feb 18 14:56:27 PST 2010


Jeffrey Yasskin wrote:
> On Thu, Feb 18, 2010 at 2:53 AM, Xerxes RĂ„nby <xerxes at zafena.se> wrote:
>   
>> Jeffrey Yasskin wrote:
>>     
>>> Author: jyasskin
>>> Date: Wed Feb 17 22:43:02 2010
>>> New Revision: 96569
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=96569&view=rev
>>> Log:
>>> Roll back the shared library, r96559.  It broke two darwins and arm, mysteriously.
>>>
>>>
>>>       
>> Hi
>> The failure on arm:
>>
>> llvm[1]: Linking Debug Shared Library LLVM2.7svn.so
>> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicAdd(unsigned int volatile*, unsigned int)':
>> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:86: undefined reference to `__sync_add_and_fetch_4'
>> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicIncrement(unsigned int volatile*)':
>> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:60: undefined reference to `__sync_add_and_fetch_4'
>> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicDecrement(unsigned int volatile*)':
>> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:73: undefined reference to `__sync_sub_and_fetch_4'
>> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)':
>> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:47: undefined reference to `__sync_val_compare_and_swap_4'
>> collect2: ld returned 1 exit status
>>
>> I have seen something similar about one year ago when we tried to make
>> libCompileDriver a shared library:
>> http://markmail.org/message/cblcpfmsfab65vue
>>
>> The issue are that the symbol __sync_add_and_fetch_4 and friends do
>> exists in libstdc++ but only in the static version.
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133
>> Quoted Mikael Pettersson from
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133#c8
>> "
>> 1. g++ links shared libraries with -shared-libgcc, which apparently is
>> important whenever exceptions are possible.
>> 2. -shared-libgcc by definition excludes the static libgcc from the link
>> command.
>> 3. Since the __sync__ procedures are only present in the static libgcc,
>> it follows that they cannot be used by -shared-libgcc objects like
>> libstdc++.so.
>> "
>>
>> A workaround might be to specify -lgcc to force linking in the static
>> libstdc++ that contains the missing symbols.
>>
>> Good news are that it looks like this bug should have been resolved in
>> gcc trunk.
>> I will do some tests with r96559 applied on arm to see if this can be
>> workaround by
>>
>> a: make the linking work by specifying -lgcc during linking.
>> or
>> b: upgrade gcc and libstdc++ on the buildbot to a newer version.
>>
>> Cheers
>> Xerxes
>>     
>
> Thanks for the explanation of the problem! To work around it, I'm
> going to remove -Wl,--no-undefined from the ARM build. I think the
> shared library should still find the __sync primitives defined in the
> main executable, and we'll get assurance that the library is complete
> from builds on non-ARM platforms.
>   
Test results of workarounds +r96559 on llvm trunk using gcc 4.3.3 on 
ubuntu arm linux

with removed  --no-undefined from tools/llvm-shlib/Makefile
the shared library links!
-rwxr-xr-x 1 xerxes xerxes 21640706 2010-02-18 23:50 
../../Release/lib/libLLVM2.7svn.so
All examples fail to link
llvm[1]: Linking Release executable BrainF (without symbols)
/usr/bin/ld: /media/disk/llvm-configure/Release/examples/BrainF: hidden 
symbol `__sync_val_compare_and_swap_4' in 
/usr/lib/gcc/arm-linux-gnueabi/4.3.3/libgcc.a(linux-atomic.o) is 
referenced by DSO

with -lgcc
LLVMLibsOptions += -lgcc
the shared library links!
-rwxr-xr-x 1 xerxes xerxes 21658573 2010-02-18 23:46 
../../Release/lib/libLLVM2.7svn.so
BrainF Fibonacci    Kaleidoscope-Ch2  Kaleidoscope-Ch4  
Kaleidoscope-Ch6  ModuleMaker
HowToUseJIT  Kaleidoscope-Ch3  Kaleidoscope-Ch5  Kaleidoscope-Ch7  
ParallelJIT
links and run
ExceptionDemo fails to link
llvm[1]: ======= Finished Linking Release Executable ParallelJIT 
(without symbols)
make[1]: Leaving directory `/media/disk/llvm-configure/examples/ParallelJIT'
make[1]: Entering directory 
`/media/disk/llvm-configure/examples/ExceptionDemo'
llvm[1]: Compiling ExceptionDemo.cpp for Release build
llvm[1]: Linking Release executable ExceptionDemo (without symbols)
/media/disk/llvm-configure/examples/ExceptionDemo/Release/ExceptionDemo.o: 
In function `ourPersonality':
ExceptionDemo.cpp:(.text+0x60c): undefined reference to `_Unwind_GetIP'
ExceptionDemo.cpp:(.text+0x7f8): undefined reference to `_Unwind_SetGR'
ExceptionDemo.cpp:(.text+0x818): undefined reference to `_Unwind_SetGR'
ExceptionDemo.cpp:(.text+0x828): undefined reference to `_Unwind_SetIP'
ExceptionDemo.cpp:(.text+0x870): undefined reference to `_Unwind_SetGR'
collect2: ld returned 1 exit status
make[1]: *** [/media/disk/llvm-configure/Release/examples/ExceptionDemo] 
Error 1
make[1]: Leaving directory 
`/media/disk/llvm-configure/examples/ExceptionDemo'
make: *** [ExceptionDemo/.makeall] Error 2

So linking in the static -lgcc makes at least the shared library usable 
on ARM and only adds 18kb to the shared library size,
still it needs to be solved how to dynamically link LLVM clients binarys 
that make use of exceptions.

I will keep you updated if this are all fixed when using a newer gcc and 
libstdc++ on ARM.

Cheers
Xerxes



More information about the llvm-commits mailing list