From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3F096139082 for ; Fri, 1 Dec 2017 23:41:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 74728E0DA3; Fri, 1 Dec 2017 23:40:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 416E0E0DA3 for ; Fri, 1 Dec 2017 23:40:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2B85033FE60 for ; Fri, 1 Dec 2017 23:40:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 333A5AE7C for ; Fri, 1 Dec 2017 23:40:53 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1512171643.3f7b543082fa986823d08a1df44eb8bf634f10df.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/llvm/files/4.0.1/, sys-devel/llvm/files/5.0.1/, sys-devel/llvm/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch sys-devel/llvm/llvm-4.0.1-r1.ebuild sys-devel/llvm/llvm-4.0.1.ebuild sys-devel/llvm/llvm-5.0.1_rc2.ebuild sys-devel/llvm/llvm-5.0.9999.ebuild X-VCS-Directories: sys-devel/llvm/files/4.0.1/ sys-devel/llvm/ sys-devel/llvm/files/5.0.1/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 3f7b543082fa986823d08a1df44eb8bf634f10df X-VCS-Branch: master Date: Fri, 1 Dec 2017 23:40:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c083da5f-3a91-493c-ba56-37de526bd17b X-Archives-Hash: ec9e3f117295218a619f07b14c5a5e04 commit: 3f7b543082fa986823d08a1df44eb8bf634f10df Author: Michał Górny gentoo org> AuthorDate: Fri Dec 1 16:23:42 2017 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri Dec 1 23:40:43 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3f7b5430 sys-devel/llvm: Backport unloading prevention fix Bug: https://bugs.gentoo.org/617154 ...Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch | 56 +++++++++++++++++ ...Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch | 71 ++++++++++++++++++++++ .../{llvm-4.0.1.ebuild => llvm-4.0.1-r1.ebuild} | 4 ++ sys-devel/llvm/llvm-5.0.1_rc2.ebuild | 4 ++ sys-devel/llvm/llvm-5.0.9999.ebuild | 4 ++ 5 files changed, 139 insertions(+) diff --git a/sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch b/sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch new file mode 100644 index 00000000000..b857136498b --- /dev/null +++ b/sys-devel/llvm/files/4.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 +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/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 00000000000..21702748893 --- /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,71 @@ +From 937b23b5fffa59deb1dc342cc5602d387d84a762 Mon Sep 17 00:00:00 2001 +From: Michal Gorny +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(+) + +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}) +diff --git a/unittests/Support/DynamicLibrary/CMakeLists.txt b/unittests/Support/DynamicLibrary/CMakeLists.txt +index 9355979221a..c6201b1ad31 100644 +--- a/unittests/Support/DynamicLibrary/CMakeLists.txt ++++ b/unittests/Support/DynamicLibrary/CMakeLists.txt +@@ -24,5 +24,12 @@ function(dynlib_add_module NAME) + add_dependencies(DynamicLibraryTests ${NAME}) + endfunction(dynlib_add_module) + ++# Revert -Wl,-z,nodelete on this test since it relies on the file ++# being unloaded. ++if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") ++ string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS ++ ${CMAKE_SHARED_LINKER_FLAGS}) ++endif() ++ + dynlib_add_module(PipSqueak) + dynlib_add_module(SecondLib) +-- +2.15.1 + diff --git a/sys-devel/llvm/llvm-4.0.1.ebuild b/sys-devel/llvm/llvm-4.0.1-r1.ebuild similarity index 97% rename from sys-devel/llvm/llvm-4.0.1.ebuild rename to sys-devel/llvm/llvm-4.0.1-r1.ebuild index 6ee123541ac..1931365e8a7 100644 --- a/sys-devel/llvm/llvm-4.0.1.ebuild +++ b/sys-devel/llvm/llvm-4.0.1-r1.ebuild @@ -75,6 +75,10 @@ src_prepare() { # https://bugs.gentoo.org/show_bug.cgi?id=565358 eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + # Backport the fix for dlclose() causing option parser mess + # e.g. https://bugs.gentoo.org/617154 + eapply "${FILESDIR}"/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch + # support building llvm against musl-libc use elibc_musl && eapply "${FILESDIR}"/9999/musl-fixes.patch diff --git a/sys-devel/llvm/llvm-5.0.1_rc2.ebuild b/sys-devel/llvm/llvm-5.0.1_rc2.ebuild index 374656b01b2..42978ec5cce 100644 --- a/sys-devel/llvm/llvm-5.0.1_rc2.ebuild +++ b/sys-devel/llvm/llvm-5.0.1_rc2.ebuild @@ -75,6 +75,10 @@ src_prepare() { # https://bugs.gentoo.org/show_bug.cgi?id=565358 eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + # Backport the fix for dlclose() causing option parser mess + # e.g. https://bugs.gentoo.org/617154 + eapply "${FILESDIR}"/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch + # disable use of SDK on OSX, bug #568758 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die diff --git a/sys-devel/llvm/llvm-5.0.9999.ebuild b/sys-devel/llvm/llvm-5.0.9999.ebuild index 3bf676e4360..2c8a9d8ecf0 100644 --- a/sys-devel/llvm/llvm-5.0.9999.ebuild +++ b/sys-devel/llvm/llvm-5.0.9999.ebuild @@ -75,6 +75,10 @@ src_prepare() { # https://bugs.gentoo.org/show_bug.cgi?id=565358 eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + # Backport the fix for dlclose() causing option parser mess + # e.g. https://bugs.gentoo.org/617154 + eapply "${FILESDIR}"/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch + # disable use of SDK on OSX, bug #568758 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die