mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
Toolchain+Ports: Update LLVM to 14.0.1
Besides a version bump, the following changes have been made to our toolchain infrastructure: - LLVM/Clang is now built with -march=native if the host compiler supports it. An exception to this is CI, as the toolchain cache is shared among many different machines there. - The LLVM tarball is not re-extracted if the hash of the applied patches doesn't differ. - The patches have been split up into atomic chunks. - Port-specific patches have been integrated into the main patches, which will aid in the work towards self-hosting. - <sysroot>/usr/local/lib is now appended to the linker's search path by default. - --pack-dyn-relocs=relr is appended to the linker command line by default, meaning ports take advantage of RELR relocations without any patches or additional compiler flags. The formatting of LLVM port's package.sh has been bothering me, so I also indented the arguments to the CMake invocation.
This commit is contained in:
parent
9a898df1cd
commit
01b31d9858
22 changed files with 664 additions and 1007 deletions
|
@ -1,54 +1,52 @@
|
|||
#!/usr/bin/env -S bash ../.port_include.sh
|
||||
port=llvm
|
||||
useconfigure=true
|
||||
version=13.0.0
|
||||
workdir=llvm-project-llvmorg-${version}
|
||||
version=14.0.1
|
||||
workdir=llvm-project-${version}.src
|
||||
configopts=("-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt")
|
||||
files="https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${version}.zip llvm.zip 333a4e053fb543d9efb8dc68126d9e7a948ecb246985f2804a0ecbc5ccdb9d08"
|
||||
files="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz llvm-project-${version}.src.tar.xz 1a3c2e57916c5a70153aaf0a0e6f1230d6368b9e0f4d04dcb9e039a31b1cd4e6"
|
||||
auth_type=sha256
|
||||
depends=("ncurses" "zlib")
|
||||
|
||||
pre_patch() {
|
||||
host_env
|
||||
mkdir -p llvm-host
|
||||
cmake ${workdir}/llvm \
|
||||
-B llvm-host \
|
||||
-DLLVM_ENABLE_PROJECTS=clang
|
||||
make -C llvm-host -j $(nproc) llvm-tblgen clang-tblgen
|
||||
target_env
|
||||
}
|
||||
|
||||
configure() {
|
||||
# The cross compilers will be picked up from the CMake toolchain file.
|
||||
# CC/CXX must point to the host compiler to let it build host tools (tblgen).
|
||||
host_env
|
||||
|
||||
if [ "$SERENITY_TOOLCHAIN" = "Clang" ]; then
|
||||
stdlib=""
|
||||
unwindlib=""
|
||||
exclude_atomic_builtin="OFF"
|
||||
else
|
||||
stdlib="libstdc++"
|
||||
unwindlib="libgcc"
|
||||
# Atomic builtins can't be cross-compiled with GCC. Use the libatomic port
|
||||
# if the program you're building has references to symbols like __atomic_load.
|
||||
exclude_atomic_builtin="ON"
|
||||
fi
|
||||
|
||||
mkdir -p llvm-build
|
||||
cmake ${workdir}/llvm \
|
||||
-G Ninja \
|
||||
-B llvm-build "${configopts[@]}" \
|
||||
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||
-DCMAKE_FIND_ROOT_PATH="$SERENITY_BUILD_DIR"/Root \
|
||||
-DCLANG_DEFAULT_CXX_STDLIB=$stdlib \
|
||||
-DCLANG_DEFAULT_UNWINDLIB=$unwindlib \
|
||||
-DCLANG_TABLEGEN=$(pwd)/llvm-host/bin/clang-tblgen \
|
||||
-DCOMPILER_RT_BUILD_CRT=ON \
|
||||
-DCOMPILER_RT_BUILD_ORC=OFF \
|
||||
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF \
|
||||
-DCOMPILER_RT_OS_DIR=serenity \
|
||||
-DHAVE_LIBRT=OFF \
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE=$SERENITY_ARCH-pc-serenity \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
|
||||
-DLLVM_HAVE_LIBXAR=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLLVM_INCLUDE_TESTS=OFF \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
||||
-DLLVM_PTHREAD_LIB=pthread \
|
||||
-DLLVM_TABLEGEN=$(pwd)/llvm-host/bin/llvm-tblgen \
|
||||
-DLLVM_TARGETS_TO_BUILD=X86
|
||||
-G Ninja \
|
||||
-B llvm-build "${configopts[@]}" \
|
||||
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||
-DCMAKE_FIND_ROOT_PATH="$SERENITY_BUILD_DIR"/Root \
|
||||
-DCROSS_TOOLCHAIN_FLAGS_NATIVE="-DCMAKE_C_COMPILER=$CC;-DCMAKE_CXX_COMPILER=$CXX" \
|
||||
-DCLANG_DEFAULT_CXX_STDLIB=$stdlib \
|
||||
-DCLANG_DEFAULT_UNWINDLIB=$unwindlib \
|
||||
-DCOMPILER_RT_BUILD_CRT=ON \
|
||||
-DCOMPILER_RT_BUILD_ORC=OFF \
|
||||
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=$exclude_atomic_builtin \
|
||||
-DCOMPILER_RT_OS_DIR=serenity \
|
||||
-DHAVE_LIBRT=OFF \
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE=$SERENITY_ARCH-pc-serenity \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
|
||||
-DLLVM_HAVE_LIBXAR=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLLVM_INCLUDE_TESTS=OFF \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
||||
-DLLVM_PTHREAD_LIB=pthread \
|
||||
-DLLVM_TARGETS_TO_BUILD=X86
|
||||
}
|
||||
|
||||
build() {
|
||||
|
|
1
Ports/llvm/patches
Symbolic link
1
Ports/llvm/patches
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../Toolchain/Patches/llvm
|
|
@ -1,45 +0,0 @@
|
|||
# Patches for LLVM on SerenityOS
|
||||
|
||||
## `insert-ifdef-serenity.patch`
|
||||
|
||||
This patch adds several defines in order to omit things not supported by SerenityOS.
|
||||
|
||||
### Status
|
||||
- [ ] Local?
|
||||
- [ ] Should be merged to upstream?
|
||||
- [X] Resolves issue(s) with our side of things
|
||||
- [x] Hack
|
||||
|
||||
## `remove-version-script.patch`
|
||||
|
||||
Instructs the linker to not build LLVM shared libraries (`libclang.so`, `libLTO.so`, etc.) with
|
||||
symbol versioning, which our dynamic linker does not support.
|
||||
|
||||
### Status
|
||||
- [ ] Local?
|
||||
- [x] Should be merged to upstream?
|
||||
- [X] Resolves issue(s) with our side of things
|
||||
- [ ] Hack
|
||||
|
||||
## `toolchain.patch`
|
||||
|
||||
Adds support for the `$arch-pc-serenity` target to the Clang front end. This makes the compiler
|
||||
look for libraries and headers in the right places, and enables some security mitigations, like
|
||||
stack-smashing protection and building position-independent executables by default.
|
||||
|
||||
### Status
|
||||
- [ ] Local?
|
||||
- [x] Should be merged to upstream?
|
||||
- [ ] Resolves issue(s) with our side of things
|
||||
- [ ] Hack
|
||||
|
||||
## `llvm-backport-objcopy-update-section.patch`
|
||||
|
||||
Backports support for `llvm-objcopy --update-section` used by our toolchain from reviews.llvm.org/D112116.
|
||||
|
||||
### Status
|
||||
- [ ] Local?
|
||||
- [ ] Should be merged to upstream?
|
||||
- [ ] Resolves issues(s) with our side of things
|
||||
- [ ] Hack
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
|
||||
index c37b3a546..e51badb34 100644
|
||||
--- a/llvm/lib/Support/Unix/Path.inc
|
||||
+++ b/llvm/lib/Support/Unix/Path.inc
|
||||
@@ -109,7 +109,7 @@ typedef uint_t uint;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
|
||||
- defined(__MVS__)
|
||||
+ defined(__MVS__) || defined(__serenity__)
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flag
|
||||
#else
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flags
|
||||
@@ -531,7 +531,7 @@ static bool is_local_impl(struct STATVFS &Vfs) {
|
||||
|
||||
// vmount entry not found; "remote" is the conservative answer.
|
||||
return false;
|
||||
-#elif defined(__MVS__)
|
||||
+#elif defined(__MVS__) || defined(__serenity__)
|
||||
// The file system can have an arbitrary structure on z/OS; must go with the
|
||||
// conservative answer.
|
||||
return false;
|
||||
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
|
||||
index be59bb023..ff8931308 100644
|
||||
--- a/llvm/lib/Support/Unix/Program.inc
|
||||
+++ b/llvm/lib/Support/Unix/Program.inc
|
||||
@@ -335,7 +335,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
|
||||
namespace llvm {
|
||||
namespace sys {
|
||||
|
||||
-#ifndef _AIX
|
||||
+#if !defined(_AIX) && !defined(__serenity__)
|
||||
using ::wait4;
|
||||
#else
|
||||
static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
|
||||
@@ -344,7 +344,7 @@ static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
|
||||
} // namespace sys
|
||||
} // namespace llvm
|
||||
|
||||
-#ifdef _AIX
|
||||
+#if defined(_AIX) || defined(__serenity__)
|
||||
#ifndef _ALL_SOURCE
|
||||
extern "C" pid_t (wait4)(pid_t pid, int *status, int options,
|
||||
struct rusage *usage);
|
||||
@@ -357,7 +357,7 @@ pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
|
||||
|
||||
// AIX wait4 does not work well with WNOHANG.
|
||||
if (!(options & WNOHANG))
|
||||
- return ::wait4(pid, status, options, usage);
|
||||
+ return ::waitpid(pid, status, options);
|
||||
|
||||
// For WNOHANG, we use waitid (which supports WNOWAIT) until the child process
|
||||
// has terminated.
|
||||
@@ -374,7 +374,7 @@ pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
|
||||
// The child has already terminated, so a blocking wait on it is okay in the
|
||||
// absence of indiscriminate `wait` calls from the current process (which
|
||||
// would cause the call here to fail with ECHILD).
|
||||
- return ::wait4(pid, status, options & ~WNOHANG, usage);
|
||||
+ return ::waitpid(pid, status, options & ~WNOHANG);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -534,10 +534,10 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
|
||||
|
||||
bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
|
||||
ArrayRef<StringRef> Args) {
|
||||
- static long ArgMax = sysconf(_SC_ARG_MAX);
|
||||
+ static long ArgMax = 4096;
|
||||
// POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible
|
||||
// value for ARG_MAX on a POSIX compliant system.
|
||||
- static long ArgMin = _POSIX_ARG_MAX;
|
||||
+ static long ArgMin = 4096;
|
||||
|
||||
// This the same baseline used by xargs.
|
||||
long EffectiveArgMax = 128 * 1024;
|
||||
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
|
||||
index 7f197a50c..03bf029db 100644
|
||||
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
|
||||
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
|
||||
@@ -50,7 +50,7 @@ void printErrorAndExit(Twine ErrMsg) {
|
||||
}
|
||||
|
||||
int openListener(std::string Host, std::string PortStr) {
|
||||
-#ifndef LLVM_ON_UNIX
|
||||
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
|
||||
// FIXME: Add TCP support for Windows.
|
||||
printErrorAndExit("listen option not supported");
|
||||
return 0;
|
||||
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
|
||||
index 8bd384ec7..a28e938ec 100644
|
||||
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
|
||||
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
|
||||
@@ -770,7 +770,7 @@ static Expected<int> connectTCPSocket(std::string Host, std::string PortStr) {
|
||||
|
||||
Expected<std::unique_ptr<ExecutorProcessControl>>
|
||||
LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor() {
|
||||
-#ifndef LLVM_ON_UNIX
|
||||
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
|
||||
// FIXME: Add TCP support for Windows.
|
||||
return make_error<StringError>("-" + OutOfProcessExecutorConnect.ArgStr +
|
||||
" not supported on non-unix platforms",
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h 2021-06-09 16:00:20.111549941 +0300
|
||||
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
|
||||
- defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
|
||||
+ defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__serenity__)
|
||||
#include <endian.h>
|
||||
#elif defined(_AIX)
|
||||
#include <sys/machine.h>
|
|
@ -1 +0,0 @@
|
|||
../../../Toolchain/Patches/llvm-backport-objcopy-update-section.patch
|
|
@ -1,35 +0,0 @@
|
|||
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
|
||||
index bf88dca0a..dfac32b16 100644
|
||||
--- a/clang/tools/libclang/CMakeLists.txt
|
||||
+++ b/clang/tools/libclang/CMakeLists.txt
|
||||
@@ -80,7 +80,7 @@ if(MSVC)
|
||||
set(LLVM_EXPORTED_SYMBOL_FILE)
|
||||
endif()
|
||||
|
||||
-if (UNIX AND NOT APPLE)
|
||||
+if (UNIX AND NOT APPLE AND NOT SERENITYOS)
|
||||
set(LLVM_EXPORTED_SYMBOL_FILE)
|
||||
set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
|
||||
endif()
|
||||
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
index 76b9a25cb..808838926 100644
|
||||
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
|
||||
@@ -33,7 +33,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
|
||||
add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
|
||||
|
||||
list(REMOVE_DUPLICATES LIB_NAMES)
|
||||
- if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
|
||||
+ if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR (SERENITYOS)
|
||||
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
|
||||
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
|
||||
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
|
||||
@@ -46,7 +46,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
|
||||
|
||||
# GNU ld doesn't resolve symbols in the version script.
|
||||
set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
|
||||
- if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
|
||||
+ if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW AND NOT SERENITYOS)
|
||||
# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
|
||||
set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
|
||||
endif()
|
|
@ -1 +0,0 @@
|
|||
../../../Toolchain/Patches/llvm.patch
|
Loading…
Add table
Add a link
Reference in a new issue