diff --git a/mingw-w64-clang/0001-genlib-named-as-llvm-dlltool.patch b/mingw-w64-clang/0001-genlib-named-as-llvm-dlltool.patch index e3aafb100a..57204eab81 100644 --- a/mingw-w64-clang/0001-genlib-named-as-llvm-dlltool.patch +++ b/mingw-w64-clang/0001-genlib-named-as-llvm-dlltool.patch @@ -1,7 +1,7 @@ -From 5e9f6cde2f8389190f318da10d8d4e70939a0e3a Mon Sep 17 00:00:00 2001 +From 462496b4bc03a0243f4c43f7e40ac70cedd1dcec Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Tue, 9 Aug 2016 17:52:46 -0700 -Subject: [PATCH 1/3] genlib: named as llvm-dlltool +Subject: [PATCH 1/6] genlib: named as llvm-dlltool A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. @@ -9,10 +9,32 @@ Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) +--- + include/llvm/DllDriver/DllDriver.h | 24 ++ + lib/CMakeLists.txt | 1 + + lib/DLLDriver/CMakeLists.txt | 11 + + lib/DLLDriver/Config.h | 119 ++++++++ + lib/DLLDriver/DllDriver.cpp | 185 ++++++++++++ + lib/DLLDriver/LLVMBuild.txt | 22 ++ + lib/DLLDriver/Librarian.cpp | 603 +++++++++++++++++++++++++++++++++++++ + lib/DLLDriver/ModuleDef.cpp | 321 ++++++++++++++++++++ + lib/DLLDriver/Options.td | 5 + + lib/Object/ArchiveWriter.cpp | 3 +- + tools/llvm-ar/CMakeLists.txt | 2 + + tools/llvm-ar/llvm-ar.cpp | 6 +- + 12 files changed, 1300 insertions(+), 2 deletions(-) + create mode 100644 include/llvm/DllDriver/DllDriver.h + create mode 100644 lib/DLLDriver/CMakeLists.txt + create mode 100644 lib/DLLDriver/Config.h + create mode 100644 lib/DLLDriver/DllDriver.cpp + create mode 100644 lib/DLLDriver/LLVMBuild.txt + create mode 100644 lib/DLLDriver/Librarian.cpp + create mode 100644 lib/DLLDriver/ModuleDef.cpp + create mode 100644 lib/DLLDriver/Options.td diff --git a/include/llvm/DllDriver/DllDriver.h b/include/llvm/DllDriver/DllDriver.h new file mode 100644 -index 0000000..79fb7b7 +index 00000000000..79fb7b76deb --- /dev/null +++ b/include/llvm/DllDriver/DllDriver.h @@ -0,0 +1,24 @@ @@ -41,18 +63,19 @@ index 0000000..79fb7b7 + +#endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt -index 9449421..03988a6 100644 +index 76549540ce0..bebb628e06d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt -@@ -20,4 +20,5 @@ add_subdirectory(LineEditor) +@@ -21,5 +21,6 @@ add_subdirectory(LineEditor) add_subdirectory(ProfileData) add_subdirectory(Fuzzer) add_subdirectory(Passes) +add_subdirectory(DLLDriver) add_subdirectory(LibDriver) + add_subdirectory(XRay) diff --git a/lib/DLLDriver/CMakeLists.txt b/lib/DLLDriver/CMakeLists.txt new file mode 100644 -index 0000000..91fb2f0 +index 00000000000..91fb2f08de0 --- /dev/null +++ b/lib/DLLDriver/CMakeLists.txt @@ -0,0 +1,11 @@ @@ -69,7 +92,7 @@ index 0000000..91fb2f0 +add_dependencies(LLVMDllDriver DllOptionsTableGen) diff --git a/lib/DLLDriver/Config.h b/lib/DLLDriver/Config.h new file mode 100644 -index 0000000..d5a3d26 +index 00000000000..d5a3d261de0 --- /dev/null +++ b/lib/DLLDriver/Config.h @@ -0,0 +1,119 @@ @@ -195,7 +218,7 @@ index 0000000..d5a3d26 \ No newline at end of file diff --git a/lib/DLLDriver/DllDriver.cpp b/lib/DLLDriver/DllDriver.cpp new file mode 100644 -index 0000000..aa9adc8 +index 00000000000..aa9adc84688 --- /dev/null +++ b/lib/DLLDriver/DllDriver.cpp @@ -0,0 +1,185 @@ @@ -386,7 +409,7 @@ index 0000000..aa9adc8 +} diff --git a/lib/DLLDriver/LLVMBuild.txt b/lib/DLLDriver/LLVMBuild.txt new file mode 100644 -index 0000000..8e2b1d65 +index 00000000000..8e2b1d651f2 --- /dev/null +++ b/lib/DLLDriver/LLVMBuild.txt @@ -0,0 +1,22 @@ @@ -414,7 +437,7 @@ index 0000000..8e2b1d65 +required_libraries = Object Option Support diff --git a/lib/DLLDriver/Librarian.cpp b/lib/DLLDriver/Librarian.cpp new file mode 100644 -index 0000000..486733e +index 00000000000..486733e6c5c --- /dev/null +++ b/lib/DLLDriver/Librarian.cpp @@ -0,0 +1,603 @@ @@ -1023,7 +1046,7 @@ index 0000000..486733e +} diff --git a/lib/DLLDriver/ModuleDef.cpp b/lib/DLLDriver/ModuleDef.cpp new file mode 100644 -index 0000000..428049a +index 00000000000..428049abc5d --- /dev/null +++ b/lib/DLLDriver/ModuleDef.cpp @@ -0,0 +1,321 @@ @@ -1350,7 +1373,7 @@ index 0000000..428049a +} // namespace llvm diff --git a/lib/DLLDriver/Options.td b/lib/DLLDriver/Options.td new file mode 100644 -index 0000000..62f33f3 +index 00000000000..62f33f386e8 --- /dev/null +++ b/lib/DLLDriver/Options.td @@ -0,0 +1,5 @@ @@ -1360,10 +1383,10 @@ index 0000000..62f33f3 +def out: JoinedOrSeparate<["-"], "o">, HelpText<"Set output file">; +def dll: JoinedOrSeparate<["-"], "d">, HelpText<"Set dll name">; diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp -index 4ede536..4e8c5f0 100644 +index f8e3c5a0a03..d5f067ed675 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp -@@ -285,7 +285,8 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind, +@@ -299,7 +299,8 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind, continue; if (!(Symflags & object::SymbolRef::SF_Global)) continue; @@ -1374,7 +1397,7 @@ index 4ede536..4e8c5f0 100644 unsigned NameOffset = NameOS.tell(); diff --git a/tools/llvm-ar/CMakeLists.txt b/tools/llvm-ar/CMakeLists.txt -index 86233df..94cc205 100644 +index 3bb0c8f7b7c..14732b47b93 100644 --- a/tools/llvm-ar/CMakeLists.txt +++ b/tools/llvm-ar/CMakeLists.txt @@ -1,6 +1,7 @@ @@ -1385,13 +1408,13 @@ index 86233df..94cc205 100644 LibDriver Object Support -@@ -12,3 +13,4 @@ add_llvm_tool(llvm-ar +@@ -15,3 +16,4 @@ add_llvm_tool(llvm-ar add_llvm_tool_symlink(llvm-ranlib llvm-ar) add_llvm_tool_symlink(llvm-lib llvm-ar) +add_llvm_tool_symlink(llvm-dlltool llvm-ar) diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp -index 40e4a3a..1ebded3 100644 +index b99a396da62..23e323c8082 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -16,6 +16,7 @@ @@ -1402,7 +1425,7 @@ index 40e4a3a..1ebded3 100644 #include "llvm/LibDriver/LibDriver.h" #include "llvm/Object/Archive.h" #include "llvm/Object/ArchiveWriter.h" -@@ -844,6 +845,9 @@ int main(int argc, char **argv) { +@@ -850,6 +851,9 @@ int main(int argc, char **argv) { llvm::InitializeAllAsmParsers(); StringRef Stem = sys::path::stem(ToolName); @@ -1412,7 +1435,7 @@ index 40e4a3a..1ebded3 100644 if (Stem.find("ranlib") == StringRef::npos && Stem.find("lib") != StringRef::npos) return libDriverMain(makeArrayRef(argv, argc)); -@@ -859,5 +863,5 @@ int main(int argc, char **argv) { +@@ -865,5 +869,5 @@ int main(int argc, char **argv) { return ranlib_main(); if (Stem.find("ar") != StringRef::npos) return ar_main(); @@ -1420,5 +1443,5 @@ index 40e4a3a..1ebded3 100644 + fail("Not ranlib, ar, lib or dlltool!"); } -- -2.8.3 +2.11.0.windows.3 diff --git a/mingw-w64-clang/0002-COFF-Fix-short-import-lib-import-name-type-bitshift.patch b/mingw-w64-clang/0002-COFF-Fix-short-import-lib-import-name-type-bitshift.patch deleted file mode 100644 index 33e9d467e3..0000000000 --- a/mingw-w64-clang/0002-COFF-Fix-short-import-lib-import-name-type-bitshift.patch +++ /dev/null @@ -1,30 +0,0 @@ -From bb716cb613551806c92d48b7a96c2cd7e76a7e06 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Sat, 1 Oct 2016 09:37:25 +0000 -Subject: [PATCH] COFF: Fix short import lib import name type bitshift - -As per the PE COFF spec (section 8.3, Import Name Type) -Offset: 18 Size 2 bits Name: Type -Offset: 20 Size 3 bits Name: Name Type - -Offset: 20 added based on 18+2 - -Partially commited as rL279069 - -Differential Revision: https://reviews.llvm.org/D23540 - -diff --git a/include/llvm/Support/COFF.h b/include/llvm/Support/COFF.h -index 7dad3e8..1ca781b9 100644 ---- a/include/llvm/Support/COFF.h -+++ b/include/llvm/Support/COFF.h -@@ -657,7 +657,7 @@ namespace COFF { - } - - ImportNameType getNameType() const { -- return static_cast((TypeInfo & 0x1C) >> 3); -+ return static_cast((TypeInfo & 0x1C) >> 2); - } - }; - --- -2.7.4 diff --git a/mingw-w64-clang/0003-mingw-w64-use-MSVC-style-ByteAlignment.patch b/mingw-w64-clang/0002-mingw-w64-use-MSVC-style-ByteAlignment.patch similarity index 72% rename from mingw-w64-clang/0003-mingw-w64-use-MSVC-style-ByteAlignment.patch rename to mingw-w64-clang/0002-mingw-w64-use-MSVC-style-ByteAlignment.patch index 5d413c02b9..65bcd766bb 100644 --- a/mingw-w64-clang/0003-mingw-w64-use-MSVC-style-ByteAlignment.patch +++ b/mingw-w64-clang/0002-mingw-w64-use-MSVC-style-ByteAlignment.patch @@ -1,16 +1,19 @@ -From c659c69306254b8068af5582803f79508e79ba63 Mon Sep 17 00:00:00 2001 +From da82422a5f9c9709ba3ac15b52891b8b310278ad Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Tue, 16 Aug 2016 12:55:01 -0700 -Subject: [PATCH 3/3] mingw-w64: use MSVC style ByteAlignment +Subject: [PATCH 2/6] mingw-w64: use MSVC style ByteAlignment We can do alignment without -aligncomm derectives in PE COFF Until we support GNU style in lld we should use this +--- + lib/MC/WinCOFFStreamer.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp -index 5c6407e..f86cbc5 100644 +index 6383d879403..06a5aef0e3b 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp -@@ -208,7 +208,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, +@@ -217,7 +217,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, auto *Symbol = cast(S); const Triple &T = getContext().getObjectFileInfo()->getTargetTriple(); @@ -19,7 +22,7 @@ index 5c6407e..f86cbc5 100644 if (ByteAlignment > 32) report_fatal_error("alignment is limited to 32-bytes"); -@@ -220,7 +220,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, +@@ -229,7 +229,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, Symbol->setExternal(true); Symbol->setCommon(Size, ByteAlignment); @@ -29,5 +32,5 @@ index 5c6407e..f86cbc5 100644 raw_svector_ostream OS(Directive); const MCObjectFileInfo *MFI = getContext().getObjectFileInfo(); -- -2.8.3 +2.11.0.windows.3 diff --git a/mingw-w64-clang/0005-Fix-GetHostTriple-for-mingw-w64-in-msys.patch b/mingw-w64-clang/0003-Fix-GetHostTriple-for-mingw-w64-in-msys.patch similarity index 64% rename from mingw-w64-clang/0005-Fix-GetHostTriple-for-mingw-w64-in-msys.patch rename to mingw-w64-clang/0003-Fix-GetHostTriple-for-mingw-w64-in-msys.patch index a919a30e25..207da58a5b 100644 --- a/mingw-w64-clang/0005-Fix-GetHostTriple-for-mingw-w64-in-msys.patch +++ b/mingw-w64-clang/0003-Fix-GetHostTriple-for-mingw-w64-in-msys.patch @@ -1,11 +1,14 @@ -From 12d299345b51c1686c1d82986de6de020970bb57 Mon Sep 17 00:00:00 2001 +From fffcfe99dab9c1ef714067d337159fbefbd5d139 Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Sun, 28 Jun 2015 20:14:51 +0100 -Subject: [PATCH] Fix GetHostTriple for mingw-w64 in msys +Subject: [PATCH 3/6] Fix GetHostTriple for mingw-w64 in msys +--- + cmake/modules/GetHostTriple.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/GetHostTriple.cmake b/cmake/modules/GetHostTriple.cmake -index 671a8ce..45c47e1 100644 +index 0cad1db4eff..47e9f986e15 100644 --- a/cmake/modules/GetHostTriple.cmake +++ b/cmake/modules/GetHostTriple.cmake @@ -8,11 +8,11 @@ function( get_host_triple var ) @@ -21,7 +24,7 @@ index 671a8ce..45c47e1 100644 + set( value "i686-w64-mingw32" ) endif() else( MSVC ) - set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess) + set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess) -- -2.4.5 +2.11.0.windows.3 diff --git a/mingw-w64-clang/0004-Globally-provide-DESTDIR-for-all-platforms.patch b/mingw-w64-clang/0004-Globally-provide-DESTDIR-for-all-platforms.patch new file mode 100644 index 0000000000..57e548871b --- /dev/null +++ b/mingw-w64-clang/0004-Globally-provide-DESTDIR-for-all-platforms.patch @@ -0,0 +1,27 @@ +From 44b291e8ebb6d4a80843cf9b46b4804b0f0d6515 Mon Sep 17 00:00:00 2001 +From: Alexey Pavlov +Date: Fri, 25 Dec 2015 20:14:51 +0100 +Subject: [PATCH 4/6] Globally provide DESTDIR for all platforms + +--- + cmake/modules/LLVMInstallSymlink.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake +index 482697b06ba..61c4b9dea80 100644 +--- a/cmake/modules/LLVMInstallSymlink.cmake ++++ b/cmake/modules/LLVMInstallSymlink.cmake +@@ -3,9 +3,9 @@ + # See PR8397. + + function(install_symlink name target outdir) ++set(DESTDIR $ENV{DESTDIR}) + if(UNIX) + set(LINK_OR_COPY create_symlink) +- set(DESTDIR $ENV{DESTDIR}) + else() + set(LINK_OR_COPY copy) + endif() +-- +2.11.0.windows.3 + diff --git a/mingw-w64-clang/0004-killthedoctor-mingw.patch b/mingw-w64-clang/0004-killthedoctor-mingw.patch deleted file mode 100644 index bb801b3daf..0000000000 --- a/mingw-w64-clang/0004-killthedoctor-mingw.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- llvm-3.9.0.src/CMakeLists.txt.orig 2016-09-09 08:09:42.327036300 +0300 -+++ llvm-3.9.0.src/CMakeLists.txt 2016-09-09 08:09:51.787577400 +0300 -@@ -768,7 +768,7 @@ - endif() - add_subdirectory(test) - add_subdirectory(unittests) -- if (MSVC) -+ if (WIN32) - # This utility is used to prevent crashing tests from calling Dr. Watson on - # Windows. - add_subdirectory(utils/KillTheDoctor) diff --git a/mingw-w64-clang/0005-not-install-msvc-files.patch b/mingw-w64-clang/0005-not-install-msvc-files.patch new file mode 100644 index 0000000000..4b967bfe6b --- /dev/null +++ b/mingw-w64-clang/0005-not-install-msvc-files.patch @@ -0,0 +1,22 @@ +From 1d467138106facb26fd780ada69314ee2ba865a2 Mon Sep 17 00:00:00 2001 +From: Alexey Pavlov +Date: Thu, 2 Feb 2017 11:43:35 +0100 +Subject: [PATCH 5/6] not install msvc files + +--- + tools/msbuild/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/msbuild/CMakeLists.txt b/tools/msbuild/CMakeLists.txt +index 4f471e5408b..9d132ea58d5 100644 +--- a/tools/msbuild/CMakeLists.txt ++++ b/tools/msbuild/CMakeLists.txt +@@ -1,4 +1,4 @@ +-if (WIN32) ++if (MSVC) + # CPack will install a registry key in this format that we wish to reference. + set(REG_KEY "${CPACK_PACKAGE_INSTALL_REGISTRY_KEY}") + set(LIB_PATH_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") +-- +2.11.0.windows.3 + diff --git a/mingw-w64-clang/0009-fix-llvm-config-shared-lib-version-on-win32.patch b/mingw-w64-clang/0006-llvm-config-look-for-unversioned-shared-lib-on-win32.patch similarity index 71% rename from mingw-w64-clang/0009-fix-llvm-config-shared-lib-version-on-win32.patch rename to mingw-w64-clang/0006-llvm-config-look-for-unversioned-shared-lib-on-win32.patch index b92b1528e0..36408ab415 100644 --- a/mingw-w64-clang/0009-fix-llvm-config-shared-lib-version-on-win32.patch +++ b/mingw-w64-clang/0006-llvm-config-look-for-unversioned-shared-lib-on-win32.patch @@ -1,18 +1,17 @@ -From ffec0c88ac778aa809e7bf99c6e61f0b4ef17e3d Mon Sep 17 00:00:00 2001 +From cccec8226592a0a635a4f00d5bf6f72803616e38 Mon Sep 17 00:00:00 2001 From: Mateusz Mikula -Date: Fri, 20 Jan 2017 23:56:47 +0100 -Subject: [PATCH] fix llvm-config shared lib version on win32 +Date: Thu, 2 Feb 2017 11:48:25 +0100 +Subject: [PATCH 6/6] llvm-config: look for unversioned shared lib on win32 -Signed-off-by: Mateusz Mikula --- tools/llvm-config/llvm-config.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 94d426b..402df01 100644 +index 25344e4cd01..24aeba7cb0f 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp -@@ -345,7 +345,7 @@ int main(int argc, char **argv) { +@@ -351,7 +351,7 @@ int main(int argc, char **argv) { const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE)); if (HostTriple.isOSWindows()) { SharedExt = "dll"; @@ -21,8 +20,8 @@ index 94d426b..402df01 100644 if (HostTriple.isOSCygMing()) { StaticExt = "a"; StaticPrefix = "lib"; -@@ -382,8 +382,10 @@ int main(int argc, char **argv) { - const bool BuiltSharedLibs = std::strcmp(LLVM_ENABLE_SHARED, "ON") == 0; +@@ -389,8 +389,10 @@ int main(int argc, char **argv) { + const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED; bool DyLibExists = false; - const std::string DyLibName = diff --git a/mingw-w64-clang/0006-use-DESTDIR-on-windows.patch b/mingw-w64-clang/0006-use-DESTDIR-on-windows.patch deleted file mode 100644 index 649d74b4dd..0000000000 --- a/mingw-w64-clang/0006-use-DESTDIR-on-windows.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/cmake/modules/LLVMInstallSymlink.cmake -+++ b/cmake/modules/LLVMInstallSymlink.cmake -@@ -3,9 +3,9 @@ - # See PR8397. - - function(install_symlink name target outdir) -+set(DESTDIR $ENV{DESTDIR}) - if(UNIX) - set(LINK_OR_COPY create_symlink) -- set(DESTDIR $ENV{DESTDIR}) - else() - set(LINK_OR_COPY copy) - endif() diff --git a/mingw-w64-clang/0007-add-pthread-as-system-lib-for-mingw.patch b/mingw-w64-clang/0007-add-pthread-as-system-lib-for-mingw.patch new file mode 100644 index 0000000000..b99298c5b9 --- /dev/null +++ b/mingw-w64-clang/0007-add-pthread-as-system-lib-for-mingw.patch @@ -0,0 +1,25 @@ +From 6caf7048b2a66fa2beb198e52e5c62fa08b786e8 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Tue, 14 Mar 2017 17:50:29 +0100 +Subject: [PATCH] add pthread as system lib for mingw + +--- + lib/Support/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +index 15418ad2fd0..c69f75b7e48 100644 +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt +@@ -2,6 +2,9 @@ set(system_libs) + if( MSVC OR MINGW ) + # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc. + set(system_libs ${system_libs} psapi shell32 ole32 uuid) ++ if( MINGW ) ++ set(system_libs ${system_libs} pthread) ++ endif() + elseif( CMAKE_HOST_UNIX ) + if( HAVE_LIBRT ) + set(system_libs ${system_libs} rt) +-- +2.12.0 diff --git a/mingw-w64-clang/0007-fix-llvm-shlib-cmake-build.patch b/mingw-w64-clang/0007-fix-llvm-shlib-cmake-build.patch deleted file mode 100644 index f38b5d59cf..0000000000 --- a/mingw-w64-clang/0007-fix-llvm-shlib-cmake-build.patch +++ /dev/null @@ -1,86 +0,0 @@ -From c36be93ddb85a15935ff32c3942628fabf698a26 Mon Sep 17 00:00:00 2001 -From: Chris Bieneman -Date: Tue, 1 Nov 2016 20:19:33 +0000 -Subject: [PATCH] Fix llvm-shlib cmake build - -Summary: -This fixes a few things that used to work with a Makefile build, but were broken in cmake. - -1. Treat MINGW like a Linux system. -2. The shlib should never contain other shared libraries. - -Patch By: Valentin Churavy - -Reviewers: axw, beanz - -Subscribers: modocache, beanz, mgorny - -Differential Revision: https://reviews.llvm.org/D25865 - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285737 91177308-0d34-0410-b5e6-96231b3b80d8 ---- - tools/llvm-shlib/CMakeLists.txt | 42 ++++++++++++++++++++--------------------- - 1 file changed, 20 insertions(+), 22 deletions(-) - -diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt -index 3fe672d..edadb82 100644 ---- a/tools/llvm-shlib/CMakeLists.txt -+++ b/tools/llvm-shlib/CMakeLists.txt -@@ -8,29 +8,27 @@ set(SOURCES - - llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS}) - --if(LLVM_LINK_LLVM_DYLIB) -- if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) -- message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") -- endif() -- -- # libLLVM.so should not have any dependencies on any other LLVM -- # shared libraries. When using the "all" pseudo-component, -- # LLVM_AVAILABLE_LIBS is added to the dependencies, which may -- # contain shared libraries (e.g. libLTO). -- # -- # Also exclude libLLVMTableGen for the following reasons: -- # - it is only used by internal *-tblgen utilities; -- # - it pollutes the global options space. -- foreach(lib ${LIB_NAMES}) -- get_target_property(t ${lib} TYPE) -- if("${lib}" STREQUAL "LLVMTableGen") -- elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") -- list(APPEND FILTERED_LIB_NAMES ${lib}) -- endif() -- endforeach() -- set(LIB_NAMES ${FILTERED_LIB_NAMES}) -+if(LLVM_LINK_LLVM_DYLIB AND LLVM_DYLIB_EXPORTED_SYMBOL_FILE) -+ message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") - endif() - -+# libLLVM.so should not have any dependencies on any other LLVM -+# shared libraries. When using the "all" pseudo-component, -+# LLVM_AVAILABLE_LIBS is added to the dependencies, which may -+# contain shared libraries (e.g. libLTO). -+# -+# Also exclude libLLVMTableGen for the following reasons: -+# - it is only used by internal *-tblgen utilities; -+# - it pollutes the global options space. -+foreach(lib ${LIB_NAMES}) -+ get_target_property(t ${lib} TYPE) -+ if("${lib}" STREQUAL "LLVMTableGen") -+ elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") -+ list(APPEND FILTERED_LIB_NAMES ${lib}) -+ endif() -+endforeach() -+set(LIB_NAMES ${FILTERED_LIB_NAMES}) -+ - if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) - set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_DYLIB_EXPORTED_SYMBOL_FILE}) - add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE}) -@@ -39,7 +37,7 @@ endif() - add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) - - list(REMOVE_DUPLICATES LIB_NAMES) --if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf" -+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf" - # GNU ld doesn't resolve symbols in the version script. - set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) - elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") diff --git a/mingw-w64-clang/0008-not-install-msvc-files.patch b/mingw-w64-clang/0008-not-install-msvc-files.patch deleted file mode 100644 index 24cd245c08..0000000000 --- a/mingw-w64-clang/0008-not-install-msvc-files.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- llvm-3.9.1.src/tools/msbuild/CMakeLists.txt.orig 2017-01-17 20:02:22.438672900 +0300 -+++ llvm-3.9.1.src/tools/msbuild/CMakeLists.txt 2017-01-17 20:02:29.920100800 +0300 -@@ -1,4 +1,4 @@ --if (WIN32) -+if (MSVC) - # CPack will install a registry key in this format that we wish to reference. - set(REG_KEY "${CPACK_PACKAGE_INSTALL_REGISTRY_KEY}") - set(LIB_PATH_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") diff --git a/mingw-w64-clang/0101-Revert-Revert-r253898-and-r253899-this-breaks-mingw-.patch b/mingw-w64-clang/0101-Revert-Revert-r253898-and-r253899-this-breaks-mingw-.patch deleted file mode 100644 index aefb57aed5..0000000000 --- a/mingw-w64-clang/0101-Revert-Revert-r253898-and-r253899-this-breaks-mingw-.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 42df5ed300973bfa10f155dd967768684c86f932 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Fri, 27 May 2016 20:30:18 -0700 -Subject: [PATCH 1/4] Revert "Revert r253898 and r253899, this breaks mingw - compilation on openSUSE." - -This reverts commit 0e2452f3055e2e2cad06a55c5ca9c2be13404781. - -diff --git a/lib/Driver/MinGWToolChain.cpp b/lib/Driver/MinGWToolChain.cpp -index 938440b..c5287bb 100644 ---- a/lib/Driver/MinGWToolChain.cpp -+++ b/lib/Driver/MinGWToolChain.cpp -@@ -66,23 +66,17 @@ MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : ToolChain(D, Triple, Args) { - getProgramPaths().push_back(getDriver().getInstalledDir()); - --// In Windows there aren't any standard install locations, we search --// for gcc on the PATH. In Linux the base is always /usr. --#ifdef LLVM_ON_WIN32 -+ // On Windows if there is no sysroot we search for gcc on the PATH. - if (getDriver().SysRoot.size()) -- Base = getDriver().SysRoot; -+ Base = getDriver().SysRoot; -+#ifdef LLVM_ON_WIN32 - else if (llvm::ErrorOr GPPName = - llvm::sys::findProgramByName("gcc")) - Base = llvm::sys::path::parent_path( - llvm::sys::path::parent_path(GPPName.get())); -- else -- Base = llvm::sys::path::parent_path(getDriver().getInstalledDir()); --#else -- if (getDriver().SysRoot.size()) -- Base = getDriver().SysRoot; -- else -- Base = "/usr"; - #endif -+ if (!Base.size()) -+ Base = llvm::sys::path::parent_path(getDriver().getInstalledDir()); - - Base += llvm::sys::path::get_separator(); - findGccLibDir(); --- -2.8.3 - diff --git a/mingw-w64-clang/0103-mingw-w64-enable-support-for-__declspec-selectany.patch b/mingw-w64-clang/0101-mingw-w64-enable-support-for-__declspec-selectany.patch similarity index 65% rename from mingw-w64-clang/0103-mingw-w64-enable-support-for-__declspec-selectany.patch rename to mingw-w64-clang/0101-mingw-w64-enable-support-for-__declspec-selectany.patch index 434f1c9834..7805b1a743 100644 --- a/mingw-w64-clang/0103-mingw-w64-enable-support-for-__declspec-selectany.patch +++ b/mingw-w64-clang/0101-mingw-w64-enable-support-for-__declspec-selectany.patch @@ -1,14 +1,17 @@ -From 05d6add74e34a5ff2aeadec722df981be2760e52 Mon Sep 17 00:00:00 2001 +From 43803cddf8b2f53203cacb575e1e53db4b8191ed Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Mon, 15 Aug 2016 20:57:27 -0700 -Subject: [PATCH 3/4] mingw-w64: enable support for __declspec(selectany) +Subject: [PATCH 1/9] mingw-w64: enable support for __declspec(selectany) +--- + include/clang/Basic/Attr.td | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td -index 7da1efe..2d4be9e 100644 +index d7db7186b3..ddb41c0eb8 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td -@@ -2097,9 +2097,8 @@ def DLLImport : InheritableAttr, TargetSpecificAttr { +@@ -2194,9 +2194,8 @@ def DLLImport : InheritableAttr, TargetSpecificAttr { let Documentation = [DLLImportDocs]; } @@ -21,5 +24,5 @@ index 7da1efe..2d4be9e 100644 } -- -2.8.3 +2.12.0 diff --git a/mingw-w64-clang/0102-Allow-build-static-clang-library-for-mingw.patch b/mingw-w64-clang/0102-Allow-build-static-clang-library-for-mingw.patch new file mode 100644 index 0000000000..9ee441c427 --- /dev/null +++ b/mingw-w64-clang/0102-Allow-build-static-clang-library-for-mingw.patch @@ -0,0 +1,25 @@ +From c1c93aaa9b8a903ce3f761ae2dabb20daf521f5c Mon Sep 17 00:00:00 2001 +From: Alexey Pavlov +Date: Fri, 25 Dec 2015 20:14:51 +0100 +Subject: [PATCH 2/9] Allow build static clang library for mingw + +--- + tools/libclang/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt +index 2dd6703076..477e53dd15 100644 +--- a/tools/libclang/CMakeLists.txt ++++ b/tools/libclang/CMakeLists.txt +@@ -74,7 +74,7 @@ if( LLVM_ENABLE_PIC ) + set(ENABLE_SHARED SHARED) + endif() + +-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) ++if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND (NOT MSVC)) + set(ENABLE_STATIC STATIC) + endif() + +-- +2.12.0 + diff --git a/mingw-w64-clang/0102-mingw-w64-setup-new-defaults-for-target.patch b/mingw-w64-clang/0102-mingw-w64-setup-new-defaults-for-target.patch deleted file mode 100644 index 81f28a7c2b..0000000000 --- a/mingw-w64-clang/0102-mingw-w64-setup-new-defaults-for-target.patch +++ /dev/null @@ -1,45 +0,0 @@ -From ee9923897d733a852efe1e8836a1a98f41ea6cf9 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Wed, 16 Dec 2015 02:07:06 -0800 -Subject: [PATCH 2/4] mingw-w64: setup new defaults for target - -runtime: compiler-rt -c++ lib: libc++ -linker: lld - -diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h -index 61c559c..78fde9b 100644 ---- a/lib/Driver/ToolChains.h -+++ b/lib/Driver/ToolChains.h -@@ -677,6 +677,15 @@ public: - const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; - -+ RuntimeLibType GetDefaultRuntimeLibType() const override { -+ return RuntimeLibType::RLT_CompilerRT; -+ } -+ -+ CXXStdlibType -+ GetCXXStdlibType(const llvm::opt::ArgList &Args) const override { -+ return ToolChain::CST_Libcxx; -+ } -+ - protected: - Tool *getTool(Action::ActionClass AC) const override; - Tool *buildLinker() const override; -diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp -index 4900e20..6673e78 100644 ---- a/lib/Driver/Tools.cpp -+++ b/lib/Driver/Tools.cpp -@@ -10443,7 +10443,7 @@ void MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, - // handled somewhere else. - Args.ClaimAllArgs(options::OPT_w); - -- StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld"); -+ StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "lld"); - if (LinkerName.equals_lower("lld")) { - CmdArgs.push_back("-flavor"); - CmdArgs.push_back("gnu"); --- -2.8.3 - diff --git a/mingw-w64-clang/0103-fix-libclang-name-for-mingw.patch b/mingw-w64-clang/0103-fix-libclang-name-for-mingw.patch new file mode 100644 index 0000000000..f6ef6e606c --- /dev/null +++ b/mingw-w64-clang/0103-fix-libclang-name-for-mingw.patch @@ -0,0 +1,25 @@ +From 180bffbe07c0c43e7f103debc8d8d777cb027096 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Thu, 2 Feb 2017 12:21:45 +0100 +Subject: [PATCH 3/9] fix libclang name for mingw + +--- + tools/libclang/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt +index 477e53dd15..dc2e3538fa 100644 +--- a/tools/libclang/CMakeLists.txt ++++ b/tools/libclang/CMakeLists.txt +@@ -78,7 +78,7 @@ if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND (NOT MSVC)) + set(ENABLE_STATIC STATIC) + endif() + +-if(WIN32) ++if(MSVC) + set(output_name "libclang") + else() + set(output_name "clang") +-- +2.12.0 + diff --git a/mingw-w64-clang/0104-don-t-use-GCC-headers.patch b/mingw-w64-clang/0104-don-t-use-GCC-headers.patch new file mode 100644 index 0000000000..2e6fc1cda1 --- /dev/null +++ b/mingw-w64-clang/0104-don-t-use-GCC-headers.patch @@ -0,0 +1,32 @@ +From b1025201e074846b13132a7c417fa776312816fc Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Thu, 2 Feb 2017 12:26:19 +0100 +Subject: [PATCH 4/9] don't use GCC headers + +--- + lib/Driver/MinGWToolChain.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/Driver/MinGWToolChain.cpp b/lib/Driver/MinGWToolChain.cpp +index e971869fb5..252c5e818f 100644 +--- a/lib/Driver/MinGWToolChain.cpp ++++ b/lib/Driver/MinGWToolChain.cpp +@@ -208,6 +208,7 @@ void MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + if (DriverArgs.hasArg(options::OPT_nostdlibinc)) + return; + ++#ifndef LLVM_ON_WIN32 + if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) { + llvm::SmallString<1024> IncludeDir(GccLibDir); + llvm::sys::path::append(IncludeDir, "include"); +@@ -218,6 +219,7 @@ void MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + Base + Arch + "/sys-root/mingw/include"); + addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str()); + } ++#endif + addSystemInclude(DriverArgs, CC1Args, + Base + Arch + llvm::sys::path::get_separator() + "include"); + addSystemInclude(DriverArgs, CC1Args, Base + "include"); +-- +2.12.0 + diff --git a/mingw-w64-clang/0104-mingw-w64-support-static-builds-of-libc.patch b/mingw-w64-clang/0104-mingw-w64-support-static-builds-of-libc.patch deleted file mode 100644 index 91a9ce3b5c..0000000000 --- a/mingw-w64-clang/0104-mingw-w64-support-static-builds-of-libc.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 5364db7f4d3f9204530f33a05388b6f54f515b21 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Fri, 5 Aug 2016 21:50:38 -0700 -Subject: [PATCH 4/4] mingw-w64: support static builds of libc++ - -Static builds require libc++abi to be linked -Will add support for both modes in future - -diff --git a/lib/Driver/MinGWToolChain.cpp b/lib/Driver/MinGWToolChain.cpp -index c5287bb..9090be5 100644 ---- a/lib/Driver/MinGWToolChain.cpp -+++ b/lib/Driver/MinGWToolChain.cpp -@@ -242,3 +242,18 @@ void MinGW::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, - break; - } - } -+ -+void MinGW::AddCXXStdlibLibArgs(const ArgList &Args, -+ ArgStringList &CmdArgs) const { -+ switch (GetCXXStdlibType(Args)) { -+ case ToolChain::CST_Libcxx: -+ CmdArgs.push_back("-lc++"); -+ // Support only static libc++ for now -+ CmdArgs.push_back("-lc++abi"); -+ break; -+ -+ case ToolChain::CST_Libstdcxx: -+ CmdArgs.push_back("-lstdc++"); -+ break; -+ } -+} -diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h -index 78fde9b..d490969 100644 ---- a/lib/Driver/ToolChains.h -+++ b/lib/Driver/ToolChains.h -@@ -673,6 +673,10 @@ public: - void - AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; -+ -+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, -+ llvm::opt::ArgStringList &CmdArgs) const override; -+ - void AddClangCXXStdlibIncludeArgs( - const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; --- -2.8.3 - diff --git a/mingw-w64-clang/0109-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch b/mingw-w64-clang/0105-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch similarity index 62% rename from mingw-w64-clang/0109-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch rename to mingw-w64-clang/0105-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch index 90824a9c31..c74654c408 100644 --- a/mingw-w64-clang/0109-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch +++ b/mingw-w64-clang/0105-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch @@ -1,14 +1,17 @@ -From 57def79f5d6e97f5b353b22a5fb856e627cdf061 Mon Sep 17 00:00:00 2001 +From 0e31fbf4e602f857cd33c1b5b446da354b64df11 Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Sun, 28 Jun 2015 19:12:19 +0100 -Subject: [PATCH] Set the x86 arch name to i686 for mingw-w64 +Subject: [PATCH 5/9] Set the x86 arch name to i686 for mingw-w64 +--- + lib/Driver/Driver.cpp | 5 +++++ + 1 file changed, 5 insertions(+) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 5451132..a6852b6 100644 +index b8ae7e4c31..a76ef16c8a 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp -@@ -1991,6 +1991,12 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, +@@ -381,6 +381,11 @@ static llvm::Triple computeTargetTriple(const Driver &D, if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) Target.setArch(AT); @@ -17,10 +20,9 @@ index 5451132..a6852b6 100644 + if (AT == llvm::Triple::x86 && Target.isWindowsGNUEnvironment() && + Target.getVendorName().equals(StringRef("w64"))) + Target.setArchName(StringRef("i686")); -+ } - return Target; + // Handle -miamcu flag. -- -2.4.5 +2.12.0 diff --git a/mingw-w64-clang/0105-mingw-enable-static-libclang.patch b/mingw-w64-clang/0105-mingw-enable-static-libclang.patch deleted file mode 100644 index d7bbc249f9..0000000000 --- a/mingw-w64-clang/0105-mingw-enable-static-libclang.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- cfe-3.7.0.src/tools/libclang/CMakeLists.txt.orig 2015-12-25 10:56:22.521432100 +0300 -+++ cfe-3.7.0.src/tools/libclang/CMakeLists.txt 2015-12-25 12:18:32.484593900 +0300 -@@ -74,7 +74,7 @@ - set(ENABLE_SHARED SHARED) - endif() - --if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) -+if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND (NOT WIN32 OR MINGW)) - set(ENABLE_STATIC STATIC) - endif() - diff --git a/mingw-w64-clang/0106-generate-libclang-instead-of-liblibclang.patch b/mingw-w64-clang/0106-generate-libclang-instead-of-liblibclang.patch deleted file mode 100644 index d182d7fc69..0000000000 --- a/mingw-w64-clang/0106-generate-libclang-instead-of-liblibclang.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -urN cfe-3.9.0.src.orig/tools/libclang/CMakeLists.txt cfe-3.9.0.src/tools/libclang/CMakeLists.txt ---- cfe-3.9.0.src.orig/tools/libclang/CMakeLists.txt 2016-03-03 12:09:43.000000000 +0100 -+++ cfe-3.9.0.src/tools/libclang/CMakeLists.txt 2016-09-26 19:40:33.887171200 +0200 -@@ -97,6 +97,15 @@ - Support - ) - -+if(MINGW) -+ set_target_properties(libclang -+ PROPERTIES -+ PREFIX "" -+ OUTPUT_NAME clang -+ RUNTIME_OUTPUT_NAME libclang -+ ARCHIVE_OUTPUT_NAME clang) -+endif() -+ - if(ENABLE_SHARED) - if(WIN32) - set_target_properties(libclang diff --git a/mingw-w64-clang/0106-link-pthread-with-mingw.patch b/mingw-w64-clang/0106-link-pthread-with-mingw.patch new file mode 100644 index 0000000000..0200f96ce9 --- /dev/null +++ b/mingw-w64-clang/0106-link-pthread-with-mingw.patch @@ -0,0 +1,26 @@ +From 2156ae73b265c3c77803b5ee1e46af45b52fccc3 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Thu, 2 Feb 2017 12:33:51 +0100 +Subject: [PATCH 6/9] link pthread with mingw + +--- + lib/Driver/Tools.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index 339f6976cd..7a6e1f6f36 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -11428,7 +11428,8 @@ void MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (Args.hasArg(options::OPT_pg)) + CmdArgs.push_back("-lgmon"); + +- if (Args.hasArg(options::OPT_pthread)) ++ // it might break libc++ ++ if (!Args.hasArg(options::OPT_no_pthread)) + CmdArgs.push_back("-lpthread"); + + // add system libraries +-- +2.12.0 + diff --git a/mingw-w64-clang/0107-dont-create-cl-mingw.patch b/mingw-w64-clang/0107-dont-create-cl-mingw.patch deleted file mode 100644 index 8506a2bc69..0000000000 --- a/mingw-w64-clang/0107-dont-create-cl-mingw.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 12d299345b51c1686c1d82986de6de020970bb57 Mon Sep 17 00:00:00 2001 -From: Alexey Pavlov -Date: Sun, 25 Dec 2015 20:14:51 +0100 -Subject: [PATCH] Don't create cl executable for mingw - - -diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt -index 671a8ce..45c47e1 100644 ---- a/tools/driver/CMakeLists.txt -+++ b/tools/driver/CMakeLists.txt -@@ -66,7 +66,7 @@ - if(NOT CLANG_LINKS_TO_CREATE) - set(CLANG_LINKS_TO_CREATE clang++ clang-cl) - -- if (WIN32) -+ if (MSVC) - list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) - endif() - endif() --- -2.4.5 diff --git a/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch b/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch new file mode 100644 index 0000000000..8ee9d391ae --- /dev/null +++ b/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch @@ -0,0 +1,35 @@ +From 2243dd85c1e5c27edf76cc7b5e2c836518ab2a6b Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Fri, 3 Feb 2017 11:04:25 +0100 +Subject: [PATCH 7/9] enable __float128 for X86 MinGW + +--- + lib/Basic/Targets.cpp | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp +index d69a0ff4ab..9fe6c51be2 100644 +--- a/lib/Basic/Targets.cpp ++++ b/lib/Basic/Targets.cpp +@@ -4443,7 +4443,9 @@ static void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) { + class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo { + public: + MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) +- : WindowsX86_32TargetInfo(Triple, Opts) {} ++ : WindowsX86_32TargetInfo(Triple, Opts) { ++ this->HasFloat128 = true; ++ } + void getTargetDefines(const LangOptions &Opts, + MacroBuilder &Builder) const override { + WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); +@@ -4735,6 +4737,7 @@ public: + // with x86 FP ops. Weird. + LongDoubleWidth = LongDoubleAlign = 128; + LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); ++ this->HasFloat128 = true; + } + + void getTargetDefines(const LangOptions &Opts, +-- +2.12.0 + diff --git a/mingw-w64-clang/0108-Don-t-create-cl-executable-for-mingw.patch b/mingw-w64-clang/0108-Don-t-create-cl-executable-for-mingw.patch new file mode 100644 index 0000000000..c4487d5e73 --- /dev/null +++ b/mingw-w64-clang/0108-Don-t-create-cl-executable-for-mingw.patch @@ -0,0 +1,25 @@ +From 28f3e2bd27cb8e3f7a182a17d45af72303a47862 Mon Sep 17 00:00:00 2001 +From: Alexey Pavlov +Date: Fri, 25 Dec 2015 20:14:51 +0100 +Subject: [PATCH 8/9] Don't create cl executable for mingw + +--- + tools/driver/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt +index f6e26fa11f..901b6d62e4 100644 +--- a/tools/driver/CMakeLists.txt ++++ b/tools/driver/CMakeLists.txt +@@ -61,7 +61,7 @@ add_dependencies(clang clang-headers) + if(NOT CLANG_LINKS_TO_CREATE) + set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) + +- if (WIN32) ++ if (MSVC) + list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) + endif() + endif() +-- +2.12.0 + diff --git a/mingw-w64-clang/0108-dont-use-gcc-headers.patch b/mingw-w64-clang/0108-dont-use-gcc-headers.patch deleted file mode 100644 index b6fc891d7d..0000000000 --- a/mingw-w64-clang/0108-dont-use-gcc-headers.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -urN cfe-3.9.0.src.orig/lib/Driver/MinGWToolChain.cpp cfe-3.9.0.src/lib/Driver/MinGWToolChain.cpp ---- cfe-3.9.0.src.orig/lib/Driver/MinGWToolChain.cpp 2016-01-12 11:41:20.000000000 +0100 -+++ cfe-3.9.0.src/lib/Driver/MinGWToolChain.cpp 2016-11-14 10:19:31.658427300 +0100 -@@ -201,6 +201,7 @@ - if (DriverArgs.hasArg(options::OPT_nostdlibinc)) - return; - -+#ifndef LLVM_ON_WIN32 - if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) { - llvm::SmallString<1024> IncludeDir(GccLibDir); - llvm::sys::path::append(IncludeDir, "include"); -@@ -211,6 +212,7 @@ - Base + Arch + "/sys-root/mingw/include"); - addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str()); - } -+#endif - addSystemInclude(DriverArgs, CC1Args, - Base + Arch + llvm::sys::path::get_separator() + "include"); - addSystemInclude(DriverArgs, CC1Args, Base + "include"); diff --git a/mingw-w64-clang/0109-use-emulated-tls-with-mingw.patch b/mingw-w64-clang/0109-use-emulated-tls-with-mingw.patch new file mode 100644 index 0000000000..09d9ffee3f --- /dev/null +++ b/mingw-w64-clang/0109-use-emulated-tls-with-mingw.patch @@ -0,0 +1,26 @@ +From 7b80268c2f6475fcb932b961680ba6acdd33758d Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Wed, 1 Mar 2017 19:56:37 +0100 +Subject: [PATCH 9/9] use emulated tls with mingw + +--- + lib/Driver/Tools.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index 7a6e1f6f36..4c7d40a549 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -5423,7 +5423,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, + Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); + // Emulated TLS is enabled by default on Android, and can be enabled manually + // with -femulated-tls. +- bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isWindowsCygwinEnvironment(); ++ bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isWindowsCygwinEnvironment() ++ || Triple.isWindowsGNUEnvironment(); + if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls, + EmulatedTLSDefault)) + CmdArgs.push_back("-femulated-tls"); +-- +2.12.0 + diff --git a/mingw-w64-clang/0110-enable-support-for-float128.patch b/mingw-w64-clang/0110-enable-support-for-float128.patch deleted file mode 100644 index 48cba7c472..0000000000 --- a/mingw-w64-clang/0110-enable-support-for-float128.patch +++ /dev/null @@ -1,1583 +0,0 @@ -From fa54202263d4a62bd3153cb9037d8801ebbdc15a Mon Sep 17 00:00:00 2001 -From: Nemanja Ivanovic -Date: Mon, 9 May 2016 08:52:33 +0000 -Subject: [PATCH] Enable support for __float128 in Clang and enable it on - pertinent platforms - -This patch corresponds to reviews: -http://reviews.llvm.org/D15120 -http://reviews.llvm.org/D19125 - -It adds support for the __float128 keyword, literals and target feature to -enable it. Based on the latter of the two aforementioned reviews, this feature -is enabled on Linux on i386/X86 as well as SystemZ. -This is also the second attempt in commiting this feature. The first attempt -did not enable it on required platforms which caused failures when compiling -type_traits with -std=gnu++11. - -If you see failures with compiling this header on your platform after this -commit, it is likely that your platform needs to have this feature enabled. - - -git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268898 91177308-0d34-0410-b5e6-96231b3b80d8 ---- - bindings/python/clang/cindex.py | 1 + - include/clang-c/Index.h | 1 + - include/clang/AST/ASTContext.h | 9 +- - include/clang/AST/BuiltinTypes.def | 3 + - include/clang/AST/Type.h | 2 +- - include/clang/AST/TypeLoc.h | 2 +- - include/clang/Basic/DiagnosticSemaKinds.td | 6 +- - include/clang/Basic/Specifiers.h | 1 + - include/clang/Basic/TargetInfo.h | 19 +++- - include/clang/Basic/TokenKinds.def | 1 + - include/clang/Driver/Options.td | 4 + - include/clang/Lex/LiteralSupport.h | 1 + - include/clang/Sema/DeclSpec.h | 1 + - include/clang/Serialization/ASTBitCodes.h | 2 + - lib/AST/ASTContext.cpp | 32 +++--- - lib/AST/ItaniumMangle.cpp | 8 +- - lib/AST/MicrosoftMangle.cpp | 1 + - lib/AST/NSAPI.cpp | 1 + - lib/AST/StmtPrinter.cpp | 1 + - lib/AST/Type.cpp | 8 +- - lib/AST/TypeLoc.cpp | 1 + - lib/Analysis/PrintfFormatString.cpp | 1 + - lib/Basic/TargetInfo.cpp | 5 + - lib/Basic/Targets.cpp | 27 ++++- - lib/CodeGen/CGDebugInfo.cpp | 6 ++ - lib/CodeGen/CGExprScalar.cpp | 14 ++- - lib/CodeGen/CodeGenTypes.cpp | 1 + - lib/CodeGen/ItaniumCXXABI.cpp | 5 +- - lib/Format/FormatToken.cpp | 1 + - lib/Index/USRGeneration.cpp | 2 + - lib/Lex/LiteralSupport.cpp | 13 ++- - lib/Parse/ParseDecl.cpp | 7 ++ - lib/Parse/ParseExpr.cpp | 1 + - lib/Parse/ParseExprCXX.cpp | 3 + - lib/Parse/ParseTentative.cpp | 3 + - lib/Sema/DeclSpec.cpp | 2 + - lib/Sema/SemaDecl.cpp | 1 + - lib/Sema/SemaExpr.cpp | 69 ++++++++++++- - lib/Sema/SemaExprCXX.cpp | 6 ++ - lib/Sema/SemaLookup.cpp | 7 -- - lib/Sema/SemaOverload.cpp | 30 ++++-- - lib/Sema/SemaTemplateVariadic.cpp | 1 + - lib/Sema/SemaType.cpp | 16 +-- - lib/Serialization/ASTCommon.cpp | 3 + - lib/Serialization/ASTReader.cpp | 3 + - test/CodeGenCXX/float128-declarations.cpp | 138 ++++++++++++++++++++++++++ - test/Preprocessor/init.c | 3 + - test/Sema/128bitfloat.cpp | 27 +++-- - test/Sema/attr-mode.c | 2 +- - test/Sema/float128-ld-incompatibility.cpp | 36 +++++++ - test/SemaCXX/deleted-operator.cpp | 2 +- - test/SemaCXX/overloaded-builtin-operators.cpp | 2 +- - tools/libclang/CXType.cpp | 2 + - 53 files changed, 462 insertions(+), 82 deletions(-) - create mode 100644 test/CodeGenCXX/float128-declarations.cpp - create mode 100644 test/Sema/float128-ld-incompatibility.cpp - -diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py -index 5f1c506..aeb34f8 100644 ---- a/bindings/python/clang/cindex.py -+++ b/bindings/python/clang/cindex.py -@@ -1731,6 +1731,7 @@ def __repr__(self): - TypeKind.OBJCID = TypeKind(27) - TypeKind.OBJCCLASS = TypeKind(28) - TypeKind.OBJCSEL = TypeKind(29) -+TypeKind.FLOAT128 = TypeKind(30) - TypeKind.COMPLEX = TypeKind(100) - TypeKind.POINTER = TypeKind(101) - TypeKind.BLOCKPOINTER = TypeKind(102) -diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h -index 4ace0f5..06f369a 100644 ---- a/include/clang-c/Index.h -+++ b/include/clang-c/Index.h -@@ -2929,6 +2929,7 @@ enum CXTypeKind { - CXType_ObjCId = 27, - CXType_ObjCClass = 28, - CXType_ObjCSel = 29, -+ CXType_Float128 = 30, - CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_ObjCSel, - -diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h -index e04d976..b29593b 100644 ---- a/include/clang/AST/ASTContext.h -+++ b/include/clang/AST/ASTContext.h -@@ -215,9 +215,6 @@ class ASTContext : public RefCountedBase { - /// \brief The typedef for the __uint128_t type. - mutable TypedefDecl *UInt128Decl; - -- /// \brief The typedef for the __float128 stub type. -- mutable TypeDecl *Float128StubDecl; -- - /// \brief The typedef for the target specific predefined - /// __builtin_va_list type. - mutable TypedefDecl *BuiltinVaListDecl; -@@ -893,9 +890,10 @@ class ASTContext : public RefCountedBase { - CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty; - CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; - CanQualType UnsignedLongLongTy, UnsignedInt128Ty; -- CanQualType FloatTy, DoubleTy, LongDoubleTy; -+ CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; - CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON - CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; -+ CanQualType Float128ComplexTy; - CanQualType VoidPtrTy, NullPtrTy; - CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy; - CanQualType BuiltinFnTy; -@@ -968,9 +966,6 @@ class ASTContext : public RefCountedBase { - /// \brief Retrieve the declaration for the 128-bit unsigned integer type. - TypedefDecl *getUInt128Decl() const; - -- /// \brief Retrieve the declaration for a 128-bit float stub type. -- TypeDecl *getFloat128StubType() const; -- - //===--------------------------------------------------------------------===// - // Type Constructors - //===--------------------------------------------------------------------===// -diff --git a/include/clang/AST/BuiltinTypes.def b/include/clang/AST/BuiltinTypes.def -index dcca44d..c0c6819 100644 ---- a/include/clang/AST/BuiltinTypes.def -+++ b/include/clang/AST/BuiltinTypes.def -@@ -133,6 +133,9 @@ FLOATING_TYPE(Double, DoubleTy) - // 'long double' - FLOATING_TYPE(LongDouble, LongDoubleTy) - -+// '__float128' -+FLOATING_TYPE(Float128, Float128Ty) -+ - //===- Language-specific types --------------------------------------------===// - - // This is the type of C++0x 'nullptr'. -diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h -index 4f64d4c..71004fc 100644 ---- a/include/clang/AST/Type.h -+++ b/include/clang/AST/Type.h -@@ -2051,7 +2051,7 @@ class BuiltinType : public Type { - } - - bool isFloatingPoint() const { -- return getKind() >= Half && getKind() <= LongDouble; -+ return getKind() >= Half && getKind() <= Float128; - } - - /// Determines whether the given kind corresponds to a placeholder type. -diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h -index ba3f848..67adf4a 100644 ---- a/include/clang/AST/TypeLoc.h -+++ b/include/clang/AST/TypeLoc.h -@@ -538,7 +538,7 @@ class BuiltinTypeLoc : public ConcreteTypeLocgetKind(); - return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) -- || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble) -+ || (bk >= BuiltinType::Short && bk <= BuiltinType::Float128) - || bk == BuiltinType::UChar - || bk == BuiltinType::SChar; - } -diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td -index c5bf16b..a6cdfa2 100644 ---- a/include/clang/Basic/DiagnosticSemaKinds.td -+++ b/include/clang/Basic/DiagnosticSemaKinds.td -@@ -5278,8 +5278,6 @@ def err_typecheck_pointer_arith_void_type : Error< - "arithmetic on%select{ a|}0 pointer%select{|s}0 to void">; - def err_typecheck_decl_incomplete_type : Error< - "variable has incomplete type %0">; --def err_typecheck_decl_incomplete_type___float128 : Error< -- "support for type '__float128' is not yet implemented">; - def ext_typecheck_decl_incomplete_type : ExtWarn< - "tentative definition of variable with internal linkage has incomplete non-array type %0">, - InGroup>; -@@ -7636,8 +7634,8 @@ def err_c99_array_usage_cxx : Error< - "feature, not permitted in C++">; - def err_type_requires_extension : Error< - "use of type %0 requires %1 extension to be enabled">; --def err_int128_unsupported : Error< -- "__int128 is not supported on this target">; -+def err_type_unsupported : Error< -+ "%0 is not supported on this target">; - def err_nsconsumed_attribute_mismatch : Error< - "overriding method has mismatched ns_consumed attribute on its" - " parameter">; -diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h -index 334719c..b296578 100644 ---- a/include/clang/Basic/Specifiers.h -+++ b/include/clang/Basic/Specifiers.h -@@ -54,6 +54,7 @@ namespace clang { - TST_half, // OpenCL half, ARM NEON __fp16 - TST_float, - TST_double, -+ TST_float128, - TST_bool, // _Bool - TST_decimal32, // _Decimal32 - TST_decimal64, // _Decimal64 -diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h -index b98a5d6..cf76dae 100644 ---- a/include/clang/Basic/TargetInfo.h -+++ b/include/clang/Basic/TargetInfo.h -@@ -58,13 +58,14 @@ class TargetInfo : public RefCountedBase { - bool BigEndian; - bool TLSSupported; - bool NoAsmVariants; // True if {|} are normal characters. -+ bool HasFloat128; - unsigned char PointerWidth, PointerAlign; - unsigned char BoolWidth, BoolAlign; - unsigned char IntWidth, IntAlign; - unsigned char HalfWidth, HalfAlign; - unsigned char FloatWidth, FloatAlign; - unsigned char DoubleWidth, DoubleAlign; -- unsigned char LongDoubleWidth, LongDoubleAlign; -+ unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align; - unsigned char LargeArrayMinWidth, LargeArrayAlign; - unsigned char LongWidth, LongAlign; - unsigned char LongLongWidth, LongLongAlign; -@@ -78,7 +79,7 @@ class TargetInfo : public RefCountedBase { - std::unique_ptr DataLayout; - const char *MCountName; - const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat, -- *LongDoubleFormat; -+ *LongDoubleFormat, *Float128Format; - unsigned char RegParmMax, SSERegParmMax; - TargetCXXABI TheCXXABI; - const LangAS::Map *AddrSpaceMap; -@@ -136,7 +137,8 @@ class TargetInfo : public RefCountedBase { - NoFloat = 255, - Float = 0, - Double, -- LongDouble -+ LongDouble, -+ Float128 - }; - - /// \brief The different kinds of __builtin_va_list types defined by -@@ -327,6 +329,9 @@ class TargetInfo : public RefCountedBase { - return getPointerWidth(0) >= 64; - } // FIXME - -+ /// \brief Determine whether the __float128 type is supported on this target. -+ virtual bool hasFloat128Type() const { return HasFloat128; } -+ - /// \brief Return the alignment that is suitable for storing any - /// object with a fundamental alignment requirement. - unsigned getSuitableAlign() const { return SuitableAlign; } -@@ -379,6 +384,14 @@ class TargetInfo : public RefCountedBase { - return *LongDoubleFormat; - } - -+ /// getFloat128Width/Align/Format - Return the size/align/format of -+ /// '__float128'. -+ unsigned getFloat128Width() const { return 128; } -+ unsigned getFloat128Align() const { return Float128Align; } -+ const llvm::fltSemantics &getFloat128Format() const { -+ return *Float128Format; -+ } -+ - /// \brief Return true if the 'long double' type should be mangled like - /// __float128. - virtual bool useFloat128ManglingForLongDouble() const { return false; } -diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def -index 3d0c657..9d97a81 100644 ---- a/include/clang/Basic/TokenKinds.def -+++ b/include/clang/Basic/TokenKinds.def -@@ -380,6 +380,7 @@ KEYWORD(__builtin_offsetof , KEYALL) - TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYNOCXX) - KEYWORD(__builtin_va_arg , KEYALL) - KEYWORD(__extension__ , KEYALL) -+KEYWORD(__float128 , KEYALL) - KEYWORD(__imag , KEYALL) - KEYWORD(__int128 , KEYALL) - KEYWORD(__label__ , KEYALL) -diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td -index 3cc7f20..e367b8c 100644 ---- a/include/clang/Driver/Options.td -+++ b/include/clang/Driver/Options.td -@@ -1507,6 +1507,10 @@ def minvariant_function_descriptors : - def mno_invariant_function_descriptors : - Flag<["-"], "mno-invariant-function-descriptors">, - Group; -+def mfloat128: Flag<["-"], "mfloat128">, -+ Group; -+def mno_float128 : Flag<["-"], "mno-float128">, -+ Group; - - def faltivec : Flag<["-"], "faltivec">, Group, Flags<[CC1Option]>, - HelpText<"Enable AltiVec vector initializer syntax">; -diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h -index a093e1a..5f946fc 100644 ---- a/include/clang/Lex/LiteralSupport.h -+++ b/include/clang/Lex/LiteralSupport.h -@@ -65,6 +65,7 @@ class NumericLiteralParser { - bool isHalf : 1; // 1.0h - bool isFloat : 1; // 1.0f - bool isImaginary : 1; // 1.0i -+ bool isFloat128 : 1; // 1.0q - uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64. - - bool isIntegerLiteral() const { -diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h -index b9e432b..d296e74 100644 ---- a/include/clang/Sema/DeclSpec.h -+++ b/include/clang/Sema/DeclSpec.h -@@ -280,6 +280,7 @@ class DeclSpec { - static const TST TST_half = clang::TST_half; - static const TST TST_float = clang::TST_float; - static const TST TST_double = clang::TST_double; -+ static const TST TST_float128 = clang::TST_float128; - static const TST TST_bool = clang::TST_bool; - static const TST TST_decimal32 = clang::TST_decimal32; - static const TST TST_decimal64 = clang::TST_decimal64; -diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h -index ef8b47b..adec500 100644 ---- a/include/clang/Serialization/ASTBitCodes.h -+++ b/include/clang/Serialization/ASTBitCodes.h -@@ -794,6 +794,8 @@ namespace clang { - PREDEF_TYPE_RESERVE_ID_ID = 42, - /// \brief The placeholder type for OpenMP array section. - PREDEF_TYPE_OMP_ARRAY_SECTION = 43, -+ /// \brief The '__float128' type -+ PREDEF_TYPE_FLOAT128_ID = 44, - /// \brief OpenCL image types with auto numeration - #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ - PREDEF_TYPE_##Id##_ID, -diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp -index f1aa16a..a99546c 100644 ---- a/lib/AST/ASTContext.cpp -+++ b/lib/AST/ASTContext.cpp -@@ -58,7 +58,7 @@ unsigned ASTContext::NumImplicitDestructors; - unsigned ASTContext::NumImplicitDestructorsDeclared; - - enum FloatingRank { -- HalfRank, FloatRank, DoubleRank, LongDoubleRank -+ HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank - }; - - RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { -@@ -734,10 +734,9 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM, - DependentTemplateSpecializationTypes(this_()), - SubstTemplateTemplateParmPacks(this_()), - GlobalNestedNameSpecifier(nullptr), Int128Decl(nullptr), -- UInt128Decl(nullptr), Float128StubDecl(nullptr), -- BuiltinVaListDecl(nullptr), BuiltinMSVaListDecl(nullptr), -- ObjCIdDecl(nullptr), ObjCSelDecl(nullptr), ObjCClassDecl(nullptr), -- ObjCProtocolClassDecl(nullptr), BOOLDecl(nullptr), -+ UInt128Decl(nullptr), BuiltinVaListDecl(nullptr), -+ BuiltinMSVaListDecl(nullptr), ObjCIdDecl(nullptr), ObjCSelDecl(nullptr), -+ ObjCClassDecl(nullptr), ObjCProtocolClassDecl(nullptr), BOOLDecl(nullptr), - CFConstantStringTagDecl(nullptr), CFConstantStringTypeDecl(nullptr), - ObjCInstanceTypeDecl(nullptr), FILEDecl(nullptr), jmp_bufDecl(nullptr), - sigjmp_bufDecl(nullptr), ucontext_tDecl(nullptr), -@@ -967,14 +966,6 @@ TypedefDecl *ASTContext::getUInt128Decl() const { - return UInt128Decl; - } - --TypeDecl *ASTContext::getFloat128StubType() const { -- assert(LangOpts.CPlusPlus && "should only be called for c++"); -- if (!Float128StubDecl) -- Float128StubDecl = buildImplicitRecord("__float128"); -- -- return Float128StubDecl; --} -- - void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) { - BuiltinType *Ty = new (*this, TypeAlignment) BuiltinType(K); - R = CanQualType::CreateUnsafe(QualType(Ty, 0)); -@@ -1023,6 +1014,9 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, - InitBuiltinType(DoubleTy, BuiltinType::Double); - InitBuiltinType(LongDoubleTy, BuiltinType::LongDouble); - -+ // GNU extension, __float128 for IEEE quadruple precision -+ InitBuiltinType(Float128Ty, BuiltinType::Float128); -+ - // GNU extension, 128-bit integers. - InitBuiltinType(Int128Ty, BuiltinType::Int128); - InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128); -@@ -1084,6 +1078,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, - FloatComplexTy = getComplexType(FloatTy); - DoubleComplexTy = getComplexType(DoubleTy); - LongDoubleComplexTy = getComplexType(LongDoubleTy); -+ Float128ComplexTy = getComplexType(Float128Ty); - - // Builtin types for 'id', 'Class', and 'SEL'. - InitBuiltinType(ObjCBuiltinIdTy, BuiltinType::ObjCId); -@@ -1341,6 +1336,7 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const { - case BuiltinType::Float: return Target->getFloatFormat(); - case BuiltinType::Double: return Target->getDoubleFormat(); - case BuiltinType::LongDouble: return Target->getLongDoubleFormat(); -+ case BuiltinType::Float128: return Target->getFloat128Format(); - } - } - -@@ -1651,6 +1647,10 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { - Width = Target->getLongDoubleWidth(); - Align = Target->getLongDoubleAlign(); - break; -+ case BuiltinType::Float128: -+ Width = Target->getFloat128Width(); -+ Align = Target->getFloat128Align(); -+ break; - case BuiltinType::NullPtr: - Width = Target->getPointerWidth(0); // C++ 3.9.1p11: sizeof(nullptr_t) - Align = Target->getPointerAlign(0); // == sizeof(void*) -@@ -4635,6 +4635,7 @@ static FloatingRank getFloatingRank(QualType T) { - case BuiltinType::Float: return FloatRank; - case BuiltinType::Double: return DoubleRank; - case BuiltinType::LongDouble: return LongDoubleRank; -+ case BuiltinType::Float128: return Float128Rank; - } - } - -@@ -4651,6 +4652,7 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size, - case FloatRank: return FloatComplexTy; - case DoubleRank: return DoubleComplexTy; - case LongDoubleRank: return LongDoubleComplexTy; -+ case Float128Rank: return Float128ComplexTy; - } - } - -@@ -4660,6 +4662,7 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size, - case FloatRank: return FloatTy; - case DoubleRank: return DoubleTy; - case LongDoubleRank: return LongDoubleTy; -+ case Float128Rank: return Float128Ty; - } - llvm_unreachable("getFloatingRank(): illegal value for rank"); - } -@@ -5489,6 +5492,7 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C, - case BuiltinType::LongDouble: return 'D'; - case BuiltinType::NullPtr: return '*'; // like char* - -+ case BuiltinType::Float128: - case BuiltinType::Half: - // FIXME: potentially need @encodes for these! - return ' '; -@@ -8695,6 +8699,8 @@ QualType ASTContext::getRealTypeForBitwidth(unsigned DestWidth) const { - return DoubleTy; - case TargetInfo::LongDouble: - return LongDoubleTy; -+ case TargetInfo::Float128: -+ return Float128Ty; - case TargetInfo::NoFloat: - return QualType(); - } -diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp -index 62b60d7..8d12105 100644 ---- a/lib/AST/ItaniumMangle.cpp -+++ b/lib/AST/ItaniumMangle.cpp -@@ -1992,7 +1992,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { - // ::= f # float - // ::= d # double - // ::= e # long double, __float80 -- // UNSUPPORTED: ::= g # __float128 -+ // ::= g # __float128 - // UNSUPPORTED: ::= Dd # IEEE 754r decimal floating point (64 bits) - // UNSUPPORTED: ::= De # IEEE 754r decimal floating point (128 bits) - // UNSUPPORTED: ::= Df # IEEE 754r decimal floating point (32 bits) -@@ -2073,6 +2073,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { - ? 'g' - : 'e'); - break; -+ case BuiltinType::Float128: -+ if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()) -+ Out << "U10__float128"; // Match the GCC mangling -+ else -+ Out << 'g'; -+ break; - case BuiltinType::NullPtr: - Out << "Dn"; - break; -diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp -index b63b5e5..c9caddb 100644 ---- a/lib/AST/MicrosoftMangle.cpp -+++ b/lib/AST/MicrosoftMangle.cpp -@@ -1751,6 +1751,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, - Out << "$$T"; - break; - -+ case BuiltinType::Float128: - case BuiltinType::Half: { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( -diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp -index 4c49e4c..ac2a8d3 100644 ---- a/lib/AST/NSAPI.cpp -+++ b/lib/AST/NSAPI.cpp -@@ -441,6 +441,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const { - case BuiltinType::Int128: - case BuiltinType::LongDouble: - case BuiltinType::UInt128: -+ case BuiltinType::Float128: - case BuiltinType::NullPtr: - case BuiltinType::ObjCClass: - case BuiltinType::ObjCId: -diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp -index cc38374..0b3f908 100644 ---- a/lib/AST/StmtPrinter.cpp -+++ b/lib/AST/StmtPrinter.cpp -@@ -1310,6 +1310,7 @@ static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, - case BuiltinType::Double: break; // no suffix. - case BuiltinType::Float: OS << 'F'; break; - case BuiltinType::LongDouble: OS << 'L'; break; -+ case BuiltinType::Float128: OS << 'Q'; break; - } - } - -diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp -index 1c6ae2a..0262f5b 100644 ---- a/lib/AST/Type.cpp -+++ b/lib/AST/Type.cpp -@@ -1777,7 +1777,7 @@ bool Type::hasUnsignedIntegerRepresentation() const { - bool Type::isFloatingType() const { - if (const BuiltinType *BT = dyn_cast(CanonicalType)) - return BT->getKind() >= BuiltinType::Half && -- BT->getKind() <= BuiltinType::LongDouble; -+ BT->getKind() <= BuiltinType::Float128; - if (const ComplexType *CT = dyn_cast(CanonicalType)) - return CT->getElementType()->isFloatingType(); - return false; -@@ -1799,7 +1799,7 @@ bool Type::isRealFloatingType() const { - bool Type::isRealType() const { - if (const BuiltinType *BT = dyn_cast(CanonicalType)) - return BT->getKind() >= BuiltinType::Bool && -- BT->getKind() <= BuiltinType::LongDouble; -+ BT->getKind() <= BuiltinType::Float128; - if (const EnumType *ET = dyn_cast(CanonicalType)) - return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped(); - return false; -@@ -1808,7 +1808,7 @@ bool Type::isRealType() const { - bool Type::isArithmeticType() const { - if (const BuiltinType *BT = dyn_cast(CanonicalType)) - return BT->getKind() >= BuiltinType::Bool && -- BT->getKind() <= BuiltinType::LongDouble; -+ BT->getKind() <= BuiltinType::Float128; - if (const EnumType *ET = dyn_cast(CanonicalType)) - // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2). - // If a body isn't seen by the time we get here, return false. -@@ -2552,6 +2552,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const { - return "double"; - case LongDouble: - return "long double"; -+ case Float128: -+ return "__float128"; - case WChar_S: - case WChar_U: - return Policy.MSWChar ? "__wchar_t" : "wchar_t"; -diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp -index 05e5a62..78947d1 100644 ---- a/lib/AST/TypeLoc.cpp -+++ b/lib/AST/TypeLoc.cpp -@@ -320,6 +320,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const { - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: -+ case BuiltinType::Float128: - llvm_unreachable("Builtin type needs extra local data!"); - // Fall through, if the impossible happens. - -diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp -index ff44a57..ac6cef9 100644 ---- a/lib/Analysis/PrintfFormatString.cpp -+++ b/lib/Analysis/PrintfFormatString.cpp -@@ -616,6 +616,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, - case BuiltinType::UInt128: - case BuiltinType::Int128: - case BuiltinType::Half: -+ case BuiltinType::Float128: - // Various types which are non-trivial to correct. - return false; - -diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp -index f6973f3..92f658a 100644 ---- a/lib/Basic/TargetInfo.cpp -+++ b/lib/Basic/TargetInfo.cpp -@@ -30,6 +30,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { - BigEndian = true; - TLSSupported = true; - NoAsmVariants = false; -+ HasFloat128 = false; - PointerWidth = PointerAlign = 32; - BoolWidth = BoolAlign = 8; - IntWidth = IntAlign = 32; -@@ -46,6 +47,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { - DoubleAlign = 64; - LongDoubleWidth = 64; - LongDoubleAlign = 64; -+ Float128Align = 128; - LargeArrayMinWidth = 0; - LargeArrayAlign = 0; - MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0; -@@ -72,6 +74,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { - FloatFormat = &llvm::APFloat::IEEEsingle; - DoubleFormat = &llvm::APFloat::IEEEdouble; - LongDoubleFormat = &llvm::APFloat::IEEEdouble; -+ Float128Format = &llvm::APFloat::IEEEquad; - MCountName = "mcount"; - RegParmMax = 0; - SSERegParmMax = 0; -@@ -223,6 +226,8 @@ TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const { - if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble || - &getLongDoubleFormat() == &llvm::APFloat::IEEEquad) - return LongDouble; -+ if (hasFloat128Type()) -+ return Float128; - break; - } - -diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp -index 6b26d14..4dac104 100644 ---- a/lib/Basic/Targets.cpp -+++ b/lib/Basic/Targets.cpp -@@ -427,6 +427,8 @@ class LinuxTargetInfo : public OSTargetInfo { - Builder.defineMacro("_REENTRANT"); - if (Opts.CPlusPlus) - Builder.defineMacro("_GNU_SOURCE"); -+ if (this->HasFloat128) -+ Builder.defineMacro("__FLOAT128__"); - } - public: - LinuxTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) -@@ -441,6 +443,11 @@ class LinuxTargetInfo : public OSTargetInfo { - case llvm::Triple::ppc64le: - this->MCountName = "_mcount"; - break; -+ case llvm::Triple::x86: -+ case llvm::Triple::x86_64: -+ case llvm::Triple::systemz: -+ this->HasFloat128 = true; -+ break; - } - } - -@@ -1096,6 +1103,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector &Features, - HasQPX = true; - } else if (Feature == "+htm") { - HasHTM = true; -+ } else if (Feature == "+float128") { -+ HasFloat128 = true; - } - // TODO: Finish this list and add an assert that we've handled them - // all. -@@ -1253,6 +1262,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, - Builder.defineMacro("__CRYPTO__"); - if (HasHTM) - Builder.defineMacro("__HTM__"); -+ if (HasFloat128) -+ Builder.defineMacro("__FLOAT128__"); - - Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); - Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); -@@ -1303,6 +1314,13 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, - << "-mno-vsx"; - return false; - } -+ -+ if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+float128") != -+ FeaturesVec.end()) { -+ Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" -+ << "-mno-vsx"; -+ return false; -+ } - } - - return true; -@@ -1371,6 +1389,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const { - .Case("htm", HasHTM) - .Case("bpermd", HasBPERMD) - .Case("extdiv", HasExtDiv) -+ .Case("float128", HasFloat128) - .Default(false); - } - -@@ -1380,19 +1399,19 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features, - // as well. Do the inverse if we're disabling vsx. We'll diagnose any user - // incompatible options. - if (Enabled) { -- if (Name == "vsx") { -- Features[Name] = true; -- } else if (Name == "direct-move") { -+ if (Name == "direct-move") { - Features[Name] = Features["vsx"] = true; - } else if (Name == "power8-vector") { - Features[Name] = Features["vsx"] = true; -+ } else if (Name == "float128") { -+ Features[Name] = Features["vsx"] = true; - } else { - Features[Name] = true; - } - } else { - if (Name == "vsx") { - Features[Name] = Features["direct-move"] = Features["power8-vector"] = -- false; -+ Features["float128"] = false; - } else { - Features[Name] = false; - } -diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp -index a98df93..a63f558 100644 ---- a/lib/CodeGen/CGDebugInfo.cpp -+++ b/lib/CodeGen/CGDebugInfo.cpp -@@ -528,7 +528,13 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { - case BuiltinType::Half: - case BuiltinType::Float: - case BuiltinType::LongDouble: -+ case BuiltinType::Float128: - case BuiltinType::Double: -+ // FIXME: For targets where long double and __float128 have the same size, -+ // they are currently indistinguishable in the debugger without some -+ // special treatment. However, there is currently no consensus on encoding -+ // and this should be updated once a DWARF encoding exists for distinct -+ // floating point types of the same size. - Encoding = llvm::dwarf::DW_ATE_float; - break; - } -diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp -index 1fd79d0..8f12296 100644 ---- a/lib/CodeGen/CGExprScalar.cpp -+++ b/lib/CodeGen/CGExprScalar.cpp -@@ -1796,15 +1796,19 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, - amt = llvm::ConstantFP::get(VMContext, - llvm::APFloat(static_cast(amount))); - else { -- // Remaining types are either Half or LongDouble. Convert from float. -+ // Remaining types are Half, LongDouble or __float128. Convert from float. - llvm::APFloat F(static_cast(amount)); - bool ignored; -+ const llvm::fltSemantics *FS; - // Don't use getFloatTypeSemantics because Half isn't - // necessarily represented using the "half" LLVM type. -- F.convert(value->getType()->isHalfTy() -- ? CGF.getTarget().getHalfFormat() -- : CGF.getTarget().getLongDoubleFormat(), -- llvm::APFloat::rmTowardZero, &ignored); -+ if (value->getType()->isFP128Ty()) -+ FS = &CGF.getTarget().getFloat128Format(); -+ else if (value->getType()->isHalfTy()) -+ FS = &CGF.getTarget().getHalfFormat(); -+ else -+ FS = &CGF.getTarget().getLongDoubleFormat(); -+ F.convert(*FS, llvm::APFloat::rmTowardZero, &ignored); - amt = llvm::ConstantFP::get(VMContext, F); - } - value = Builder.CreateFAdd(value, amt, isInc ? "inc" : "dec"); -diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp -index 33e53a6..ebe55c7 100644 ---- a/lib/CodeGen/CodeGenTypes.cpp -+++ b/lib/CodeGen/CodeGenTypes.cpp -@@ -449,6 +449,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: -+ case BuiltinType::Float128: - ResultType = getTypeForFormat(getLLVMContext(), - Context.getFloatTypeSemantics(T), - /* UseNativeHalf = */ false); -diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp -index b44e840..52e519f 100644 ---- a/lib/CodeGen/ItaniumCXXABI.cpp -+++ b/lib/CodeGen/ItaniumCXXABI.cpp -@@ -2530,6 +2530,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) { - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: -+ case BuiltinType::Float128: - case BuiltinType::Char16: - case BuiltinType::Char32: - case BuiltinType::Int128: -@@ -3349,8 +3350,8 @@ void ItaniumCXXABI::EmitFundamentalRTTIDescriptors() { - getContext().UnsignedLongLongTy, getContext().Int128Ty, - getContext().UnsignedInt128Ty, getContext().HalfTy, - getContext().FloatTy, getContext().DoubleTy, -- getContext().LongDoubleTy, getContext().Char16Ty, -- getContext().Char32Ty, -+ getContext().LongDoubleTy, getContext().Float128Ty, -+ getContext().Char16Ty, getContext().Char32Ty - }; - for (const QualType &FundamentalType : FundamentalTypes) - EmitFundamentalRTTIDescriptor(FundamentalType); -diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp -index d6cd450..2ae4ddc 100644 ---- a/lib/Format/FormatToken.cpp -+++ b/lib/Format/FormatToken.cpp -@@ -53,6 +53,7 @@ bool FormatToken::isSimpleTypeSpecifier() const { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_wchar_t: - case tok::kw_bool: - case tok::kw___underlying_type: -diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp -index 65de75b..40283dc 100644 ---- a/lib/Index/USRGeneration.cpp -+++ b/lib/Index/USRGeneration.cpp -@@ -618,6 +618,8 @@ void USRGenerator::VisitType(QualType T) { - c = 'd'; break; - case BuiltinType::LongDouble: - c = 'D'; break; -+ case BuiltinType::Float128: -+ c = 'Q'; break; - case BuiltinType::NullPtr: - c = 'n'; break; - #define BUILTIN_TYPE(Id, SingletonId) -diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp -index 27c80b9..e68b82f 100644 ---- a/lib/Lex/LiteralSupport.cpp -+++ b/lib/Lex/LiteralSupport.cpp -@@ -525,6 +525,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, - isHalf = false; - isFloat = false; - isImaginary = false; -+ isFloat128 = false; - MicrosoftInteger = 0; - hadError = false; - -@@ -567,9 +568,17 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, - case 'f': // FP Suffix for "float" - case 'F': - if (!isFPConstant) break; // Error for integer constant. -- if (isHalf || isFloat || isLong) break; // HF, FF, LF invalid. -+ if (isHalf || isFloat || isLong || isFloat128) -+ break; // HF, FF, LF, QF invalid. - isFloat = true; - continue; // Success. -+ case 'q': // FP Suffix for "__float128" -+ case 'Q': -+ if (!isFPConstant) break; // Error for integer constant. -+ if (isHalf || isFloat || isLong || isFloat128) -+ break; // HQ, FQ, LQ, QQ invalid. -+ isFloat128 = true; -+ continue; // Success. - case 'u': - case 'U': - if (isFPConstant) break; // Error for floating constant. -@@ -579,7 +588,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, - case 'l': - case 'L': - if (isLong || isLongLong) break; // Cannot be repeated. -- if (isHalf || isFloat) break; // LH, LF invalid. -+ if (isHalf || isFloat || isFloat128) break; // LH, LF, LQ invalid. - - // Check for long long. The L's need to be adjacent and the same case. - if (s[1] == s[0]) { -diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp -index 6b7ffb6..2171e5c 100644 ---- a/lib/Parse/ParseDecl.cpp -+++ b/lib/Parse/ParseDecl.cpp -@@ -3306,6 +3306,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, - isInvalid = DS.SetTypeSpecType(DeclSpec::TST_double, Loc, PrevSpec, - DiagID, Policy); - break; -+ case tok::kw___float128: -+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float128, Loc, PrevSpec, -+ DiagID, Policy); -+ break; - case tok::kw_wchar_t: - isInvalid = DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec, - DiagID, Policy); -@@ -4279,6 +4283,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_bool: - case tok::kw__Bool: - case tok::kw__Decimal32: -@@ -4353,6 +4358,7 @@ bool Parser::isTypeSpecifierQualifier() { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_bool: - case tok::kw__Bool: - case tok::kw__Decimal32: -@@ -4507,6 +4513,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_bool: - case tok::kw__Bool: - case tok::kw__Decimal32: -diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp -index 2745c33..5b7c839 100644 ---- a/lib/Parse/ParseExpr.cpp -+++ b/lib/Parse/ParseExpr.cpp -@@ -1166,6 +1166,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_void: - case tok::kw_typename: - case tok::kw_typeof: -diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp -index afed9b1..b569e7a 100644 ---- a/lib/Parse/ParseExprCXX.cpp -+++ b/lib/Parse/ParseExprCXX.cpp -@@ -1928,6 +1928,9 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { - case tok::kw_double: - DS.SetTypeSpecType(DeclSpec::TST_double, Loc, PrevSpec, DiagID, Policy); - break; -+ case tok::kw___float128: -+ DS.SetTypeSpecType(DeclSpec::TST_float128, Loc, PrevSpec, DiagID, Policy); -+ break; - case tok::kw_wchar_t: - DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec, DiagID, Policy); - break; -diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp -index 747d0a9..4d4bd80 100644 ---- a/lib/Parse/ParseTentative.cpp -+++ b/lib/Parse/ParseTentative.cpp -@@ -946,6 +946,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { - case tok::kw_char: - case tok::kw_const: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_enum: - case tok::kw_half: - case tok::kw_float: -@@ -1426,6 +1427,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_void: - case tok::annot_decltype: - if (NextToken().is(tok::l_paren)) -@@ -1517,6 +1519,7 @@ bool Parser::isCXXDeclarationSpecifierAType() { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_void: - case tok::kw___unknown_anytype: - case tok::kw___auto_type: -diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp -index 4bc1d34..ddfe625 100644 ---- a/lib/Sema/DeclSpec.cpp -+++ b/lib/Sema/DeclSpec.cpp -@@ -289,6 +289,7 @@ bool Declarator::isDeclarationOfFunction() const { - case TST_decimal32: - case TST_decimal64: - case TST_double: -+ case TST_float128: - case TST_enum: - case TST_error: - case TST_float: -@@ -457,6 +458,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, - case DeclSpec::TST_half: return "half"; - case DeclSpec::TST_float: return "float"; - case DeclSpec::TST_double: return "double"; -+ case DeclSpec::TST_float128: return "__float128"; - case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool"; - case DeclSpec::TST_decimal32: return "_Decimal32"; - case DeclSpec::TST_decimal64: return "_Decimal64"; -diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp -index 058a25b..5360cbb 100644 ---- a/lib/Sema/SemaDecl.cpp -+++ b/lib/Sema/SemaDecl.cpp -@@ -108,6 +108,7 @@ bool Sema::isSimpleTypeSpecifier(tok::TokenKind Kind) const { - case tok::kw_half: - case tok::kw_float: - case tok::kw_double: -+ case tok::kw___float128: - case tok::kw_wchar_t: - case tok::kw_bool: - case tok::kw___underlying_type: -diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp -index 66b8712..a5ee8be 100644 ---- a/lib/Sema/SemaExpr.cpp -+++ b/lib/Sema/SemaExpr.cpp -@@ -1155,6 +1155,48 @@ static QualType handleFloatConversion(Sema &S, ExprResult &LHS, - /*convertFloat=*/!IsCompAssign); - } - -+/// \brief Diagnose attempts to convert between __float128 and long double if -+/// there is no support for such conversion. Helper function of -+/// UsualArithmeticConversions(). -+static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, -+ QualType RHSType) { -+ /* No issue converting if at least one of the types is not a floating point -+ type or the two types have the same rank. -+ */ -+ if (!LHSType->isFloatingType() || !RHSType->isFloatingType() || -+ S.Context.getFloatingTypeOrder(LHSType, RHSType) == 0) -+ return false; -+ -+ assert(LHSType->isFloatingType() && RHSType->isFloatingType() && -+ "The remaining types must be floating point types."); -+ -+ auto *LHSComplex = LHSType->getAs(); -+ auto *RHSComplex = RHSType->getAs(); -+ -+ QualType LHSElemType = LHSComplex ? -+ LHSComplex->getElementType() : LHSType; -+ QualType RHSElemType = RHSComplex ? -+ RHSComplex->getElementType() : RHSType; -+ -+ // No issue if the two types have the same representation -+ if (&S.Context.getFloatTypeSemantics(LHSElemType) == -+ &S.Context.getFloatTypeSemantics(RHSElemType)) -+ return false; -+ -+ bool Float128AndLongDouble = (LHSElemType == S.Context.Float128Ty && -+ RHSElemType == S.Context.LongDoubleTy); -+ Float128AndLongDouble |= (LHSElemType == S.Context.LongDoubleTy && -+ RHSElemType == S.Context.Float128Ty); -+ -+ /* We've handled the situation where __float128 and long double have the same -+ representation. The only other allowable conversion is if long double is -+ really just double. -+ */ -+ return Float128AndLongDouble && -+ (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) != -+ &llvm::APFloat::IEEEdouble); -+} -+ - typedef ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType); - - namespace { -@@ -1318,6 +1360,11 @@ QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, - - // At this point, we have two different arithmetic types. - -+ // Diagnose attempts to convert between __float128 and long double where -+ // such conversions currently can't be handled. -+ if (unsupportedTypeConversion(*this, LHSType, RHSType)) -+ return QualType(); -+ - // Handle complex types first (C99 6.3.1.8p1). - if (LHSType->isComplexType() || RHSType->isComplexType()) - return handleComplexFloatConversion(*this, LHS, RHS, LHSType, RHSType, -@@ -3327,10 +3374,12 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { - } - } else if (Literal.isFloat) - Ty = Context.FloatTy; -- else if (!Literal.isLong) -- Ty = Context.DoubleTy; -- else -+ else if (Literal.isLong) - Ty = Context.LongDoubleTy; -+ else if (Literal.isFloat128) -+ Ty = Context.Float128Ty; -+ else -+ Ty = Context.DoubleTy; - - Res = BuildFloatingLiteral(*this, Literal, Ty, Tok.getLocation()); - -@@ -6604,6 +6653,15 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, - QualType LHSTy = LHS.get()->getType(); - QualType RHSTy = RHS.get()->getType(); - -+ // Diagnose attempts to convert between __float128 and long double where -+ // such conversions currently can't be handled. -+ if (unsupportedTypeConversion(*this, LHSTy, RHSTy)) { -+ Diag(QuestionLoc, -+ diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy -+ << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); -+ return QualType(); -+ } -+ - // OpenCL v2.0 s6.12.5 - Blocks cannot be used as expressions of the ternary - // selection operator (?:). - if (getLangOpts().OpenCL && -@@ -7337,6 +7395,11 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, - return Incompatible; - } - -+ // Diagnose attempts to convert between __float128 and long double where -+ // such conversions currently can't be handled. -+ if (unsupportedTypeConversion(*this, LHSType, RHSType)) -+ return Incompatible; -+ - // Arithmetic conversions. - if (LHSType->isArithmeticType() && RHSType->isArithmeticType() && - !(getLangOpts().CPlusPlus && LHSType->isEnumeralType())) { -diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp -index e11d9c8..3e95076 100644 ---- a/lib/Sema/SemaExprCXX.cpp -+++ b/lib/Sema/SemaExprCXX.cpp -@@ -5176,6 +5176,12 @@ QualType Sema::CXXCheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, - QualType ResTy = UsualArithmeticConversions(LHS, RHS); - if (LHS.isInvalid() || RHS.isInvalid()) - return QualType(); -+ if (ResTy.isNull()) { -+ Diag(QuestionLoc, -+ diag::err_typecheck_cond_incompatible_operands) << LTy << RTy -+ << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); -+ return QualType(); -+ } - - LHS = ImpCastExprToType(LHS.get(), ResTy, PrepareScalarCast(LHS, ResTy)); - RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy)); -diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp -index b2ab39a..f1eed0e 100644 ---- a/lib/Sema/SemaLookup.cpp -+++ b/lib/Sema/SemaLookup.cpp -@@ -680,13 +680,6 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) { - NameKind == Sema::LookupRedeclarationWithLinkage) { - IdentifierInfo *II = R.getLookupName().getAsIdentifierInfo(); - if (II) { -- if (S.getLangOpts().CPlusPlus11 && S.getLangOpts().GNUMode && -- II == S.getFloat128Identifier()) { -- // libstdc++4.7's type_traits expects type __float128 to exist, so -- // insert a dummy type to make that header build in gnu++11 mode. -- R.addDecl(S.getASTContext().getFloat128StubType()); -- return true; -- } - if (S.getLangOpts().CPlusPlus && NameKind == Sema::LookupOrdinaryName) { - if (II == S.getASTContext().getMakeIntegerSeqName()) { - R.addDecl(S.getASTContext().getMakeIntegerSeqDecl()); -diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp -index 0b36fef..4a6831d 100644 ---- a/lib/Sema/SemaOverload.cpp -+++ b/lib/Sema/SemaOverload.cpp -@@ -1671,6 +1671,20 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, - SCS.Second = ICK_Complex_Real; - FromType = ToType.getUnqualifiedType(); - } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) { -+ // FIXME: disable conversions between long double and __float128 if -+ // their representation is different until there is back end support -+ // We of course allow this conversion if long double is really double. -+ if (&S.Context.getFloatTypeSemantics(FromType) != -+ &S.Context.getFloatTypeSemantics(ToType)) { -+ bool Float128AndLongDouble = ((FromType == S.Context.Float128Ty && -+ ToType == S.Context.LongDoubleTy) || -+ (FromType == S.Context.LongDoubleTy && -+ ToType == S.Context.Float128Ty)); -+ if (Float128AndLongDouble && -+ (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) != -+ &llvm::APFloat::IEEEdouble)) -+ return false; -+ } - // Floating point conversions (C++ 4.8). - SCS.Second = ICK_Floating_Conversion; - FromType = ToType.getUnqualifiedType(); -@@ -1973,7 +1987,8 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) { - if (!getLangOpts().CPlusPlus && - (FromBuiltin->getKind() == BuiltinType::Float || - FromBuiltin->getKind() == BuiltinType::Double) && -- (ToBuiltin->getKind() == BuiltinType::LongDouble)) -+ (ToBuiltin->getKind() == BuiltinType::LongDouble || -+ ToBuiltin->getKind() == BuiltinType::Float128)) - return true; - - // Half can be promoted to float. -@@ -7198,13 +7213,13 @@ class BuiltinOperatorOverloadBuilder { - // provided via the getArithmeticType() method below. - // The "promoted arithmetic types" are the arithmetic - // types are that preserved by promotion (C++ [over.built]p2). -- static const unsigned FirstIntegralType = 3; -- static const unsigned LastIntegralType = 20; -- static const unsigned FirstPromotedIntegralType = 3, -- LastPromotedIntegralType = 11; -+ static const unsigned FirstIntegralType = 4; -+ static const unsigned LastIntegralType = 21; -+ static const unsigned FirstPromotedIntegralType = 4, -+ LastPromotedIntegralType = 12; - static const unsigned FirstPromotedArithmeticType = 0, -- LastPromotedArithmeticType = 11; -- static const unsigned NumArithmeticTypes = 20; -+ LastPromotedArithmeticType = 12; -+ static const unsigned NumArithmeticTypes = 21; - - /// \brief Get the canonical type for a given arithmetic type index. - CanQualType getArithmeticType(unsigned index) { -@@ -7215,6 +7230,7 @@ class BuiltinOperatorOverloadBuilder { - &ASTContext::FloatTy, - &ASTContext::DoubleTy, - &ASTContext::LongDoubleTy, -+ &ASTContext::Float128Ty, - - // Start of integral types. - &ASTContext::IntTy, -diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp -index c23b5a2a..52a1ad5 100644 ---- a/lib/Sema/SemaTemplateVariadic.cpp -+++ b/lib/Sema/SemaTemplateVariadic.cpp -@@ -727,6 +727,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { - case TST_half: - case TST_float: - case TST_double: -+ case TST_float128: - case TST_bool: - case TST_decimal32: - case TST_decimal64: -diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp -index c8c8af1..7fd43a8 100644 ---- a/lib/Sema/SemaType.cpp -+++ b/lib/Sema/SemaType.cpp -@@ -1397,7 +1397,8 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { - } - case DeclSpec::TST_int128: - if (!S.Context.getTargetInfo().hasInt128Type()) -- S.Diag(DS.getTypeSpecTypeLoc(), diag::err_int128_unsupported); -+ S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) -+ << "__int128"; - if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) - Result = Context.UnsignedInt128Ty; - else -@@ -1419,6 +1420,12 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { - declarator.setInvalidType(true); - } - break; -+ case DeclSpec::TST_float128: -+ if (!S.Context.getTargetInfo().hasFloat128Type()) -+ S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) -+ << "__float128"; -+ Result = Context.Float128Ty; -+ break; - case DeclSpec::TST_bool: Result = Context.BoolTy; break; // _Bool or bool - break; - case DeclSpec::TST_decimal32: // _Decimal32 -@@ -7004,13 +7011,6 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T, - if (!Diagnoser) - return true; - -- // We have an incomplete type. Produce a diagnostic. -- if (Ident___float128 && -- T == Context.getTypeDeclType(Context.getFloat128StubType())) { -- Diag(Loc, diag::err_typecheck_decl_incomplete_type___float128); -- return true; -- } -- - Diagnoser->diagnose(*this, Loc, T); - - // If the type was a forward declaration of a class/struct/union -diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp -index 2382f8e..792fac9 100644 ---- a/lib/Serialization/ASTCommon.cpp -+++ b/lib/Serialization/ASTCommon.cpp -@@ -91,6 +91,9 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) { - case BuiltinType::LongDouble: - ID = PREDEF_TYPE_LONGDOUBLE_ID; - break; -+ case BuiltinType::Float128: -+ ID = PREDEF_TYPE_FLOAT128_ID; -+ break; - case BuiltinType::NullPtr: - ID = PREDEF_TYPE_NULLPTR_ID; - break; -diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp -index 5d459ac..0f4a7d3 100644 ---- a/lib/Serialization/ASTReader.cpp -+++ b/lib/Serialization/ASTReader.cpp -@@ -6040,6 +6040,9 @@ QualType ASTReader::GetType(TypeID ID) { - case PREDEF_TYPE_LONGDOUBLE_ID: - T = Context.LongDoubleTy; - break; -+ case PREDEF_TYPE_FLOAT128_ID: -+ T = Context.Float128Ty; -+ break; - case PREDEF_TYPE_OVERLOAD_ID: - T = Context.OverloadTy; - break; -diff --git a/test/CodeGenCXX/float128-declarations.cpp b/test/CodeGenCXX/float128-declarations.cpp -new file mode 100644 -index 0000000..e1604a6 ---- /dev/null -+++ b/test/CodeGenCXX/float128-declarations.cpp -@@ -0,0 +1,138 @@ -+// RUN: %clang_cc1 -emit-llvm -triple powerpc64-unknown-unknown \ -+// RUN: -target-feature +float128 -std=c++11 %s -o - | FileCheck %s -+// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \ -+// RUN: -target-feature +float128 -std=c++11 %s -o - | FileCheck %s -+// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-linux-gnu -std=c++11 \ -+// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 -+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++11 \ -+// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 -+// RUN: %clang_cc1 -emit-llvm -triple systemz-unknown-linux-gnu -std=c++11 \ -+// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-SYSZ -+// -+/* Various contexts where type __float128 can appear. The different check -+ prefixes are due to different mangling on X86 and different calling -+ convention on SystemZ. */ -+ -+/* Namespace */ -+namespace { -+ __float128 f1n; -+ __float128 f2n = 33.q; -+ __float128 arr1n[10]; -+ __float128 arr2n[] = { 1.2q, 3.0q, 3.e11q }; -+ const volatile __float128 func1n(const __float128 &arg) { -+ return arg + f2n + arr1n[4] - arr2n[1]; -+ } -+} -+ -+/* File */ -+__float128 f1f; -+__float128 f2f = 32.4q; -+static __float128 f3f = f2f; -+__float128 arr1f[10]; -+__float128 arr2f[] = { -1.2q, -3.0q, -3.e11q }; -+__float128 func1f(__float128 arg); -+ -+/* Class */ -+class C1 { -+ __float128 f1c; -+ static const __float128 f2c; -+ volatile __float128 f3c; -+public: -+ C1(__float128 arg) : f1c(arg), f3c(arg) { } -+ __float128 func1c(__float128 arg ) { -+ return f1c + arg; -+ } -+ static __float128 func2c(__float128 arg) { -+ return arg * C1::f2c; -+ } -+}; -+ -+/* Template */ -+template C func1t(C arg) { return arg * 2.q; } -+template struct S1 { -+ C mem1; -+}; -+template <> struct S1<__float128> { -+ __float128 mem2; -+}; -+ -+/* Local */ -+int main(void) { -+ __float128 f1l = 123e220q; -+ __float128 f2l = -0.q; -+ __float128 f3l = 1.189731495357231765085759326628007e4932q; -+ C1 c1(f1l); -+ S1<__float128> s1 = { 132.q }; -+ __float128 f4l = func1n(f1l) + func1f(f2l) + c1.func1c(f3l) + c1.func2c(f1l) + -+ func1t(f1l) + s1.mem2 - f1n + f2n; -+#if (__cplusplus >= 201103L) -+ auto f5l = -1.q, *f6l = &f2l, f7l = func1t(f3l); -+#endif -+ __float128 f8l = f4l++; -+ __float128 arr1l[] = { -1.q, -0.q, -11.q }; -+} -+// CHECK-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global fp128 0xL00000000000000000000000000000000 -+// CHECK-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL00000000000000004004080000000000 -+// CHECK-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128] -+// CHECK-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL33333333333333333FFF333333333333, fp128 0xL00000000000000004000800000000000, fp128 0xL00000000000000004025176592E00000] -+// CHECK-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKU10__float128(fp128* -+// CHECK-DAG: @f1f = global fp128 0xL00000000000000000000000000000000 -+// CHECK-DAG: @f2f = global fp128 0xL33333333333333334004033333333333 -+// CHECK-DAG: @arr1f = global [10 x fp128] -+// CHECK-DAG: @arr2f = global [3 x fp128] [fp128 0xL3333333333333333BFFF333333333333, fp128 0xL0000000000000000C000800000000000, fp128 0xL0000000000000000C025176592E00000] -+// CHECK-DAG: declare fp128 @_Z6func1fU10__float128(fp128) -+// CHECK-DAG: define linkonce_odr void @_ZN2C1C2EU10__float128(%class.C1* %this, fp128 %arg) -+// CHECK-DAG: define linkonce_odr fp128 @_ZN2C16func2cEU10__float128(fp128 %arg) -+// CHECK-DAG: define linkonce_odr fp128 @_Z6func1tIU10__float128ET_S0_(fp128 %arg) -+// CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { fp128 0xL00000000000000004006080000000000 } -+// CHECK-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16 -+// CHECK-DAG: store fp128 0xL00000000000000008000000000000000, fp128* %f2l, align 16 -+// CHECK-DAG: store fp128 0xLFFFFFFFFFFFFFFFF7FFEFFFFFFFFFFFF, fp128* %f3l, align 16 -+// CHECK-DAG: store fp128 0xL0000000000000000BFFF000000000000, fp128* %f5l, align 16 -+// CHECK-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l -+// CHECK-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 0xL00000000000000003FFF000000000000 -+// CHECK-DAG: store fp128 [[INC]], fp128* %f4l -+ -+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global fp128 0xL00000000000000000000000000000000 -+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL00000000000000004004080000000000 -+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128] -+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL33333333333333333FFF333333333333, fp128 0xL00000000000000004000800000000000, fp128 0xL00000000000000004025176592E00000] -+// CHECK-X86-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKg(fp128* -+// CHECK-X86-DAG: @f1f = global fp128 0xL00000000000000000000000000000000 -+// CHECK-X86-DAG: @f2f = global fp128 0xL33333333333333334004033333333333 -+// CHECK-X86-DAG: @arr1f = global [10 x fp128] -+// CHECK-X86-DAG: @arr2f = global [3 x fp128] [fp128 0xL3333333333333333BFFF333333333333, fp128 0xL0000000000000000C000800000000000, fp128 0xL0000000000000000C025176592E00000] -+// CHECK-X86-DAG: declare fp128 @_Z6func1fg(fp128) -+// CHECK-X86-DAG: define linkonce_odr void @_ZN2C1C2Eg(%class.C1* %this, fp128 %arg) -+// CHECK-X86-DAG: define linkonce_odr fp128 @_ZN2C16func2cEg(fp128 %arg) -+// CHECK-X86-DAG: define linkonce_odr fp128 @_Z6func1tIgET_S0_(fp128 %arg) -+// CHECK-X86-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { fp128 0xL00000000000000004006080000000000 } -+// CHECK-X86-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16 -+// CHECK-X86-DAG: store fp128 0xL00000000000000008000000000000000, fp128* %f2l, align 16 -+// CHECK-X86-DAG: store fp128 0xLFFFFFFFFFFFFFFFF7FFEFFFFFFFFFFFF, fp128* %f3l, align 16 -+// CHECK-X86-DAG: store fp128 0xL0000000000000000BFFF000000000000, fp128* %f5l, align 16 -+// CHECK-X86-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l -+// CHECK-X86-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 0xL00000000000000003FFF000000000000 -+// CHECK-X86-DAG: store fp128 [[INC]], fp128* %f4l -+ -+// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global fp128 0xL00000000000000000000000000000000 -+// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL00000000000000004004080000000000 -+// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128] -+// CHECK-SYSZ-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL33333333333333333FFF333333333333, fp128 0xL00000000000000004000800000000000, fp128 0xL00000000000000004025176592E00000] -+// CHECK-SYSZ-DAG: define internal void @_ZN12_GLOBAL__N_16func1nERKU10__float128(fp128* -+// CHECK-SYSZ-DAG: @f1f = global fp128 0xL00000000000000000000000000000000 -+// CHECK-SYSZ-DAG: @f2f = global fp128 0xL33333333333333334004033333333333 -+// CHECK-SYSZ-DAG: @arr1f = global [10 x fp128] -+// CHECK-SYSZ-DAG: @arr2f = global [3 x fp128] [fp128 0xL3333333333333333BFFF333333333333, fp128 0xL0000000000000000C000800000000000, fp128 0xL0000000000000000C025176592E00000] -+// CHECK-SYSZ-DAG: declare void @_Z6func1fU10__float128(fp128* -+// CHECK-SYSZ-DAG: define linkonce_odr void @_ZN2C1C2EU10__float128(%class.C1* %this, fp128* -+// CHECK-SYSZ-DAG: define linkonce_odr void @_ZN2C16func2cEU10__float128(fp128* -+// CHECK-SYSZ-DAG: define linkonce_odr void @_Z6func1tIU10__float128ET_S0_(fp128* -+// CHECK-SYSZ-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { fp128 0xL00000000000000004006080000000000 } -+// CHECK-SYSZ-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16 -+// CHECK-SYSZ-DAG: store fp128 0xL00000000000000008000000000000000, fp128* %f2l, align 16 -+// CHECK-SYSZ-DAG: store fp128 0xLFFFFFFFFFFFFFFFF7FFEFFFFFFFFFFFF, fp128* %f3l, align 16 -+// CHECK-SYSZ-DAG: store fp128 0xL0000000000000000BFFF000000000000, fp128* %f5l, align 16 -+// CHECK-SYSZ-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l -+// CHECK-SYSZ-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 0xL00000000000000003FFF000000000000 -+// CHECK-SYSZ-DAG: store fp128 [[INC]], fp128* %f4l -diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c -index 98be2ac..41f5010 100644 ---- a/test/Preprocessor/init.c -+++ b/test/Preprocessor/init.c -@@ -5827,6 +5827,9 @@ - // PPCPOWER8:#define _ARCH_PWR7 1 - // PPCPOWER8:#define _ARCH_PWR8 1 - // -+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +float128 -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-FLOAT128 %s -+// PPC-FLOAT128:#define __FLOAT128__ 1 -+// - // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-LINUX %s - // - // PPC64-LINUX:#define _ARCH_PPC 1 -diff --git a/test/Sema/128bitfloat.cpp b/test/Sema/128bitfloat.cpp -index cb76dac..2449cb6 100644 ---- a/test/Sema/128bitfloat.cpp -+++ b/test/Sema/128bitfloat.cpp -@@ -1,24 +1,35 @@ - // RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s - // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -+#ifdef __FLOAT128__ -+__float128 f; -+template struct __is_floating_point_helper {}; -+template<> struct __is_floating_point_helper<__float128> {}; -+int g(int x, __float128 *y) { -+ return x + *y; -+} -+ -+// expected-no-diagnostics -+#else - #if !defined(__STRICT_ANSI__) --__float128 f; // expected-error {{support for type '__float128' is not yet implemented}} -+__float128 f; // expected-error {{__float128 is not supported on this target}} - // But this should work: - template struct __is_floating_point_helper {}; --template<> struct __is_floating_point_helper<__float128> {}; -+template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{__float128 is not supported on this target}} - - // FIXME: This could have a better diag. --void g(int x, __float128 *y) { -- x + *y; // expected-error {{invalid operands to binary expression ('int' and '__float128')}} -+int g(int x, __float128 *y) { // expected-error {{__float128 is not supported on this target}} -+ return x + *y; - } - - #else --__float128 f; // expected-error {{unknown type name '__float128'}} -+__float128 f; // expected-error {{__float128 is not supported on this target}} - template struct __is_floating_point_helper {}; --template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{use of undeclared identifier '__float128'}} -+template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{__float128 is not supported on this target}} - --void g(int x, __float128 *y) { // expected-error {{unknown type name '__float128'}} -- x + *y; -+int g(int x, __float128 *y) { // expected-error {{__float128 is not supported on this target}} -+ return x + *y; - } - - #endif -+#endif -diff --git a/test/Sema/attr-mode.c b/test/Sema/attr-mode.c -index e011549..e160d8d 100644 ---- a/test/Sema/attr-mode.c -+++ b/test/Sema/attr-mode.c -@@ -76,7 +76,7 @@ void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); } - void test_long_to_i64(long* y) { f_i64_arg(y); } - void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); } - #endif --typedef float f128ibm __attribute__ ((mode (TF))); // expected-error{{unsupported machine mode 'TF'}} -+typedef float f128ibm __attribute__ ((mode (TF))); - #elif TEST_64BIT_PPC64 - typedef float f128ibm __attribute__ ((mode (TF))); - typedef _Complex float c128ibm __attribute__ ((mode (TC))); -diff --git a/test/Sema/float128-ld-incompatibility.cpp b/test/Sema/float128-ld-incompatibility.cpp -new file mode 100644 -index 0000000..d993ed7 ---- /dev/null -+++ b/test/Sema/float128-ld-incompatibility.cpp -@@ -0,0 +1,36 @@ -+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \ -+// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr8 \ -+// RUN: -target-feature +float128 %s -+ -+__float128 qf(); -+long double ldf(); -+ -+// FIXME: once operations between long double and __float128 are implemented for -+// targets where the types are different, these next two will change -+long double ld{qf()}; // expected-error {{cannot initialize a variable of type 'long double' with an rvalue of type '__float128'}} -+__float128 q{ldf()}; // expected-error {{cannot initialize a variable of type '__float128' with an rvalue of type 'long double'}} -+ -+auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+ return q + ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+} -+ -+auto test2(long double a, __float128 b) -> decltype(a + b) { // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+ return a + b; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+} -+ -+void test3(bool b) { -+ long double ld; -+ __float128 q; -+ -+ ld + q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+ q + ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+ ld - q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+ q - ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+ ld * q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+ q * ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+ ld / q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}} -+ q / ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}} -+ ld = q; // expected-error {{assigning to 'long double' from incompatible type '__float128'}} -+ q = ld; // expected-error {{assigning to '__float128' from incompatible type 'long double'}} -+ q + b ? q : ld; // expected-error {{incompatible operand types ('__float128' and 'long double')}} -+} -diff --git a/test/SemaCXX/deleted-operator.cpp b/test/SemaCXX/deleted-operator.cpp -index df67978..f71e83a 100644 ---- a/test/SemaCXX/deleted-operator.cpp -+++ b/test/SemaCXX/deleted-operator.cpp -@@ -9,7 +9,7 @@ int PR10757f() { - PR10757 a1; - // FIXME: We get a ridiculous number of "built-in candidate" notes here... - if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 8 {{built-in candidate}} -- if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 121 {{built-in candidate}} -+ if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 144 {{built-in candidate}} - } - - struct DelOpDel { -diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp -index 4c2953b..7a99a89 100644 ---- a/test/SemaCXX/overloaded-builtin-operators.cpp -+++ b/test/SemaCXX/overloaded-builtin-operators.cpp -@@ -183,7 +183,7 @@ void test_dr425(A a) { - // FIXME: lots of candidates here! - (void)(1.0f * a); // expected-error{{ambiguous}} \ - // expected-note 4{{candidate}} \ -- // expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}} -+ // expected-note {{remaining 140 candidates omitted; pass -fshow-overloads=all to show them}} - } - - // pr5432 -diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp -index fbe1eda..fb0e5b5 100644 ---- a/tools/libclang/CXType.cpp -+++ b/tools/libclang/CXType.cpp -@@ -51,6 +51,7 @@ static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) { - BTCASE(Float); - BTCASE(Double); - BTCASE(LongDouble); -+ BTCASE(Float128); - BTCASE(NullPtr); - BTCASE(Overload); - BTCASE(Dependent); -@@ -467,6 +468,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { - TKIND(Float); - TKIND(Double); - TKIND(LongDouble); -+ TKIND(Float128); - TKIND(NullPtr); - TKIND(Overload); - TKIND(Dependent); diff --git a/mingw-w64-clang/0111-fix-clang-with-libstdc.patch b/mingw-w64-clang/0111-fix-clang-with-libstdc.patch deleted file mode 100644 index 215051dba5..0000000000 --- a/mingw-w64-clang/0111-fix-clang-with-libstdc.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff -urN cfe-3.9.0.src.orig/lib/Driver/Tools.cpp cfe-3.9.0.src/lib/Driver/Tools.cpp ---- cfe-3.9.0.src.orig/lib/Driver/Tools.cpp 2016-08-13 22:43:56.000000000 +0200 -+++ cfe-3.9.0.src/lib/Driver/Tools.cpp 2016-10-20 17:35:19.119164300 +0200 -@@ -2608,7 +2608,7 @@ - case llvm::Triple::wasm32: - case llvm::Triple::wasm64: - getWebAssemblyTargetFeatures(Args, Features); -- break; -+ break; - case llvm::Triple::sparc: - case llvm::Triple::sparcel: - case llvm::Triple::sparcv9: -@@ -5008,7 +5008,8 @@ - Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); - // Emulated TLS is enabled by default on Android, and can be enabled manually - // with -femulated-tls. -- bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isWindowsCygwinEnvironment(); -+ bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isWindowsCygwinEnvironment() -+ || getToolChain().getTriple().isWindowsGNUEnvironment(); - if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls, - EmulatedTLSDefault)) - CmdArgs.push_back("-femulated-tls"); -@@ -10490,7 +10491,8 @@ - if (Args.hasArg(options::OPT_pg)) - CmdArgs.push_back("-lgmon"); - -- if (Args.hasArg(options::OPT_pthread)) -+ if (!Args.hasArg(options::OPT_no_pthread) && -+ (TC.GetCXXStdlibType(Args) != ToolChain::CST_Libcxx)) - CmdArgs.push_back("-lpthread"); - - // add system libraries diff --git a/mingw-w64-clang/0112-objc-eh-personality.patch b/mingw-w64-clang/0112-objc-eh-personality.patch deleted file mode 100644 index 870d97099c..0000000000 --- a/mingw-w64-clang/0112-objc-eh-personality.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 3a07c87d4dc20c8d6b02a1d6cf38a5d1eb245a7f Mon Sep 17 00:00:00 2001 -From: Benjamin Kramer -Date: Sun, 8 Jan 2017 22:58:07 +0000 -Subject: [PATCH] Use the correct ObjC EH personality - -This fixes ObjC exceptions on Win64 (which uses SEH), among others. - -Patch by Jonathan Schleifer! - -git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291408 91177308-0d34-0410-b5e6-96231b3b80d8 ---- - lib/CodeGen/CGCleanup.h | 2 ++ - lib/CodeGen/CGException.cpp | 8 ++++++++ - 2 files changed, 10 insertions(+) - -diff --git a/lib/CodeGen/CGCleanup.h b/lib/CodeGen/CGCleanup.h -index 2166490..105c562 100644 ---- a/lib/CodeGen/CGCleanup.h -+++ b/lib/CodeGen/CGCleanup.h -@@ -616,6 +616,8 @@ struct EHPersonality { - static const EHPersonality GNU_C_SJLJ; - static const EHPersonality GNU_C_SEH; - static const EHPersonality GNU_ObjC; -+ static const EHPersonality GNU_ObjC_SJLJ; -+ static const EHPersonality GNU_ObjC_SEH; - static const EHPersonality GNUstep_ObjC; - static const EHPersonality GNU_ObjCXX; - static const EHPersonality NeXT_ObjC; -diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp -index 7b7880e..f908bf2 100644 ---- a/lib/CodeGen/CGException.cpp -+++ b/lib/CodeGen/CGException.cpp -@@ -97,6 +97,10 @@ EHPersonality::GNU_CPlusPlus_SEH = { "__gxx_personality_seh0", nullptr }; - const EHPersonality - EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", "objc_exception_throw"}; - const EHPersonality -+EHPersonality::GNU_ObjC_SJLJ = {"__gnu_objc_personality_sj0", "objc_exception_throw"}; -+const EHPersonality -+EHPersonality::GNU_ObjC_SEH = {"__gnu_objc_personality_seh0", "objc_exception_throw"}; -+const EHPersonality - EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", nullptr }; - const EHPersonality - EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", nullptr }; -@@ -137,6 +141,10 @@ static const EHPersonality &getObjCPersonality(const llvm::Triple &T, - // fallthrough - case ObjCRuntime::GCC: - case ObjCRuntime::ObjFW: -+ if (L.SjLjExceptions) -+ return EHPersonality::GNU_ObjC_SJLJ; -+ else if (useLibGCCSEHPersonality(T)) -+ return EHPersonality::GNU_ObjC_SEH; - return EHPersonality::GNU_ObjC; - } - llvm_unreachable("bad runtime kind"); diff --git a/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch b/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch new file mode 100644 index 0000000000..78b6d16a2f --- /dev/null +++ b/mingw-w64-clang/0202-compiler-rt-fix-mingw-build.patch @@ -0,0 +1,24 @@ +From b65c6b61099d87369d756a4137ea731a3a45f192 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Wed, 15 Feb 2017 19:21:48 +0100 +Subject: [PATCH] compiler-rt: fix mingw build + +--- + lib/profile/InstrProfilingPort.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/profile/InstrProfilingPort.h b/lib/profile/InstrProfilingPort.h +index 578935195..3bda151ad 100644 +--- a/lib/profile/InstrProfilingPort.h ++++ b/lib/profile/InstrProfilingPort.h +@@ -44,7 +44,7 @@ + #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1)) + #else + #define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len) +-#ifndef _MSC_VER ++#ifndef _WIN32 + #define COMPILER_RT_HAS_UNAME 1 + #endif + #endif +-- +2.11.1 diff --git a/mingw-w64-clang/0202-mingw-fixes-for-compiler-rt.patch b/mingw-w64-clang/0202-mingw-fixes-for-compiler-rt.patch deleted file mode 100644 index fa7cc71f85..0000000000 --- a/mingw-w64-clang/0202-mingw-fixes-for-compiler-rt.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff -urN compiler-rt-3.9.0.src.orig/lib/profile/InstrProfilingPort.h compiler-rt-3.9.0.src/lib/profile/InstrProfilingPort.h ---- compiler-rt-3.9.0.src.orig/lib/profile/InstrProfilingPort.h 2016-07-15 20:48:14.000000000 +0200 -+++ compiler-rt-3.9.0.src/lib/profile/InstrProfilingPort.h 2016-09-23 00:20:25.833117600 +0200 -@@ -10,7 +10,7 @@ - #ifndef PROFILE_INSTRPROFILING_PORT_H_ - #define PROFILE_INSTRPROFILING_PORT_H_ - --#ifdef _MSC_VER -+#ifdef _WIN32 - #define COMPILER_RT_ALIGNAS(x) __declspec(align(x)) - #define COMPILER_RT_VISIBILITY - /* FIXME: selectany does not have the same semantics as weak. */ -@@ -33,14 +33,14 @@ - #define COMPILER_RT_SEG "" - #endif - --#ifdef _MSC_VER -+#ifdef _WIN32 - #define COMPILER_RT_SECTION(Sect) __declspec(allocate(Sect)) - #else - #define COMPILER_RT_SECTION(Sect) __attribute__((section(Sect))) - #endif - - #define COMPILER_RT_MAX_HOSTLEN 128 --#ifdef _MSC_VER -+#ifdef _WIN32 - #define COMPILER_RT_GETHOSTNAME(Name, Len) gethostname(Name, Len) - #elif defined(__ORBIS__) - #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1)) -@@ -50,9 +50,9 @@ - #endif - - #if COMPILER_RT_HAS_ATOMICS == 1 --#ifdef _MSC_VER -+#ifdef _WIN32 - #include --#if _MSC_VER < 1900 -+#if defined(_MSC_VER) && _MSC_VER < 1900 - #define snprintf _snprintf - #endif - #if defined(_WIN64) diff --git a/mingw-w64-clang/0303-Fix-LLVM_LINK_LLVM_DYLIB-build.patch b/mingw-w64-clang/0303-Fix-LLVM_LINK_LLVM_DYLIB-build.patch deleted file mode 100644 index 5a79884fc3..0000000000 --- a/mingw-w64-clang/0303-Fix-LLVM_LINK_LLVM_DYLIB-build.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 1bfb013604fbda1cdabf941ee1cef05105c09508 Mon Sep 17 00:00:00 2001 -From: Pavel Labath -Date: Mon, 9 Jan 2017 09:57:08 +0000 -Subject: [PATCH] [lld][cmake] Fix LLVM_LINK_LLVM_DYLIB build - -Summary: -Lld's build had a couple of issues which prevented a successfull -LLVM_LINK_LLVM_DYLIB compilation. - -- add_llvm_library vs llvm_add_library: One adds a library to libLLVM.so, other - one doesn't. Lld was using the wrong one, causing symbols to be mupltiply - defined in things linking to libLLVM. -- confusion when to use LINK_LIBS vs LINK_COMPONENTS in llvm_add_library -- not using LLVM_LINK_COMPONENTS for add_lld_tool - -With these fixes lld compiles and it's test suite passes both in -LLVM_LINK_LLVM_DYLIB mode and without it. - -Reviewers: ruiu, beanz - -Subscribers: llvm-commits, mgorny - -Differential Revision: https://reviews.llvm.org/D28397 - -git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291432 91177308-0d34-0410-b5e6-96231b3b80d8 ---- - cmake/modules/AddLLD.cmake | 2 +- - lib/Config/CMakeLists.txt | 4 ++-- - lib/Core/CMakeLists.txt | 4 ++-- - lib/Driver/CMakeLists.txt | 8 +++++--- - lib/ReaderWriter/CMakeLists.txt | 6 ++++-- - lib/ReaderWriter/MachO/CMakeLists.txt | 11 +++++++---- - lib/ReaderWriter/YAML/CMakeLists.txt | 5 ++++- - tools/lld/CMakeLists.txt | 5 ++++- - 8 files changed, 29 insertions(+), 16 deletions(-) - -diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake -index 752ca7f..906b295 100644 ---- a/cmake/modules/AddLLD.cmake -+++ b/cmake/modules/AddLLD.cmake -@@ -1,5 +1,5 @@ - macro(add_lld_library name) -- add_llvm_library(${name} ${ARGN}) -+ llvm_add_library(${name} ${ARGN}) - set_target_properties(${name} PROPERTIES FOLDER "lld libraries") - endmacro(add_lld_library) - -diff --git a/lib/Config/CMakeLists.txt b/lib/Config/CMakeLists.txt -index e971b0b..3e142b6 100644 ---- a/lib/Config/CMakeLists.txt -+++ b/lib/Config/CMakeLists.txt -@@ -4,6 +4,6 @@ add_lld_library(lldConfig - ADDITIONAL_HEADER_DIRS - ${LLD_INCLUDE_DIR}/lld/Config - -- LINK_LIBS -- LLVMSupport -+ LINK_COMPONENTS -+ Support - ) -diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt -index d89ca4a..7f4c47f 100644 ---- a/lib/Core/CMakeLists.txt -+++ b/lib/Core/CMakeLists.txt -@@ -12,6 +12,6 @@ add_lld_library(lldCore - ADDITIONAL_HEADER_DIRS - ${LLD_INCLUDE_DIR}/lld/Core - -- LINK_LIBS -- LLVMSupport -+ LINK_COMPONENTS -+ Support - ) -diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt -index 1bd1f21..be75872 100644 ---- a/lib/Driver/CMakeLists.txt -+++ b/lib/Driver/CMakeLists.txt -@@ -8,15 +8,17 @@ add_lld_library(lldDriver - ADDITIONAL_HEADER_DIRS - ${LLD_INCLUDE_DIR}/lld/Driver - -+ LINK_COMPONENTS -+ Object -+ Option -+ Support -+ - LINK_LIBS - lldConfig - lldMachO - lldCore - lldReaderWriter - lldYAML -- LLVMObject -- LLVMOption -- LLVMSupport - ) - - add_dependencies(lldDriver DriverOptionsTableGen) -diff --git a/lib/ReaderWriter/CMakeLists.txt b/lib/ReaderWriter/CMakeLists.txt -index 4408d9c..8751d56 100644 ---- a/lib/ReaderWriter/CMakeLists.txt -+++ b/lib/ReaderWriter/CMakeLists.txt -@@ -11,9 +11,11 @@ add_lld_library(lldReaderWriter - ADDITIONAL_HEADER_DIRS - ${LLD_INCLUDE_DIR}/lld/ReaderWriter - -+ LINK_COMPONENTS -+ Object -+ Support -+ - LINK_LIBS - lldCore - lldYAML -- LLVMObject -- LLVMSupport - ) -diff --git a/lib/ReaderWriter/MachO/CMakeLists.txt b/lib/ReaderWriter/MachO/CMakeLists.txt -index 6a1064d..3b06985 100644 ---- a/lib/ReaderWriter/MachO/CMakeLists.txt -+++ b/lib/ReaderWriter/MachO/CMakeLists.txt -@@ -18,11 +18,14 @@ add_lld_library(lldMachO - StubsPass.cpp - TLVPass.cpp - WriterMachO.cpp -+ -+ LINK_COMPONENTS -+ Object -+ Support -+ - LINK_LIBS - lldCore - lldYAML -- LLVMObject -- LLVMSupport - ${PTHREAD_LIB} - ) - -diff --git a/lib/ReaderWriter/YAML/CMakeLists.txt b/lib/ReaderWriter/YAML/CMakeLists.txt -index 5c25444..0e63574 100644 ---- a/lib/ReaderWriter/YAML/CMakeLists.txt -+++ b/lib/ReaderWriter/YAML/CMakeLists.txt -@@ -1,6 +1,9 @@ - add_lld_library(lldYAML - ReaderWriterYAML.cpp -+ -+ LINK_COMPONENTS -+ Support -+ - LINK_LIBS - lldCore -- LLVMSupport - ) -diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt -index 0c946a3..2df1069 100644 ---- a/tools/lld/CMakeLists.txt -+++ b/tools/lld/CMakeLists.txt -@@ -1,3 +1,7 @@ -+set(LLVM_LINK_COMPONENTS -+ Support -+ ) -+ - add_lld_tool(lld - lld.cpp - ) -@@ -6,7 +10,6 @@ target_link_libraries(lld - lldDriver - lldCOFF - lldELF -- LLVMSupport - ) - - install(TARGETS lld diff --git a/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch b/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch index 0d1f5d8a13..e8c339a2ac 100644 --- a/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch +++ b/mingw-w64-clang/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch @@ -1,124 +1,156 @@ -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++ +From b45cafc920b84ea40f9760266473c0da2260c58e Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Mon, 20 Mar 2017 18:33:53 +0100 +Subject: [PATCH] workarounds to build libc++ with MinGW -CMAKE_HOST_WIN32 change can be upstreamed in a different patch +Based on Martell's patches +--- + cmake/Modules/CheckLibcxxAtomic.cmake | 2 +- + cmake/config-ix.cmake | 6 +++++- + include/__config | 5 +++-- + include/locale | 8 ++++++++ + include/support/win32/locale_win32.h | 26 ++++++++++++++++++++------ + include/support/win32/support.h | 5 +++-- + lib/CMakeLists.txt | 2 +- + src/locale.cpp | 2 +- + src/new.cpp | 2 +- + src/support/win32/locale_win32.cpp | 4 ++++ + src/support/win32/support.cpp | 2 ++ + src/system_error.cpp | 2 +- + 12 files changed, 56 insertions(+), 17 deletions(-) -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) +diff --git a/cmake/Modules/CheckLibcxxAtomic.cmake b/cmake/Modules/CheckLibcxxAtomic.cmake +index a7ae667..4f9de3e 100644 +--- a/cmake/Modules/CheckLibcxxAtomic.cmake ++++ b/cmake/Modules/CheckLibcxxAtomic.cmake +@@ -9,7 +9,7 @@ INCLUDE(CheckCXXSourceCompiles) - 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 + function(check_cxx_atomics varname) + set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) +- set(CMAKE_REQUIRED_FLAGS "-nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include") ++ set(CMAKE_REQUIRED_FLAGS "-std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include") + if (${LIBCXX_GCC_TOOLCHAIN}) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") + endif() +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 4f13b78..1590399 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -24,7 +24,11 @@ endif() + # required during compilation (which has the -nodefaultlibs). libc is + # required for the link to go through. We remove sanitizers from the + # configuration checks to avoid spurious link errors. +-check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) ++if (MINGW) ++ SET(LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG NO) ++else() ++ check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) ++endif() + if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + if (LIBCXX_HAS_C_LIB) diff --git a/include/__config b/include/__config -index 353ca10..b58c350 100644 +index 340c573..db9b74a 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 @@ +@@ -222,7 +222,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(_LIBCPP_WIN32API) +#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( +@@ -930,7 +935,8 @@ _LIBCPP_FUNC_VIS 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" + # define _LIBCPP_HAS_THREAD_API_PTHREAD + # elif defined(_LIBCPP_WIN32API) + # define _LIBCPP_HAS_THREAD_API_WIN32 +diff --git a/include/locale b/include/locale +index 9cef429..ad3586a 100644 +--- a/include/locale ++++ b/include/locale +@@ -695,7 +695,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end, + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; ++#ifdef __MINGW32__ ++ long long __ll = strtoll(__a, &__p2, __base); ++#else + long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++#endif + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +@@ -735,7 +739,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; ++#ifdef __MINGW32__ ++ unsigned long long __ll = strtoull(__a, &__p2, __base); ++#else + unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++#endif + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h -index 7f3710e..d167309 100644 +index ebf5bda..525cfc7 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 ); +@@ -11,7 +11,11 @@ + #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H + #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H +#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); -+} -+ ++#define _VC_CRT_MAJOR_VERSION 6 ++#else + #include +#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 _VC_CRT_MAJOR_VERSION < 14 + // ctype mask table defined in msvcrt.dll +@@ -40,16 +44,26 @@ int wctob_l( wint_t c, locale_t loc ); + inline _LIBCPP_ALWAYS_INLINE + decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) + { ++#ifdef __MINGW32__ ++ return MB_CUR_MAX; ++#else + return ___mb_cur_max_l_func(__l); ++#endif } --#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*/ ) ++#ifdef __MINGW32__ ++# define strtod_l _strtod_l ++# define strtof_l _strtod_l ++# define strtold_l _strtod_l ++#else + // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ +-#define mbtowc_l _mbtowc_l +-#define strtoll_l _strtoi64_l +-#define strtoull_l _strtoui64_l +-#define strtof_l _strtof_l +-#define strtod_l _strtod_l +-#define strtold_l _strtold_l ++# define mbtowc_l _mbtowc_l ++# define strtoll_l _strtoi64_l ++# define strtoull_l _strtoui64_l ++# define strtof_l _strtof_l ++# define strtod_l _strtod_l ++# define strtold_l _strtold_l ++#endif + + inline _LIBCPP_INLINE_VISIBILITY + int diff --git a/include/support/win32/support.h b/include/support/win32/support.h -index 5765bab..4955b3a 100644 +index f961344..501cd06 100644 --- a/include/support/win32/support.h +++ b/include/support/win32/support.h @@ -37,12 +37,13 @@ extern "C" { @@ -126,7 +158,7 @@ index 5765bab..4955b3a 100644 int vasprintf(char **sptr, const char *__restrict fmt, va_list ap); int asprintf(char **sptr, const char *__restrict fmt, ...); +} -+#endif // __MINGW32__ ++#endif + size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, size_t nmc, size_t len, mbstate_t *__restrict ps); @@ -135,102 +167,69 @@ index 5765bab..4955b3a 100644 -} -#endif // __MINGW32__ - #if defined(_LIBCPP_MSVCRT) + #if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf -diff --git a/include/type_traits b/include/type_traits -index 0d578bb..88dfd99 100644 ---- a/include/type_traits -+++ b/include/type_traits -@@ -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(_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 +index cc3ed16..3c2716f 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) +@@ -101,8 +101,8 @@ endif() + # Setup flags. + if (NOT WIN32) + add_flags_if_supported(-fPIC) + add_link_flags_if_supported(-nodefaultlibs) -+else() -+ add_library_flags(-lc++abi) -+endif() + endif() +-add_link_flags_if_supported(-nodefaultlibs) - if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR - LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) + if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY) + if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION) diff --git a/src/locale.cpp b/src/locale.cpp -index da2fd11..03696a7 100644 +index 338ffde..5c44346 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 +@@ -1114,7 +1114,7 @@ ctype::classic_table() _NOEXCEPT + #if _VC_CRT_MAJOR_VERSION < 14 + // This is assumed to be safe, which is a nonsense assumption because we're + // going to end up dereferencing it later... +- return _ctype+1; // internal ctype mask table defined in msvcrt.dll ++ return (const long unsigned int*)(_ctype + 1); // internal ctype mask table defined in msvcrt.dll + #else + return __pctype_func(); #endif - #include +diff --git a/src/new.cpp b/src/new.cpp +index b1e8ee3..e57b773 100644 +--- a/src/new.cpp ++++ b/src/new.cpp +@@ -162,7 +162,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC + if (static_cast(alignment) < sizeof(void*)) + alignment = std::align_val_t(sizeof(void*)); + void* p; +-#if defined(_LIBCPP_MSVCRT) ++#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) + while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr) + #else + while (::posix_memalign(&p, static_cast(alignment), size) != 0) diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp -index 5a43743..b220afe 100644 +index ee13811..f6ac5ed 100644 --- a/src/support/win32/locale_win32.cpp +++ b/src/support/win32/locale_win32.cpp -@@ -8,6 +8,11 @@ - // - //===----------------------------------------------------------------------===// +@@ -13,7 +13,11 @@ + #include + #include +#ifdef __MINGW32__ -+#define _GNU_SOURCE -+#include ++#define _VC_CRT_MAJOR_VERSION 6 ++#else + #include +#endif -+ - #include - #include // va_start, va_end + typedef _VSTD::remove_pointer::type __locale_struct; + typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp -index e989681..0d60ef4 100644 +index e989681..0628767 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 @@ +@@ -17,6 +17,7 @@ // Some of these functions aren't standard or if they conform, the name does not. @@ -238,7 +237,7 @@ index e989681..0d60ef4 100644 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 ) +@@ -51,6 +52,7 @@ int vasprintf( char **sptr, const char *__restrict format, va_list ap ) *sptr = p; return count; } @@ -247,22 +246,17 @@ index e989681..0d60ef4 100644 // 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 +index c547124..42171ef 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 +@@ -65,7 +65,7 @@ constexpr size_t strerror_buff_size = 1024; + + string do_strerror_r(int ev); + +-#if defined(_LIBCPP_MSVCRT) ++#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) string do_strerror_r(int ev) { + char buffer[strerror_buff_size]; + if (::strerror_s(buffer, strerror_buff_size, ev) == 0) -- -2.8.3 - +2.12.0 diff --git a/mingw-w64-clang/0402-fix-compilation-with-gcc.patch b/mingw-w64-clang/0402-fix-compilation-with-gcc.patch deleted file mode 100644 index 3d1900afe6..0000000000 --- a/mingw-w64-clang/0402-fix-compilation-with-gcc.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff -urN libcxx-3.9.0.origlibcxx/include/__config libcxx-3.9.0libcxx/include/__config ---- libcxx-3.9.0.origlibcxx/include/__config 2016-09-21 16:28:09.452978000 +0200 -+++ libcxx-3.9.0libcxx/include/__config 2016-09-25 01:19:05.170475000 +0200 -@@ -150,8 +150,6 @@ - # // 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 - -@@ -496,8 +494,14 @@ - #endif - - // Determine if GCC supports relaxed constexpr --#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L --#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -+// GCC 6.X is retarded, it thinks it supports __cpp_constexpr 201304 but ... -+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297 -+#if defined(__clang__) || __GNUC__ > 6 -+# if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L -+# define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -+# endif -+#elif defined(__GNUC__) -+# define _LIBCPP_HAS_NO_CXX14_CONSTEXPR - #endif - - // GCC 5 will support variable templates diff --git a/mingw-w64-clang/0501-lldb-mingw-fixes.patch b/mingw-w64-clang/0501-lldb-mingw-fixes.patch deleted file mode 100644 index 1dc8740e8e..0000000000 --- a/mingw-w64-clang/0501-lldb-mingw-fixes.patch +++ /dev/null @@ -1,256 +0,0 @@ -diff -urN lldb-3.9.0.src.orig/cmake/LLDBDependencies.cmake lldb-3.9.0.src/cmake/LLDBDependencies.cmake ---- lldb-3.9.0.src.orig/cmake/LLDBDependencies.cmake 2016-06-29 14:30:18.000000000 +0200 -+++ lldb-3.9.0.src/cmake/LLDBDependencies.cmake 2016-11-06 12:57:45.641325900 +0100 -@@ -92,6 +92,7 @@ - lldbPluginProcessWindowsCommon - Ws2_32 - Rpcrt4 -+ dbghelp - ) - endif () - -diff -urN lldb-3.9.0.src.orig/cmake/modules/LLDBConfig.cmake lldb-3.9.0.src/cmake/modules/LLDBConfig.cmake ---- lldb-3.9.0.src.orig/cmake/modules/LLDBConfig.cmake 2016-05-26 18:11:04.000000000 +0200 -+++ lldb-3.9.0.src/cmake/modules/LLDBConfig.cmake 2016-11-06 17:50:27.409562300 +0100 -@@ -248,8 +248,10 @@ - endif() - - # Use the Unicode (UTF-16) APIs by default on Win32 --if (CMAKE_SYSTEM_NAME MATCHES "Windows") -- add_definitions( /D _UNICODE /D UNICODE ) -+if (MSVC) -+ add_definitions( /D _UNICODE /D UNICODE ) -+elseif (WIN32) -+ add_definitions( -municode ) - endif() - - set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -diff -urN lldb-3.9.0.src.orig/include/lldb/Host/windows/win32.h lldb-3.9.0.src/include/lldb/Host/windows/win32.h ---- lldb-3.9.0.src.orig/include/lldb/Host/windows/win32.h 2015-08-20 22:53:15.000000000 +0200 -+++ lldb-3.9.0.src/include/lldb/Host/windows/win32.h 2016-11-06 12:57:45.653320700 +0100 -@@ -14,7 +14,9 @@ - #include - - // posix utilities -+#ifndef __MINGW64_VERSION_MAJOR - int vasprintf(char **ret, const char *fmt, va_list ap); -+#endif - char * strcasestr(const char *s, const char* find); - char* realpath(const char * name, char * resolved); - -@@ -33,6 +35,7 @@ - # define S_IWUSR S_IWRITE /* write, user */ - # define S_IXUSR 0 /* execute, user */ - #endif -+#ifndef __MINGW64_VERSION_MAJOR - #define S_IRGRP 0 /* read, group */ - #define S_IWGRP 0 /* write, group */ - #define S_IXGRP 0 /* execute, group */ -@@ -42,6 +45,7 @@ - #define S_IRWXU 0 - #define S_IRWXG 0 - #define S_IRWXO 0 -+#endif // __MINGW64_VERSION_MAJOR - - #ifdef _MSC_VER - -@@ -93,7 +97,7 @@ - - // timespec - // MSVC 2015 and higher have timespec. Otherwise we need to define it ourselves. --#if defined(_MSC_VER) && _MSC_VER >= 1900 -+#if defined(_MSC_VER) && _MSC_VER >= 1900 || defined(__MINGW64_VERSION_MAJOR) - #include - #else - struct timespec -diff -urN lldb-3.9.0.src.orig/include/lldb/lldb-defines.h lldb-3.9.0.src/include/lldb/lldb-defines.h ---- lldb-3.9.0.src.orig/include/lldb/lldb-defines.h 2015-07-24 02:23:29.000000000 +0200 -+++ lldb-3.9.0.src/include/lldb/lldb-defines.h 2016-11-06 15:22:20.184084400 +0100 -@@ -12,7 +12,7 @@ - - #include "lldb/lldb-types.h" - --#if defined (_MSC_VER) -+#if defined (_WIN32) - #if defined(EXPORT_LIBLLDB) - #define LLDB_API __declspec(dllexport) - #elif defined(IMPORT_LIBLLDB) -@@ -20,7 +20,7 @@ - #else - #define LLDB_API - #endif --#else // defined (_MSC_VER) -+#else // defined (_WIN32) - #define LLDB_API - #endif - -diff -urN lldb-3.9.0.src.orig/include/lldb/Utility/TaskPool.h lldb-3.9.0.src/include/lldb/Utility/TaskPool.h ---- lldb-3.9.0.src.orig/include/lldb/Utility/TaskPool.h 2015-11-03 23:29:20.000000000 +0100 -+++ lldb-3.9.0.src/include/lldb/Utility/TaskPool.h 2016-11-06 12:57:45.664322400 +0100 -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff -urN lldb-3.9.0.src.orig/source/API/CMakeLists.txt lldb-3.9.0.src/source/API/CMakeLists.txt ---- lldb-3.9.0.src.orig/source/API/CMakeLists.txt 2016-06-23 10:35:37.000000000 +0200 -+++ lldb-3.9.0.src/source/API/CMakeLists.txt 2016-11-06 12:57:45.670323200 +0100 -@@ -101,7 +101,7 @@ - endif() - endif() - --if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) -+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT MINGW ) - # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs, - # so only it needs to explicitly link against ${PYTHON_LIBRARY} - if (MSVC AND NOT LLDB_DISABLE_PYTHON) -diff -urN lldb-3.9.0.src.orig/source/Host/common/File.cpp lldb-3.9.0.src/source/Host/common/File.cpp ---- lldb-3.9.0.src.orig/source/Host/common/File.cpp 2016-08-12 20:10:54.000000000 +0200 -+++ lldb-3.9.0.src/source/Host/common/File.cpp 2016-11-06 12:57:45.676322400 +0100 -@@ -17,6 +17,7 @@ - - #ifdef _WIN32 - #include "lldb/Host/windows/windows.h" -+#include - #else - #include - #endif -diff -urN lldb-3.9.0.src.orig/source/Host/windows/ProcessRunLock.cpp lldb-3.9.0.src/source/Host/windows/ProcessRunLock.cpp ---- lldb-3.9.0.src.orig/source/Host/windows/ProcessRunLock.cpp 2015-05-15 00:50:19.000000000 +0200 -+++ lldb-3.9.0.src/source/Host/windows/ProcessRunLock.cpp 2016-11-06 12:57:45.685323900 +0100 -@@ -3,7 +3,7 @@ - - namespace - { --#if defined(__MINGW32__) -+#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) - // Taken from WinNT.h - typedef struct _RTL_SRWLOCK { - PVOID Ptr; -diff -urN lldb-3.9.0.src.orig/source/Host/windows/Windows.cpp lldb-3.9.0.src/source/Host/windows/Windows.cpp ---- lldb-3.9.0.src.orig/source/Host/windows/Windows.cpp 2016-04-19 03:09:37.000000000 +0200 -+++ lldb-3.9.0.src/source/Host/windows/Windows.cpp 2016-11-06 12:57:45.690322800 +0100 -@@ -53,6 +53,7 @@ - } - } - -+#ifndef __MINGW64_VERSION_MAJOR - int vasprintf(char **ret, const char *fmt, va_list ap) - { - char *buf; -@@ -79,6 +80,7 @@ - va_end(ap2); - return len; - } -+#endif //__MINGW64_VERSION_MAJOR - - char* strcasestr(const char *s, const char* find) - { -diff -urN lldb-3.9.0.src.orig/source/Symbol/ClangASTContext.cpp lldb-3.9.0.src/source/Symbol/ClangASTContext.cpp ---- lldb-3.9.0.src.orig/source/Symbol/ClangASTContext.cpp 2016-07-14 21:31:18.000000000 +0200 -+++ lldb-3.9.0.src/source/Symbol/ClangASTContext.cpp 2016-11-06 12:57:45.699323500 +0100 -@@ -4903,7 +4903,6 @@ - - case clang::BuiltinType::Half: - case clang::BuiltinType::Float: -- case clang::BuiltinType::Float128: - case clang::BuiltinType::Double: - case clang::BuiltinType::LongDouble: - return lldb::eEncodingIEEE754; -diff -urN lldb-3.9.0.src.orig/source/Target/ProcessLaunchInfo.cpp lldb-3.9.0.src/source/Target/ProcessLaunchInfo.cpp ---- lldb-3.9.0.src.orig/source/Target/ProcessLaunchInfo.cpp 2016-05-11 18:59:04.000000000 +0200 -+++ lldb-3.9.0.src/source/Target/ProcessLaunchInfo.cpp 2016-11-06 12:57:45.708324500 +0100 -@@ -362,7 +362,7 @@ - __FUNCTION__); - - int open_flags = O_RDWR | O_NOCTTY; --#if !defined(_MSC_VER) -+#if !defined(_WIN32) - // We really shouldn't be specifying platform specific flags - // that are intended for a system call in generic code. But - // this will have to do for now. -diff -urN lldb-3.9.0.src.orig/source/Utility/PseudoTerminal.cpp lldb-3.9.0.src/source/Utility/PseudoTerminal.cpp ---- lldb-3.9.0.src.orig/source/Utility/PseudoTerminal.cpp 2015-05-12 03:10:56.000000000 +0200 -+++ lldb-3.9.0.src/source/Utility/PseudoTerminal.cpp 2016-11-06 12:57:45.728347300 +0100 -@@ -20,7 +20,11 @@ - - #ifdef _WIN32 - #include "lldb/Host/windows/win32.h" -+ -+#ifndef __MINGW64_VERSION_MAJOR - typedef uint32_t pid_t; -+#endif -+ - // empty functions - int posix_openpt(int flag) { return 0; } - -@@ -364,4 +368,3 @@ - m_slave_fd = invalid_fd; - return fd; - } -- -diff -urN lldb-3.9.0.src.orig/tools/driver/Driver.cpp lldb-3.9.0.src/tools/driver/Driver.cpp ---- lldb-3.9.0.src.orig/tools/driver/Driver.cpp 2016-04-15 01:31:17.000000000 +0200 -+++ lldb-3.9.0.src/tools/driver/Driver.cpp 2016-11-06 17:01:16.257838300 +0100 -@@ -1308,13 +1308,13 @@ - } - - int --#ifdef WIN32 -+#ifdef MSVC - wmain(int argc, wchar_t const *wargv[]) - #else - main(int argc, char const *argv[]) - #endif - { --#ifdef _WIN32 -+#ifdef MSVC - // Convert wide arguments to UTF-8 - std::vector argvStrings(argc); - std::vector argvPointers(argc); -diff -urN lldb-3.9.0.src.orig/tools/lldb-mi/MIDataTypes.h lldb-3.9.0.src/tools/lldb-mi/MIDataTypes.h ---- lldb-3.9.0.src.orig/tools/lldb-mi/MIDataTypes.h 2015-07-21 13:27:40.000000000 +0200 -+++ lldb-3.9.0.src/tools/lldb-mi/MIDataTypes.h 2016-11-06 12:57:45.745348400 +0100 -@@ -40,12 +40,12 @@ - #define MIunused(x) (void) x; - - // Portability issues --#ifdef _WIN64 -+#if defined(_WIN64) && defined(_MSC_VER) - typedef unsigned __int64 size_t; - typedef __int64 MIint; - typedef unsigned __int64 MIuint; - #else --#ifdef _WIN32 -+#if defined(_WIN32) && defined(_MSC_VER) - typedef unsigned int size_t; - typedef int MIint; - typedef unsigned int MIuint; -@@ -53,7 +53,10 @@ - typedef int MIint; - typedef unsigned int MIuint; - -+#ifndef __MINGW32__ - #define MAX_PATH 4096 -+#endif -+ - #endif // _WIN32 - #endif // _WIN64 - -diff -urN lldb-3.9.0.src.orig/tools/lldb-mi/Platform.h lldb-3.9.0.src/tools/lldb-mi/Platform.h ---- lldb-3.9.0.src.orig/tools/lldb-mi/Platform.h 2016-03-22 18:58:09.000000000 +0100 -+++ lldb-3.9.0.src/tools/lldb-mi/Platform.h 2016-11-06 12:57:45.750349300 +0100 -@@ -86,8 +86,10 @@ - - #include - #include -+#ifndef __MINGW64_VERSION_MAJOR - #include - #include -+#endif // __MINGW64_VERSION_MAJOR - #include - - #include diff --git a/mingw-w64-clang/0501-minor-fixes-to-get-lldb-building.patch b/mingw-w64-clang/0501-minor-fixes-to-get-lldb-building.patch new file mode 100644 index 0000000000..59262d9939 --- /dev/null +++ b/mingw-w64-clang/0501-minor-fixes-to-get-lldb-building.patch @@ -0,0 +1,130 @@ +From 273fab668205311f4850fc025f7735f1019392a1 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Thu, 16 Feb 2017 00:37:27 +0100 +Subject: [PATCH] hacky changes to get lldb building + +--- + cmake/LLDBDependencies.cmake | 6 ++++++ + include/lldb/Host/windows/PosixApi.h | 18 +++++++++++------- + source/Host/windows/Windows.cpp | 2 ++ + tools/lldb-mi/MIDataTypes.h | 7 +++++++ + tools/lldb-mi/Platform.h | 4 ++++ + 5 files changed, 30 insertions(+), 7 deletions(-) + +diff --git a/cmake/LLDBDependencies.cmake b/cmake/LLDBDependencies.cmake +index e12a52268..53b348caa 100644 +--- a/cmake/LLDBDependencies.cmake ++++ b/cmake/LLDBDependencies.cmake +@@ -94,6 +94,12 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) + ws2_32 + rpcrt4 + ) ++ if (MINGW) ++ list(APPEND LLDB_USED_LIBS ++ dbghelp ++ psapi ++ ) ++ endif () + endif () + + # Linux-only libraries +diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h +index 4f2573781..519038296 100644 +--- a/include/lldb/Host/windows/PosixApi.h ++++ b/include/lldb/Host/windows/PosixApi.h +@@ -73,23 +73,27 @@ typedef uint32_t pid_t; + #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) + #endif + +-#endif // _MSC_VER ++#elif __MINGW64_VERSION_MAJOR ++#include ++#endif + + // Various useful posix functions that are not present in Windows. We provide + // custom implementations. ++#ifndef __MINGW64_VERSION_MAJOR ++int chdir(const char *path); ++char *getcwd(char *path, int max); + int vasprintf(char **ret, const char *fmt, va_list ap); ++int usleep(uint32_t useconds); ++int strcasecmp(const char *s1, const char *s2); ++int strncasecmp(const char *s1, const char *s2, size_t n); ++#endif ++ + char *strcasestr(const char *s, const char *find); + char *realpath(const char *name, char *resolved); + +-int usleep(uint32_t useconds); +-char *getcwd(char *path, int max); +-int chdir(const char *path); + char *basename(char *path); + char *dirname(char *path); + +-int strcasecmp(const char *s1, const char *s2); +-int strncasecmp(const char *s1, const char *s2, size_t n); +- + // empty functions + inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; } + +diff --git a/source/Host/windows/Windows.cpp b/source/Host/windows/Windows.cpp +index 21afc6d85..4f75442e1 100644 +--- a/source/Host/windows/Windows.cpp ++++ b/source/Host/windows/Windows.cpp +@@ -50,6 +50,7 @@ bool wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize) { + } + } + ++#ifndef __MINGW64_VERSION_MAJOR + int vasprintf(char **ret, const char *fmt, va_list ap) { + char *buf; + int len; +@@ -76,6 +77,7 @@ int vasprintf(char **ret, const char *fmt, va_list ap) { + va_end(ap2); + return len; + } ++#endif + + char *strcasestr(const char *s, const char *find) { + char c, sc; +diff --git a/tools/lldb-mi/MIDataTypes.h b/tools/lldb-mi/MIDataTypes.h +index 34fe45751..5522201d6 100644 +--- a/tools/lldb-mi/MIDataTypes.h ++++ b/tools/lldb-mi/MIDataTypes.h +@@ -40,9 +40,16 @@ const bool failure = false; + + // Portability issues + #ifdef _WIN64 ++# ifdef _MSC_VER + typedef unsigned __int64 size_t; + typedef __int64 MIint; + typedef unsigned __int64 MIuint; ++# else ++# include ++typedef uint64_t size_t; ++typedef int64_t MIint; ++typedef uint64_t MIuint; ++# endif + #else + #ifdef _WIN32 + typedef unsigned int size_t; +diff --git a/tools/lldb-mi/Platform.h b/tools/lldb-mi/Platform.h +index 1b6ff5549..147bb57a4 100644 +--- a/tools/lldb-mi/Platform.h ++++ b/tools/lldb-mi/Platform.h +@@ -79,8 +79,12 @@ typedef void (*sighandler_t)(int); + + #include + #include ++ ++#ifndef __MINGW64_VERSION_MAJOR + #include + #include ++#endif ++ + #include + + #include +-- +2.12.0 + diff --git a/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch b/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch index c2a09b8c8f..e72daf21cb 100644 --- a/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch +++ b/mingw-w64-clang/0502-hack-to-use-64-bit-time-for-mingw.patch @@ -2,11 +2,11 @@ diff -urN lldb-3.9.0.src.orig/source/Host/windows/FileSystem.cpp lldb-3.9.0.src/ --- lldb-3.9.0.src.orig/source/Host/windows/FileSystem.cpp 2016-03-22 18:58:09.000000000 +0100 +++ lldb-3.9.0.src/source/Host/windows/FileSystem.cpp 2016-11-10 01:55:34.663530600 +0100 @@ -276,7 +276,7 @@ - return -EINVAL; - } - int stat_result; + return -EINVAL; + } + int stat_result; -#ifdef _USE_32BIT_TIME_T +#if defined(_USE_32BIT_TIME_T) && !defined(__MINGW64_VERSION_MAJOR) - struct _stat32 file_stats; - stat_result = ::_wstat32(wpath.c_str(), &file_stats); + struct _stat32 file_stats; + stat_result = ::_wstat32(wpath.c_str(), &file_stats); #else diff --git a/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch b/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch index ba02c4d890..eca72b9974 100644 --- a/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch +++ b/mingw-w64-clang/0601-libunwind-add-support-for-mingw-w64.patch @@ -1,14 +1,20 @@ -From 81b5dabfed88d2976faf587598361c054630ef95 Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Tue, 21 Jul 2015 04:35:55 +0100 +From dfe4f4533d720f2e057f35b104b3fd50cf9d0f32 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Fri, 17 Mar 2017 21:20:49 +0100 Subject: [PATCH] libunwind add support for mingw-w64 +--- + include/unwind.h | 2 +- + src/AddressSpace.hpp | 15 ++++++++------- + src/assembly.h | 2 ++ + src/config.h | 16 +++++++++++++++- + 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/unwind.h b/include/unwind.h -index 31fb871..e8c63d7 100644 +index 1d163ca..e54f39d 100644 --- a/include/unwind.h +++ b/include/unwind.h -@@ -121,7 +121,7 @@ struct _Unwind_Exception { +@@ -122,7 +122,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 @@ -18,7 +24,7 @@ index 31fb871..e8c63d7 100644 // 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 67aa664..f61e620 100644 --- a/src/AddressSpace.hpp +++ b/src/AddressSpace.hpp @@ -18,7 +18,7 @@ @@ -30,7 +36,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 +45,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 +54,32 @@ index 567cbda..fd0b233 100644 return get64(addr); #else return get32(addr); -@@ -434,6 +434,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, +@@ -306,7 +306,7 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, + return result; + } + +-#ifdef __APPLE__ ++#ifdef __APPLE__ + struct dyld_unwind_sections + { + const struct mach_header* mh; +@@ -324,13 +324,13 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, + // In 10.6.x and earlier, we need to implement this functionality. Note + // that this requires a newer version of libmacho (from cctools) than is + // present in libSystem on 10.6.x (for getsectiondata). +- static inline bool _dyld_find_unwind_sections(void* addr, ++ static inline bool _dyld_find_unwind_sections(void* addr, + dyld_unwind_sections* info) { + // Find mach-o image containing address. + Dl_info dlinfo; + if (!dladdr(addr, &dlinfo)) + return false; +-#if __LP64__ ++#if defined(__LP64__) || defined(_WIN64) + const struct mach_header_64 *mh = (const struct mach_header_64 *)dlinfo.dli_fbase; + #else + const struct mach_header *mh = (const struct mach_header *)dlinfo.dli_fbase; +@@ -445,6 +445,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, }, &cb_data); return static_cast(found); @@ -56,32 +87,17 @@ 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) { +@@ -468,7 +469,7 @@ 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) ++#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) 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 +index 9fb9905..6391f22 100644 --- a/src/assembly.h +++ b/src/assembly.h @@ -26,6 +26,8 @@ @@ -94,10 +110,10 @@ index f46a24d..4d6c3e1 100644 #define HIDDEN_DIRECTIVE .hidden #endif diff --git a/src/config.h b/src/config.h -index c9ec087..6f14e92 100644 +index 4e4dd99..f6002af 100644 --- a/src/config.h +++ b/src/config.h -@@ -39,6 +39,16 @@ +@@ -40,6 +40,16 @@ #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 #endif @@ -114,7 +130,7 @@ index c9ec087..6f14e92 100644 #else #if defined(__ARM_DWARF_EH__) || !defined(__arm__) #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 -@@ -51,9 +51,13 @@ +@@ -52,9 +62,13 @@ #endif #endif @@ -130,5 +146,5 @@ index c9ec087..6f14e92 100644 #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__) #define _LIBUNWIND_BUILD_SJLJ_APIS 1 -- -2.4.5 +2.12.0 diff --git a/mingw-w64-clang/0701-fix-visibility-for-libc-abi-on-win32.patch b/mingw-w64-clang/0701-fix-visibility-for-libc-abi-on-win32.patch new file mode 100644 index 0000000000..693f5f154c --- /dev/null +++ b/mingw-w64-clang/0701-fix-visibility-for-libc-abi-on-win32.patch @@ -0,0 +1,36 @@ +From a5908c964e8d40c084a912ec1ecfd45127c732d0 Mon Sep 17 00:00:00 2001 +From: Mateusz Mikula +Date: Mon, 20 Mar 2017 18:44:00 +0100 +Subject: [PATCH] fix visibility for libc++abi on win32 + +--- + src/private_typeinfo.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/private_typeinfo.h b/src/private_typeinfo.h +index f3d3e1d..99651a7 100644 +--- a/src/private_typeinfo.h ++++ b/src/private_typeinfo.h +@@ -16,7 +16,9 @@ + #include + + namespace __cxxabiv1 { ++#ifndef _WIN32 + #pragma GCC visibility push(hidden) ++#endif + + class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info { + public: +@@ -248,7 +250,9 @@ public: + _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const; + }; + ++#ifndef _WIN32 + #pragma GCC visibility pop ++#endif + + } // __cxxabiv1 + +-- +2.12.0 + diff --git a/mingw-w64-clang/PKGBUILD b/mingw-w64-clang/PKGBUILD index 74b92c4a15..a0976621fc 100644 --- a/mingw-w64-clang/PKGBUILD +++ b/mingw-w64-clang/PKGBUILD @@ -18,17 +18,14 @@ pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}" "${MINGW_PACKAGE_PREFIX}-lld" "${MINGW_PACKAGE_PREFIX}-libunwind" "${MINGW_PACKAGE_PREFIX}-llvm" - "${MINGW_PACKAGE_PREFIX}-lldb" - ) -pkgver=3.9.1 -pkgrel=3 + "${MINGW_PACKAGE_PREFIX}-lldb") +pkgver=4.0.0 +pkgrel=1 pkgdesc="C language family frontend for LLVM (mingw-w64)" arch=('any') url="http://llvm.org" license=("custom:University of Illinois/NCSA Open Source License") makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" - $([[ "$_compiler" == "gcc" ]] && echo \ - "${MINGW_PACKAGE_PREFIX}-gcc") $([[ "$_compiler" == "clang" ]] && echo \ "${MINGW_PACKAGE_PREFIX}-clang") "${MINGW_PACKAGE_PREFIX}-libffi" @@ -50,95 +47,84 @@ source=(http://llvm.org/releases/${pkgver}/llvm-${pkgver}.src.tar.xz{,.sig} http://llvm.org/releases/${pkgver}/lldb-${pkgver}.src.tar.xz{,.sig} http://llvm.org/releases/${pkgver}/libunwind-${pkgver}.src.tar.xz{,.sig} "0001-genlib-named-as-llvm-dlltool.patch" - "0002-COFF-Fix-short-import-lib-import-name-type-bitshift.patch" - "0003-mingw-w64-use-MSVC-style-ByteAlignment.patch" - "0004-killthedoctor-mingw.patch" - "0005-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" - "0006-use-DESTDIR-on-windows.patch" - "0007-fix-llvm-shlib-cmake-build.patch" - "0008-not-install-msvc-files.patch" - "0009-fix-llvm-config-shared-lib-version-on-win32.patch" - "0101-Revert-Revert-r253898-and-r253899-this-breaks-mingw-.patch" - "0102-mingw-w64-setup-new-defaults-for-target.patch" - "0103-mingw-w64-enable-support-for-__declspec-selectany.patch" - "0104-mingw-w64-support-static-builds-of-libc.patch" - "0105-mingw-enable-static-libclang.patch" - "0106-generate-libclang-instead-of-liblibclang.patch" - "0107-dont-create-cl-mingw.patch" - "0108-dont-use-gcc-headers.patch" - "0109-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" - "0110-enable-support-for-float128.patch" - "0111-fix-clang-with-libstdc.patch" - "0112-objc-eh-personality.patch" + "0002-mingw-w64-use-MSVC-style-ByteAlignment.patch" + "0003-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" + "0004-Globally-provide-DESTDIR-for-all-platforms.patch" + "0005-not-install-msvc-files.patch" + "0006-llvm-config-look-for-unversioned-shared-lib-on-win32.patch" + "0007-add-pthread-as-system-lib-for-mingw.patch" + "0101-mingw-w64-enable-support-for-__declspec-selectany.patch" + "0102-Allow-build-static-clang-library-for-mingw.patch" + "0103-fix-libclang-name-for-mingw.patch" + "0104-don-t-use-GCC-headers.patch" + "0105-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" + "0106-link-pthread-with-mingw.patch" + "0107-enable-__float128-for-X86-MinGW.patch" + "0108-Don-t-create-cl-executable-for-mingw.patch" + "0109-use-emulated-tls-with-mingw.patch" "0201-mingw-w64-__udivdi3-mangle-hack.patch" - "0202-mingw-fixes-for-compiler-rt.patch" + "0202-compiler-rt-fix-mingw-build.patch" "0301-COFF-gnu-driver-support.patch" "0302-add-install-target-for-the-lld-tool.patch" - "0303-Fix-LLVM_LINK_LLVM_DYLIB-build.patch" "0401-mingw-w64-hack-and-slash-fixes-for-libc.patch" - "0402-fix-compilation-with-gcc.patch" - "0501-lldb-mingw-fixes.patch" + "0501-minor-fixes-to-get-lldb-building.patch" "0502-hack-to-use-64-bit-time-for-mingw.patch" - "0601-libunwind-add-support-for-mingw-w64.patch") + "0601-libunwind-add-support-for-mingw-w64.patch" + "0701-fix-visibility-for-libc-abi-on-win32.patch") # Some patch notes :) #0001-0099 -> llvm #0101-0199 -> clang #0201-0299 -> rt #0301-0399 -> lld -#0401-0499 -> c++ +#0401-0499 -> libc++ #0501-0599 -> lldb #0601-0699 -> libunwind -sha256sums=('1fd90354b9cf19232e8f168faf2220e79be555df3aa743242700879e8fd329ee' +#0701-0799 -> libc++abi +sha256sums=('8d10511df96e73b8ff9e7abbfb4d4d432edbdbe965f1f4f07afaf370b8a533be' 'SKIP' - 'e6c4cebb96dee827fa0470af313dff265af391cb6da8d429842ef208c8f25e63' + 'cea5f88ebddb30e296ca89130c83b9d46c2d833685e2912303c828054c4dc98a' 'SKIP' - 'd30967b1a5fa51a2503474aacc913e69fd05ae862d37bf310088955bdb13ec99' + 'd3f25b23bef24c305137e6b44f7e81c51bbec764c119e01512a9bd2330be3115' 'SKIP' - '2fbc9d6aa709b584a8e3bb0b6517679cd022d92e4105fcddac94241b09aa48a0' + '31544baafbee0d6c652637f6dfa19ca91afe5ca577e07752f4b2c23656bc6304' 'SKIP' - '25e615e428f60e651ed09ffd79e563864e3f4bc69a9e93ee41505c419d1a7461' + '4f4d33c4ad69bf9e360eebe6b29b7b19486948b1a41decf89d4adec12473cf96' 'SKIP' - '920d8be32e6f5574a3fb293f93a31225eeba15086820fcb942155bf50dc029e2' + 'dca9cb619662ad2d3a0d685c4366078345247218c3702dd35bcaaa23f63481d8' 'SKIP' - '29a5b65bdeff7767782d4427c7c64d54c3a8684bc6b217b74a70e575e4813635' + '41b7d37eb128fd362ab3431be5244cf50325bb3bb153895735c5bacede647c99' 'SKIP' - '48e128fabb2ddaee64ecb8935f7ac315b6e68106bc48aeaf655d179c65d87f34' + '33e06457b9ce0563c89b11ccc7ccabf9cff71b83571985a5bf8684c9150e7502' 'SKIP' - '7e3311b2a1f80f4d3426e09f9459d079cab4d698258667e50a46dccbaaa460fc' + '2dbd8f05c662c1c9f11270fc9d0c63b419ddc988095e0ad107ed911cf882033d' 'SKIP' - '0b0bc73264d7ab77d384f8a7498729e3c4da8ffee00e1c85ad02a2f85e91f0e6' + '0755efa9f969373d4d543123bbed4b3f9a835f6302875c1379c5745857725973' 'SKIP' - 'a69d60c2ae36f253f34ab3cfaaa4ff10522692dd4a1a646f2f8fa8996fbd026b' - '89e86d7f53b97bbaef6ee02aa817e979bc122b4844e237b2f5f2af8c268c44c4' - '3c429a6762c66ffd18b0f378debe0527e15f27e5caa0bb47d2e88f8afe68b093' - 'e83fe9effaa3d0ba21d3bb98bfd471dc0acd2dd99c72695fb33685d69f8e2a76' - '0804146b32138d55c611336cc81e1783c29a8fab0fe62f248ba1ad7acc711c4d' - '76bcdcae0ef3a4d3ae7082b7fcd668e9560e63fb82068c3f889f9e89b9becf4a' - '1f750fa6a822876dc05bbd7178cf96e9dcaa61f5538e3e0dc223f30514726e40' - '94ccd90b92a2a570c6ee72ac9c1aa402e179ecebb27821e1998025949e09b12a' - 'ed2b45e86da7166aafa3c0b9408db2bac120fdcae9a0fb2ef53ae0f49818ab1c' - '31e0f242f4463cadc1b867a87b38e4c2f689e70fdd6d64a44dcc3784f352b20f' - 'ba703d3d0f100d02ba01501319e6ec29565a199176fb20d11f89fa31b479df5f' - 'b00b3e2395d9262c999c6865da59837f0712454803e0d4e776181267df89f083' - '0c570da0d1357cfef276da685b67118d48a6a6f5a0fc4e281c2925c10f8be9ca' - '0e45e76ee6d6658de52edb7b508a8bcc9f10ff0b295ff2a4e35577136a40c6a5' - '177f45e72cb361414dc80374be25e7913a6b33724e17434f2c55a66ac9143705' - 'b03cfc7ebbbfb847e88ae3569d9dcafb01f179b06f1312de29fbd5b7cf906617' - 'c30c5477bcb7052245e4ea24a33b60564efc968df81c515f2a512eaa1d45c1a7' - '13a95a61e9c1c44c18a69947734e07515332a549446394f48b86b52511d221de' - '7abd9894abe9d28da975fadbad27478c308ed1455a5130091ad0ffd0351bfa52' - '72cae8e17236d6ad625641a6661ce179b8446bd5119f32a352e5b3b9c1a3f397' - '19d6b59c47f62abcd7fcc2f510e305a1fcdfb4e2016b71245db8e312c038e8b2' + '3f55d2114805110e370fab6630763c359d83b07c356f61b86afc32feb7cf7514' + '78b6951956360a8e05fdc7020bc7e1996da75b499022f9213465070fc238529c' + 'aceffb61d57c7c01bc2d9d5461f961df26cffdffaaabb8dda9f219acfe59c77a' + 'bccdb99553424121927b3f82086efb2adeee230f18944504ddd93d2d72371d5c' + 'c840f4e2286385c4ab3503c02976fd2459516fdc05e44f702d648afaaaebd97f' + 'f06f57af203811f6a4c62ac3f1e4545628db13185f5e7d3225d4b1104ca69be1' + 'c57d5f2904158b992378906bcddbae79d0566cdb07cc74fbd9b2d76d52661a12' + 'afdd708e2431874da4e03d9f51848840ec30ef64b4d440c8dfd50446b2f5ce1a' + '8ba3968939f9a7c6a51849aaf1ab6126f85aa612349570b3644f855929d496fc' + '1740ffa1d23fdee2b147a46cfed4d186bf7d3dc626bb3a1d3ca925147895a2d4' + 'e8c8ebbcc7353548974e640b76bfe13d6b89afc832066e0d7156fe242b561a93' + '066e61c097fcad202b3b4f26dbe667719a9f5ae872837250629d69fe06bd1af1' + 'cae561cb643daeb68e9ec2716928ba79b459ec2064829e54ecd1edcc378d293b' + '8a636174bff1a05872777b935e27c15c3b87683b57c4277de0d1e9ecc1ca5548' + 'f2931ac1ebcc33faa1fa320ebe76143baf9d7635f4819e0f9e37924e70f30d39' + '9f9a12749869bb6c5817d6d5231417195c2e3bd80c10059b3f3e70b010159c26' 'fb1ef06b26e88d37d52c3e0b3b261089e92bb7c08231ec8fa234465fdbdab308' - 'c19a3e49f692eba9143bb67c39a9e6df33fa604d85b0b7834d99cdd58a28d23a' + '29e61097ca4f9b1df304e1e7a8f65e6d8ed452e9eb88d9d8cc6ff78b64d84aa8' '852d55907b469739fca96b043e41c596824ad9d933268ce65a82100b975e91fb' '0f2cf89298303911a20e9cee7208ed418d91cf700af611a142dc735c708e1435' - 'ffbce44f0787dd3defa708f9637353856d70d4b0b888121dd600c6b269b167e1' - 'd9b46363c0db63316bdaa29580c446bfe5bc7b43eb8d00f894b72415066da53e' - '461c75905768ce9ed14db48e6c959695f8a61c58c60486c2671b6d4d10923bad' - '0371289d17563a2f29dd7041349e7fe24ed5f217c548c8bff93b47c5b5df2d20' - '4be9205a90b3ed2d23b8e84cac36697c5a85026b6ab3193061fbb0b3915d76c9' - '0a5529a5e9871ec5252c3853f1fdda69253c1a7505837e9c45ae14bcb76a8660') + '84e929fd0f59a90f8c46cf831f420a36e5e4dff359f2ae9338c42ea20f1243d7' + '5782b351170ab747c046efb79244a36de2c531014d5b719e7398f1597a10b948' + 'fbb5f936a0c23529a7ec43d458ea22c033a6c84c2017178ad3645b03d8584bcf' + '1ebe995823d427177bf79c4c73e205f708c58e25616b4183d5981a1b4c8130e0' + 'eecb723ed6fa59d9debd84a11bcede607020beadfdd0988778392dd7a1820963') validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D' # Hans Wennborg, Google. '11E521D646982372EB577A1F8F0871F202119294') # Tom Stellard noextract=(cfe-${pkgver}.src.tar.xz @@ -170,52 +156,48 @@ prepare() { lib/DLLDriver/Options.td \ include/llvm/DllDriver/DllDriver.h || true patch -p1 -i "${srcdir}/0001-genlib-named-as-llvm-dlltool.patch" - patch -p1 -i "${srcdir}/0002-COFF-Fix-short-import-lib-import-name-type-bitshift.patch" - patch -p1 -i "${srcdir}/0003-mingw-w64-use-MSVC-style-ByteAlignment.patch" - patch -p1 -i "${srcdir}/0004-killthedoctor-mingw.patch" - patch -p1 -i "${srcdir}/0005-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" - patch -p1 -i "${srcdir}/0006-use-DESTDIR-on-windows.patch" - patch -p1 -i "${srcdir}/0007-fix-llvm-shlib-cmake-build.patch" - patch -p1 -i "${srcdir}/0008-not-install-msvc-files.patch" - patch -p1 -i "${srcdir}/0009-fix-llvm-config-shared-lib-version-on-win32.patch" + patch -p1 -i "${srcdir}/0002-mingw-w64-use-MSVC-style-ByteAlignment.patch" + patch -p1 -i "${srcdir}/0003-Fix-GetHostTriple-for-mingw-w64-in-msys.patch" + patch -p1 -i "${srcdir}/0004-Globally-provide-DESTDIR-for-all-platforms.patch" + patch -p1 -i "${srcdir}/0005-not-install-msvc-files.patch" + patch -p1 -i "${srcdir}/0006-llvm-config-look-for-unversioned-shared-lib-on-win32.patch" + patch -p1 -i "${srcdir}/0007-add-pthread-as-system-lib-for-mingw.patch" cd "${srcdir}/cfe-${pkgver}.src" - patch -p1 -i "${srcdir}/0101-Revert-Revert-r253898-and-r253899-this-breaks-mingw-.patch" - #patch -p1 -i "${srcdir}/0012-mingw-w64-setup-new-defaults-for-target.patch" - patch -p1 -i "${srcdir}/0103-mingw-w64-enable-support-for-__declspec-selectany.patch" - patch -p1 -i "${srcdir}/0104-mingw-w64-support-static-builds-of-libc.patch" - patch -p1 -i "${srcdir}/0105-mingw-enable-static-libclang.patch" - patch -p1 -i "${srcdir}/0106-generate-libclang-instead-of-liblibclang.patch" - patch -p1 -i "${srcdir}/0107-dont-create-cl-mingw.patch" - patch -p1 -i "${srcdir}/0108-dont-use-gcc-headers.patch" - patch -p1 -i "${srcdir}/0109-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" - patch -p1 -R -i "${srcdir}/0110-enable-support-for-float128.patch" - patch -p1 -i "${srcdir}/0111-fix-clang-with-libstdc.patch" - patch -p1 -i "${srcdir}/0112-objc-eh-personality.patch" + patch -p1 -i "${srcdir}/0101-mingw-w64-enable-support-for-__declspec-selectany.patch" + patch -p1 -i "${srcdir}/0102-Allow-build-static-clang-library-for-mingw.patch" + patch -p1 -i "${srcdir}/0103-fix-libclang-name-for-mingw.patch" + patch -p1 -i "${srcdir}/0104-don-t-use-GCC-headers.patch" + patch -p1 -i "${srcdir}/0105-Set-the-x86-arch-name-to-i686-for-mingw-w64.patch" + patch -p1 -i "${srcdir}/0106-link-pthread-with-mingw.patch" + patch -p1 -i "${srcdir}/0107-enable-__float128-for-X86-MinGW.patch" + patch -p1 -i "${srcdir}/0108-Don-t-create-cl-executable-for-mingw.patch" + patch -p1 -i "${srcdir}/0109-use-emulated-tls-with-mingw.patch" cd "${srcdir}/compiler-rt-${pkgver}.src" patch -p1 -i "${srcdir}/0201-mingw-w64-__udivdi3-mangle-hack.patch" - patch -p1 -i "${srcdir}/0202-mingw-fixes-for-compiler-rt.patch" + patch -p1 -i "${srcdir}/0202-compiler-rt-fix-mingw-build.patch" - cd "${srcdir}/lld-${pkgver}.src" - # cleanup file created by patch - rm -rf cmake/modules/AddLLD.cmake || true - patch -p1 -i "${srcdir}/0301-COFF-gnu-driver-support.patch" - patch -p1 -i "${srcdir}/0302-add-install-target-for-the-lld-tool.patch" - patch -p1 -i "${srcdir}/0303-Fix-LLVM_LINK_LLVM_DYLIB-build.patch" + # not ported for 4.0 + #cd "${srcdir}/lld-${pkgver}.src" + ## cleanup file created by patch + #rm -rf cmake/modules/AddLLD.cmake || true + #patch -p1 -i "${srcdir}/0301-COFF-gnu-driver-support.patch" + #patch -p1 -i "${srcdir}/0302-add-install-target-for-the-lld-tool.patch" cd "${srcdir}/libcxx-${pkgver}.src" patch -p1 -i "${srcdir}/0401-mingw-w64-hack-and-slash-fixes-for-libc.patch" - patch -p1 -i "${srcdir}/0402-fix-compilation-with-gcc.patch" cd "${srcdir}/lldb-${pkgver}.src" - patch -p1 -i "${srcdir}/0501-lldb-mingw-fixes.patch" - # this hack allows to build 32 bit lldb but probably breaks XP support + patch -p1 -i "${srcdir}/0501-minor-fixes-to-get-lldb-building.patch" patch -p1 -i "${srcdir}/0502-hack-to-use-64-bit-time-for-mingw.patch" cd "${srcdir}/libunwind-${pkgver}.src" patch -p1 -i "${srcdir}/0601-libunwind-add-support-for-mingw-w64.patch" + cd "${srcdir}/libcxxabi-${pkgver}.src" + patch -p1 -i "${srcdir}/0701-fix-visibility-for-libc-abi-on-win32.patch" + # At the present, clang must reside inside the LLVM source code tree to build # See http://llvm.org/bugs/show_bug.cgi?id=4840 @@ -284,7 +266,7 @@ build() { -DLLVM_ENABLE_FFI=ON \ -DLLVM_ENABLE_SPHINX=ON \ -DLLVM_BUILD_LLVM_DYLIB=ON \ - -DLLVM_LINK_LLVM_DYLIB=OFF \ + -DLLVM_LINK_LLVM_DYLIB=ON \ -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE" \ -DLIBCLANG_BUILD_STATIC=ON \ -DLIBCXX_ENABLE_SHARED=OFF \ @@ -314,12 +296,11 @@ build() { package_llvm() { pkgdesc="Low Level Virtual Machine (mingw-w64)" depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs") # "compiler-rt" - #install=llvm-${CARCH}.install cd "${srcdir}"/llvm-${pkgver}.src make -C ../build-${CARCH} DESTDIR="${pkgdir}" install - + # TODO: why CMake haven't included it? cp ../build-${CARCH}/lib/libLLVM.dll.a "${pkgdir}/${MINGW_PREFIX}/lib/" @@ -398,7 +379,8 @@ package_lld() { package_clang() { pkgdesc="C language family frontend for LLVM (mingw-w64)" url="http://clang.llvm.org/" - depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}-${pkgrel}") + depends=("${MINGW_PACKAGE_PREFIX}-llvm=${pkgver}-${pkgrel}" + "${MINGW_PACKAGE_PREFIX}-gcc") cd "${srcdir}/llvm-${pkgver}.src" make -C ../build-${CARCH}/tools/clang DESTDIR="${pkgdir}" install diff --git a/mingw-w64-clang/llvm-i686.install b/mingw-w64-clang/llvm-i686.install deleted file mode 100755 index 083c192bc2..0000000000 --- a/mingw-w64-clang/llvm-i686.install +++ /dev/null @@ -1,10 +0,0 @@ -post_install() { - cd mingw32 - local _prefix=$(pwd -W) - cd - - sed -e "s|/mingw32|${_prefix}|g" -i mingw32/share/llvm/cmake/LLVMConfig.cmake -} - -post_upgrade() { - post_install -} diff --git a/mingw-w64-clang/llvm-x86_64.install b/mingw-w64-clang/llvm-x86_64.install deleted file mode 100755 index a49c817881..0000000000 --- a/mingw-w64-clang/llvm-x86_64.install +++ /dev/null @@ -1,10 +0,0 @@ -post_install() { - cd mingw64 - local _prefix=$(pwd -W) - cd - - sed -e "s|/mingw64|${_prefix}|g" -i mingw64/share/llvm/cmake/LLVMConfig.cmake -} - -post_upgrade() { - post_install -}