build: three device-free executables do not build with the documented clang-cl route #3869
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#3869
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?
@triggered02 on GitHub · 2026-12-02 15:43 UTC · original
Summary.
docs/non-windows-hosts.mdsays the clang-cl + xwin route builds "the eight startup stand-ins (xmem_shim,d3d12_xs_shimand the sixstartup_stub_*targets) and the device-free test executables ... from a clean checkout". I built the whole tree that way on currentmainand three device-free executables do not build. One is a plain clang/MSVC divergence with a one-line fix (PR below); the other two I am reporting without a fix.Environment: Debian, clang-cl 19.1.1 + lld-link,
xwin splatof SDK 10.0.26100, Release, the toolchain file from that doc section. Tree:mainat0939575e, clean checkout.xapuis the known gap (no MSVCm.libon this host, already documented). The other three are below.1.
startup_gameinput_trace— const-cast idiom, fixed in #3868.vtblisconst void* const*, and four calls doreinterpret_cast<Fn>(vtbl[n]), which dropsconst:MSVC accepts this, clang does not. Casting through
const_cast<void*>first is accepted by both and changes nothing at runtime. With that one change the target links.2.
xmem_commit_protection_check— the compiler crashes.139 is SIGSEGV in the frontend, not a diagnostic. It may be a clang 19.1.1 bug rather than anything this repo does, but it means the target cannot be built on this route at all. I have not reduced it;
-vand a reduced preprocessed source would be the next step, and I do not know whether it reproduces on other clang versions.3.
startup_host_cpu_probe— intrinsics unresolved at link.The source uses intrinsics that MSVC's headers declare
__forceinlinefrom<intrin.h>; with this layout they arrive as external calls instead. Likely a missing#include <intrin.h>or an architecture flag (/arch:SSE2/-msse2) on this route. I have not confirmed which.What I am not claiming. None of this affects the Windows build or CI — MSVC remains the reference and Windows CI is green. It only narrows what "builds on Linux with clang-cl" actually covers, and two of the three gaps look like documentation overstatement rather than code defects worth changing for their own sake.
I am fixing (1) in a PR because it is small, verifiable here, and inside the route the doc already promises. Say if you would rather the doc name the narrower set of targets that currently build and I will do that instead.
@triggered02 on GitHub · 2026-12-02 15:46 UTC · original
Progress on two of the three, plus a root cause for the third.
2.
xmem_commit_protection_check— reduced, fixed in #3871, and it is an upstream clang bug. The crash is inGenerateSEHFilterFunction→EmitCapturedLocals→recoverAddrOfEscapedLocal. Trigger, reduced to ~20 lines:__exceptfiltercapture_fault(GetExceptionInformation(), &info)capture_fault(plain_ep(), &info)capture_fault(GetExceptionInformation())— no captured localSo clang 19.1.1 cannot recover an escaped local inside an outlined SEH filter when that filter also references the exception record. The workaround in #3871 records through a
thread_localsink so the filter captures nothing; semantics and MSVC output are unchanged.3.
startup_host_cpu_probe— root cause identified, not fixed. It is not a missing<intrin.h>(the file already includes<immintrin.h>and<intrin.h>). The build picks up xwin's MSVC CRT headers, not clang's:MSVC's headers declare these intrinsics and rely on
#pragma intrinsic; under clang-cl those declarations are not turned into clang builtins, so_mm_loadu_si128,__rdtscp,_mm_set_epi32,_mm_add_epi32are emitted as calls and stay undefined at link:__SSE2__is defined and the target is x86-64, so this is not an architecture-flag problem — it is header precedence: the/imsvcxwin paths are searched before clang's-internal-isystemresource headers. The fix therefore belongs in the toolchain file or the CMake warning/feature block, not in the test source, and I would rather you decide which side owns it than have me move header precedence around in a file other contributors copy into their own toolchains. Options I see: give clang's resource include priority over the xwin CRT for<*.h>intrinsics, or add#if defined(__clang__)builtin mappings in the one test that needs them.1.
startup_gameinput_trace— fixed in #3870.@triggered02 on GitHub · 2026-12-02 16:05 UTC · original
Correction on item 3 — that one is my host, not the repository. Please disregard the header-precedence theory; I found the actual cause and it is a broken toolchain install on my side.
My unpacked Ubuntu
llvm-19archive has no clang resource headers at all —lib/clang/19/includedoes not exist. So clang-cl has no intrinsic headers of its own, picks up the MSVC<immintrin.h>from the xwin CRT, and MSVC's declarations stay unresolved because clang does not honour#pragma intrinsicfor them._mm_loadu_si128etc. therefore become calls, exactly asllvm-nmshowed.On a toolchain that ships
libclang-common-19-dev(or any complete clang install) the resource headers are present, clang's own<immintrin.h>defines those intrinsics as builtins, and this link failure should not occur. So item 3 is not evidence against the documented route and needs no repository change. I have not verified that on a complete install — I am telling you what the missing directory implies, not claiming a clean build I did not run.For completeness, I also tested the fix that would have followed from my wrong theory: putting clang's resource include first in the
/imsvclist changes nothing here, because the directory is empty. That experiment is void.Status of the three gaps, corrected:
startup_gameinput_trace— repository bug, fixed in #3870 (approved).xmem_commit_protection_check— upstream clang bug, reduced, worked around in #3871 (merged intomainas6e3a181b).startup_host_cpu_probe— my host's incomplete LLVM install, not a repository issue. Withdraw.I would still like to know whether the doc's sentence holds on a complete clang install, but that is your call to spend time on — from here the only honest next step I could take is installing the missing headers and re-running, which does not test the repository at all.