site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc11 Thunderbird/3.0.1 On 05/09/2010 10:57 AM, Jack Howarth wrote:
In the new Link Time Optimization support for darwin in current FSF gcc trunk, we have run into one lto testcase that passes under linux with binutils but fails for darwin's linker. The reduced testcase is...
[MacPro:~/lto_bug] howarth% cat 20081222_0.h int x();
[MacPro:~/lto_bug] howarth% cat 20081222_1.c #include "20081222_0.h"
Part of the "problem" is that Mac OS X prepends an underscore to C symbols, whereas many linux systems don't (this is not consistent across all architectures with linux).
/* Actually, call "x" "INT_X", and make it hidden. */ extern __typeof (x) x __asm__ ("INT_x")
Need to change this to __asm__ ("_INT_x")
__attribute__ (( __visibility__ ("hidden")));
int x () { return 7; }
/* Make an externally-visible symbol "X" that's an alias for INT_x. */ extern __typeof (x) EXT_x __asm__ ("x")
and this to __asm__ ("_x")
__attribute__ (( __alias__ ("INT_x")));
[MacPro:~/lto_bug] howarth% gcc -O0 -c -o c_lto_20081222_1.o 20081222_1.c 20081222_1.c:16: error: ‘EXT_x’ aliased to undefined symbol ‘INT_x’
Then the message becomes for the __weak__ case becomes: 20081222_1.c:16: warning: alias definitions not supported in Mach-O; ignored Which is odd because as you have pointed out clang does it fine by simply adding: .globl _x _x = _INT_x for the non-weak case, and, for the __weak__ case: .weak_reference _x _x = _INT_x to the assembly. It may be that this works by accident with clang, for this minor test case, though, I don't know. Peter _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com