[PATCH] D33388: [libcxx] fixup bootstrapping for mingw-w64

Martell Malone via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 21 11:46:07 PDT 2017


martell created this revision.
Herald added a subscriber: mgorny.

This can technically be split into different commits.
I just wanted to get a review of them together to move things along

The first part is the same as what is in https://reviews.llvm.org/D33384 so once that is reviewed and accepted this should be approved also.

The change to the CMakeLists.txt is so that we get libc++ and not liblibc++ for mingw which is silly.
I am open to an alternative way to achieve this if this isn't a good solution.

Lastly is a header include fixup, mingw from linux doesn't like `<Windows.h>`
Throughout all llvm projects we use a lowercase `w` because of this, see https://reviews.llvm.org/rL302340 for reference.


Repository:
  rL LLVM

https://reviews.llvm.org/D33388

Files:
  libcxx/trunk/cmake/config-ix.cmake
  libcxx/trunk/include/__threading_support
  libcxx/trunk/lib/CMakeLists.txt


Index: libcxx/trunk/lib/CMakeLists.txt
===================================================================
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -243,7 +243,7 @@
   add_library(cxx_static STATIC $<TARGET_OBJECTS:cxx_objects>)
   target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
   set(STATIC_OUTPUT_NAME "c++")
-  if (WIN32)
+  if (WIN32 AND NOT MINGW)
     set(STATIC_OUTPUT_NAME "libc++")
   endif()
   set_target_properties(cxx_static
Index: libcxx/trunk/include/__threading_support
===================================================================
--- libcxx/trunk/include/__threading_support
+++ libcxx/trunk/include/__threading_support
@@ -27,7 +27,7 @@
 # include <pthread.h>
 # include <sched.h>
 #elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
-#include <Windows.h>
+#include <windows.h>
 #include <process.h>
 #include <fibersapi.h>
 #include <__undef_min_max>
Index: libcxx/trunk/cmake/config-ix.cmake
===================================================================
--- libcxx/trunk/cmake/config-ix.cmake
+++ libcxx/trunk/cmake/config-ix.cmake
@@ -41,7 +41,16 @@
   if (MINGW)
     # Mingw64 requires quite a few "C" runtime libraries in order for basic
     # programs to link successfully with -nodefaultlibs.
-    list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+    if (LIBCXX_USE_COMPILER_RT)
+      set(MINGW_RUNTIME ${LIBCXXABI_BUILTINS_LIBRARY})
+    else ()
+      set(MINGW_RUNTIME gcc_s gcc)
+    endif()
+    set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32
+                        shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
+                        moldname mingwex msvcrt)
+    list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0600")
   endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33388.99700.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170521/fed36e83/attachment.bin>


More information about the llvm-commits mailing list