[llvm-commits] [llvm] r154124 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp
Bill Wendling
isanbard at gmail.com
Mon Apr 9 15:52:43 PDT 2012
On Apr 9, 2012, at 3:09 PM, Rafael EspĂndola <rafael.espindola at gmail.com> wrote:
>> Consider the following program:
>>
>> $ cat main.c
>> void foo(void) { }
>>
>> int main(int argc, char *argv[]) {
>> foo();
>> return 0;
>> }
>> $ cat bundle.c
>> extern void foo(void);
>>
>> void bar(void) {
>> foo();
>> }
>> $ clang -o main main.c
>> $ clang -o bundle.so bundle.c -bundle -bundle_loader ./main
>> $ nm -m bundle.so
>> 0000000000000f40 (__TEXT,__text) external _bar
>> (undefined) external _foo (from executable)
>> (undefined) external dyld_stub_binder (from libSystem)
>> $ clang -o main main.c -O4
>> $ clang -o bundle.so bundle.c -bundle -bundle_loader ./main
>> Undefined symbols for architecture x86_64:
>> "_foo", referenced from:
>> _bar in bundle-elQN6d.o
>> ld: symbol(s) not found for architecture x86_64
>> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
> Note that I get exactly the same error with:
>
> $ clang -o main main.c -Wl,-dead_strip -O3
> $ clang -o bundle.so bundle.c -bundle -bundle_loader ./main
> Undefined symbols for architecture x86_64:
> "_foo", referenced from:
> _bar in bundle-LRWElp.o
> ld: symbol(s) not found for architecture x86_64
> clang-3: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> Which shows that the problem is *not* with us running internalize, it
> is with the linker telling us the foo is not needed.
>
This has nothing to do with my changes:
[bwendling:llvm] clang -O3 -Wl,-dead_strip a.c
[bwendling:llvm] nm -m a.out
0000000100000000 (__TEXT,__text) [referenced dynamically] external __mh_execute_header
0000000100000f70 (__TEXT,__text) external _main
(undefined) external dyld_stub_binder (from libSystem)
-bw
More information about the llvm-commits
mailing list