@@ -, +, @@ -rtlib=compiler-rt. --- .../llvm/files/9999/unwind_linking.patch | 44 +++++++++++++++++++ sys-devel/llvm/llvm-10.0.0.9999.ebuild | 17 +++++++ sys-devel/llvm/llvm-10.0.0.ebuild | 17 +++++++ sys-devel/llvm/llvm-11.0.0.9999.ebuild | 17 +++++++ 4 files changed, 95 insertions(+) create mode 100644 sys-devel/llvm/files/9999/unwind_linking.patch --- a/sys-devel/llvm/files/9999/unwind_linking.patch +++ a/sys-devel/llvm/files/9999/unwind_linking.patch @@ -0,0 +1,44 @@ +--- /CMakeLists.txt ++++ /CMakeLists.txt +@@ -335,6 +335,7 @@ if(LLVM_ENABLE_BACKTRACES) + endif() + + option(LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON) ++set(UNWIND_LIBRARIES "" CACHE STRING "Additional libraries needed for unwind functions") + + option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON) + if(LLVM_ENABLE_CRASH_OVERRIDES) +--- /cmake/modules/AddLLVM.cmake ++++ /cmake/modules/AddLLVM.cmake +@@ -641,6 +641,9 @@ function(llvm_add_library name) + ${lib_deps} + ${llvm_libs} + ) ++ if(UNWIND_LIBRARIES) ++ target_link_libraries(${name} PRIVATE -Wl,--push-state -Wl,--as-needed ${UNWIND_LIBRARIES} -Wl,--pop-state) ++ endif() + + if(LLVM_COMMON_DEPENDS) + add_dependencies(${name} ${LLVM_COMMON_DEPENDS}) +@@ -868,6 +871,9 @@ macro(add_llvm_executable name) + # API for all shared libaries loaded by this executable. + target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB}) + endif() ++ if(UNWIND_LIBRARIES) ++ target_link_libraries(${name} PRIVATE -Wl,--push-state -Wl,--as-needed ${UNWIND_LIBRARIES} -Wl,--pop-state) ++ endif() + + llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH}) + endmacro(add_llvm_executable name) +--- /unittests/Support/DynamicLibrary/CMakeLists.txt ++++ /unittests/Support/DynamicLibrary/CMakeLists.txt +@@ -26,6 +26,9 @@ function(dynlib_add_module NAME) + PipSqueak.cpp + ) + set_target_properties(${NAME} PROPERTIES FOLDER "Tests") ++ if(UNWIND_LIBRARIES) ++ target_link_libraries(${NAME} PRIVATE -Wl,--push-state -Wl,--as-needed ${UNWIND_LIBRARIES} -Wl,--pop-state) ++ endif() + + set_output_directory(${NAME} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR} --- a/sys-devel/llvm/llvm-10.0.0.9999.ebuild +++ a/sys-devel/llvm/llvm-10.0.0.9999.ebuild @@ -174,6 +174,8 @@ 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 + eapply "${FILESDIR}"/9999/unwind_linking.patch + # disable use of SDK on OSX, bug #568758 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die @@ -372,6 +374,21 @@ multilib_src_configure() { ) fi + if tc-is-clang; then + local compiler_rt=$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name) + if [[ ${compiler_rt} == *libclang_rt* ]]; then + if has_version sys-libs/llvm-libunwind; then + mycmakeargs+=( + -DUNWIND_LIBRARIES=unwind + ) + else + mycmakeargs+=( + -DUNWIND_LIBRARIES=gcc_s + ) + fi + fi + fi + # Note: go bindings have no CMake rules at the moment # but let's kill the check in case they are introduced # if ! multilib_is_native_abi || ! use go; then --- a/sys-devel/llvm/llvm-10.0.0.ebuild +++ a/sys-devel/llvm/llvm-10.0.0.ebuild @@ -99,6 +99,8 @@ 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 + eapply "${FILESDIR}"/9999/unwind_linking.patch + # disable use of SDK on OSX, bug #568758 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die @@ -294,6 +296,21 @@ multilib_src_configure() { ) fi + if tc-is-clang; then + local compiler_rt=$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name) + if [[ ${compiler_rt} == *libclang_rt* ]]; then + if has_version sys-libs/llvm-libunwind; then + mycmakeargs+=( + -DUNWIND_LIBRARIES=unwind + ) + else + mycmakeargs+=( + -DUNWIND_LIBRARIES=gcc_s + ) + fi + fi + fi + # Note: go bindings have no CMake rules at the moment # but let's kill the check in case they are introduced # if ! multilib_is_native_abi || ! use go; then --- a/sys-devel/llvm/llvm-11.0.0.9999.ebuild +++ a/sys-devel/llvm/llvm-11.0.0.9999.ebuild @@ -174,6 +174,8 @@ 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 + eapply "${FILESDIR}"/9999/unwind_linking.patch + # disable use of SDK on OSX, bug #568758 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die @@ -374,6 +376,21 @@ multilib_src_configure() { ) fi + if tc-is-clang; then + local compiler_rt=$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -print-libgcc-file-name) + if [[ ${compiler_rt} == *libclang_rt* ]]; then + if has_version sys-libs/llvm-libunwind; then + mycmakeargs+=( + -DUNWIND_LIBRARIES=unwind + ) + else + mycmakeargs+=( + -DUNWIND_LIBRARIES=gcc_s + ) + fi + fi + fi + # Note: go bindings have no CMake rules at the moment # but let's kill the check in case they are introduced # if ! multilib_is_native_abi || ! use go; then --