[cfe-dev] alias attributes in clang on darwin

Jack Howarth howarth at bromo.med.uc.edu
Mon May 10 16:40:36 PDT 2010


   While looking into a failing LTO testcase on FSF gcc trunk
on darwin, I noticed that clang appears to tolerate the code
whereas llvm-gcc-4.2 (like FSF gcc trunk doesn't). The simple
testcase is...

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__ (( __alias__ ("INT_x")));

which in FSF gcc 4.4.4, 4.5.0, trunk, Apple gcc 4.2.1 and llvm-gcc produce...

gcc -O0 -c -o c_lto_20081222_1.o 20081222_1.c
20081222_1.c:16: error: only weak aliases are supported in this configuration

Clang however compiles this without complaint. Is this an enhancement in clang
on the alias attribute handling on darwin or a bug? If it is that latter,
can this enhancement be backported into llvm-gcc-4.2?
          Jack
ps I would also note that if I change the last line of 20081222_1.c to...

        __attribute__ (( weak, __alias__ ("INT_x")));

Apple's gcc-4.2.1 and llvm-gcc-4.2 both produce the compilation failure...

llvm-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’






More information about the cfe-dev mailing list