[cfe-dev] alias attributes in clang on darwin
Jack Howarth
howarth at bromo.med.uc.edu
Tue May 11 06:19:25 PDT 2010
On Mon, May 10, 2010 at 09:28:14PM -0700, Chris Lattner wrote:
>
> On May 10, 2010, at 4:40 PM, Jack Howarth wrote:
> > Clang however compiles this without complaint. Is this an enhancement in clang
> > on the alias attribute handling on darwin or a bug?
>
> I don't know.
Chris,
Peter O'Gorman pointed out that Mac OS X prepends an underscore to C symbols
while whereas many linux systems don't. So, for Apple's gcc-4.2, if I change
the testcase to...
cat 20081222_0.h
int x();
cat 20081222_1.c
#include "20081222_0.h"
/* Actually, call "x" "INT_X", and make it hidden. */
extern __typeof (x) x
__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")
__attribute__ (( weak, __alias__ ("INT_x")));
by prepending "_" for the __asm__(), it also produces the expected warning of...
gcc-4.2 -O0 -c -o c_lto_20081222_1.o 20081222_1.c
20081222_1.c:16: warning: alias definitions not supported in Mach-O; ignored
Interestingly, clang accepts both the original and the modified test
case without complaint. Considering that Mach-O doesn't support alias
definitions this should probably be looked into as a potential bug in
clang on darwin.
Jack
ps Unless I am confused, these issues were addressed by Geoff Keating
with weakref's but it is unclear if a bug-free implementation was ever
achieved...
http://gcc.gnu.org/ml/gcc/2005-12/msg00009.html
Note the comment "I couldn't fully test this patch because weakrefs
still don't seem to be working properly on Darwin".
>
> > If it is that latter, can this enhancement be backported into llvm-gcc-4.2?
>
> No, in general, we don't plan to backport any clang enhancements into llvm-gcc.
>
> -Chris
More information about the cfe-dev
mailing list