emscripten: update to 2.0.32 (#7905)
* emscripten: update to 2.0.32 * emscripten: drop debianutils Upstream has replaced "which" usage with POSIX "command -v" * emscripten: subpackage third party test suite * emscripten: add detail run test suite instruction * emscripten: use TERMUX_PKG_RM_AFTER_INSTALL * emscripten: split patch to separate diff files * emscripten-llvm: switch to use LLD
This commit is contained in:
parent
af28096a00
commit
cefee4f432
|
@ -2,16 +2,39 @@ TERMUX_PKG_HOMEPAGE=https://emscripten.org
|
|||
TERMUX_PKG_DESCRIPTION="Emscripten: An LLVM-to-WebAssembly Compiler"
|
||||
TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_MAINTAINER="@truboxl"
|
||||
TERMUX_PKG_VERSION=2.0.31
|
||||
TERMUX_PKG_REVISION=3
|
||||
TERMUX_PKG_VERSION=2.0.32
|
||||
TERMUX_PKG_SRCURL=https://github.com/emscripten-core/emscripten.git
|
||||
TERMUX_PKG_GIT_BRANCH=$TERMUX_PKG_VERSION
|
||||
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
||||
TERMUX_PKG_RECOMMENDS="emscripten-llvm, emscripten-binaryen, python, nodejs-lts | nodejs, debianutils"
|
||||
TERMUX_PKG_RECOMMENDS="emscripten-llvm, emscripten-binaryen, python, nodejs-lts | nodejs"
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
TERMUX_PKG_HOSTBUILD=true
|
||||
TERMUX_PKG_NO_STATICSPLIT=true
|
||||
|
||||
# remove files according to emsdk/upstream directory after running
|
||||
# ./emsdk install latest
|
||||
TERMUX_PKG_RM_AFTER_INSTALL="
|
||||
opt/emscripten-llvm/bin/clang-check
|
||||
opt/emscripten-llvm/bin/clang-cl
|
||||
opt/emscripten-llvm/bin/clang-cpp
|
||||
opt/emscripten-llvm/bin/clang-extdef-mapping
|
||||
opt/emscripten-llvm/bin/clang-format
|
||||
opt/emscripten-llvm/bin/clang-func-mapping
|
||||
opt/emscripten-llvm/bin/clang-import-test
|
||||
opt/emscripten-llvm/bin/clang-offload-bundler
|
||||
opt/emscripten-llvm/bin/clang-refactor
|
||||
opt/emscripten-llvm/bin/clang-rename
|
||||
opt/emscripten-llvm/bin/clang-scan-deps
|
||||
opt/emscripten-llvm/bin/ld.lld
|
||||
opt/emscripten-llvm/bin/ld64.lld
|
||||
opt/emscripten-llvm/bin/ld64.lld.darwin*
|
||||
opt/emscripten-llvm/bin/lld-link
|
||||
opt/emscripten-llvm/bin/llvm-lib
|
||||
opt/emscripten-llvm/lib/libclang.so*
|
||||
opt/emscripten-llvm/share
|
||||
opt/emscripten/LICENSE
|
||||
"
|
||||
|
||||
# https://github.com/emscripten-core/emscripten/blob/main/docs/packaging.md
|
||||
# https://github.com/archlinux/svntogit-community/tree/packages/emscripten/trunk
|
||||
# below generates commit hash for the deps according to emscripten releases
|
||||
|
@ -27,13 +50,13 @@ TERMUX_PKG_NO_STATICSPLIT=true
|
|||
|
||||
# https://github.com/emscripten-core/emscripten/issues/11362
|
||||
# can switch to stable LLVM to save space once above is fixed
|
||||
LLVM_COMMIT=8fa2394bad433558f3083cee158043e2fb66d781
|
||||
LLVM_TGZ_SHA256=5199e1e459a9b1308e145d775c540bac72d0a75b81a4558d08ffd7444412f8d1
|
||||
LLVM_COMMIT=9403514e764950a0dfcd627fc90c73432314bced
|
||||
LLVM_TGZ_SHA256=fb355b3cd159e0e699a32f7fb1e2612322b019ed73b4aa37b493fc7f9fe03f31
|
||||
|
||||
# https://github.com/emscripten-core/emscripten/issues/12252
|
||||
# upstream says better bundle the right binaryen revision for now
|
||||
BINARYEN_COMMIT=65bcde2c30e82047a892332b95b114bc86f89614
|
||||
BINARYEN_TGZ_SHA256=093bf206d34a7e239b4ae9dd9e9f393099622cebaa781d859b0f85e2305735d4
|
||||
BINARYEN_COMMIT=c19ff59c71824b34fa312aac9ad979e2198d7d36
|
||||
BINARYEN_TGZ_SHA256=cfd4d53d22c868587ffa8020f32e41fa9bb847b368d1c29dc82da2ce35e5d816
|
||||
|
||||
# https://github.com/emscripten-core/emsdk/blob/main/emsdk.py
|
||||
# https://chromium.googlesource.com/emscripten-releases/+/refs/heads/main/src/build.py
|
||||
|
@ -58,6 +81,7 @@ LLVM_BUILD_ARGS="
|
|||
-DLLVM_LINK_LLVM_DYLIB=ON
|
||||
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
|
||||
|
||||
-DCLANG_DEFAULT_LINKER=lld
|
||||
-DCLANG_ENABLE_ARCMT=OFF
|
||||
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
|
||||
-DCLANG_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/clang-tblgen
|
||||
|
@ -92,7 +116,9 @@ termux_step_post_get_source() {
|
|||
tar -xf "$TERMUX_PKG_CACHEDIR/binaryen.tar.gz" -C "$TERMUX_PKG_CACHEDIR"
|
||||
|
||||
cd "$TERMUX_PKG_CACHEDIR/llvm-project-$LLVM_COMMIT"
|
||||
git apply "$TERMUX_PKG_BUILDER_DIR/llvm-project.git-patch.txt"
|
||||
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch.diff; do
|
||||
patch -p1 -i "$patch"
|
||||
done
|
||||
}
|
||||
|
||||
termux_step_host_build() {
|
||||
|
@ -152,10 +178,13 @@ termux_step_make() {
|
|||
}
|
||||
|
||||
termux_step_make_install() {
|
||||
# skip using Makefile which does host npm install, tar archive and extract steps
|
||||
# skip using Makefile which does host npm install
|
||||
rm -fr "$TERMUX_PREFIX/opt/emscripten"
|
||||
./tools/install.py "$TERMUX_PREFIX/opt/emscripten"
|
||||
|
||||
# subpackage optional third party test suite files
|
||||
cp -fr "$TERMUX_PKG_SRCDIR/tests/third_party" "$TERMUX_PREFIX/opt/emscripten/tests/third_party"
|
||||
|
||||
# first run generates .emscripten and exits immediately
|
||||
rm -f "$TERMUX_PKG_SRCDIR/.emscripten"
|
||||
./emcc
|
||||
|
@ -166,34 +195,31 @@ termux_step_make_install() {
|
|||
grep "$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR/.emscripten"
|
||||
install -Dm644 "$TERMUX_PKG_SRCDIR/.emscripten" "$TERMUX_PREFIX/opt/emscripten/.emscripten"
|
||||
|
||||
# https://github.com/emscripten-core/emscripten/issues/9098 (fixed in 2.0.17)
|
||||
# add emscripten directory to PATH var
|
||||
cat <<- EOF > "$TERMUX_PKG_TMPDIR/emscripten.sh"
|
||||
#!$TERMUX_PREFIX/bin/sh
|
||||
export PATH=\$PATH:$TERMUX_PREFIX/opt/emscripten
|
||||
EOF
|
||||
install -Dm644 "$TERMUX_PKG_TMPDIR/emscripten.sh" "$TERMUX_PREFIX/etc/profile.d/emscripten.sh"
|
||||
|
||||
# remove unneeded files
|
||||
for tool in clang-{check,cl,cpp,extdef-mapping,format,func-mapping,import-test,offload-bundler,refactor,rename,scan-deps} \
|
||||
lld-link ld.lld ld64.lld llvm-lib ld64.lld.darwin{new,old}; do
|
||||
rm -f "$TERMUX_PREFIX/opt/emscripten-llvm/bin/$tool"
|
||||
done
|
||||
rm -f $TERMUX_PREFIX/opt/emscripten-llvm/lib/libclang.so*
|
||||
rm -fr "$TERMUX_PREFIX/opt/emscripten-llvm/share"
|
||||
|
||||
# termux_step_install_license also handles LICENSE file
|
||||
rm -f "$TERMUX_PREFIX/opt/emscripten/LICENSE"
|
||||
|
||||
# add useful tools not installed by LLVM_INSTALL_TOOLCHAIN_ONLY=ON
|
||||
for tool in FileCheck llc llvm-{as,dis,link,mc,nm,objdump,readobj,size,dwarfdump,dwp} opt; do
|
||||
install -Dm755 "$TERMUX_PKG_CACHEDIR/build-llvm/bin/$tool" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/$tool"
|
||||
done
|
||||
|
||||
# unable to determine the reason why different linker searches for
|
||||
# libclang_rt.builtins-*-android.a in different paths even after adding
|
||||
# the patches from libllvm (also which one is more correct?)
|
||||
#
|
||||
# binutils LD searches lib/clang/14.0.0/lib/linux (exist)
|
||||
# LLVM LD.LLD searches lib/clang/14.0.0/lib/android (not exist)
|
||||
ln -fsT "linux" "$TERMUX_PREFIX/opt/emscripten-llvm/lib/clang/14.0.0/lib/android"
|
||||
}
|
||||
|
||||
termux_step_create_debscripts() {
|
||||
cat <<- EOF > postinst
|
||||
#!$TERMUX_PREFIX/bin/sh
|
||||
if [ -n "\$(which npm)" ]; then
|
||||
if [ -n "\$(command -v npm)" ]; then
|
||||
echo 'Running "npm ci --no-optional --production" in $TERMUX_PREFIX/opt/emscripten ...'
|
||||
cd "$TERMUX_PREFIX/opt/emscripten"
|
||||
npm ci --no-optional --production
|
||||
|
@ -207,17 +233,14 @@ termux_step_create_debscripts() {
|
|||
please start a new session to take effect.
|
||||
If you are upgrading, you may want to clear the
|
||||
cache by running the command below to fix issues.
|
||||
"emcc --clear-cache"
|
||||
|
||||
Optional: Run the command below in Emscripten
|
||||
directory to install tests dependencies before
|
||||
running test suite.
|
||||
"npm ci --no-optional"'
|
||||
emcc --clear-cache'
|
||||
if [ -d "$TERMUX_PREFIX/lib/emscripten" ]; then
|
||||
echo '
|
||||
Note: The old Emscripten path has been deprecated.
|
||||
To delete, simply run the command below.
|
||||
"rm -fr $TERMUX_PREFIX/lib/emscripten"'
|
||||
|
||||
rm -fr $TERMUX_PREFIX/lib/emscripten'
|
||||
fi
|
||||
echo '
|
||||
===================='
|
||||
|
@ -231,3 +254,18 @@ termux_step_create_debscripts() {
|
|||
esac
|
||||
EOF
|
||||
}
|
||||
|
||||
# Emscripten Test Suite (Optional)
|
||||
# Some preparations need to be made in Emscripten directory before running
|
||||
# test suite on Android / Termux. Refer docs below:
|
||||
# https://emscripten.org/docs/getting_started/test-suite.html
|
||||
# https://github.com/emscripten-core/emscripten/pull/13493
|
||||
# https://github.com/emscripten-core/emscripten/issues/9098
|
||||
#
|
||||
# Steps:
|
||||
# - pkg install emscripten-tests-third-party openjdk-17
|
||||
# - cd $PREFIX/opt/emscripten
|
||||
# - npm ci --no-optional
|
||||
# - export EMCC_CORES=1
|
||||
# - export EMTEST_SKIP_V8=1
|
||||
# - tests/runner {test_name}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
TERMUX_SUBPKG_DESCRIPTION="Emscripten third party test suite files"
|
||||
TERMUX_SUBPKG_PLATFORM_INDEPENDENT=true
|
||||
TERMUX_SUBPKG_INCLUDE="opt/emscripten/tests/third_party"
|
|
@ -0,0 +1,21 @@
|
|||
diff -uNr llvm-project/clang/lib/Driver/ToolChain.cpp llvm-project.mod/clang/lib/Driver/ToolChain.cpp
|
||||
--- llvm-project/clang/lib/Driver/ToolChain.cpp 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/clang/lib/Driver/ToolChain.cpp 2021-10-29 10:06:11.727942353 +0800
|
||||
@@ -405,7 +405,7 @@
|
||||
case llvm::Triple::AIX:
|
||||
return "aix";
|
||||
default:
|
||||
- return getOS();
|
||||
+ return Triple.isAndroid() ? "android":getOS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -943,7 +943,7 @@
|
||||
|
||||
switch (Type) {
|
||||
case ToolChain::CST_Libcxx:
|
||||
- CmdArgs.push_back("-lc++");
|
||||
+ CmdArgs.push_back("-lc++_shared");
|
||||
break;
|
||||
|
||||
case ToolChain::CST_Libstdcxx:
|
|
@ -0,0 +1,38 @@
|
|||
diff -uNr llvm-project/clang/lib/Driver/ToolChains/Linux.cpp llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
--- llvm-project/clang/lib/Driver/ToolChains/Linux.cpp 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp 2021-10-29 14:39:16.043930634 +0800
|
||||
@@ -287,7 +287,7 @@
|
||||
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
|
||||
Triple.isArch64Bit())
|
||||
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
|
||||
- else
|
||||
+ else if (!IsAndroid)
|
||||
addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
|
||||
if (IsRISCV) {
|
||||
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
|
||||
@@ -302,7 +302,7 @@
|
||||
// searched.
|
||||
// FIXME: It's not clear whether we should use the driver's installed
|
||||
// directory ('Dir' below) or the ResourceDir.
|
||||
- if (StringRef(D.Dir).startswith(SysRoot)) {
|
||||
+ if (StringRef(D.Dir).startswith(SysRoot) && !IsAndroid) {
|
||||
// Even if OSLibDir != "lib", this is needed for Clang in the build
|
||||
// directory (not installed) to find libc++.
|
||||
addPathIfExists(D, D.Dir + "/../lib", Paths);
|
||||
@@ -311,7 +311,15 @@
|
||||
}
|
||||
|
||||
addPathIfExists(D, SysRoot + "/lib", Paths);
|
||||
- addPathIfExists(D, SysRoot + "/usr/lib", Paths);
|
||||
+ bool nativeBuild = MultiarchTriple == getMultiarchTriple(D, llvm::Triple(llvm::sys::getDefaultTargetTriple()), SysRoot);
|
||||
+ if (nativeBuild || !IsAndroid)
|
||||
+ addPathIfExists(D, SysRoot + "/usr/lib", Paths);
|
||||
+
|
||||
+ if (IsAndroid) {
|
||||
+ addPathIfExists(D, SysRoot + "/usr/" + MultiarchTriple + "/lib", Paths);
|
||||
+ addPathIfExists(D, "/system/" + OSLibDir, Paths);
|
||||
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
|
||||
+ }
|
||||
}
|
||||
|
||||
ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
|
|
@ -0,0 +1,31 @@
|
|||
diff -uNr llvm-project/compiler-rt/CMakeLists.txt llvm-project.mod/compiler-rt/CMakeLists.txt
|
||||
--- llvm-project/compiler-rt/CMakeLists.txt 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/compiler-rt/CMakeLists.txt 2021-10-29 15:54:24.623927409 +0800
|
||||
@@ -201,6 +201,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)
|
||||
@@ -215,7 +218,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)
|
||||
|
||||
@@ -524,6 +527,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++")
|
|
@ -0,0 +1,12 @@
|
|||
diff -uNr llvm-project/compiler-rt/lib/builtins/CMakeLists.txt llvm-project.mod/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
--- llvm-project/compiler-rt/lib/builtins/CMakeLists.txt 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/compiler-rt/lib/builtins/CMakeLists.txt 2021-10-29 10:02:39.095942505 +0800
|
||||
@@ -732,6 +732,8 @@
|
||||
# Release mode already sets it via -O2/3, Debug mode doesn't.
|
||||
if (${arch} STREQUAL "armhf")
|
||||
list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
|
||||
+ elseif(${arch} STREQUAL "arm" AND ANDROID)
|
||||
+ list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer)
|
||||
endif()
|
||||
|
||||
# For RISCV32, we must force enable int128 for compiling long
|
|
@ -0,0 +1,14 @@
|
|||
diff -uNr llvm-project/libunwind/CMakeLists.txt llvm-project.mod/libunwind/CMakeLists.txt
|
||||
--- llvm-project/libunwind/CMakeLists.txt 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/libunwind/CMakeLists.txt 2021-10-29 10:02:54.163942494 +0800
|
||||
@@ -194,6 +194,10 @@
|
||||
add_compile_flags_if_supported(-Werror=return-type)
|
||||
|
||||
if (LIBUNWIND_ENABLE_CET)
|
||||
+ if (NOT "libunwind" IN_LIST LLVM_ENABLE_RUNTIMES
|
||||
+ AND "clang" IN_LIST LLVM_ENABLE_PROJECTS)
|
||||
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../clang/lib/Headers")
|
||||
+ endif()
|
||||
add_compile_flags_if_supported(-fcf-protection=full)
|
||||
add_compile_flags_if_supported(-mshstk)
|
||||
if (NOT LIBUNWIND_SUPPORTS_FCF_PROTECTION_EQ_FULL_FLAG)
|
|
@ -0,0 +1,12 @@
|
|||
diff -uNr llvm-project/libunwind/src/assembly.h llvm-project.mod/libunwind/src/assembly.h
|
||||
--- llvm-project/libunwind/src/assembly.h 2021-10-01 20:31:40.000000000 +0800
|
||||
+++ llvm-project.mod/libunwind/src/assembly.h 2021-10-25 01:37:06.375932899 +0800
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef UNWIND_ASSEMBLY_H
|
||||
#define UNWIND_ASSEMBLY_H
|
||||
|
||||
-#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
|
||||
+#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__) && defined(_LIBUNWIND_USE_CET)
|
||||
#include <cet.h>
|
||||
#define _LIBUNWIND_CET_ENDBR _CET_ENDBR
|
||||
#else
|
|
@ -0,0 +1,30 @@
|
|||
diff -uNr llvm-project/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp llvm-project.mod/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
|
||||
--- llvm-project/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp 2021-10-20 02:24:04.000000000 +0800
|
||||
+++ llvm-project.mod/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp 2021-10-29 10:03:12.035942481 +0800
|
||||
@@ -286,7 +286,7 @@
|
||||
uintptr_t SlabSize = 0;
|
||||
uintptr_t CurrentSlabOffset = 0;
|
||||
SectionIDMap *SecIDMap = nullptr;
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
unsigned UsedTLSStorage = 0;
|
||||
#endif
|
||||
};
|
||||
@@ -350,7 +350,7 @@
|
||||
|
||||
// In case the execution needs TLS storage, we define a very small TLS memory
|
||||
// area here that will be used in allocateTLSSection().
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
extern "C" {
|
||||
alignas(16) __attribute__((visibility("hidden"), tls_model("initial-exec"),
|
||||
used)) thread_local char LLVMRTDyldTLSSpace[16];
|
||||
@@ -361,7 +361,7 @@
|
||||
TrivialMemoryManager::allocateTLSSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID,
|
||||
StringRef SectionName) {
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
if (Size + UsedTLSStorage > sizeof(LLVMRTDyldTLSSpace)) {
|
||||
return {};
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
|
||||
index 16331d948b12..c99b3574e218 100644
|
||||
--- a/libunwind/CMakeLists.txt
|
||||
+++ b/libunwind/CMakeLists.txt
|
||||
@@ -188,6 +188,10 @@ endif()
|
||||
add_compile_flags_if_supported(-Werror=return-type)
|
||||
|
||||
if (LIBUNWIND_ENABLE_CET)
|
||||
+ if (NOT "libunwind" IN_LIST LLVM_ENABLE_RUNTIMES
|
||||
+ AND "clang" IN_LIST LLVM_ENABLE_PROJECTS)
|
||||
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../clang/lib/Headers")
|
||||
+ endif()
|
||||
add_compile_flags_if_supported(-fcf-protection=full)
|
||||
add_compile_flags_if_supported(-mshstk)
|
||||
if (NOT LIBUNWIND_SUPPORTS_FCF_PROTECTION_EQ_FULL_FLAG)
|
||||
diff --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
|
||||
index e38d32336929..aadb4bc6a083 100644
|
||||
--- a/libunwind/src/assembly.h
|
||||
+++ b/libunwind/src/assembly.h
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef UNWIND_ASSEMBLY_H
|
||||
#define UNWIND_ASSEMBLY_H
|
||||
|
||||
-#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
|
||||
+#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__) && defined(_LIBUNWIND_USE_CET)
|
||||
#include <cet.h>
|
||||
#define _LIBUNWIND_CET_ENDBR _CET_ENDBR
|
||||
#else
|
||||
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
|
||||
index 02c11f7689fb..eb6a02ec9198 100644
|
||||
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
|
||||
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
|
||||
@@ -285,7 +285,7 @@ private:
|
||||
uintptr_t SlabSize = 0;
|
||||
uintptr_t CurrentSlabOffset = 0;
|
||||
SectionIDMap *SecIDMap = nullptr;
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
unsigned UsedTLSStorage = 0;
|
||||
#endif
|
||||
};
|
||||
@@ -347,7 +347,7 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
|
||||
|
||||
// In case the execution needs TLS storage, we define a very small TLS memory
|
||||
// area here that will be used in allocateTLSSection().
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
extern "C" {
|
||||
alignas(16) __attribute__((visibility("hidden"), tls_model("initial-exec"),
|
||||
used)) thread_local char LLVMRTDyldTLSSpace[16];
|
||||
@@ -358,7 +358,7 @@ TrivialMemoryManager::TLSSection
|
||||
TrivialMemoryManager::allocateTLSSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID,
|
||||
StringRef SectionName) {
|
||||
-#if defined(__x86_64__) && defined(__ELF__)
|
||||
+#if defined(__x86_64__) && defined(__ELF__) && !defined(__TERMUX__)
|
||||
if (Size + UsedTLSStorage > sizeof(LLVMRTDyldTLSSpace)) {
|
||||
return {};
|
||||
}
|
Loading…
Reference in New Issue