Revert normalize case of __rootpath__ on Windows - #27639
Merged
Merged
Conversation
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
kripken
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #27626,
__rootpath__was changed to useos.path.normcase(__file__)to prevent caller-specified casing from propagating toconfig.LLVM_ROOTandsanity.txt.However, on Windows
normcaseunconditionally converts the entire path including the drive letter to lowercase (c:\...). This lowercases all paths derived frompath_from_root, including defaultconfig.CACHEandEMSCRIPTEN_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 betweenc:\...andC:\...caused CMake to treat the sysroot include directory as an explicit non-system include, injecting-isystemand disrupting libc++ header search order intest_cmake_install. It also caused assertion failures intest_cmake_compile_commands_noforce.The normalization of
config.LLVM_ROOTingenerate_sanity()intools/shared.py(also added in #27626) is already sufficient to ensure thatsanity.txtremains consistent regardless of the casing used to invokeemcc. Normalizing__rootpath__is unnecessary and harmful.See: #27626