This is an archive of the discontinued LLVM Phabricator instance.

[clang] [Driver] Add clang's relative `../lib` path only when in build tree
AbandonedPublic

Authored by MaskRay on Mar 24 2022, 12:17 PM.

Details

Reviewers
sunlin
mgorny
Summary

Change the code responsible for adding ../lib directory relative
to the clang executable directory to apply only if clang is actually
run from the build directory. According to the existing comment, this
is what the purpose of the code is.

Before, the addition was unconditional and therefore it was added
for installed clang as well. Unfortunately, this meant that on 64-bit
Gentoo systems the effective /usr/lib/llvm/*/lib path would be added
implicitly and would take precedence over the correct
/usr/lib/llvm/*/lib64 path if supplied by user. Since lib contains
32-bit LLVM/Clang libraries, it would break the 64-bit apps trying
to link against them.

Diff Detail

Event Timeline

mgorny created this revision.Mar 24 2022, 12:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 12:17 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
mgorny requested review of this revision.Mar 24 2022, 12:17 PM
MaskRay added a comment.EditedMar 24 2022, 12:23 PM

Is addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); from D108286 the issue?

If yes, I lean toward reverting D108286 and possibly removing LIBCXX_LIBDIR_SUFFIX as a CMake configuration (#libc_vendors).

The multilib style lib32 lib64 are more about glibc and GCC library search paths. llvm-project runtime libraries (including libc++) do not necessarily use that style.
In addition, we are shifting to multiarch style hierarchies which render lib32/lib64 unnecessary.

Is addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); from D108286 the issue?

No, the issue is actually the hardcoded lib directory that breaks multilib builds when using LLD.

MaskRay commandeered this revision.May 3 2022, 10:36 AM
MaskRay edited reviewers, added: mgorny; removed: MaskRay.

Obsoleted by D122444 (Hope I am not mistaken)

MaskRay abandoned this revision.May 3 2022, 10:36 AM