llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.63k stars 11.36k forks source link

[thinLTO] Unable to compile with IFUNC symbol #45833

Open llvmbot opened 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 46488
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @EliaGeretto,@stephenhines

Extended Description

The code example:

$ cat thinlto-ifunc.c typedef int (*func)(void);

int called(void) { return 1; }

func resolver(void) { return called; }

attribute ((ifunc ("resolver"))) int foo(void);

int main(int argc, char *argv[]) { foo(); }

$ clang -O3 -flto=thin thinlto-ifunc.c -o out /usr/bin/ld: /tmp/lto-llvm-1798eb.o: in function main': thinlto-ifunc.c:(.text.main+0x2): undefined reference toresolver' clang: error: linker command failed with exit code 1 (use -v to see invocation)

And in case if ifunc call is in another C file: $ clang -O3 -flto=thin thinlto-ifunc.c ex.c -o out /tmp/lto-llvm-d8c1fd.o: in function main': ex.c:(.text.main+0x2): undefined reference tofoo' clang: error: linker command failed with exit code 1 (use -v to see invocation)

EliaGeretto commented 3 years ago

A patch trying to solve this issue is under review: https://reviews.llvm.org/D82745

nyh commented 1 month ago

I think this bug has been solved already so perhaps this issue should be closed? The original example given above seems to build fine. Also, a project I tried that used to have a problem with the IFUNC now seems to work correctly.