On Fri, Jan 06, 2012 at 06:07:37PM +0000, Iain Sandoe wrote: > > On 6 Jan 2012, at 18:04, Patrick Marlier wrote: > >> On 01/06/2012 12:30 PM, Iain Sandoe wrote: >>> >>> On 6 Jan 2012, at 16:42, Jack Howarth wrote: >>> >>>> On Fri, Jan 06, 2012 at 10:58:51AM -0500, Patrick Marlier wrote: >>>>> On 01/06/2012 10:38 AM, Mike Stump wrote: >>>>>> On Jan 6, 2012, at 12:29 AM, Iain Sandoe wrote: >>>>>>>> I think something is wrong in the configure. Indeed, on >>>>>>>> apple-darwin10.8.0, weak ref works but it is configure as "no". >>>>>>>> I guess it should not try to run it but only compile it (or the >>>>>>>> symbol should exists). >>>>>>> >>>>>>> Which tool-chain are you using ? (XCode version) - the problem is >>>>>>> tool-chain related. >>>>>>> thanks >>>>>> >>>>>> 3.2.6 on x86_64-apple-darwin10.8.0 works for me with either >>>>>> -m32 or >>>>>> -m64. If you have an older Xcode 3.2.x, try updating. >>>>> >>>>> 4.0 (build 4A304a) on x86_64-apple-darwin10.8.0. I will try to >>>>> update >>>>> it. >>>>> >>>>> Thanks. >>>> >>>> Using Xcode 4.2 on Snow Leopard, I see the same runtime failure for >>>> the configure test of >>>> "checking whether weak refs work like ELF"... >>> >>> Note the "like ELF" >>> .. the purpose of the test is to find out if we need to have the >>> dummy >>> routines. >>> >>> (weak refs actually work at runtime for all current versions of >>> Darwin - >>> - the tricky bit is getting the link phase right) >>> >>> Is the resulting libitm working? >> >> libitm compiles but the dummy function are used at runtime (eh-1.C >> testcase fails)... >> Removing the dummy definitions in eh_cpp.cc makes it compile and work. > > OK. could you file a PR please? > thanks
Iain, We have radar Problem ID: 10466868, "-undefined dynamic_lookup linker bug" open with your testcase (which I appended below). Do you recall if Nick ever indicated that this was recognized a real regression in Xcode 4's linker or if it was unsupported behavior on darwin that happened to work with the linker on prior Xcode releases? Also, perhaps we can find someone with access to the Xcode 4.3 pre-release so they can check if this is fixed yet. Jack 17-Nov-2011 08:22 PM Jack Howarth: Summary: The following weak.c test case reveals a linker bug in -undefined dynamic_lookup in Xcode 4.2/4.2.1 under both darwin10 and darwin11. --------------- weak.c --------------------- #include <stdio.h> char *myweakfunc(void) __attribute__((weak)) ; int main(int argc, char **argv) { if (myweakfunc) printf ("found myweakfunc %s\n", myweakfunc()); else printf("Weak func not found\n"); return 0; } ------------------------------------------- Steps to Reproduce: 1) Install Xcode 4.2 on darwin10 or darwin11. 2) Compile the weak.c test case with... /usr/bin/llvm-gcc weak.c -o wk -undefined dynamic_lookup 3) Execute the resulting "wk" executable Expected Results: I expected the same results as is seen when the weak.c test case is compiled with llvm-gcc from Xcode 3.2.6... howarth% /Developer-3.2.6/usr/bin/llvm-gcc weak.c -o wk -undefined dynamic_lookup howarth% ./wk Weak func not found Actual Results: The resulting binary fails to execute with the runtime error... dyld: Symbol not found: _myweakfunc Referenced from: /Users/howarth/./wk Expected in: flat namespace in /Users/howarth/./wk Trace/BPT trap Regression: This can be shown to be a regression in Xcode 4.2's ld since... howarth% /usr/bin/llvm-gcc weak.c -o wk -undefined dynamic_lookup --save-temps howarth% /Developer-3.2.6//usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.6.8 -undefined dynamic_lookup -weak_reference_mismatches non-weak -undefined dynamic_lookup -o wk -lcrt1.10.6.o -L/Developer-3.2.6/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/i686-apple-darwin10/4.2.1 -L/Developer-3.2.6/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1 -L/Developer-3.2.6/usr/llvm-gcc-4.2/bin/../lib/gcc -L/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/Developer-3.2.6/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../.. -L/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/../../.. weak.o -lSystem -lgcc -lSystem howarth% ./wk Weak func not found works when the Xcode 3.2.6 linker is used instead of the Xcode 4.2 linker. Notes: > Iain