serenity/Toolchain/Patches/llvm/0003-tools-Support-building-shared-libLLVM-and-libClang-f.patch
Dan Klishch fa1eef8bbe Toolchain: Update LLVM to 18.1.3
Apart from bumping the toolchain Clang's and port's version, this commit
completely overhauls the way LLVM toolchain is built.

First, it gets rid of a complicated two-stage process of first compiling
clang and compiler-rt builtins and then building libunwind, libc++abi,
and libc++ -- it is possible to create a complete cross-compilation
toolchain in a single CMake invocation with a modern LLVM. Moreover, the
old method was inherently unsupported and subtly broken.

Next, it utilizes full potential of the Stubs "framework". Now we are
even able to compile Clang with -Wl,-z,defs which makes one of the
patches obsolete and the whole installation less error-prone. Note that
it comes at a cost of complicating the bootstrap process on a completely
novel architecture but this hopefully won't happen often.

Lastly, it fixes handling of the -no*lib* family of flags in the
Serenity LLVM driver and correctly uses -nostartfiles in conjunction
with stubs to make necessary CMake configure-time checks succeed.
2024-04-18 13:14:33 -06:00

47 lines
2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <dani@danielbertalan.dev>
Date: Mon, 18 Apr 2022 22:32:29 +0200
Subject: [PATCH] [tools] Support building shared libLLVM and libClang for
SerenityOS
This patch tells CMake that the --whole-archive linker option should be
used for specifying the archives whose members will constitute these
shared libraries.
Symbol versioning is disabled, as the SerenityOS loader doesn't support
it, and the ELF sections that store version data would just waste space.
---
llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 29d0d46fdcb4..df8d63902dfd 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -181,7 +181,7 @@ if(WIN32)
elseif(FUCHSIA OR UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
- if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ if(APPLE OR SERENITYOS OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else()
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index b20ac318e768..d3df0de2f694 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -51,7 +51,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()
--
2.44.0