libllvm: add libcompiler-rt subpackage

Fixes https://github.com/termux/termux-packages/issues/2403.
This commit is contained in:
Henrik Grimler 2020-09-21 03:42:12 +02:00
parent e10dbc14a7
commit 675f40c259
5 changed files with 74 additions and 4 deletions

View File

@ -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() {

View File

@ -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

View File

@ -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})

View File

@ -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
"

View File

@ -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++")