fix: give the mingw target a sysroot that holds mingw-w64 alone #44
No reviewers
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!44
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/issue-43"
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?
Fixes #43.
The first three commits are the original fix. The nine after
5fdbf2baddress the 15 findings of a/code-reviewof it. They are listed under "Review round" below.What was wrong
Inside the Flatpak, the mingw-w64 prefix is the host's
/usr, and it went to clang as--sysroot=/run/host/usr. clang's MinGW driver treats a sysroot as a tree that holds only mingw-w64. It searches that tree'sinclude/andlib/too, and for/usrthose are the Linux system's own:libstdc++'s
<ext/atomicity.h>found glibc's<sys/single_threaded.h>, soshared_ptrread::__libc_single_threaded, which nothing on Windows defines, and every program using one failed to link.CRAFTER_MINGW_DIR=/usrbroke the same way outside the Flatpak.The fix
MingwSysroot()): a prefix that holds only mingw-w64 is passed whole, as before, so Windows libraries installed into itsinclude/andlib/keep working. A prefix that also holds a Linux system is shown through a view instead: links to itsx86_64-w64-mingw32/,lib/gcc/andlib64/gcc/, the directory the issue suggests. Two cases count as a system prefix: the host's/usrinside the Flatpak, always, and any prefix whoseinclude/has a C library'sfeatures.h, as/usrdoes.$XDG_RUNTIME_DIR/crafter.build, where the XDG spec guarantees them.BuildStdPcm's errors, name headers by their path in the prefix, not in the hashed cache directory.StdPcmFlagsis the one source ofBuildStdPcm's flags.StdPcmKeynames the directory by target, march and toolchain, plus a hash of those flags and, for mingw, of the prefix.VariantId()hashesStdPcmKey, so a build moves with its std module. This replaces the per-target special cases inStdPcmDir. It also ends a std PCM being rebuilt in place on every run when only-mtuneor the sysroot differs, for example a project with-mtune=genericagainstproject.cpp's-mtune=native.-fmodule-file-deps). A std module rebuilt in place, after a libc++ update or a mingw-w64 update under the same prefix, now recompiles its importers instead of only relinking them.Inside the Flatpak the view looks like this, and nothing else of the host's
/usrreaches clang:For the release notes
project.cppthat reads the toolchain:Toolchain::mingwSysrootis nowmingwPrefix(withmingwPrefixIsSystembeside it). The mingw target's--sysrootisMingwSysroot(). PassingmingwPrefixas--sysrootwould bring #43 back for a system prefix. None of the Catcrafts repos checked out on the dev machine reads the field.crafter-build clean, or until the cache is cleared by hand.stableandbetacan, now rebuild such an external from nothing each time they take turns, where before they reused each other's objects.Review round
fix(external)+ExternalReconfigurefix: key the std module's directory…include/andlib/fix(mingw)fix(mingw)(test isolation),fix(lint)+ Lint caseCMAKE_SYSROOTfix(mingw)fix(mingw)(XDG_RUNTIME_DIRfallback)MingwSysroottest compiled x86 with-march=native, which fails on non-x86 hostsfix(mingw)(test)fix(mingw)(MingwViewToPrefix)lib64/gccand the Flatpak cache locationdocsfix(mingw)fix(mingw)StdPcmDirkeyed on per-target special casesfix: key the std module's directory….cppunits did not record imported BMIsfix: recompile the units…+StdPcmRebuildStdPcmKeychecks inVariantIdOne shortcut stays in a test:
MingwSysrootwrites its stand-inexport module std;throughstd::format, because the import scanner reads string literals as code. #45 replaces the scanner's regexes withclang-scan-deps, and drops the workaround.Testing
MingwSysroot,StdPcmRebuild,ExternalReconfigureand a new Lint case. Against the code before their fixes, each fails on the check its fix guards. I checked that by reverting each fix in the working tree, apart from the newStdPcmKeyandMakeMingwSysrootAPI, which doesn't exist without them.ToolchainResolve(spellings, which prefixes count as a system),VariantId(StdPcmKeyper toolchain: mingw prefix, whole or viewed,-mtune, sysroot, wasm variant), andSysrootCompileFlags(its own cache).CRAFTER_MINGW_DIR=/usrbuilds astd::make_sharedprogram through the view, and the.exeprintshiunder wine. On master it fails withundefined symbol: __libc_single_threaded.include/andlib/, is passed whole. The header and-lwinonlyare found, the.exeprints42, and no view is made for it.stablebranch (4.0.0, clang 23.1.2), with the host's mingw-w64 at/run/host/usrand noCRAFTER_MINGW_DIR. This tree was bootstrapped there with the bundled LLVM, as the manifest does.std::make_sharedprogram with the issue'sundefined symbol: __libc_single_threaded.clean, builds into a new variant directory, compiles and links. The.exeprintshiunder wine.WasiBrowserRuntimeExit, because the sandbox has no node).fix(mingw)and the std module key) each bootstrap and pass their tests on their own.formatandlintare clean. The native suite gives 44 passed and 3 skipped, the usual environment skips:WasmExceptionsandWasmHelloRunsneed an exception-enabled WASI sysroot, andConcurrentCacheRaceneeds an installedshare/crafter-build.🤖 Generated with Claude Code