This is an archive of the discontinued LLVM Phabricator instance.

[Driver][Linux] Remove D.Dir+"/../lib" from default search paths for LLVM_ENABLE_RUNTIMES builds
ClosedPublic

Authored by MaskRay on Mar 24 2022, 5:10 PM.

Details

Summary

The rule was added in 2014 to support -stdlib=libc++ and -lc++ without
specifying -L, when D.Dir is not a well-known system library directory like
/usr/lib /usr/lib64. This rule turns out to get in the way with (-m32 for
64-bit clang) or (-m64 for 32-bit clang) for Gentoo :
https://github.com/llvm/llvm-project/issues/54515

Nowadays LLVM_ENABLE_RUNTIMES is the only recommended way building libc++ and
LLVM_ENABLE_PROJECTS=libc++ is deprecated. LLVM_ENABLE_RUNTIMES builds libc++
in D.Dir+"/../lib/${triple}/". The rule is unneeded. Also reverts D108286.

Gentoo uses a modified LLVM_ENABLE_RUNTIMES that installs libc++.so in
well-known paths like /usr/lib64 and /usr/lib which are already covered by
nearby search paths.

Implication: if a downstream package needs something like -lLLVM-15git and uses
libLLVM-15git.so not in a well-known path, it needs to supply -L
D.Dir+"/../lib" explicitly (e.g. via LLVMConfig.cmake), instead of relying on
the previous default search path.

Diff Detail

Event Timeline

MaskRay created this revision.Mar 24 2022, 5:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 5:10 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
MaskRay requested review of this revision.Mar 24 2022, 5:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 5:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mgorny added inline comments.Mar 25 2022, 1:47 AM
clang/lib/Driver/ToolChains/Linux.cpp
316

I wonder if this still wouldn't get in the way of some (non-Gentoo) people who have clang in /usr/bin/clang and 32-bit libc++ in /usr/lib/libc++.so.

MaskRay marked an inline comment as done.Mar 25 2022, 9:38 AM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Linux.cpp
316

It won't. /lib and /usr/lib follow this search directory. Since /lib and /usr/lib are usually the same, or at least include different sets of files, the user will not observe different behaviors.

mgorny accepted this revision.Mar 25 2022, 9:53 AM

Thanks. Technically, it looks good to me. However, I'd suggest waiting until Jannik is able to test it.

This revision is now accepted and ready to land.Mar 25 2022, 9:53 AM
MaskRay edited the summary of this revision. (Show Details)Mar 25 2022, 2:52 PM
MaskRay edited the summary of this revision. (Show Details)Mar 25 2022, 2:54 PM
MaskRay edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.
jdoerfert reopened this revision.Mar 28 2022, 8:53 AM
jdoerfert added a subscriber: jdoerfert.

So, this broke all OpenMP (offloading) as libomp and (libomptarget) are no longer found by default. (OpenMP is build as ENABLE_RUNTIME.)

How do we fix this?

This revision is now accepted and ready to land.Mar 28 2022, 8:53 AM

This change broke finding the OpenMP runtime libraries when using the LLVM runtimes build.

clang foo.c -fopenmp -fopenmp-targets=nvptx64
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lomp
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lomptarget
MaskRay closed this revision.Apr 21 2022, 9:49 PM