diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -91,7 +91,13 @@ option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) -option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) +set(ENABLE_EXPERIMENTAL_DEFAULT ON) +if (WIN32 AND LIBCXX_ENABLE_SHARED) + # When libc++ is built as a DLL, all headers indicate DLL linkage, while + # libc++experimental always is linked statically. + set(ENABLE_EXPERIMENTAL_DEFAULT OFF) +endif() +option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ${ENABLE_EXPERIMENTAL_DEFAULT}) set(ENABLE_FILESYSTEM_DEFAULT ON) if (WIN32 AND NOT MINGW) # Filesystem is buildable for windows, but it requires __int128 helper @@ -402,6 +408,14 @@ message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") endif () +if (WIN32 AND LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) + message(FATAL_ERROR "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY can't be enabled" + " when LIBCXX_ENABLE_SHARED also is enabled for Windows," + " as the c++experimental library only is built as a" + " static library, while the headers signal dllimport" + " linkage.") +endif() + #=============================================================================== # Configure System #=============================================================================== diff --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst --- a/libcxx/docs/BuildingLibcxx.rst +++ b/libcxx/docs/BuildingLibcxx.rst @@ -90,7 +90,6 @@ -T "ClangCL" ^ -DLIBCXX_ENABLE_SHARED=YES ^ -DLIBCXX_ENABLE_STATIC=NO ^ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ \path\to\libcxx > cmake --build . @@ -120,7 +119,6 @@ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_C_COMPILER=clang-cl ^ -DCMAKE_CXX_COMPILER=clang-cl ^ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ path/to/libcxx > ninja cxx > ninja check-cxx diff --git a/libcxx/test/libcxx/experimental/lit.local.cfg b/libcxx/test/libcxx/experimental/lit.local.cfg --- a/libcxx/test/libcxx/experimental/lit.local.cfg +++ b/libcxx/test/libcxx/experimental/lit.local.cfg @@ -1,3 +1,7 @@ # Disable all of the experimental tests if the correct feature is not available. if 'c++experimental' not in config.available_features: config.unsupported = True +# If built as a DLL on Windows, headers indicate DLL linkage, which breaks +# linking against the static-only libc++experimental. +if config.enable_shared and 'windows' in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/experimental/lit.local.cfg b/libcxx/test/std/experimental/lit.local.cfg --- a/libcxx/test/std/experimental/lit.local.cfg +++ b/libcxx/test/std/experimental/lit.local.cfg @@ -1,3 +1,7 @@ # Disable all of the experimental tests if the correct feature is not available. if 'c++experimental' not in config.available_features: config.unsupported = True +# If built as a DLL on Windows, headers indicate DLL linkage, which breaks +# linking against the static-only libc++experimental. +if config.enable_shared and 'windows' in config.available_features: + config.unsupported = True