[libcxx-commits] [PATCH] D99178: [libcxx] Disable c++experimental by default in DLL builds

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 12 12:53:54 PDT 2021


mstorsjo updated this revision to Diff 344923.
mstorsjo added a comment.

Rebased on top of other Windows CI updates.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99178/new/

https://reviews.llvm.org/D99178

Files:
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxx/utils/ci/run-buildbot


Index: libcxx/utils/ci/run-buildbot
===================================================================
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -516,13 +516,7 @@
 ;;
 windows-dll)
     clean
-    # TODO: Currently, building with the experimental library breaks running
-    # tests (the test linking look for the c++experimental library with the
-    # wrong name, and the statically linked c++experimental can't be linked
-    # correctly when libc++ visibility attributes indicate dllimport linkage
-    # anyway), thus just disable the experimental library. Remove this
-    # setting when cmake and the test driver does the right thing automatically.
-    generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
+    generate-cmake-libcxx-win
     echo "+++ Running the libc++ tests"
     ${NINJA} -vC "${BUILD_DIR}" check-cxx
 ;;
Index: libcxx/docs/BuildingLibcxx.rst
===================================================================
--- libcxx/docs/BuildingLibcxx.rst
+++ 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 .
 
@@ -123,7 +122,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
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -88,7 +88,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
@@ -399,6 +405,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."
+                      " The c++experimental library is only built as a"
+                      " static library, while the headers signal dllimport"
+                      " linkage.")
+endif()
+
 #===============================================================================
 # Configure System
 #===============================================================================


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99178.344923.patch
Type: text/x-patch
Size: 3487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210512/8c288654/attachment.bin>


More information about the libcxx-commits mailing list