diff --git a/D68899-de1c2877a9ff12899ef50e179ade748fba8ab0c0.patch b/D68899-de1c2877a9ff12899ef50e179ade748fba8ab0c0.patch new file mode 100644 index 0000000..a06a7b6 --- /dev/null +++ b/D68899-de1c2877a9ff12899ef50e179ade748fba8ab0c0.patch @@ -0,0 +1,52 @@ +From de1c2877a9ff12899ef50e179ade748fba8ab0c0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lu=C3=ADs=20Marques?= +Date: Fri, 14 Feb 2020 11:49:18 +0000 +Subject: [PATCH] llvm/cmake/config.guess: add support for riscv32 and riscv64 + +Summary: LLVM configuration fails with 'unable to guess system type' on riscv64. +Add support for detecting riscv32 and riscv64 systems. + +Patch by Gokturk Yuksek (gokturk) +Reviewers: erichkeane, rengolin, mgorny, aaron.ballman, beanz, luismarques +Reviewed By: luismarques +Tags: #llvm +Differential Revision: https://reviews.llvm.org/D68899 +--- + llvm/cmake/config.guess | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/llvm/cmake/config.guess b/llvm/cmake/config.guess +index ccb30f4e75e8..26d120601e49 100644 +--- a/llvm/cmake/config.guess ++++ b/llvm/cmake/config.guess +@@ -973,6 +973,30 @@ EOF + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; ++ riscv32:Linux:*:* | riscv64:Linux:*:*) ++ LIBC=gnu ++ eval $set_cc_for_build ++ # Do not check for __GLIBC__ because uclibc defines it too ++ sed 's/^ //' << EOF >$dummy.c ++ #include ++ #if defined(__UCLIBC__) ++ LIBC=uclibc ++ #elif defined(__dietlibc__) ++ LIBC=dietlibc ++ #endif ++EOF ++ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ++ ++ # There is no features test macro for musl ++ # Follow the GNU's config.guess approach of ++ # checking the output of ldd ++ if command -v ldd >/dev/null && \ ++ ldd --version 2>&1 | grep -q ^musl; then ++ LIBC=musl ++ fi ++ ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; diff --git a/D68964-cef85193b2cc1817ca43199a0ae9c6f25723997d.patch b/D68964-cef85193b2cc1817ca43199a0ae9c6f25723997d.patch new file mode 100644 index 0000000..2be80af --- /dev/null +++ b/D68964-cef85193b2cc1817ca43199a0ae9c6f25723997d.patch @@ -0,0 +1,49 @@ +From cef85193b2cc1817ca43199a0ae9c6f25723997d Mon Sep 17 00:00:00 2001 +From: Gokturk Yuksek +Date: Mon, 17 Feb 2020 18:36:18 +0000 +Subject: [PATCH] [CMake] CheckAtomic.cmake: catch false positives in RISC-V + +The check for 'HAVE_CXX_ATOMICS_WITHOUT_LIB' may create false +positives in RISC-V. This is reproducible when compiling LLVM natively +using GCC on a rv64gc (rv64imafdgc) host. Due to the 'A' (atomic) +extension, g++ replaces calls to libatomic operations on the +std::atomic type with the native hardware instructions. As a +result, the compilation succeeds and the build system thinks it +doesn't need to pass '-latomic'. + +Improve the reliability of the 'HAVE_CXX_ATOMICS_WITHOUT_LIB' test in +two steps: + +1. Force a pre-increment on x (++x), which should force a call to a +libatomic function; + +2. Because step 1 would resolve the increment to 'amoadd.w.aq' under +the 'A' extension, force the same operation on sub-word types, for +which there is no hardware support. + +Reviewers: jfb, hintonda, smeenai, mgorny, JDevlieghere, jyknight +Reviewed By: jfb +Tags: #llvm +Differential Revision: https://reviews.llvm.org/D68964 +--- + llvm/cmake/modules/CheckAtomic.cmake | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/llvm/cmake/modules/CheckAtomic.cmake b/llvm/cmake/modules/CheckAtomic.cmake +index af925f5bf9ec..5d22a131e5cb 100644 +--- a/llvm/cmake/modules/CheckAtomic.cmake ++++ b/llvm/cmake/modules/CheckAtomic.cmake +@@ -12,8 +12,12 @@ function(check_working_cxx_atomics varname) + CHECK_CXX_SOURCE_COMPILES(" + #include + std::atomic x; ++std::atomic y; ++std::atomic z; + int main() { +- return x; ++ ++z; ++ ++y; ++ return ++x; + } + " ${varname}) + set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) diff --git a/D69003-09856feb3cc141f4f9c8b9edec28602ac4f21575.patch b/D69003-09856feb3cc141f4f9c8b9edec28602ac4f21575.patch new file mode 100644 index 0000000..126e512 --- /dev/null +++ b/D69003-09856feb3cc141f4f9c8b9edec28602ac4f21575.patch @@ -0,0 +1,28 @@ +From 09856feb3cc141f4f9c8b9edec28602ac4f21575 Mon Sep 17 00:00:00 2001 +From: Gokturk Yuksek +Date: Mon, 17 Feb 2020 22:26:59 +0000 +Subject: [PATCH] [dsymutil] Explicitly link against libatomic when necessary + +In some systems, such as RISC-V, atomic support requires explicit linking +against '-latomic' (see https://github.com/riscv/riscv-gcc/issues/12). + +Reviewers: davezarzycki, hhb, beanz, jfb, JDevlieghere +Reviewed By: beanz, JDevlieghere +Tags: #llvm +Differential Revision: https://reviews.llvm.org/D69003 +--- + llvm/tools/dsymutil/CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt +index a6543c9ff2ce..dc31b86b2fc9 100644 +--- a/llvm/tools/dsymutil/CMakeLists.txt ++++ b/llvm/tools/dsymutil/CMakeLists.txt +@@ -37,3 +37,7 @@ add_llvm_tool(dsymutil + if(APPLE) + target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation") + endif(APPLE) ++ ++if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB) ++ target_link_libraries(dsymutil PRIVATE atomic) ++endif() diff --git a/D69444-d4a4a32cd94eccbaaa4608b0daac8b820e041214.patch b/D69444-d4a4a32cd94eccbaaa4608b0daac8b820e041214.patch new file mode 100644 index 0000000..a8c83a4 --- /dev/null +++ b/D69444-d4a4a32cd94eccbaaa4608b0daac8b820e041214.patch @@ -0,0 +1,32 @@ +From d4a4a32cd94eccbaaa4608b0daac8b820e041214 Mon Sep 17 00:00:00 2001 +From: Gokturk Yuksek +Date: Tue, 18 Feb 2020 07:52:29 +0000 +Subject: [PATCH] [Support] Check for atomics64 when deciding if '-latomic' is + needed + +The CheckAtomic module performs two tests to determine if passing +'-latomic' to the linker is required: one for 64-bit atomics, and +another for non-64-bit atomics. Include the missing check for 64-bit +atomics. + +Reviewers: beanz, compnerd +Reviewed By: beanz, compnerd +Tags: #llvm +Differential Revision: https://reviews.llvm.org/D69444 +--- + llvm/lib/Support/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt +index 26332d4f539c..41c5258d0b2b 100644 +--- a/llvm/lib/Support/CMakeLists.txt ++++ b/llvm/lib/Support/CMakeLists.txt +@@ -26,7 +26,7 @@ elseif( CMAKE_HOST_UNIX ) + set(system_libs ${system_libs} ${TERMINFO_LIBS}) + endif() + endif() +- if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC ) ++ if( LLVM_ENABLE_THREADS AND (HAVE_LIBATOMIC OR HAVE_CXX_LIBATOMICS64) ) + set(system_libs ${system_libs} atomic) + endif() + set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB}) diff --git a/f128f442a3d23674bee19ae18e29f92c9dfe40cd.patch b/f128f442a3d23674bee19ae18e29f92c9dfe40cd.patch new file mode 100644 index 0000000..733d1f6 --- /dev/null +++ b/f128f442a3d23674bee19ae18e29f92c9dfe40cd.patch @@ -0,0 +1,27 @@ +From f128f442a3d23674bee19ae18e29f92c9dfe40cd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lu=C3=ADs=20Marques?= +Date: Mon, 17 Feb 2020 15:21:41 +0000 +Subject: [PATCH] [CMake] Fix setting result of libatomic check for MSVC + +We were skipping the libatomic requirement check for MSVC, but not setting +the corresponding variable, HAVE_CXX_ATOMICS_WITHOUT_LIB. D69869 seems to +have to failed to build on ARM MSVC because of that, and was reverted. This +should probably fix the issue. The plan is to check the result of the build +bots and then submit a more thoroughly refactored version for review. +--- + llvm/cmake/modules/CheckAtomic.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/llvm/cmake/modules/CheckAtomic.cmake b/llvm/cmake/modules/CheckAtomic.cmake +index 29f3bdd57f03..af925f5bf9ec 100644 +--- a/llvm/cmake/modules/CheckAtomic.cmake ++++ b/llvm/cmake/modules/CheckAtomic.cmake +@@ -53,6 +53,8 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE) + message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.") + endif() + endif() ++elseif(MSVC) ++ set(HAVE_CXX_ATOMICS_WITHOUT_LIB True) + endif() + + # Check for 64 bit atomic operations.