A toolchain whose path has a space or a shell metacharacter cannot be used: the compiler and llvm-ar go into shell commands unquoted #56
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#56
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
crafter-build runs its commands through
sh, and puts the toolchain's own programs into some of them quoted and into others as they stand. Where the toolchain's directory has a space, or a character the shell interprets, the first unquoted command, a probeGetToolchain()runs, already fails, and nothing builds.CRAFTER_BUILD_LLVM_DIRcan name such a directory, and so can a toolchain installed beside crafter-build:The toolchain goes into a command unquoted in:
GetToolchain()'s three probes,-print-target-triple,--versionand-no-canonical-prefixes --version(implementations/Crafter.Build-Toolchain.cpp:412,:428,:434);ClangResourceDir(), lint's-print-resource-dir(implementations/Crafter.Build-Lint.cpp:718);GetBaseCommand(), the first word of every compile command, of the std module's, of the host PCM cache's and of project.cpp's own (implementations/Crafter.Build-Platform.cpp:994);implementations/Crafter.Build-Clang.cpp:2014).It is quoted, with
ShellQuote, by the scan, for the scanner and the compiler the scan is given (implementations/Crafter.Build-Clang.cpp:1179); by the Flatpak packager, for the compiler's-print-file-nameand for llvm-readelf (implementations/Crafter.Build-Flatpak.cpp:215,:226); and by the CMake externals, forCMAKE_C_COMPILERandCMAKE_CXX_COMPILER(implementations/Crafter.Build-External.cpp:135-136).The compile command carries other paths unquoted too, the std module's and the configuration's PCM directories (
-fprebuilt-module-path) and the sysroot (implementations/Crafter.Build-Clang.cpp:665,:668), and the comment onCommandToArgstakes that as known: "the build assembles and runs this very string through a shell, so a path containing a space is already unsupported upstream of here" (implementations/Crafter.Build-Lint.cpp:358-361). Nothing tells the user, though: the message above is the shell's.Reproduced with
cb8914d(6.4.3) built natively,CRAFTER_BUILD_LLVM_DIRnaming a directory with a space whosebin/links to the system's clang++, clang, llvm-ar, llvm-readelf and clang-scan-deps. Found by the pre-push review of 6.4.3.Line numbers refer to
cb8914d(6.4.3).Proposal
Quote every path the commands carry, as the scan, the packager and the CMake externals already do. Or refuse a toolchain or project path that the shell would split or interpret, where the Toolchain and the configuration are resolved, with a message that says why.