This is an archive of the discontinued LLVM Phabricator instance.

[clang] [ToolChains/NetBSD] Support relative libc++ header path
ClosedPublic

Authored by mgorny on Feb 24 2019, 2:32 AM.

Details

Summary

Support locating the libc++ header files relatively to the clang
executable, in addition to the default system path. This is meant
to cover two use cases: running just-built clang from the install
directory, and running installed clang from non-standard location
(e.g. /usr/local).

This is the first step towards ensuring that tests of more LLVM projects
can work out-of-the-box within the build tree, and use the correct set
of headers (rather than e.g. mixing just-built clang+libcxx with system
install of libcxx). It avoids requiring the user to hack around missing
include paths, or LLVM build system to replicate system-specific C++
library defaults in order to append appropriate paths implicitly.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny created this revision.Feb 24 2019, 2:32 AM
Herald added a project: Restricted Project. · View Herald Transcript
krytarowski added inline comments.Feb 24 2019, 3:28 AM
clang/lib/Driver/ToolChains/NetBSD.cpp
430 ↗(On Diff #188079)

I propose to go for:

getDriver().SysRoot + "/usr/include/c++/v1", with a fallback for getDriver().SysRoot + "/usr/include/c++",

This innocent customization of paths triggers a lot of headache.

We should switch system location to /usr/include/c++/v1 for next version of LLVM (9.0 as 8.0 is branched and will be released soon).

This way we will keep compat with legacy paths and new clang.

mgorny marked an inline comment as done.Feb 24 2019, 3:35 AM
mgorny added inline comments.
clang/lib/Driver/ToolChains/NetBSD.cpp
430 ↗(On Diff #188079)

This is already handled by the relative path (when getDriver().Dir is /usr/bin).

krytarowski added inline comments.Feb 24 2019, 3:37 AM
clang/lib/Driver/ToolChains/NetBSD.cpp
430 ↗(On Diff #188079)

We still can build newer Clang in pkgsrc on newer base with headers moved to /usr/include/v1/c++ and it will break.

mgorny marked an inline comment as done.Feb 24 2019, 4:45 AM
mgorny added inline comments.
clang/lib/Driver/ToolChains/NetBSD.cpp
430 ↗(On Diff #188079)

I don't understand. Why would it break? (besides the typo in the path)

krytarowski added inline comments.Feb 24 2019, 8:21 AM
clang/lib/Driver/ToolChains/NetBSD.cpp
430 ↗(On Diff #188079)

clang will be installed into /usr/pkg/bin/clang and we want to reach the default headers in /usr/include/c++/v1 (in a setup without installing libc++ in pkgsrc)

joerg added a comment.Feb 24 2019, 9:23 AM

I'm not in favor of this. It adds overhead for the system compiler and generally makes the logic more complicated. This seems to be another hack around the fact that the driver has no clear notion of "use system runtime" vs "use custom runtime".

mgorny updated this revision to Diff 188083.Feb 24 2019, 9:37 AM

Shamelessly increased overhead by checking one more path as requested by Kamil.

krytarowski accepted this revision.Feb 24 2019, 10:23 AM

This will make life much more easier now with this change.

This revision is now accepted and ready to land.Feb 24 2019, 10:23 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2019, 2:06 AM