🐛 Build every C and C++ part of a Windows install with clang
A user's install of development on Windows stopped in sdl3-sys's CMake build: their environment's CC named Visual Studio's cl.exe, cc-rs gave the build MSVC's C flags (and clang's C++ flags, CXX being unset), and CMake, which reads CC itself where the cmake crate names no compiler, took cl.exe. Its test compile failed once MSYS2 had turned /nologo into C:/msys64/nologo. Visual Studio's install alone does not do it: cc-rs takes cl.exe from it for MSVC targets only, and our hosts set no CC, so no run of ours met it. install-ctl.sh on Windows now sets CC, CXX and AR, their per-target forms that cc-rs takes first, and CMake's generator, to CLANG64's clang, clang++, llvm-ar and MSYS Makefiles, for cargo's build scripts, CMake, QEMU's configure and meson alike. The generator is the one the cmake crate chose with none set, and CLANG64's ar is llvm-ar, so a host without those variables builds as before.
This commit is contained in:
1 parent
8807df2aa4
commit
bd239b6ddf
2 files changed
+12
No files matched your search
@@ -123,6 +123,7 @@ one. A new trap found the same way goes here.
|
||||
|
||||
- A file named for a device Windows keeps keeps the whole tree off Windows, and no check outside Windows sees it. `crates/reims-restore/src/aux.rs` landed with the restore batch (ad3b37b8e, 2026-11-16 02:03) through every check, as none checks the tree out on Windows, and from then on no Windows checkout of development worked: AUX, like CON, PRN, NUL, COM1 to COM9 and LPT1 to LPT9, is a name no Windows file takes, with any extension, so git for Windows refuses the path (`invalid path`, under `core.protectNTFS`, on by default). A Windows user's clone failed, and potluck seeded no workspace on homelab-mac-mini-2018 (m3-max-35864), so every Windows job at the tip failed before it began. A name holding `<>:"|?*`, or ending in a dot or a space, fails the same way, and two paths that differ only by case check out as one file. `cargo xtask paths`, the first step of `cargo xtask check`, checks every path `git ls-files` lists, the reims-ctl and reims-restore workspaces' among them. The next one shows as a Windows job, or clone, that fails before it starts with `invalid path` from git.
|
||||
- A checkout Git for Windows makes holds every text file with CRLF line ends where the repository says nothing of line ends, and a build that hashes its sources then fails there alone. Git for Windows' installer sets `core.autocrlf=true`, and a user's `install.ps1` clone of development held all 1730 text files CRLF: `cargo xtask dist` stopped in reims-vgpu-vulkan's build script, whose sha256 of the `.metal` sources no longer matched `metallibs/metallibs.toml` (2026-11-16). No check saw it, as every check's tree comes from a Mac, from Linux or from potluck's carried tree, never from a clone Git for Windows made. `.gitattributes` keeps the committed bytes in every checkout (`text=auto eol=lf`), but git does not write again a file a later checkout leaves as it was: a CRLF clone moved past `.gitattributes` keeps each file the move does not change CRLF, which `install-ctl.sh`'s `rewrite_crlf` writes out again. How to spot the next one: a hash or byte comparison that fails in a Windows checkout alone; `git ls-files --eol` shows `w/crlf` against `i/lf`.
|
||||
- A build script's C compiler is the one the environment names, and a host's own setting there reaches every crate that builds C. A user's Windows install of development stopped in sdl3-sys's CMake build: `CMAKE_C_FLAGS` held MSVC's flags (`-nologo -MD -Brepro -W0`) where `CMAKE_CXX_FLAGS` held clang's (`--target=x86_64-pc-windows-gnu`), and CMake took Visual Studio's `cl.exe` by its full path, whose test compile failed once MSYS2 had turned `/nologo` into `C:/msys64/nologo` (2026-11-16). cc-rs 1.5.1 takes `cl.exe` from Visual Studio's install for an MSVC target alone, for C and C++ alike, so only `CC` (or `HOST_CC`, `CC_<target>`) can split them; and the cmake crate (0.1.58) gives CMake no compiler on a Windows host for a `windows-gnu` target, so CMake reads `CC` itself. Our runs never met it, as no host of ours sets `CC`. `install-ctl.sh` on Windows sets the compilers, archiver and CMake generator for every build it runs. How to spot the next one: a C build that takes another compiler on one host; compare its C and C++ flags, and read the environment of the shell the build ran in.
|
||||
- A dependency reims-ctl takes is built for Windows too, and only a Windows build sees it. reims-ctl's arm64 restore (b5ad91b93) made it depend on reims-restore, written for the Mac and Linux, and with it on std's Unix `FileExt`, libc's `flock`, `statvfs` and signals, so reims-ctl built for Windows no more (m3-max-35871), though its tests, rustfmt and clippy passed on the Mac and Linux, the hosts its checks run on. The next one shows only in a Windows build of reims-ctl, on the mini (`cargo check --all-targets` in `crates/reims-ctl`): look there when a change gives reims-ctl a dependency or an OS call. reims-ctl's `os` module, reims-restore's `sys` and reims-apfs's `file_at` hold each OS's form.
|
||||
- A hard link shares a file's bytes, so code that may write the file it opens writes the original too. A live check of the IPSW download hard-linked the owner's cached 27.2.1 IPSW into a scratch cache as a finished `.part`, expecting the downloader only to hash it and read the CDN's 416 for a range past the file's end. Apple's CDN answers that 416 with `Content-Range: */25595954706`, without the `bytes` unit RFC 9110 puts there (**measured** 2026-11-11), which the downloader's parser didn't read, so it took the part for a wrong one, and its start-over truncated the part in place, and with it the owner's file. The downloader now never truncates or rewrites a file: it starts over by unlinking the part and making a new one, and learns the length first, so a whole part is only hashed. How to avoid the next: a live check never links an owner's file; it uses an APFS clone (`cp -c`) or a reflink, whose writes don't reach the original, or a cache of its own. Before linking anything, read the code for every write and truncate it could reach.
|
||||
|
||||
|
||||
@@ -463,6 +463,17 @@ if [[ $WINDOWS == 1 ]]; then
|
||||
export RUSTUP_TOOLCHAIN="$CHANNEL-x86_64-pc-windows-gnullvm"
|
||||
rustup toolchain install --profile minimal "$RUSTUP_TOOLCHAIN" ||
|
||||
die "rustup could not install $RUSTUP_TOOLCHAIN, the toolchain the build runs on Windows"
|
||||
# Every C and C++ build below runs CLANG64's clang and llvm-ar, whatever
|
||||
# compiler the environment names. A user's CC named Visual Studio's cl.exe:
|
||||
# cc-rs gave SDL3's CMake build (sdl3-sys, through the cmake crate) MSVC's C
|
||||
# flags, and CMake, which reads CC itself, took cl.exe, whose test compile
|
||||
# failed. cc-rs takes CC_<target> before HOST_CC and CC; CMake, QEMU's
|
||||
# configure and meson read CC, CXX and AR; the cmake crate takes
|
||||
# CMAKE_GENERATOR_<target> before CMAKE_GENERATOR, and chooses MSYS Makefiles
|
||||
# itself where neither is set. CLANG64's ar is llvm-ar.
|
||||
export CC=clang CXX=clang++ AR=llvm-ar CMAKE_GENERATOR="MSYS Makefiles"
|
||||
export CC_x86_64_pc_windows_gnullvm=clang CXX_x86_64_pc_windows_gnullvm=clang++ \
|
||||
AR_x86_64_pc_windows_gnullvm=llvm-ar CMAKE_GENERATOR_x86_64_pc_windows_gnullvm="MSYS Makefiles"
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------ sources
|
||||
|
||||
Reference in new issue
Block a user