From c1e32c95870939dcc0a98be0119b74e36ec772d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 25 Aug 2016 13:12:45 +0300 Subject: [PATCH] Updated libunwind, libcxx and libcxx patches and build commands Build libcxx and libcxxabi (succeeding) and libunwind (patch rebased but build not working). --- Dockerfile | 103 ++++++++++---- patches/libcxx-0001.patch | 265 +++++++++++++++++++++++++++++++++-- patches/libcxx-0002.patch | 79 +++++++---- patches/libcxx-0003.patch | 35 ----- patches/libcxx-0004.patch | 34 ----- patches/libcxxabi-0001.patch | 25 ++++ patches/libunwind-0001.patch | 73 ++++++---- patches/libunwind-0002.patch | 8 +- 8 files changed, 455 insertions(+), 167 deletions(-) delete mode 100644 patches/libcxx-0003.patch delete mode 100644 patches/libcxx-0004.patch create mode 100644 patches/libcxxabi-0001.patch diff --git a/Dockerfile b/Dockerfile index ecd59d2..dc95222 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ RUN cd llvm/tools && \ RUN mkdir /build/patches -COPY patches/llvm-*.patch patches/clang-*.patch patches/lld-*.patch patches/libcxx-*.patch /build/patches/ +COPY patches/llvm-*.patch patches/clang-*.patch patches/lld-*.patch /build/patches/ RUN cd llvm && \ git am /build/patches/llvm-*.patch @@ -137,42 +137,91 @@ RUN cd /build/mingw-w64/mingw-w64-tools/widl && \ make -j4 && \ make install -#RUN git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libcxx.git && \ -# git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libcxxabi.git && \ -# git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libunwind.git +RUN git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libcxx.git && \ + git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libcxxabi.git && \ + git clone -b release_39 --depth=1 https://github.com/llvm-mirror/libunwind.git -# libcxx-*.patch were already copied earlier -#RUN cd libcxx && \ -# git am /build/patches/libcxx-*.patch +COPY patches/libcxx-*.patch /build/patches/ +RUN cd libcxx && \ + git am /build/patches/libcxx-*.patch + +COPY patches/libcxxabi-*.patch /build/patches/ +RUN cd libcxxabi && \ + git am /build/patches/libcxxabi-*.patch # COPY patches/libunwind-*.patch /build/patches/ #RUN cd libunwind && \ # git am /build/patches/libunwind-*.patch -#RUN cd libunwind && mkdir build && cd build && \ -# CXXFLAGS="-nodefaultlibs -D_LIBUNWIND_IS_BAREMETAL" \ -# LDFLAGS="/build/prefix/armv7-w64-mingw32/lib/crt2.o /build/prefix/armv7-w64-mingw32/lib/crtbegin.o -lmingw32 /build/prefix/bin/../lib/clang/3.8.1/lib/windows/libclang_rt.builtins-arm.a -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 /build/prefix/armv7-w64-mingw32/lib/crtend.o" \ -# cmake \ -# -DCMAKE_CXX_COMPILER_WORKS=TRUE \ -# -DLLVM_ENABLE_LIBCXX=TRUE \ -# -DCMAKE_BUILD_TYPE=Release \ -# -DLIBUNWIND_ENABLE_SHARED=OFF \ -# .. +RUN cd libunwind && mkdir build && cd build && \ + CXXFLAGS="-nodefaultlibs -D_LIBUNWIND_IS_BAREMETAL" \ + LDFLAGS="/build/prefix/armv7-w64-mingw32/lib/crt2.o /build/prefix/armv7-w64-mingw32/lib/crtbegin.o -lmingw32 /build/prefix/bin/../lib/clang/3.9.0/lib/windows/libclang_rt.builtins-arm.a -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 /build/prefix/armv7-w64-mingw32/lib/crtend.o" \ + cmake \ + -DCMAKE_CXX_COMPILER_WORKS=TRUE \ + -DLLVM_ENABLE_LIBCXX=TRUE \ + -DCMAKE_BUILD_TYPE=Release \ + -DLIBUNWIND_ENABLE_SHARED=OFF \ + .. #RUN cd libunwind/build && make -j4 #RUN cd libunwind/build && make install -#RUN cd libcxx && mkdir build && cd build && \ -# CXXFLAGS="-nodefaultlibs -D_GNU_SOURCE -D_LIBCPP_HAS_NO_CONSTEXPR" \ -# LDFLAGS="/build/prefix/armv7-w64-mingw32/lib/crt2.o /build/prefix/armv7-w64-mingw32/lib/crtbegin.o -lmingw32 /build/prefix/bin/../lib/clang/3.8.1/lib/windows/libclang_rt.builtins-arm.a -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 /build/prefix/armv7-w64-mingw32/lib/crtend.o" \ -# cmake \ -# -DCMAKE_CXX_COMPILER_WORKS=TRUE \ -# -DLIBCXX_ENABLE_SHARED=OFF \ -# -DCMAKE_BUILD_TYPE=Release \ -# -DCMAKE_INSTALL_PREFIX="/build/prefix" \ -# .. && \ -# make -j8 && \ -# make install +RUN cd libcxx && mkdir build && cd build && \ + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_CROSSCOMPILING=TRUE \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DCMAKE_CXX_COMPILER_WORKS=TRUE \ + -DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \ + -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \ + -DLIBCXX_INSTALL_HEADERS=ON \ + -DLIBCXX_ENABLE_EXCEPTIONS=OFF \ + -DLIBCXX_ENABLE_THREADS=OFF \ + -DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF \ + -DLIBCXX_ENABLE_SHARED=OFF \ + -DLIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG=TRUE \ + -DLIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB=TRUE \ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \ + -DLIBCXX_ENABLE_FILESYSTEM=OFF \ + -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \ + -DLIBCXX_CXX_ABI=libcxxabi \ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include \ + -DCMAKE_CXX_FLAGS="-fno-exceptions" \ + .. && \ + make -j4 && \ + make install + +RUN cd libcxxabi && mkdir build && cd build && \ + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_CROSSCOMPILING=TRUE \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DCMAKE_CXX_COMPILER_WORKS=TRUE \ + -DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \ + -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \ + -DLIBCXXABI_USE_COMPILER_RT=ON \ + -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \ + -DLIBCXXABI_ENABLE_THREADS=OFF \ + -DLIBCXXABI_TARGET_TRIPLE=$TARGET_TUPLE \ + -DLIBCXXABI_SYSROOT=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \ + -DLIBCXXABI_ENABLE_SHARED=OFF \ + -DLIBCXXABI_LIBCXX_INCLUDES=$TOOLCHAIN_PREFIX/$TARGET_TUPLE/c++/v1 \ + -DLLVM_NO_OLD_LIBSTDCXX=TRUE \ + -DCXX_SUPPORTS_CXX11=TRUE \ + -DCMAKE_CXX_FLAGS="-fno-exceptions" \ + .. && \ + make -j4 && \ + make install + +RUN cd /build/prefix/include && ln -s /build/prefix/$TARGET_TUPLE/include/c++ . RUN mkdir gaspp && cd gaspp && \ wget -q https://raw.githubusercontent.com/libav/gas-preprocessor/master/gas-preprocessor.pl && \ diff --git a/patches/libcxx-0001.patch b/patches/libcxx-0001.patch index afc5a2d..ea4f9b0 100644 --- a/patches/libcxx-0001.patch +++ b/patches/libcxx-0001.patch @@ -1,25 +1,268 @@ -From ab3797f34376ddbf35d4a5eed8af1aa1209727c1 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -Date: Thu, 12 May 2016 20:57:05 +0200 -Subject: [PATCH] Fix win32 build +From 57d48bf47108014aa5e0c5435c107581e86e3045 Mon Sep 17 00:00:00 2001 +From: Martell Malone +Date: Sat, 6 Aug 2016 03:54:22 -0700 +Subject: [PATCH] mingw-w64 hack and slash fixes for libc++ ---- - include/type_traits | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) +CMAKE_HOST_WIN32 change can be upstreamed in a different patch +This is very hacky but gets libcxx to compile +Make sure you only install the headers after building +Will need to run the test suite and do more work here + +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index 219d1b7..2a9337f 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -27,7 +27,7 @@ if (LIBCXX_INSTALL_HEADERS) + + if (LIBCXX_NEEDS_SITE_CONFIG) + set(UNIX_CAT cat) +- if (WIN32) ++ if (CMAKE_HOST_WIN32) + set(UNIX_CAT type) + endif() + # Generate and install a custom __config header. The new header is created +diff --git a/include/__config b/include/__config +index 353ca10..b58c350 100644 +--- a/include/__config ++++ b/include/__config +@@ -152,6 +152,8 @@ + # // If mingw not explicitly detected, assume using MS C runtime only. + # ifndef __MINGW32__ + # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library ++# else ++# define _LIBCPP_HAS_NO_CONSTEXPR + # endif + #endif // _WIN32 + +@@ -177,7 +179,7 @@ + // including accesses to the special files under /dev. C++11's + // std::random_device is instead exposed through a NaCl syscall. + # define _LIBCPP_USING_NACL_RANDOM +-#elif defined(_WIN32) ++#elif defined(_MSC_VER) + # define _LIBCPP_USING_WIN32_RANDOM + #else + # define _LIBCPP_USING_DEV_RANDOM +@@ -831,7 +833,8 @@ extern "C" void __sanitizer_annotate_contiguous_container( + defined(__linux__) || \ + defined(__APPLE__) || \ + defined(__CloudABI__) || \ +- defined(__sun__) ++ defined(__sun__) || \ ++ defined(__MINGW32__) + # define _LIBCPP_HAS_THREAD_API_PTHREAD + # else + # error "No thread API" +diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h +index 7f3710e..d167309 100644 +--- a/include/support/win32/locale_win32.h ++++ b/include/support/win32/locale_win32.h +@@ -64,6 +64,15 @@ isupper_l(int c, _locale_t loc) + return _isupper_l((int)c, loc); + } + ++#define open _open ++#define close _close ++#define read _read ++ ++#define strtod_l _strtod_l ++ ++// TODO: add _strtof_l to mingw-w64 ++#define strtof_l _strtod_l ++ + #define isdigit_l _isdigit_l + #define isxdigit_l _isxdigit_l + #define strcoll_l _strcoll_l +@@ -93,6 +102,33 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...); + int asprintf_l( char **ret, locale_t loc, const char *format, ... ); + int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ); + ++#ifdef __MINGW32__ ++ ++// Stubs ++inline _locale_t _get_current_locale(void) { ++ return NULL; ++} ++ ++inline _locale_t _create_locale(int _Category,const char *_Locale) { ++ _locale_t loc; ++ return loc; ++} ++//extern "C" void _free_locale(_locale_t _Locale) {} ++//void __cdecl _free_locale(_locale_t _Locale); ++inline _locale_t _free_locale(_locale_t _Locale) { ++ _locale_t loc; ++ return loc; ++} ++ ++ ++#include ++ ++inline size_t _strftime_l(char* s, size_t n, const char * f, const struct tm * tm, _locale_t l) ++{ ++ return strftime(s, n, f, tm); ++} ++ ++#endif + + // not-so-pressing FIXME: use locale to determine blank characters + inline int isblank_l( int c, locale_t /*loc*/ ) +@@ -104,7 +140,7 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ ) + return ( c == L' ' || c == L'\t' ); + } + +-#if defined(_LIBCPP_MSVCRT) ++#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) + inline int isblank( int c, locale_t /*loc*/ ) + { return ( c == ' ' || c == '\t' ); } + inline int iswblank( wint_t c, locale_t /*loc*/ ) +diff --git a/include/support/win32/support.h b/include/support/win32/support.h +index 5765bab..4955b3a 100644 +--- a/include/support/win32/support.h ++++ b/include/support/win32/support.h +@@ -37,12 +37,13 @@ extern "C" { + + int vasprintf(char **sptr, const char *__restrict fmt, va_list ap); + int asprintf(char **sptr, const char *__restrict fmt, ...); ++} ++#endif // __MINGW32__ ++ + size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, + size_t nmc, size_t len, mbstate_t *__restrict ps); + size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps); +-} +-#endif // __MINGW32__ + + #if defined(_LIBCPP_MSVCRT) + #define snprintf _snprintf diff --git a/include/type_traits b/include/type_traits -index b7adfeb..f7cef9d 100644 +index 0d578bb..88dfd99 100644 --- a/include/type_traits +++ b/include/type_traits -@@ -1630,7 +1630,7 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); +@@ -1671,7 +1671,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) -#if !defined(_LIBCPP_MSVC) -+#if !defined(_WIN32) ++#if !defined(_LIBCPP_MSVC) && !defined(__MINGW32__) _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); #endif // !_LIBCPP_MSVC +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index cabf2e6..8729707 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -33,9 +33,11 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}" + + add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}") + ++if(NOT MINGW) + add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic") + add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}") + add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive") ++endif() + + if (APPLE AND LLVM_USE_SANITIZER) + if ("${LLVM_USE_SANITIZER}" STREQUAL "Address") +@@ -71,9 +73,14 @@ add_library_flags_if(LIBCXX_HAS_RT_LIB rt) + add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s) + add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic) + +-# Setup flags. + add_flags_if_supported(-fPIC) +-add_link_flags_if_supported(-nodefaultlibs) ++ ++# Setup flags. ++if (NOT MINGW) ++ add_link_flags_if_supported(-nodefaultlibs) ++else() ++ add_library_flags(-lc++abi) ++endif() + + if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR + LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) +diff --git a/src/locale.cpp b/src/locale.cpp +index da2fd11..03696a7 100644 +--- a/src/locale.cpp ++++ b/src/locale.cpp +@@ -26,9 +26,9 @@ + #include "cstring" + #include "cwctype" + #include "__sso_allocator" +-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) ++#if defined(_LIBCPP_MSVCRT) + #include "support/win32/locale_win32.h" +-#elif !defined(__ANDROID__) ++#elif !defined(__ANDROID__) && !defined(__MINGW32__) + #include + #endif + #include +diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp +index 5a43743..b220afe 100644 +--- a/src/support/win32/locale_win32.cpp ++++ b/src/support/win32/locale_win32.cpp +@@ -8,6 +8,11 @@ + // + //===----------------------------------------------------------------------===// + ++#ifdef __MINGW32__ ++#define _GNU_SOURCE ++#include ++#endif ++ + #include + #include // va_start, va_end + +diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp +index e989681..0d60ef4 100644 +--- a/src/support/win32/support.cpp ++++ b/src/support/win32/support.cpp +@@ -8,6 +8,10 @@ + // + //===----------------------------------------------------------------------===// + ++#ifdef __MINGW32__ ++#define _GNU_SOURCE ++#endif ++ + #include // va_start, va_end + #include // size_t + #include // malloc +@@ -17,6 +21,7 @@ + + // Some of these functions aren't standard or if they conform, the name does not. + ++#ifndef __MINGW32__ + int asprintf(char **sptr, const char *__restrict format, ...) + { + va_list ap; +@@ -51,6 +56,7 @@ int vasprintf( char **sptr, const char *__restrict format, va_list ap ) + *sptr = p; + return count; + } ++#endif + + // Returns >= 0: the number of wide characters found in the + // multi byte sequence src (of src_size_bytes), that fit in the buffer dst +diff --git a/src/system_error.cpp b/src/system_error.cpp +index 87f35ae..fdd56ea 100644 +--- a/src/system_error.cpp ++++ b/src/system_error.cpp +@@ -70,6 +70,12 @@ string do_strerror_r(int ev) { + char* ret = ::strerror_r(ev, buffer, strerror_buff_size); + return string(ret); + } ++#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) ++string do_strerror_r(int ev) { ++ char buffer[strerror_buff_size]; ++ std::snprintf(buffer, strerror_buff_size, "Win32 Unsupported %d", ev); ++ return string(buffer); ++} + #else + // POSIX version + string do_strerror_r(int ev) { -- -2.8.1 +2.8.3 diff --git a/patches/libcxx-0002.patch b/patches/libcxx-0002.patch index 04783ac..72a6d91 100644 --- a/patches/libcxx-0002.patch +++ b/patches/libcxx-0002.patch @@ -1,40 +1,59 @@ -From cd25e08b778f0bc44872121cb9ed07534d4367f5 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -Date: Fri, 13 May 2016 11:29:03 +0200 -Subject: [PATCH] Always include locale_win32.h for win32 builds, including - mingw +From a91ea0b2d56e1dc45dbe3edda9e16a8724311d21 Mon Sep 17 00:00:00 2001 +From: Martin Storsjo +Date: Thu, 25 Aug 2016 12:59:57 +0300 +Subject: [PATCH 2/2] Hack +Also remove unnecessary defines for open/read/close that are handled +by linker aliases now. --- - include/ctype.h | 2 +- - include/stdlib.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + include/support/win32/locale_win32.h | 6 ++---- + src/new.cpp | 2 +- + 2 files changed, 3 insertions(+), 5 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); +diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h +index d167309..c4cdd93 100644 +--- a/include/support/win32/locale_win32.h ++++ b/include/support/win32/locale_win32.h +@@ -64,10 +64,6 @@ isupper_l(int c, _locale_t loc) + return _isupper_l((int)c, loc); + } - #ifdef __cplusplus +-#define open _open +-#define close _close +-#define read _read +- + #define strtod_l _strtod_l --#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 + // TODO: add _strtof_l to mingw-w64 +@@ -104,6 +100,7 @@ int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ); - extern "C++" { + #ifdef __MINGW32__ --#ifdef _LIBCPP_MSVCRT -+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) - #include "support/win32/locale_win32.h" - #endif // _LIBCPP_MSVCRT ++#if 0 + // Stubs + inline _locale_t _get_current_locale(void) { + return NULL; +@@ -120,6 +117,7 @@ inline _locale_t _free_locale(_locale_t _Locale) { + return loc; + } ++#endif + + #include + +diff --git a/src/new.cpp b/src/new.cpp +index f4f73d8..62222e1 100644 +--- a/src/new.cpp ++++ b/src/new.cpp +@@ -31,7 +31,7 @@ + #endif // _LIBCPPABI_VERSION + #endif + +-#ifndef __GLIBCXX__ ++#if 0 + + // Implement all new and delete operators as weak definitions + // in this shared library, so that they can be overridden by programs -- -2.8.1 +2.7.4 diff --git a/patches/libcxx-0003.patch b/patches/libcxx-0003.patch deleted file mode 100644 index 4b4437b..0000000 --- a/patches/libcxx-0003.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 53625b291503734db14e4a6146ceb06f288fd987 Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 - diff --git a/patches/libcxx-0004.patch b/patches/libcxx-0004.patch deleted file mode 100644 index 5ba57c8..0000000 --- a/patches/libcxx-0004.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 2062557696978b361b40717ed8e4cf84765c95ab Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -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 - diff --git a/patches/libcxxabi-0001.patch b/patches/libcxxabi-0001.patch new file mode 100644 index 0000000..f15f747 --- /dev/null +++ b/patches/libcxxabi-0001.patch @@ -0,0 +1,25 @@ +From af6e844261dda2786985ff43fcd6873b636b57aa Mon Sep 17 00:00:00 2001 +From: Martin Storsjo +Date: Sat, 27 Aug 2016 14:02:18 +0300 +Subject: [PATCH] Hack cmake configure + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 300d6da..d00a942 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -47,7 +47,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") +- set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake") ++ set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib/cmake/llvm") + set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py") + else() + message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. " +-- +2.7.4 + diff --git a/patches/libunwind-0001.patch b/patches/libunwind-0001.patch index 9a9a73e..cbe9708 100644 --- a/patches/libunwind-0001.patch +++ b/patches/libunwind-0001.patch @@ -1,11 +1,18 @@ -From 81b5dabfed88d2976faf587598361c054630ef95 Mon Sep 17 00:00:00 2001 +From 46a001b37a0355b588ad99a3aab5593926fa31bc Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Tue, 21 Jul 2015 04:35:55 +0100 -Subject: [PATCH] libunwind add support for mingw-w64 +Subject: [PATCH 1/2] libunwind add support for mingw-w64 +--- + include/unwind.h | 2 +- + src/AddressSpace.hpp | 11 +++++++---- + src/UnwindLevel1-gcc-ext.c | 2 +- + src/assembly.h | 2 ++ + src/config.h | 14 ++++++++++++++ + 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/unwind.h b/include/unwind.h -index 31fb871..e8c63d7 100644 +index f3860d9..8f54d4d 100644 --- a/include/unwind.h +++ b/include/unwind.h @@ -121,7 +121,7 @@ struct _Unwind_Exception { @@ -14,11 +21,11 @@ index 31fb871..e8c63d7 100644 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 + // The implementation of _Unwind_Exception uses an attribute mode on the + // above fields which has 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 +index da1b6a4..892950f 100644 --- a/src/AddressSpace.hpp +++ b/src/AddressSpace.hpp @@ -18,7 +18,7 @@ @@ -30,7 +37,7 @@ index 567cbda..fd0b233 100644 #include #endif -@@ -104,7 +104,7 @@ struct UnwindInfoSections { +@@ -109,7 +109,7 @@ struct UnwindInfoSections { /// making local unwinds fast. class __attribute__((visibility("hidden"))) LocalAddressSpace { public: @@ -39,7 +46,7 @@ index 567cbda..fd0b233 100644 typedef uint64_t pint_t; typedef int64_t sint_t; #else -@@ -156,7 +156,7 @@ public: +@@ -161,7 +161,7 @@ public: }; inline uintptr_t LocalAddressSpace::getP(pint_t addr) { @@ -48,7 +55,7 @@ index 567cbda..fd0b233 100644 return get64(addr); #else return get32(addr); -@@ -434,6 +434,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, +@@ -439,6 +439,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, }, &cb_data); return static_cast(found); @@ -56,7 +63,7 @@ index 567cbda..fd0b233 100644 #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) { +@@ -462,7 +463,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) { @@ -81,7 +88,7 @@ index 28ba092..0decf77 100644 (long)exception_object->unwinder_cache.reserved1); #else diff --git a/src/assembly.h b/src/assembly.h -index f46a24d..4d6c3e1 100644 +index 06b29b3..96f46e3 100644 --- a/src/assembly.h +++ b/src/assembly.h @@ -26,6 +26,8 @@ @@ -94,33 +101,47 @@ index f46a24d..4d6c3e1 100644 #define HIDDEN_DIRECTIVE .hidden #endif diff --git a/src/config.h b/src/config.h -index c9ec087..6f14e92 100644 +index a50222f..acc52a5 100644 --- a/src/config.h +++ b/src/config.h -@@ -60,6 +60,23 @@ +@@ -39,6 +39,14 @@ + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 #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) ++ #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + // 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 + #if defined(__ARM_DWARF_EH__) || !defined(__arm__) + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 +@@ -51,9 +59,14 @@ + #endif + #endif ++#ifdef _WIN32 ++#define _LIBUNWIND_EXPORT ++#define _LIBUNWIND_HIDDEN ++#else + // FIXME: these macros are not correct for COFF targets + #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) + #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) ++#endif + + #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__) + #define _LIBUNWIND_BUILD_SJLJ_APIS 1 +@@ -69,6 +82,7 @@ + + #if defined(__i386__) || defined(__x86_64__) || \ + (!defined(__APPLE__) && defined(__arm__)) || \ ++ (defined(_WIN32)) || \ + (defined(__arm64__) || defined(__aarch64__)) || \ + (defined(__APPLE__) && defined(__mips__)) + #define _LIBUNWIND_BUILD_ZERO_COST_APIS 1 -- -2.4.5 +2.7.4 diff --git a/patches/libunwind-0002.patch b/patches/libunwind-0002.patch index 2677b0f..49d5b48 100644 --- a/patches/libunwind-0002.patch +++ b/patches/libunwind-0002.patch @@ -1,14 +1,14 @@ -From 9d0332b9dac6c5925c827d8b372f3c846da8a639 Mon Sep 17 00:00:00 2001 +From 17e850de43aefe7da87db8c2eaa521e5159c1cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 13 May 2016 15:07:26 +0200 -Subject: [PATCH] Define _Unwind_Ptr on windows +Subject: [PATCH 2/2] Define _Unwind_Ptr on windows --- src/AddressSpace.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp -index ab17d42..8e5fc20 100644 +index 892950f..9751d9e 100644 --- a/src/AddressSpace.hpp +++ b/src/AddressSpace.hpp @@ -47,6 +47,8 @@ extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int *len); @@ -21,5 +21,5 @@ index ab17d42..8e5fc20 100644 #include #else // !defined(_LIBUNWIND_IS_BAREMETAL) -- -2.8.1 +2.7.4