The scan passes no -resource-dir, so a clang-scan-deps of another LLVM release than clang++ looks for clang's own headers where its own release would keep them #58
Labels
No labels
bug
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Build#58
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Since 6.4.2 a build reads what each
.cppmand.cppdeclares and imports with clang-scan-deps over the source's compile command (ScanSource,implementations/Crafter.Build-Clang.cpp:1171-1179). That command has no-resource-dir, and clang-scan-deps then works the resource directory out as a driver does, from the command's first word:<its directory>/../lib/clang/<major>, with the major of the release clang-scan-deps was built from, not the compiler's. In LLVM 23.1.2,--resource-dir-recipeismodify-compiler-pathunless it is given (clang/tools/clang-scan-deps/ClangScanDeps.cpp:79-82,:112,:239-253); onlyinvoke-compilerasks the compiler (:945-952); and the directory is made withCLANG_VERSION_MAJOR_STRING(clang/lib/Options/OptionUtils.cpp:226-236). The compile works it out with the compiler's own major.The two are of one release where the Toolchain takes them from one prefix,
CRAFTER_BUILD_LLVM_DIRor a toolchain beside crafter-build, as in the Flatpak. Without one, the compiler is the bareclang++and the scanner the bareclang-scan-deps(implementations/Crafter.Build-Toolchain.cpp:223-228), each the first of its name on PATH, and those can come from different installations: say, a PATH whoseclang++is LLVM 23's and whoseclang-scan-depsis another release's. The scan then looks forstddef.h, which libc++'s headers include, in a directory named for the scanner's release under the compiler's installation. Where there is none, the scan of every source that includes a header of the C++ standard library fails on'stddef.h' file not found, and the build with it, though the compile would find the header. A scan whose first word leads to no resource directory fails in just that way: it is how a compiler reached through a link from another directory failed its scan in 6.4.2, which 6.4.3 fixed.Which directory the scan works it out from changed in 6.4.3. Through 6.4.2 the first word was
clang++as the Toolchain has it, which clang-scan-deps looks up on PATH without following a link; since 6.4.3 it is the compiler in the directoryclang++ --versionnames (ScannedAs,implementations/Crafter.Build-Clang.cpp:1141-1162). Which of the two has alib/clang/<scanner's major>depends on how the installations are laid out.Lint's parse gives libclang a
-resource-dirfromclang++ -print-resource-dir, for the same reason with a libclang of another release than the compiler (ClangResourceDir,implementations/Crafter.Build-Lint.cpp:710-725, used at:782).Not run: only one LLVM major is at hand, 23.1.3 natively and 23.1.2 in the Flatpak. Found by the pre-push review of 6.4.3. #52 is about clang-scan-deps of another release as well.
Line numbers refer to
cb8914d(6.4.3), and LLVM's to 23.1.2.Proposal
Give the scan the compile's resource directory:
-resource-dir=from the compiler, as lint has it, withClangResourceDirmoved into the Toolchain so that both read one answer, or--resource-dir-recipe=invoke-compiler, which has clang-scan-deps run<first word> -print-resource-dironce per compiler. Or, where the Toolchain comes from PATH, take clang-scan-deps from the directory the compiler is installed in (installedDir) when it is there, and llvm-ar and llvm-readelf with it, so that the tools of one build cannot be of two releases.