diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-01-13 09:00:42 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-01-13 09:00:42 +0300 |
commit | 66df4a402d0ea0716f25e9af04105c038cfa39a9 (patch) | |
tree | fc914166e14de865d146b9db87cd6f8f31dbf21b | |
parent | 8bcc2ededbcb7b67e946fb577b87e4fec5c12791 (diff) |
llvm, clang: missed patches
4 files changed, 246 insertions, 0 deletions
diff --git a/sys-devel/clang/files/5.0.0/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch b/sys-devel/clang/files/5.0.0/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch new file mode 100644 index 0000000..7d53cbd --- /dev/null +++ b/sys-devel/clang/files/5.0.0/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch @@ -0,0 +1,136 @@ +From 19e3dc0ce4949cc7f869b4552c6a7f28cd59c3b7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Thu, 17 Nov 2016 14:19:18 +0100 +Subject: [PATCH] [Driver] Use arch type to find compiler-rt libraries (on + Linux) + +Use llvm::Triple::getArchTypeName() when looking for compiler-rt +libraries, rather than the exact arch string from the triple. This is +more correct as it matches the values used when building compiler-rt +(builtin-config-ix.cmake) which are the subset of the values allowed +in triples. + +For example, this fixes an issue when the compiler set for +i686-pc-linux-gnu triple would not find an i386 compiler-rt library, +while this is the exact arch that is detected by compiler-rt. The same +applies to any other i?86 variant allowed by LLVM. + +This also makes the special case for MSVC unnecessary, since now i386 +will be used reliably for all 32-bit x86 variants. +--- + lib/Driver/ToolChain.cpp | 5 +---- + .../usr/i686-unknown-linux/lib/.keep | 0 + .../usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o | 0 + test/Driver/linux-ld.c | 21 +++++++++++++++++++++ + test/Driver/nostdlib.c | 2 +- + test/Driver/print-libgcc-file-name-clangrt.c | 10 ++++++++-- + test/Driver/windows-cross.c | 2 +- + 7 files changed, 32 insertions(+), 8 deletions(-) + create mode 100644 test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep + create mode 100644 test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o + +diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp +index 6adc0386ee..7e4222f087 100644 +--- a/lib/Driver/ToolChain.cpp ++++ b/lib/Driver/ToolChain.cpp +@@ -283,15 +283,12 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC, + const llvm::Triple &Triple = TC.getTriple(); + bool IsWindows = Triple.isOSWindows(); + +- if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86) +- return "i386"; +- + if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb) + return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows) + ? "armhf" + : "arm"; + +- return TC.getArchName(); ++ return llvm::Triple::getArchTypeName(TC.getArch()); + } + + std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, +diff --git a/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep b/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o b/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c +index e5aa870866..92b199b9d4 100644 +--- a/test/Driver/linux-ld.c ++++ b/test/Driver/linux-ld.c +@@ -71,6 +71,27 @@ + // CHECK-LD-RT: libclang_rt.builtins-x86_64.a" + // + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=i686-unknown-linux \ ++// RUN: --gcc-toolchain="" \ ++// RUN: --sysroot=%S/Inputs/basic_linux_tree \ ++// RUN: --rtlib=compiler-rt \ ++// RUN: | FileCheck --check-prefix=CHECK-LD-RT-I686 %s ++// CHECK-LD-RT-I686-NOT: warning: ++// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" ++// CHECK-LD-RT-I686: "--eh-frame-hdr" ++// CHECK-LD-RT-I686: "-m" "elf_i386" ++// CHECK-LD-RT-I686: "-dynamic-linker" ++// CHECK-LD-RT-I686: "{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o" ++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0" ++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib" ++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.." ++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib" ++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib" ++// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" ++// CHECK-LD-RT-I686: "-lc" ++// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ + // RUN: --target=arm-linux-androideabi \ + // RUN: --gcc-toolchain="" \ + // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +diff --git a/test/Driver/nostdlib.c b/test/Driver/nostdlib.c +index a9ef665c57..c9793d968c 100644 +--- a/test/Driver/nostdlib.c ++++ b/test/Driver/nostdlib.c +@@ -27,5 +27,5 @@ + // + // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' + // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +-// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i686.a" ++// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i386.a" + // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' +diff --git a/test/Driver/print-libgcc-file-name-clangrt.c b/test/Driver/print-libgcc-file-name-clangrt.c +index 9f8120c31d..28c758881d 100644 +--- a/test/Driver/print-libgcc-file-name-clangrt.c ++++ b/test/Driver/print-libgcc-file-name-clangrt.c +@@ -6,6 +6,12 @@ + // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a + + // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ ++// RUN: --target=i386-pc-linux \ ++// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s ++// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a ++ ++// Check whether alternate arch values map to the correct library. ++// ++// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ + // RUN: --target=i686-pc-linux \ +-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s +-// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a ++// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s +diff --git a/test/Driver/windows-cross.c b/test/Driver/windows-cross.c +index 5a2fe52b09..78b4981c9d 100644 +--- a/test/Driver/windows-cross.c ++++ b/test/Driver/windows-cross.c +@@ -59,7 +59,7 @@ + // RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86 + + // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address" +-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" "___asan_seh_interceptor" ++// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i386.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib" "--undefined" "___asan_seh_interceptor" + + // RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \ + // RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-TSAN +-- +2.11.0 + diff --git a/sys-devel/llvm/.llvm-5.0.9999.ebuild.swp b/sys-devel/llvm/.llvm-5.0.9999.ebuild.swp Binary files differnew file mode 100644 index 0000000..13d4ee7 --- /dev/null +++ b/sys-devel/llvm/.llvm-5.0.9999.ebuild.swp diff --git a/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch b/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch new file mode 100644 index 0000000..b857136 --- /dev/null +++ b/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch @@ -0,0 +1,56 @@ +From 937b23b5fffa59deb1dc342cc5602d387d84a762 Mon Sep 17 00:00:00 2001 +From: Michal Gorny <mgorny@gentoo.org> +Date: Mon, 27 Nov 2017 22:23:09 +0000 +Subject: [PATCH] [cmake] Pass -Wl,-z,nodelete on Linux to prevent unloading + +Prevent unloading shared libraries on Linux when dlclose() is called. +This is necessary since command-line option parsing API relies on +registering the global option instances in the option parser instance +which can be loaded in a different shared library. + +Given that we can't reliably remove those options when a library is +unloaded, the parser ends up containing dangling references. Since glibc +has relatively complex library unloading rules, some of the LLVM +libraries can be unloaded while others (including the Support library) +stay loaded causing quite a mayhem. To reliably prevent that, just +forbid unloading all libraries -- it's a very bad idea anyway. + +While the issue arguably happens only with BUILD_SHARED_LIBS, it may +affect any library reusing llvm::cl interface. + +Based on patch provided Ross Hayward on https://bugs.gentoo.org/617154. +Previously hit by Fedora back in Feb 2016: +https://lists.freedesktop.org/archives/mesa-dev/2016-February/107242.html + +Differential Revision: https://reviews.llvm.org/D40459 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319105 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + cmake/modules/HandleLLVMOptions.cmake | 8 ++++++++ + unittests/Support/DynamicLibrary/CMakeLists.txt | 7 +++++++ + 2 files changed, 15 insertions(+) + + 4.0.1 backport: removed the unittest part + +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index c5390371845..b5059a8a60e 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -151,6 +151,14 @@ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") + endif() + ++# Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded ++# by dlclose(). We need that since the CLI API relies on cross-references ++# between global objects which became horribly broken when one of the libraries ++# is unloaded. ++if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete") ++endif() ++ + + function(append value) + foreach(variable ${ARGN}) +-- +2.15.1 + diff --git a/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch b/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file mode 100644 index 0000000..5def55d --- /dev/null +++ b/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch @@ -0,0 +1,54 @@ +From 628b899be14a6bab4b32dbd53aabd447dcc16cb7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Sat, 20 Aug 2016 23:47:41 +0200 +Subject: [PATCH] llvm-config: Clean up exported values, update for shared + linking + +Gentoo-specific fixup for llvm-config, including: +- wiping build-specific CFLAGS, CXXFLAGS, +- making --src-root return invalid path (/dev/null). + +Thanks to Steven Newbury for the initial patch. + +Bug: https://bugs.gentoo.org/565358 +Bug: https://bugs.gentoo.org/501684 + +diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt +index 744fa4e44d1..593788aaef3 100644 +--- a/tools/llvm-config/CMakeLists.txt ++++ b/tools/llvm-config/CMakeLists.txt +@@ -32,8 +32,12 @@ get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS) + set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR}) + set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR}) + set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") +-set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") +-set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}") ++# Just use CMAKE_CPP_FLAGS for CFLAGS and CXXFLAGS, otherwise compiler ++# specific flags will be set when we don't know what compiler will be used ++# with external project utilising llvm-config. C++ Standard is required. ++# TODO: figure out if we can remove -std=c++11 and move it to revdeps. ++set(LLVM_CFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") ++set(LLVM_CXXFLAGS "${CMAKE_CPP_FLAGS} -std=c++11 ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") + set(LLVM_BUILD_SYSTEM cmake) + set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI}) + set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}") +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index d780094861c..c61c72ff48c 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -549,7 +550,11 @@ int main(int argc, char **argv) { + } else if (Arg == "--obj-root") { + OS << ActivePrefix << '\n'; + } else if (Arg == "--src-root") { +- OS << LLVM_SRC_ROOT << '\n'; ++ if (IsInDevelopmentTree) { ++ OS << LLVM_SRC_ROOT << '\n'; ++ } else { ++ OS << "/dev/null\n"; ++ } + } else if (Arg == "--ignore-libllvm") { + LinkDyLib = false; + LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto; +-- +2.11.0 + |