emscripten: update some details

* upstream now use LLVM 15, update patches
* drop building libunwind until further notice
* patch binaryen CMakeLists.txt
* should be able to run tests now that python3 multiprocessing works
This commit is contained in:
Jia Yuan Lo 2022-02-26 19:53:42 +08:00 committed by xtkoba
parent 33345543a2
commit 49f4c2dbe1
10 changed files with 82 additions and 49 deletions

View File

@ -0,0 +1,15 @@
diff -uNr binaryen/CMakeLists.txt binaryen.mod/CMakeLists.txt
--- binaryen/CMakeLists.txt 2022-02-26 23:46:13.824326901 +0800
+++ binaryen.mod/CMakeLists.txt 2022-02-27 00:20:59.532106415 +0800
@@ -317,7 +317,10 @@
add_subdirectory(test/lit)
# Configure GTest unit tests
-add_subdirectory(test/gtest)
+option(ENABLE_GTEST "Enable GTest unit tests" ON)
+if(ENABLE_GTEST)
+ add_subdirectory(test/gtest)
+endif()
# Object files
set(binaryen_objs

View File

@ -0,0 +1,28 @@
diff -uNr binaryen/third_party/CMakeLists.txt binaryen.mod/third_party/CMakeLists.txt
--- binaryen/third_party/CMakeLists.txt 2022-02-26 23:46:14.268336047 +0800
+++ binaryen.mod/third_party/CMakeLists.txt 2022-02-27 00:30:42.657030709 +0800
@@ -2,15 +2,14 @@
add_subdirectory(llvm-project)
endif()
-include_directories(
- googletest/googletest
- googletest/googletest/include
-)
+if(ENABLE_GTEST)
+ include_directories(
+ googletest/googletest
+ googletest/googletest/include)
-add_library(gtest STATIC
- googletest/googletest/src/gtest-all.cc
-)
+ add_library(gtest STATIC
+ googletest/googletest/src/gtest-all.cc)
-add_library(gtest_main STATIC
- googletest/googletest/src/gtest_main.cc
-)
+ add_library(gtest_main STATIC
+ googletest/googletest/src/gtest_main.cc)
+endif()

View File

@ -84,7 +84,7 @@ LLVM_BUILD_ARGS="
-DLLVM_ENABLE_LIBEDIT=OFF
-DLLVM_ENABLE_LIBPFM=OFF
-DLLVM_ENABLE_LIBXML2=OFF
-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;libunwind;lld
-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld
-DLLVM_ENABLE_TERMINFO=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
@ -104,14 +104,12 @@ LLVM_BUILD_ARGS="
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
-DCOMPILER_RT_BUILD_XRAY=OFF
-DCOMPILER_RT_INCLUDE_TESTS=OFF
-DLIBUNWIND_USE_COMPILER_RT=ON
"
# https://github.com/WebAssembly/binaryen/blob/main/CMakeLists.txt
BINARYEN_BUILD_ARGS="
-DCMAKE_BUILD_TYPE=MinSizeRel
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX/opt/emscripten-binaryen
-DENABLE_GTEST=OFF
"
termux_step_post_get_source() {
@ -130,6 +128,11 @@ termux_step_post_get_source() {
for patch in $TERMUX_PKG_BUILDER_DIR/llvm-project-*.patch.diff; do
patch -p1 -i "$patch"
done
cd "$TERMUX_PKG_CACHEDIR/binaryen-$BINARYEN_COMMIT"
for patch in $TERMUX_PKG_BUILDER_DIR/binaryen-*.patch.diff; do
patch -p1 -i "$patch"
done
}
termux_step_host_build() {
@ -231,9 +234,9 @@ termux_step_make_install() {
# 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"
# binutils LD searches lib/clang/15.0.0/lib/linux (exist)
# LLVM LD.LLD searches lib/clang/15.0.0/lib/android (not exist)
ln -fsT "linux" "$TERMUX_PREFIX/opt/emscripten-llvm/lib/clang/15.0.0/lib/android"
}
termux_step_create_debscripts() {
@ -289,7 +292,6 @@ termux_step_create_debscripts() {
# Steps:
# - pkg install emscripten-tests-third-party openjdk-17
# - cd $PREFIX/opt/emscripten
# - npm ci --no-optional
# - export EMCC_CORES=1
# - npm install --no-optional
# - export EMTEST_SKIP_V8=1
# - tests/runner {test_name}

View File

@ -1,7 +1,7 @@
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-11-27 10:21:24.849951600 +0800
+++ llvm-project.mod/clang/lib/Driver/ToolChain.cpp 2021-11-27 12:35:59.478509300 +0800
@@ -403,7 +403,7 @@
--- llvm-project/clang/lib/Driver/ToolChain.cpp 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/clang/lib/Driver/ToolChain.cpp 2022-02-26 20:33:29.973336795 +0800
@@ -414,7 +414,7 @@
case llvm::Triple::AIX:
return "aix";
default:
@ -10,7 +10,7 @@ diff -uNr llvm-project/clang/lib/Driver/ToolChain.cpp llvm-project.mod/clang/lib
}
}
@@ -941,7 +941,7 @@
@@ -965,7 +965,7 @@
switch (Type) {
case ToolChain::CST_Libcxx:

View File

@ -1,6 +1,6 @@
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-11-04 18:24:28.000000000 +0800
+++ llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp 2021-11-20 09:32:21.097136800 +0800
--- llvm-project/clang/lib/Driver/ToolChains/Linux.cpp 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp 2022-02-26 20:33:29.977336914 +0800
@@ -162,8 +162,8 @@
// FIXME: This is a bit of a hack. We should really unify this code for
// reasoning about oslibdir spellings with the lib dir spellings in the
@ -12,7 +12,7 @@ diff -uNr llvm-project/clang/lib/Driver/ToolChains/Linux.cpp llvm-project.mod/cl
return "lib32";
if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
@@ -294,7 +294,7 @@
@@ -291,7 +291,7 @@
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
Triple.isArch64Bit())
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
@ -21,7 +21,7 @@ diff -uNr llvm-project/clang/lib/Driver/ToolChains/Linux.cpp llvm-project.mod/cl
addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
if (IsRISCV) {
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
@@ -309,7 +309,7 @@
@@ -306,7 +306,7 @@
// searched.
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
@ -30,7 +30,7 @@ diff -uNr llvm-project/clang/lib/Driver/ToolChains/Linux.cpp llvm-project.mod/cl
// Even if OSLibDir != "lib", this is needed for Clang in the build
// directory (not installed) to find libc++.
addPathIfExists(D, D.Dir + "/../lib", Paths);
@@ -318,7 +318,15 @@
@@ -315,7 +315,15 @@
}
addPathIfExists(D, SysRoot + "/lib", Paths);

View File

@ -1,7 +1,7 @@
diff -uNr llvm-project/compiler-rt/CMakeLists.txt llvm-project.mod/compiler-rt/CMakeLists.txt
--- llvm-project/compiler-rt/CMakeLists.txt 2021-11-27 10:22:13.468604500 +0800
+++ llvm-project.mod/compiler-rt/CMakeLists.txt 2021-11-27 12:36:17.443010100 +0800
@@ -201,6 +201,9 @@
--- llvm-project/compiler-rt/CMakeLists.txt 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/compiler-rt/CMakeLists.txt 2022-02-26 20:33:34.369468491 +0800
@@ -186,6 +186,9 @@
elseif (FUCHSIA)
set(${var}_LIBNAME "libc++")
set(${var}_INTREE 1)
@ -11,7 +11,7 @@ diff -uNr llvm-project/compiler-rt/CMakeLists.txt llvm-project.mod/compiler-rt/C
else()
set(${var}_LIBNAME "libstdc++")
set(${var}_SYSTEM 1)
@@ -215,7 +218,7 @@
@@ -200,7 +203,7 @@
# which pulls in the ABI transitively.
set(SANITIZER_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use.")
@ -20,7 +20,7 @@ diff -uNr llvm-project/compiler-rt/CMakeLists.txt llvm-project.mod/compiler-rt/C
set_property(CACHE SANITIZER_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
handle_default_cxx_lib(SANITIZER_CXX_ABI)
@@ -526,6 +529,8 @@
@@ -528,6 +531,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)

View File

@ -1,7 +1,7 @@
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 @@
--- llvm-project/compiler-rt/lib/builtins/CMakeLists.txt 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/compiler-rt/lib/builtins/CMakeLists.txt 2022-02-26 20:33:34.373468611 +0800
@@ -738,6 +738,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)

View File

@ -1,7 +1,7 @@
diff -uNr llvm-project/libunwind/CMakeLists.txt llvm-project.mod/libunwind/CMakeLists.txt
--- llvm-project/libunwind/CMakeLists.txt 2021-11-27 10:22:36.327950400 +0800
+++ llvm-project.mod/libunwind/CMakeLists.txt 2021-11-27 12:36:37.310685400 +0800
@@ -212,6 +212,10 @@
--- llvm-project/libunwind/CMakeLists.txt 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/libunwind/CMakeLists.txt 2022-02-26 20:33:34.373468611 +0800
@@ -222,6 +222,10 @@
add_compile_flags_if_supported(-Werror=return-type)
if (LIBUNWIND_ENABLE_CET)

View File

@ -1,12 +0,0 @@
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

View File

@ -1,12 +1,12 @@
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
--- llvm-project/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp 2022-02-26 20:36:55.959542847 +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__)
-#if defined(__x86_64__) && defined(__ELF__) && defined(__linux__)
+#if defined(__x86_64__) && defined(__ELF__) && defined(__linux__) && !defined(__TERMUX__)
unsigned UsedTLSStorage = 0;
#endif
};
@ -14,8 +14,8 @@ diff -uNr llvm-project/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp llvm-project.mod/l
// 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__)
-#if defined(__x86_64__) && defined(__ELF__) && defined(__linux__)
+#if defined(__x86_64__) && defined(__ELF__) && defined(__linux__) && !defined(__TERMUX__)
extern "C" {
alignas(16) __attribute__((visibility("hidden"), tls_model("initial-exec"),
used)) thread_local char LLVMRTDyldTLSSpace[16];
@ -23,8 +23,8 @@ diff -uNr llvm-project/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp llvm-project.mod/l
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 defined(__x86_64__) && defined(__ELF__) && defined(__linux__)
+#if defined(__x86_64__) && defined(__ELF__) && defined(__linux__) && !defined(__TERMUX__)
if (Size + UsedTLSStorage > sizeof(LLVMRTDyldTLSSpace)) {
return {};
}