This is an archive of the discontinued LLVM Phabricator instance.

libclc: Pass system libraries to the linker after llvm libraries
ClosedPublic

Authored by tstellar on Apr 20 2020, 9:52 PM.

Details

Summary

The llvm libraries depend on the symbols in the system libaries, so
the system libraries need to be added after.

Diff Detail

Event Timeline

tstellar created this revision.Apr 20 2020, 9:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2020, 9:52 PM
jvesely accepted this revision.Apr 22 2020, 4:43 PM

was this a problem with using -Wl,--as-needed?

LGTM.

This revision is now accepted and ready to land.Apr 22 2020, 4:43 PM

was this a problem with using -Wl,--as-needed?

LGTM.

No, I was hitting this when using the default build options for both LLVM and libclc.

was this a problem with using -Wl,--as-needed?

LGTM.

No, I was hitting this when using the default build options for both LLVM and libclc.

that's weird. linker shouldn't really drop libraries unless as-needed is used. can you post the falling cmdline?

was this a problem with using -Wl,--as-needed?

LGTM.

No, I was hitting this when using the default build options for both LLVM and libclc.

that's weird. linker shouldn't really drop libraries unless as-needed is used. can you post the falling cmdline?

This is the failing cmdline (from here https://github.com/tstellar/llvm-project/runs/587088911):

/usr/bin/c++ CMakeFiles/prepare_builtins.dir/utils/prepare-builtins.cpp.o -o prepare_builtins -L/home/runner/work/llvm-project/llvm-project/build/lib -Wl,-rpath,/home/runner/work/llvm-project/llvm-project/build/lib -lz -lrt -ldl -ltinfo -lpthread -lm -lxml2 -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle

This is the failing cmdline (from here https://github.com/tstellar/llvm-project/runs/587088911):

/usr/bin/c++ CMakeFiles/prepare_builtins.dir/utils/prepare-builtins.cpp.o -o prepare_builtins -L/home/runner/work/llvm-project/llvm-project/build/lib -Wl,-rpath,/home/runner/work/llvm-project/llvm-project/build/lib -lz -lrt -ldl -ltinfo -lpthread -lm -lxml2 -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle

Looks like this is caused by Ubuntu enabling -Wl,--as-needed by default (since 11.10) [0]

[0] https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--as-needed

This revision was automatically updated to reflect the committed changes.