Skip to content

Revert normalize case of __rootpath__ on Windows - #27639

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:fix-windows-rootpath-normcase
Sep 1, 2026
Merged

Revert normalize case of __rootpath__ on Windows#27639
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:fix-windows-rootpath-normcase

Conversation

@sbc100

@sbc100 sbc100 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

In #27626, __rootpath__ was changed to use
os.path.normcase(__file__) to prevent caller-specified casing from propagating to config.LLVM_ROOT and sanity.txt.

However, on Windows normcase unconditionally converts the entire path including the drive letter to lowercase (c:\...). This lowercases all paths derived from path_from_root, including default config.CACHE and EMSCRIPTEN_SYSROOT.

When CMake runs on Windows, imported targets and compiler autodetection preserve uppercase drive letters (C:\...). Because CMake's implicit include directory checks are case-sensitive string comparisons, the mismatch between c:\... and C:\... caused CMake to treat the sysroot include directory as an explicit non-system include, injecting -isystem and disrupting libc++ header search order in test_cmake_install. It also caused assertion failures in test_cmake_compile_commands_noforce.

The normalization of config.LLVM_ROOT in generate_sanity() in tools/shared.py (also added in #27626) is already sufficient to ensure that sanity.txt remains consistent regardless of the casing used to invoke emcc. Normalizing __rootpath__ is unnecessary and harmful.

See: #27626

In emscripten-core#27626, `__rootpath__` was changed to use
`os.path.normcase(__file__)` to prevent caller-specified casing from
propagating to `config.LLVM_ROOT` and `sanity.txt`.

However, on Windows `normcase` unconditionally converts the entire path
including the drive letter to lowercase (`c:\...`). This lowercases all
paths derived from `path_from_root`, including default `config.CACHE`
and `EMSCRIPTEN_SYSROOT`.

When CMake runs on Windows, imported targets and compiler autodetection
preserve uppercase drive letters (`C:\...`). Because CMake's implicit
include directory checks are case-sensitive string comparisons, the
mismatch between `c:\...` and `C:\...` caused CMake to treat the
sysroot include directory as an explicit non-system include, injecting
`-isystem` and disrupting libc++ header search order in
`test_cmake_install`. It also caused assertion failures in
`test_cmake_compile_commands_noforce`.

The normalization of `config.LLVM_ROOT` in `generate_sanity()` in
`tools/shared.py` (also added in emscripten-core#27626) is already sufficient to ensure
that `sanity.txt` remains consistent regardless of the casing used to
invoke `emcc`. Normalizing `__rootpath__` is unnecessary and harmful.

See: emscripten-core#27626
@sbc100
sbc100 requested review from dschuff and kripken September 1, 2026 18:34
@sbc100
sbc100 merged commit a2059f9 into emscripten-core:main Sep 1, 2026
40 of 42 checks passed
@sbc100
sbc100 deleted the fix-windows-rootpath-normcase branch September 1, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants