Cross builds with clang 18 work again: mimalloc's C++ gets past the MSVC headers' Clang 19 check (STL1000) #4353

Closed
github-bot wants to merge 14 commits from github-bot/gh-4352 into main AGit
Owner

@⁠kMagic142 on GitHub · 2026-11-30 19:14 UTC · original
kMagic142:pr-clang-mimalloc → main · +967 −847 · 33 files · 14 commits · closed without merging

What it changes

Since #1487, victory-gpu depends on mimalloc. On MSVC targets libmimalloc-sys (0.1.49) compiles mimalloc's sources as C++, so they include the C++ headers of Microsoft's STL, and those stop any Clang older than 19:

error STL1000: Unexpected compiler version, expected Clang 19.0.0 or newer.

A cross build with cargo-xwin (docs/linux-proton.md) compiles them with the system's clang-cl, and on Ubuntu 24.04 that is clang 18.1.3. So cargo xwin build, check, clippy and test of main stop in libmimalloc-sys's build script there. Windows builds with Visual Studio, as in CI, are not affected.

.cargo/config.toml now sets this, with a comment saying why:

[env]
CL = "/D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"

Cargo passes [env] to build scripts, and the compiler cc runs from them inherits it: CL holds options that cl.exe and clang-cl put in front of their own command line. The macro turns off only the compiler-version checks in yvals_core.h (STL1000 for Clang, STL1001 for cl.exe, STL1002 for CUDA); nothing else in the headers reads it. mimalloc then compiles with clang 18.

  • _CL_ would not do: its options go after the command's own, and cc ends a clang-cl command with -- <source file>, so they would be read as file names.
  • Visual Studio's cl.exe reads CL too, and there the define changes nothing: cl.exe passes its own headers' check already.
  • A CL already set in the environment is kept; cargo's [env] does not replace a variable that is set.
  • Other build scripts that compile C: in the lockfile only blake3's, which compiles its SSE/AVX assembly and checks the /arch:AVX512 flag. No C++ header is involved there, and the extra /D changes nothing. The workspace's own build scripts compile nothing (victory-gpu and victory-shader fingerprint their sources; apps/victory and tests/fixtures/hle-probe pass linker arguments).
  • Cargo.lock does not change, so neither does the translator's fingerprint. cc has a build script rerun when CL changes, so the first build after this runs libmimalloc-sys's again, once.

The [env] table goes above [alias], so that it merges without conflict with the open PRs that add a table below [alias] (see below).

How it was tested

  • GPU and profile: build only; nothing changes at run time. Cross-built with cargo-xwin on Ubuntu 24.04 (clang 18.1.3), main at e1251c31.
  • Before: main, in an empty target directory. cargo xwin check --locked -p victory --target x86_64-pc-windows-msvc fails (exit 101) with failed to run custom build command for libmimalloc-sys v0.1.49:
    yvals_core.h(908,1): error: static assertion failed: error STL1000: Unexpected compiler version, expected Clang 19.0.0 or newer.
    
  • After: this branch, after cargo clean -p libmimalloc-sys --target x86_64-pc-windows-msvc. The same command passes (exit 0). libmimalloc-sys's build script ran with CL set to the define, and mimalloc's object was compiled by clang 18.1.3.
  • Not built with Visual Studio's cl.exe here; CI's Windows job does that, now with CL set.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: it touches no crate's code; the check above runs every build script victory needs.

Checked for overlap

  • I searched the open pull requests for mimalloc, clang, clang-cl, STL1000, xwin, cargo-xwin and the macro's name, and for the file this touches (.cargo/config.toml). None of them fixes this. Related:
    • #537 and #730 add a rustflags table (target-cpu=x86-64-v3) below [alias] in .cargo/config.toml. This PR merges with either without conflict (checked with git merge-file).
    • #1630 adds a linux-cross CI job that runs cargo xwin clippy and cargo xwin build with the clang Ubuntu installs on ubuntu-latest (24.04, clang 18). That is the setup above, so on today's main that job would stop at STL1000 too; with this PR it would not.
    • #3687 adds a job that checks and tests the workspace for Linux itself. There mimalloc compiles as C with the Linux compiler, which does not read CL, so nothing changes for it.
