__attribute__((alias))

Hi,

Some time ago I added support for __attribute__((alias)). However it is not working when referencing an aliased function from a different file where it was defined.
Take a look at this example:

foo.ll:
declare void @zend_error(i32, i8*, ...)
;declare void @zend_error_noreturn(i32, i8*, ...) noreturn
@zend_error_noreturn = alias void (i32, i8*, ...)* @zend_error ; <void (i32, i8*, ...)*> [#uses=0]

bar.ll:
declare void @zend_error_noreturn(i32, i8*, ...) noreturn

linking those files leads to:
llvm-as foo.ll; llvm-as bar.ll
llvm-ld -native -o xpto foo.bc bar.bc

llvm-ld: LinkModules.cpp:425: void ForceRenaming(llvm::GlobalValue*, const std::string&): Assertion `ConflictGV->hasInternalLinkage() && "Not conflicting with a static global, should link instead!"' failed.

If you uncomment the 2nd line of foo.ll it doesn't trigger that exception. Is this a bug in the linker or should clang generate the extra declaration?

Nuno

P.S.: after fixing this problem, PHP should finally compile :slight_smile:

Mmm, yes, I remember seeing that alias when I tried compiling PHP; I
got around it by tweaking a couple of ifdefs.

I think llvm-ld is doing the wrong thing here. Testcase:
x.c:
int a() {return 0;}int b() __attribute((alias("a")));
y.c:
int b(); int main() {return b();}

Both clang and llvm-gcc generate approximately the same thing, the
results of both cause link errors with llvm-ld, and both work fine if
compiled separately.

-Eli

Hello, Eli

Both clang and llvm-gcc generate approximately the same thing, the
results of both cause link errors with llvm-ld, and both work fine if
compiled separately.

This is PR2146

Both clang and llvm-gcc generate approximately the same thing, the
results of both cause link errors with llvm-ld, and both work fine if
compiled separately.

This is PR2146

Uhm, damn. Are you working on a fix for the problem? Do you have any ETA?
If not I may try to adventure myself and try to fix it (although I prefer not to learn yet another sources right now).

Thanks,
Nuno

Hello, Eli

Both clang and llvm-gcc generate approximately the same thing, the
results of both cause link errors with llvm-ld, and both work fine if
compiled separately.

This is PR2146

Ok, it's working now after your fix. Thanks!
Now PHP compiles fine and passes most of the tests. However it is segfaulting in a few dozen tests and producing weird valgrind reports in others. How I love compilers.. :slight_smile:

Nuno