Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 853967 - sys-devel/clang: standard headers installed to the wrong directory
Summary: sys-devel/clang: standard headers installed to the wrong directory
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-24 03:50 UTC by Peter Levine
Modified: 2022-06-25 00:04 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Levine 2022-06-24 03:50:42 UTC
I've been trying to debug some issues with clangd on a test build of qt-creator-8.0.0_beta1.  Having made attempts to work around the issue in an earlier version of qt-creator, it appears that clangd expects to find clang's standard headers at ../lib/clang/<version>/include (see https://github.com/gentoo/qt/pull/252#issuecomment-1164987058).  From https://clangd.llvm.org/troubleshooting#cant-find-compiler-built-in-headers-stddefh-etc:

> They must be found in ../lib/clang/<version>/include. If you’ve built clangd 
> from source or installed it from a package, these should be in the right 
> place. If you’ve moved the binary around, move it back!

With clang-14.0.5, that would be /usr/lib/llvm/14/lib/clang/14.0.5/include.  By default, that is where the build installs it, but in multilib_src_install(), there's:

> mv "${ED}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED}"/usr/include/clangrt || die

And in src_install() there's:

> # Move runtime headers to /usr/lib/clang, where they belong
> mv "${ED}"/usr/include/clangrt "${ED}"/usr/lib/clang || die

After omitting those lines and remerging, clangd finds the headers and all is well.

Although there exists the clangd flag '--resource-dir=', from `clangd --help-list-hidden`, if would seem to be a workaround that IDE's would have no reasonable expectation to have to support.  Furthermore, I could find no other distro that seemed to move the headers to the location Gentoo does.  Although it would present an unaesthetic asymmetry to leave clang's headers in the llvm prefix path, it would resolve issues with clangd.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-06-24 04:13:33 UTC
This is clangd bug.  Clang is built with CLANG_RESOURCE_DIR, so I don't see any reason why clangd would hardcode some stupid magic instead of using that.  Or calling `clang -print-resource-dir` that would also work.
Comment 2 Peter Levine 2022-06-25 00:04:20 UTC
Sorry.  It appears you're right. Clangd references CLANG_RESOURCE_DIR with
> Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR)

The problem is with assumptions made in qt-creator codebase.