**@⁠kMagic142** on GitHub · 2026-11-30 19:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4352) `kMagic142:pr-clang-mimalloc` → `main` · +967 −847 · 33 files · 14 commits · closed without merging ## What it changes Since #1487, `victory-gpu` depends on mimalloc. On MSVC targets `libmimalloc-sys` (0.1.49) compiles mimalloc's sources as C++, so they include the C++ headers of Microsoft's STL, and those stop any Clang older than 19: ``` error STL1000: Unexpected compiler version, expected Clang 19.0.0 or newer. ``` A cross build with cargo-xwin (`docs/linux-proton.md`) compiles them with the system's `clang-cl`, and on Ubuntu 24.04 that is clang 18.1.3. So `cargo xwin build`, `check`, `clippy` and `test` of main stop in libmimalloc-sys's build script there. Windows builds with Visual Studio, as in CI, are not affected. `.cargo/config.toml` now sets this, with a comment saying why: ```toml [env] CL = "/D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH" ``` Cargo passes `[env]` to build scripts, and the compiler cc runs from them inherits it: `CL` holds options that cl.exe and clang-cl put in front of their own command line. The macro turns off only the compiler-version checks in `yvals_core.h` (STL1000 for Clang, STL1001 for cl.exe, STL1002 for CUDA); nothing else in the headers reads it. mimalloc then compiles with clang 18. - `_CL_` would not do: its options go after the command's own, and cc ends a clang-cl command with `-- <source file>`, so they would be read as file names. - Visual Studio's cl.exe reads `CL` too, and there the define changes nothing: cl.exe passes its own headers' check already. - A `CL` already set in the environment is kept; cargo's `[env]` does not replace a variable that is set. - Other build scripts that compile C: in the lockfile only `blake3`'s, which compiles its SSE/AVX assembly and checks the `/arch:AVX512` flag. No C++ header is involved there, and the extra `/D` changes nothing. The workspace's own build scripts compile nothing (`victory-gpu` and `victory-shader` fingerprint their sources; `apps/victory` and `tests/fixtures/hle-probe` pass linker arguments). - `Cargo.lock` does not change, so neither does the translator's fingerprint. cc has a build script rerun when `CL` changes, so the first build after this runs libmimalloc-sys's again, once. The `[env]` table goes above `[alias]`, so that it merges without conflict with the open PRs that add a table below `[alias]` (see below). ## How it was tested - GPU and profile: build only; nothing changes at run time. Cross-built with cargo-xwin on Ubuntu 24.04 (clang 18.1.3), main at e1251c31. - Before: main, in an empty target directory. `cargo xwin check --locked -p victory --target x86_64-pc-windows-msvc` fails (exit 101) with `failed to run custom build command for libmimalloc-sys v0.1.49`: ``` yvals_core.h(908,1): error: static assertion failed: error STL1000: Unexpected compiler version, expected Clang 19.0.0 or newer. ``` - After: this branch, after `cargo clean -p libmimalloc-sys --target x86_64-pc-windows-msvc`. The same command passes (exit 0). libmimalloc-sys's build script ran with `CL` set to the define, and mimalloc's object was compiled by clang 18.1.3. - Not built with Visual Studio's cl.exe here; CI's Windows job does that, now with `CL` set. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: it touches no crate's code; the check above runs every build script `victory` needs. ## Checked for overlap - [x] I searched the open pull requests for mimalloc, clang, clang-cl, STL1000, xwin, cargo-xwin and the macro's name, and for the file this touches (`.cargo/config.toml`). None of them fixes this. Related: - #537 and #730 add a `rustflags` table (`target-cpu=x86-64-v3`) below `[alias]` in `.cargo/config.toml`. This PR merges with either without conflict (checked with `git merge-file`). - #1630 adds a `linux-cross` CI job that runs `cargo xwin clippy` and `cargo xwin build` with the `clang` Ubuntu installs on `ubuntu-latest` (24.04, clang 18). That is the setup above, so on today's main that job would stop at STL1000 too; with this PR it would not. - #3687 adds a job that checks and tests the workspace for Linux itself. There mimalloc compiles as C with the Linux compiler, which does not read `CL`, so nothing changes for it.
libmimalloc-sys compiles mimalloc's sources as C++ on MSVC targets, and the
C++ headers of Microsoft's STL stop any Clang older than 19 with error
STL1000. A cross build with cargo-xwin uses the system's clang-cl, which is
Clang 18 on Ubuntu 24.04, so cargo xwin build/check/clippy/test of main
failed in libmimalloc-sys's build script there.

.cargo/config.toml now sets CL, the options cl.exe and clang-cl put in front
of their own command line, to /D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH.
The macro turns off only the headers' compiler-version checks, which Visual
Studio's own cl.exe passes anyway; a CL already set is kept. (_CL_ would land
after cc's `--` and be read as a file name.) The [env] table goes above
[alias] so it merges cleanly with the open PRs that add a table below it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:16:02 +00:00
github-bot closed this pull request 2026-12-01 18:43:48 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4352#issuecomment-7321380672) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4353
No description provided.