libcxx now compiles

This commit is contained in:
Hugo Beauzée-Luyssen committed 2016-08-04 16:20:17 +02:00
1 parent 4808f05671
commit 1e0a216c46
7 files changed
+339 -23

No files matched your search

+19 -12
View File
@@ -1,18 +1,25 @@
Index: include/type_traits
===================================================================
--- include/type_traits
+++ include/type_traits
@@ -1147,10 +1147,10 @@
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
From ab3797f34376ddbf35d4a5eed8af1aa1209727c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Thu, 12 May 2016 20:57:05 +0200
Subject: [PATCH] Fix win32 build
---
include/type_traits | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/type_traits b/include/type_traits
index b7adfeb..f7cef9d 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -1630,7 +1630,7 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
-// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
-#if !defined(_LIBCPP_MSVC)
+// PE COFF does not support alignment beyond 8192 (=0x2000)
+#if !defined(_WIN32)
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
-#endif // !_LIBCPP_MSVC
+#endif // !_WIN32
#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
#endif // !_LIBCPP_MSVC
--
2.8.1
+40
View File
@@ -0,0 +1,40 @@
From cd25e08b778f0bc44872121cb9ed07534d4367f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Fri, 13 May 2016 11:29:03 +0200
Subject: [PATCH] Always include locale_win32.h for win32 builds, including
mingw
---
include/ctype.h | 2 +-
include/stdlib.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/ctype.h b/include/ctype.h
index 22d6c49..bf57a25 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -40,7 +40,7 @@ int toupper(int c);
#ifdef __cplusplus
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
// We support including .h headers inside 'extern "C"' contexts, so switch
// back to C++ linkage before including these C++ headers.
extern "C++" {
diff --git a/include/stdlib.h b/include/stdlib.h
index 12fd676..9308c73 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -97,7 +97,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
extern "C++" {
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
#include "support/win32/locale_win32.h"
#endif // _LIBCPP_MSVCRT
--
2.8.1
+35
View File
@@ -0,0 +1,35 @@
From 53625b291503734db14e4a6146ceb06f288fd987 Mon Sep 17 00:00:00 2001
From: Martell Malone <martellmalone@gmail.com>
Date: Sun, 5 Jul 2015 00:54:34 +0100
Subject: [PATCH] libcxx: add support for mingw-w64
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index d3d5f38..4820f2c 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTOR
# Get sources
file(GLOB LIBCXX_SOURCES ../src/*.cpp)
-if(WIN32)
+if(MSVC)
file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
diff --git a/src/random.cpp b/src/random.cpp
index 4ab424e..d3062f5 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_LIBCPP_USING_WIN32_RANDOM)
+#if defined(_LIBCPP_USING_WIN32_RANDOM) || defined(__MINGW32__)
// Must be defined before including stdlib.h to enable rand_s().
#define _CRT_RAND_S
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
--
2.4.5
+34
View File
@@ -0,0 +1,34 @@
From 2062557696978b361b40717ed8e4cf84765c95ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Fri, 13 May 2016 13:20:17 +0200
Subject: [PATCH] Don't build debug code
---
src/debug.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/debug.cpp b/src/debug.cpp
index b1a16e6..dfdbbdb 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#define _LIBCPP_DEBUG 1
#include "__config"
+
+#ifdef _LIBCPP_DEBUG
+
#include "__debug"
#include "functional"
#include "algorithm"
@@ -568,3 +570,5 @@ __c_node::__remove(__i_node* p)
}
_LIBCPP_END_NAMESPACE_STD
+
+#endif
--
2.8.1
+126
View File
@@ -0,0 +1,126 @@
From 81b5dabfed88d2976faf587598361c054630ef95 Mon Sep 17 00:00:00 2001
From: Martell Malone <martellmalone@gmail.com>
Date: Tue, 21 Jul 2015 04:35:55 +0100
Subject: [PATCH] libunwind add support for mingw-w64
diff --git a/include/unwind.h b/include/unwind.h
index 31fb871..e8c63d7 100644
--- a/include/unwind.h
+++ b/include/unwind.h
@@ -121,7 +121,7 @@ struct _Unwind_Exception {
_Unwind_Exception *exc);
uintptr_t private_1; // non-zero means forced unwind
uintptr_t private_2; // holds sp that phase1 found for phase2 to use
-#ifndef __LP64__
+#if !defined(__LP64__) && !defined(_WIN64)
// The gcc implementation of _Unwind_Exception used attribute mode on the
// above fields which had the side effect of causing this whole struct to
// round up to 32 bytes in size. To be more explicit, we add pad fields
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
index 567cbda..fd0b233 100644
--- a/src/AddressSpace.hpp
+++ b/src/AddressSpace.hpp
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include <string.h>
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
#include <dlfcn.h>
#endif
@@ -104,7 +104,7 @@ struct UnwindInfoSections {
/// making local unwinds fast.
class __attribute__((visibility("hidden"))) LocalAddressSpace {
public:
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
typedef uint64_t pint_t;
typedef int64_t sint_t;
#else
@@ -156,7 +156,7 @@ public:
};
inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
return get64(addr);
#else
return get32(addr);
@@ -434,6 +434,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
},
&cb_data);
return static_cast<bool>(found);
+#elif defined(_WIN32)
#else
#error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
#endif
@@ -457,7 +458,9 @@ inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t &fde) {
inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
size_t bufLen,
unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#ifdef _WIN32
+// FIXME: support DLLs on Windows.
+#elif !defined(_LIBUNWIND_IS_BAREMETAL)
Dl_info dyldInfo;
if (dladdr((void *)addr, &dyldInfo)) {
if (dyldInfo.dli_sname != NULL) {
diff --git a/src/UnwindLevel1-gcc-ext.c b/src/UnwindLevel1-gcc-ext.c
index 28ba092..0decf77 100644
--- a/src/UnwindLevel1-gcc-ext.c
+++ b/src/UnwindLevel1-gcc-ext.c
@@ -29,7 +29,7 @@
_LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
#if _LIBUNWIND_ARM_EHABI
- _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld\n",
+ _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR "\n",
(void *)exception_object,
(long)exception_object->unwinder_cache.reserved1);
#else
diff --git a/src/assembly.h b/src/assembly.h
index f46a24d..4d6c3e1 100644
--- a/src/assembly.h
+++ b/src/assembly.h
@@ -26,6 +26,8 @@
#if defined(__APPLE__)
#define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+#define HIDDEN_DIRECTIVE .globl
#else
#define HIDDEN_DIRECTIVE .hidden
#endif
diff --git a/src/config.h b/src/config.h
index c9ec087..6f14e92 100644
--- a/src/config.h
+++ b/src/config.h
@@ -60,6 +60,23 @@
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
#endif
+#elif defined(_WIN32)
+ // Note! the assembler files must be .S and not .s.
+ #define _LIBUNWIND_BUILD_ZERO_COST_APIS 1
+
+ // #define _LIBUNWIND_BUILD_SJLJ_APIS
+ // #define _LIBUNWIND_SUPPORT_FRAME_APIS
+ #define _LIBUNWIND_EXPORT
+ #define _LIBUNWIND_HIDDEN
+ #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
+ #define _LIBUNWIND_ABORT(msg) do { fprintf(stderr, msg); abort(); } while(0)
+ #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
+ #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+ // #define _LIBUNWIND_SUPPORT_DWARF_INDEX
+ #define bzero(s,n) memset(s,0,n)
+ // libcxx may have defined __USE_MINGW_ANSI_STDIO.
+ // Here we would like to get the regular versions, not the _mingw ones.
+ #undef __USE_MINGW_ANSI_STDIO
#else
#include <stdlib.h>
--
2.4.5
+43
View File
@@ -0,0 +1,43 @@
From 9a11fcabc10601818896b63f3ac54fa6df58d70e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Fri, 13 May 2016 12:40:30 +0200
Subject: [PATCH] math.h: Fix arm build
---
mingw-w64-headers/crt/math.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h
index 171208f..d855a0f 100644
--- a/mingw-w64-headers/crt/math.h
+++ b/mingw-w64-headers/crt/math.h
@@ -431,7 +431,7 @@ typedef long double double_t;
__mingw_fp_types_t hlp;
unsigned int l, h;
- hlp.d = &x;
+ hlp.ld = &x;
h = hlp.ldt->lh.high;
l = hlp.ldt->lh.low | (h & 0xfffff);
h &= 0x7ff00000;
@@ -591,7 +591,7 @@ __mingw_choose_expr ( \
__mingw_fp_types_t hlp;
int l, h;
- hlp.d = &_x;
+ hlp.ld = &_x;
l = hlp.dt->lh.low;
h = hlp.dt->lh.high & 0x7fffffff;
h |= (unsigned int) (l | -l) >> 31;
@@ -662,7 +662,7 @@ __mingw_choose_expr ( \
#elif defined(__arm__) || defined(_ARM_)
__mingw_fp_types_t hlp;
- hlp.d = &x;
+ hlp.ld = &x;
return ((hlp.dt->lh.high & 0x80000000) != 0);
#elif defined(__i386__) || defined(_X86_)
unsigned short stw;
--
2.8.1