-
Couldn't load subscription status.
- Fork 15k
Description
When configuring a freestanding libcxx build on Windows using the runtimes build entrypoint, setting -DLIBCXX_ENABLE_FILESYSTEM=OFF does not prevent filesystem source files from being added to the build target. This results in a compilation failure, as these sources have dependencies (e.g, Unicode, wide characters) that are typically disabled in such a configuration.
This issue does not occur on Linux with an identical configruation.
Environment
- OS: Windows 10 22H2
- Compiler: Clang 21.1.1 (From MSYS2
clang64toolchain) - Build System: Ninja
- LLVM commit:
mainbranch
Reproduction
- From the root of
llvm-project, run the following CMake command:
cmake -G Ninja -S runtimes -B build-freestanding
-DLLVM_ENABLE_RUNTIMES=libcxx
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=install
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DLIBCXX_ENABLE_SHARED=OFF
-DLIBCXX_ENABLE_STATIC=ON
-DLIBCXX_CXX_ABI=none
-DLIBCXX_ENABLE_EXCEPTIONS=OFF
-DLIBCXX_ENABLE_RTTI=OFF
-DLIBCXX_ENABLE_FILESYSTEM=OFF
-DLIBCXX_ENABLE_LOCALIZATION=OFF
-DLIBCXX_ENABLE_UNICODE=OFF
-DLIBCXX_ENABLE_WIDE_CHARACTERS=OFF
-DLIBCXX_ENABLE_THREADS=OFF
-DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF
-DLIBCXX_ENABLE_TIME_ZONE_DATABASE=OFF
-DLIBCXX_ENABLE_RANDOM_DEVICE=OFF
-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=OFF
-DLIBCXX_INCLUDE_TESTS=OFF
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
-DLIBCXX_USE_COMPILER_RT=ON- Go to the build directoryt and run
ninja:
cd build-freestanding
ninja
Actual Behavior
The build fails with compilation errors in filesystem-related source files.
... llvm-project/build-freestanding/include/c++/v1/__filesystem/path.h:186:9: error: unknown type name 'wstring'; did you mean 'string'?
186 | typedef wstring __path_string;
| ^~~~~~~
| string
... llvm-project/build-freestanding/include/c++/v1/__fwd/string.h:45:7: note: 'string' declared here
45 | using string = basic_string<char>;
| ^
Expected Behavior
The build should succeed. Source files from the libcxx/src/filesystem directory should not be part of the build when LIBCXX_ENABLE_FILESYSTEM is OFF.
Speculation
Probable root cause is in libcxx/src/CMakeLists.txt. Filesystem source files (filesystem_*.cpp) are unconditionally added to the LIBCXX_SOURCES variable.
These files should be moved inside the guard for LIBCXX_ENABLE_FILESYSTEM block.