From 675f40c259416b14d4cd169da1f9e6b9e8df5a2d Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Mon, 21 Sep 2020 03:42:12 +0200 Subject: [PATCH] libllvm: add libcompiler-rt subpackage Fixes https://github.com/termux/termux-packages/issues/2403. --- packages/libllvm/build.sh | 19 ++++++++++-- packages/libllvm/clang.subpackage.sh | 5 +++- packages/libllvm/compiler-rt-ndk-version.diff | 11 +++++++ packages/libllvm/libcompiler-rt.subpackage.sh | 13 ++++++++ .../projects-compiler-rt-CMakeLists.txt.patch | 30 +++++++++++++++++++ 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 packages/libllvm/compiler-rt-ndk-version.diff create mode 100644 packages/libllvm/libcompiler-rt.subpackage.sh create mode 100644 packages/libllvm/projects-compiler-rt-CMakeLists.txt.patch diff --git a/packages/libllvm/build.sh b/packages/libllvm/build.sh index befec22cf..7e913d1ed 100644 --- a/packages/libllvm/build.sh +++ b/packages/libllvm/build.sh @@ -2,17 +2,19 @@ TERMUX_PKG_HOMEPAGE=https://clang.llvm.org/ TERMUX_PKG_DESCRIPTION="Modular compiler and toolchain technologies library" TERMUX_PKG_LICENSE="NCSA" TERMUX_PKG_VERSION=10.0.1 -TERMUX_PKG_REVISION=2 +TERMUX_PKG_REVISION=3 TERMUX_PKG_SHA256=(c5d8e30b57cbded7128d78e5e8dad811bff97a8d471896812f57fa99ee82cdf3 f99afc382b88e622c689b6d96cadfa6241ef55dca90e87fc170352e12ddb2b24 591449e0aa623a6318d5ce2371860401653c48bb540982ccdd933992cb88df7a d19f728c8e04fb1e94566c8d76aef50ec926cd2f95ef3bf1e0a5de4909b28b44 - d093782bcfcd0c3f496b67a5c2c997ab4b85816b62a7dd5b27026634ccf5c11a) + d093782bcfcd0c3f496b67a5c2c997ab4b85816b62a7dd5b27026634ccf5c11a + d90dc8e121ca0271f0fd3d639d135bfaa4b6ed41e67bd6eb77808f72629658fa) TERMUX_PKG_SRCURL=(https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/llvm-$TERMUX_PKG_VERSION.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/clang-$TERMUX_PKG_VERSION.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/lld-$TERMUX_PKG_VERSION.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/openmp-$TERMUX_PKG_VERSION.src.tar.xz - https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/clang-tools-extra-$TERMUX_PKG_VERSION.src.tar.xz) + https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/clang-tools-extra-$TERMUX_PKG_VERSION.src.tar.xz + https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/compiler-rt-$TERMUX_PKG_VERSION.src.tar.xz) TERMUX_PKG_HOSTBUILD=true TERMUX_PKG_RM_AFTER_INSTALL=" lib/libgomp.a @@ -59,6 +61,7 @@ termux_step_post_get_source() { mv clang-tools-extra-${TERMUX_PKG_VERSION}.src tools/clang/tools/extra mv lld-${TERMUX_PKG_VERSION}.src tools/lld mv openmp-${TERMUX_PKG_VERSION}.src projects/openmp + mv compiler-rt-${TERMUX_PKG_VERSION}.src projects/compiler-rt fi } @@ -71,6 +74,11 @@ termux_step_host_build() { } termux_step_pre_configure() { + echo "Applying patch: compiler-rt-ndk-version.diff" + sed "s%\@TERMUX_NDK_VERSION_NUM\@%${TERMUX_NDK_VERSION_NUM}%g" \ + "$TERMUX_PKG_BUILDER_DIR/compiler-rt-ndk-version.diff" | \ + patch --silent -p1 + if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then mkdir projects/openmp/runtime/src/android cp $TERMUX_PKG_BUILDER_DIR/nl_types.h projects/openmp/runtime/src/android @@ -114,6 +122,11 @@ termux_step_post_make_install() { for tool in clang clang++ cc c++ cpp gcc g++ ${TERMUX_HOST_PLATFORM}-{clang,clang++,gcc,g++,cpp}; do ln -f -s clang-${TERMUX_PKG_VERSION:0:2} $tool done + + cd $TERMUX_PREFIX/lib/clang/$TERMUX_PKG_VERSION/lib/ + # Trying to build a program with -fsanitizer=address on device leads to an error + # due to clang looking for the libs in linux/ and not android/ + mv android/ linux/ } termux_step_post_massage() { diff --git a/packages/libllvm/clang.subpackage.sh b/packages/libllvm/clang.subpackage.sh index bf0fc0184..ebfa92dc8 100644 --- a/packages/libllvm/clang.subpackage.sh +++ b/packages/libllvm/clang.subpackage.sh @@ -9,7 +9,10 @@ bin/git-clang-format bin/scan-* include/clang* include/omp.h -lib/clang +lib/clang/*/include/*.h +lib/clang/*/include/openmp_wrappers/ +lib/clang/*/include/ppc_wrappers/ +lib/clang/*/include/cuda_wrappers/ lib/cmake/clang lib/libclang*so lib/libomp.a diff --git a/packages/libllvm/compiler-rt-ndk-version.diff b/packages/libllvm/compiler-rt-ndk-version.diff new file mode 100644 index 000000000..0307f5c0e --- /dev/null +++ b/packages/libllvm/compiler-rt-ndk-version.diff @@ -0,0 +1,11 @@ +--- ../projects-compiler-rt-CMakeLists.txt.orig 2020-09-22 14:12:54.771097201 +0000 ++++ ./projects/compiler-rt/CMakeLists.txt 2020-09-22 16:11:07.568559345 +0000 +@@ -114,7 +114,7 @@ + endif() + pythonize_bool(ANDROID) + +-set(ANDROID_NDK_VERSION 18 ++set(ANDROID_NDK_VERSION @TERMUX_NDK_VERSION_NUM@ + CACHE STRING "Set this to the Android NDK version that you are using") + + set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/packages/libllvm/libcompiler-rt.subpackage.sh b/packages/libllvm/libcompiler-rt.subpackage.sh new file mode 100644 index 000000000..96d83a963 --- /dev/null +++ b/packages/libllvm/libcompiler-rt.subpackage.sh @@ -0,0 +1,13 @@ +TERMUX_SUBPKG_DESCRIPTION="Compiler runtime libraries for clang" +TERMUX_SUBPKG_INCLUDE=" +lib/clang/**/bin/asan_device_setup +lib/clang/**/bin/hwasan_symbolize +lib/clang/**/include/fuzzer/FuzzedDataProvider.h +lib/clang/**/include/profile/InstrProfData.inc +lib/clang/**/include/sanitizer/ +lib/clang/**/include/xray/ +lib/clang/**/lib/linux/ +lib/clang/**/share/asan_blacklist.txt +lib/clang/**/share/cfi_blacklist.txt +lib/clang/**/share/hwasan_blacklist.txt +" diff --git a/packages/libllvm/projects-compiler-rt-CMakeLists.txt.patch b/packages/libllvm/projects-compiler-rt-CMakeLists.txt.patch new file mode 100644 index 000000000..6082a0f8f --- /dev/null +++ b/packages/libllvm/projects-compiler-rt-CMakeLists.txt.patch @@ -0,0 +1,30 @@ +--- ../projects-compiler-rt-CMakeLists.txt.orig 2020-09-22 14:12:54.771097201 +0000 ++++ ./projects/compiler-rt/CMakeLists.txt 2020-09-22 16:11:07.568559345 +0000 +@@ -182,6 +182,9 @@ + elseif (FUCHSIA) + set(${var}_LIBNAME "libc++") + set(${var}_INTREE 1) ++ elseif (ANDROID) ++ set(${var}_LIBNAME "libc++_shared") ++ set(${var}_SYSTEM 1) + else() + set(${var}_LIBNAME "libstdc++") + set(${var}_SYSTEM 1) +@@ -196,7 +199,7 @@ + # which pulls in the ABI transitively. + set(SANITIZER_CXX_ABI "default" CACHE STRING + "Specify C++ ABI library to use.") +-set(CXXABIS none default libstdc++ libc++ libcxxabi) ++set(CXXABIS none default libc++_shared libstdc++ libc++ libcxxabi) + set_property(CACHE SANITIZER_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) + handle_default_cxx_lib(SANITIZER_CXX_ABI) + +@@ -438,6 +441,8 @@ + list(APPEND SANITIZER_CXX_ABI_LIBRARIES "c++abi") + elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libstdc++") + append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARIES) ++elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++_shared") ++ list(APPEND SANITIZER_CXX_ABI_LIBRARIES "c++_shared") + endif() + + if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++")