[LLVMdev] Gold plugin and LLVM tools documentation

Rafael Espíndola rafael.espindola at gmail.com
Tue May 1 13:32:21 PDT 2012


> First, I create libjscore.a with ar, where I've changed the command
> line to load the plugin:
> ar cqs --plugin
> /home/tmjackso/multicompiler/llvm-3.0/release/lib/LLVMgold.so
> libjscore.a <list of object files>

Note that you shouldn't need to pass --plugin to ar, it searches bfd-plugins.

> Then I link jsc against libjscore.a:
> /home/tmjackso/multicompiler/llvm-3.0/release/bin/clang++
> -Wl,-plugin,/home/tmjackso/multicompiler/llvm-3.0/release/lib/LLVMgold.so
> -Wl,-rpath,/home/tmjackso/builds/qt/qt-4.8.1/lib
> -Wl,-rpath,/home/tmjackso/builds/webkit/WebKit-r94287/WebKitBuild/Release/lib
> -o ./jsc obj/release/jsc.o    -L./release
> -L/home/tmjackso/builds/qt/qt-4.8.1/lib -ljscore -lQtCore
> -L/home/tmjackso/builds/qt/qt-4.8.1/lib -lpthread
> /usr/bin/ld: error: jscore: malformed archive header name at 8
>
> When I change the link command to not use "-ljscore" but the path to
> libjscore.a, it works:
> /home/tmjackso/multicompiler/llvm-3.0/release/bin/clang++
> -Wl,-plugin,/home/tmjackso/multicompiler/llvm-3.0/release/lib/LLVMgold.so
> -Wl,-rpath,/home/tmjackso/builds/qt/qt-4.8.1/lib
> -Wl,-rpath,/home/tmjackso/builds/webkit/WebKit-r94287/WebKitBuild/Release/lib
> -o ./jsc obj/release/jsc.o libjscore.a  -L./release
> -L/home/tmjackso/builds/qt/qt-4.8.1/lib -lQtCore
> -L/home/tmjackso/builds/qt/qt-4.8.1/lib -lpthread
>
> Does anyone know what I'm doing wrong in the first case? The build is
> managed by qmake, and I'm working on coaxing it into generating the
> second line.

What does ld -v shows? Can you run nm on  libjscore.a?

> Also, because the documentation is dated in 2010, is it current? I'll
> have some time in about two weeks to take a look at it if it's not.
> For example, using clang -O4 has never worked for me.  That's why I
> pass -Wl to load the linker plugin.

Not a lot has changed. You should be able to pass -flto when linking
to causes clang to pass the plugin to the linker automatically btw.

> Thanks,
>
> Todd Jackson

Cheers,
Rafael




More information about the llvm-dev mailing list