From 941d68ac2d1dbb3cca4ffdb644558f28d4e14a43 Mon Sep 17 00:00:00 2001 From: implicitfield <114500360+implicitfield@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:39:28 +0400 Subject: [PATCH] Toolchain+Ports: Update LLVM to 16.0.6 --- CMakeLists.txt | 2 +- Meta/CMake/serenity_compile_options.cmake | 3 +- Ports/AvailablePorts.md | 2 +- Ports/llvm/package.sh | 4 +- Toolchain/BuildClang.sh | 4 +- ...port-for-building-LLVM-on-SerenityOS.patch | 30 +++++++------- ...002-Triple-Add-triple-for-SerenityOS.patch | 28 ++++++------- ...03-Driver-Add-support-for-SerenityOS.patch | 39 ++++++++++--------- ...o-ftls-model-initial-exec-on-Serenit.patch | 7 ++-- ...0005-libc-Add-support-for-SerenityOS.patch | 22 +++++------ ...d-crtbegin.o-crtend.o-for-SerenityOS.patch | 4 +- ...llow-undefined-symbols-on-SerenityOS.patch | 8 ++-- ...ilding-shared-libLLVM-and-libClang-f.patch | 16 ++++---- ...-Enable-profile-instrumentation-for-.patch | 12 +++--- .../0010-Add-SerenityOS-to-config.guess.patch | 2 +- ...t-the-use-of-POSIX-shm-on-SerenityOS.patch | 8 ++-- ...he-default-stack-size-when-running-o.patch | 4 +- 17 files changed, 99 insertions(+), 96 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a9522ec061..e2a0f361634 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ endif() # Check for toolchain mismatch, user might need to rebuild toolchain set(GCC_VERSION "13.1.0") -set(LLVM_VERSION "15.0.3") +set(LLVM_VERSION "16.0.6") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(EXPECTED_COMPILER_VERSION "${GCC_VERSION}") else() diff --git a/Meta/CMake/serenity_compile_options.cmake b/Meta/CMake/serenity_compile_options.cmake index d1a24f14cae..1680b0fa9de 100644 --- a/Meta/CMake/serenity_compile_options.cmake +++ b/Meta/CMake/serenity_compile_options.cmake @@ -36,7 +36,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$") add_compile_options(-Wno-unused-private-field) # Clang doesn't add compiler_rt to the search path when compiling with -nostdlib. - link_directories(${TOOLCHAIN_ROOT}/lib/clang/${CMAKE_CXX_COMPILER_VERSION}/lib/${SERENITY_ARCH}-pc-serenity/) + string(REGEX REPLACE "\\.(.*)" "" LLVM_MAJOR_VERSION "${CMAKE_CXX_COMPILER_VERSION}") + link_directories(${TOOLCHAIN_ROOT}/lib/clang/${LLVM_MAJOR_VERSION}/lib/${SERENITY_ARCH}-pc-serenity/) endif() if ("${SERENITY_ARCH}" STREQUAL "aarch64") diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index bee2e974738..d5e2e388092 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -162,7 +162,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`libzip`](libzip/) | libzip | 1.8.0 | https://libzip.org/ | | [`links`](links/) | Links web browser | 2.26 | http://links.twibright.com/ | | [`lite-xl`](lite-xl/) | Lite-XL | 2.1.0 | https://lite-xl.com/ | -| [`llvm`](llvm/) | LLVM | 15.0.3 | https://llvm.org/ | +| [`llvm`](llvm/) | LLVM | 16.0.6 | https://llvm.org/ | | [`lowdown`](lowdown/) | lowdown | 1.0.2 | https://kristaps.bsd.lv/lowdown/ | | [`lrzip`](lrzip/) | lrzip | 0.651 | https://github.com/ckolivas/lrzip | | [`lua`](lua/) | Lua | 5.4.4 | https://www.lua.org/ | diff --git a/Ports/llvm/package.sh b/Ports/llvm/package.sh index 791fedc00d1..41f0f2c4203 100755 --- a/Ports/llvm/package.sh +++ b/Ports/llvm/package.sh @@ -1,12 +1,12 @@ #!/usr/bin/env -S bash ../.port_include.sh port='llvm' useconfigure='true' -version='15.0.3' +version='16.0.6' workdir="llvm-project-${version}.src" configopts=( "-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt" ) -files="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz llvm-project-${version}.src.tar.xz dd07bdab557866344d85ae21bbeca5259d37b4b0e2ebf6e0481f42d1ba0fee88" +files="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz llvm-project-${version}.src.tar.xz ce5e71081d17ce9e86d7cbcfa28c4b04b9300f8fb7e78422b1feb6bc52c3028e" auth_type='sha256' depends=( "ncurses" diff --git a/Toolchain/BuildClang.sh b/Toolchain/BuildClang.sh index 437b219d94e..33025231a35 100755 --- a/Toolchain/BuildClang.sh +++ b/Toolchain/BuildClang.sh @@ -69,8 +69,8 @@ echo PREFIX is "$PREFIX" mkdir -p "$DIR/Tarballs" -LLVM_VERSION="15.0.3" -LLVM_MD5SUM="d435e1160fd16b8efe1e0f4d1058bd50" +LLVM_VERSION="16.0.6" +LLVM_MD5SUM="dc13938a604f70379d3b38d09031de98" LLVM_NAME="llvm-project-$LLVM_VERSION.src" LLVM_PKG="$LLVM_NAME.tar.xz" LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_PKG" diff --git a/Toolchain/Patches/llvm/0001-Support-Add-support-for-building-LLVM-on-SerenityOS.patch b/Toolchain/Patches/llvm/0001-Support-Add-support-for-building-LLVM-on-SerenityOS.patch index 6b97ed94521..cb03543dd52 100644 --- a/Toolchain/Patches/llvm/0001-Support-Add-support-for-building-LLVM-on-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0001-Support-Add-support-for-building-LLVM-on-SerenityOS.patch @@ -14,11 +14,11 @@ process's resource usage information. 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h -index e8612ba6654b5d950b2eb570c23ebbb79d4dc035..f0109f4b30e83cefc745e0575deaf89b1e51c35a 100644 +index 9dd08665b..8915f92e8 100644 --- a/llvm/include/llvm/Support/SwapByteOrder.h +++ b/llvm/include/llvm/Support/SwapByteOrder.h -@@ -22,7 +22,7 @@ - #endif +@@ -20,7 +20,7 @@ + #include #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ - defined(__Fuchsia__) || defined(__EMSCRIPTEN__) @@ -27,19 +27,19 @@ index e8612ba6654b5d950b2eb570c23ebbb79d4dc035..f0109f4b30e83cefc745e0575deaf89b #elif defined(_AIX) #include diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc -index 2ae7c6dc47e071a7801c346a6d40e0db45e49beb..bf173117bb9be72902597569dc94ff81efe5af38 100644 +index 3efcad4f2..4f83d0e76 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -112,7 +112,7 @@ typedef uint_t uint; #endif - #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \ + #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 -@@ -512,6 +512,9 @@ static bool is_local_impl(struct STATVFS &Vfs) { +@@ -506,6 +506,9 @@ static bool is_local_impl(struct STATVFS &Vfs) { #elif defined(__HAIKU__) // Haiku doesn't expose this information. return false; @@ -47,13 +47,13 @@ index 2ae7c6dc47e071a7801c346a6d40e0db45e49beb..bf173117bb9be72902597569dc94ff81 + // Serenity doesn't yet support remote filesystem mounts. + return false; #elif defined(__sun) - // statvfs::f_basetype contains a null-terminated FSType name of the mounted target - StringRef fstype(Vfs.f_basetype); + // statvfs::f_basetype contains a null-terminated FSType name of the mounted + // target diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc -index 089342030b97e178d749a54b2d43ae5338b5b097..3ffe064e5f0de06ac76c34b218e44fe7a8d9eaf6 100644 +index 897e22711..23965a1a1 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc -@@ -336,7 +336,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, +@@ -340,7 +340,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, namespace llvm { namespace sys { @@ -61,8 +61,8 @@ index 089342030b97e178d749a54b2d43ae5338b5b097..3ffe064e5f0de06ac76c34b218e44fe7 +#if !defined(_AIX) && !defined(__serenity__) using ::wait4; #else - static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage); -@@ -379,6 +379,13 @@ pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options, + static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage); +@@ -383,6 +383,13 @@ pid_t(llvm::sys::wait4)(pid_t pid, int *status, int options, } #endif @@ -73,6 +73,6 @@ index 089342030b97e178d749a54b2d43ae5338b5b097..3ffe064e5f0de06ac76c34b218e44fe7 +} +#endif + - ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, - bool WaitUntilTerminates, std::string *ErrMsg, - Optional *ProcStat) { + ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, + std::optional SecondsToWait, + std::string *ErrMsg, diff --git a/Toolchain/Patches/llvm/0002-Triple-Add-triple-for-SerenityOS.patch b/Toolchain/Patches/llvm/0002-Triple-Add-triple-for-SerenityOS.patch index dcb961459ce..0d8ecd0b049 100644 --- a/Toolchain/Patches/llvm/0002-Triple-Add-triple-for-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0002-Triple-Add-triple-for-SerenityOS.patch @@ -4,15 +4,15 @@ Date: Thu, 14 Apr 2022 09:51:24 +0200 Subject: [PATCH] [Triple] Add triple for SerenityOS --- - llvm/include/llvm/ADT/Triple.h | 8 +++++++- - llvm/lib/Support/Triple.cpp | 2 ++ + llvm/include/llvm/TargetParser/Triple.h | 8 +++++++- + llvm/lib/TargetParser/Triple.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) -diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h -index ba4584dc60faf1b9a170493bbe3075c08d5ff2a8..56e793cc0c0afa7c5f6bdd2e019a61dc518964f4 100644 ---- a/llvm/include/llvm/ADT/Triple.h -+++ b/llvm/include/llvm/ADT/Triple.h -@@ -219,7 +219,8 @@ public: +diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h +index 59513fa2f..951d69010 100644 +--- a/llvm/include/llvm/TargetParser/Triple.h ++++ b/llvm/include/llvm/TargetParser/Triple.h +@@ -223,7 +223,8 @@ public: WASI, // Experimental WebAssembly OS Emscripten, ShaderModel, // DirectX ShaderModel @@ -22,7 +22,7 @@ index ba4584dc60faf1b9a170493bbe3075c08d5ff2a8..56e793cc0c0afa7c5f6bdd2e019a61dc }; enum EnvironmentType { UnknownEnvironment, -@@ -652,6 +653,11 @@ public: +@@ -670,6 +671,11 @@ public: return getOS() == Triple::AIX; } @@ -34,11 +34,11 @@ index ba4584dc60faf1b9a170493bbe3075c08d5ff2a8..56e793cc0c0afa7c5f6bdd2e019a61dc /// Tests whether the OS uses the ELF binary format. bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; -diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp -index 6696d158b2c1ae3d31f0819880ec0814f74a3a16..5292164d7aaed944c934a89fe3e809fc427218eb 100644 ---- a/llvm/lib/Support/Triple.cpp -+++ b/llvm/lib/Support/Triple.cpp -@@ -234,6 +234,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { +diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp +index a68035989..1ee9ea3b1 100644 +--- a/llvm/lib/TargetParser/Triple.cpp ++++ b/llvm/lib/TargetParser/Triple.cpp +@@ -237,6 +237,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { case PS5: return "ps5"; case RTEMS: return "rtems"; case Solaris: return "solaris"; @@ -46,7 +46,7 @@ index 6696d158b2c1ae3d31f0819880ec0814f74a3a16..5292164d7aaed944c934a89fe3e809fc case TvOS: return "tvos"; case WASI: return "wasi"; case WatchOS: return "watchos"; -@@ -587,6 +588,7 @@ static Triple::OSType parseOS(StringRef OSName) { +@@ -596,6 +597,7 @@ static Triple::OSType parseOS(StringRef OSName) { .StartsWith("wasi", Triple::WASI) .StartsWith("emscripten", Triple::Emscripten) .StartsWith("shadermodel", Triple::ShaderModel) diff --git a/Toolchain/Patches/llvm/0003-Driver-Add-support-for-SerenityOS.patch b/Toolchain/Patches/llvm/0003-Driver-Add-support-for-SerenityOS.patch index 25385fa0882..72a0652e55a 100644 --- a/Toolchain/Patches/llvm/0003-Driver-Add-support-for-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0003-Driver-Add-support-for-SerenityOS.patch @@ -14,16 +14,16 @@ protection and position-independent code by default. clang/lib/Driver/Driver.cpp | 4 + clang/lib/Driver/ToolChain.cpp | 2 + clang/lib/Driver/ToolChains/Serenity.cpp | 336 +++++++++++++++++++++++ - clang/lib/Driver/ToolChains/Serenity.h | 99 +++++++ - 8 files changed, 467 insertions(+) + clang/lib/Driver/ToolChains/Serenity.h | 100 +++++++ + 7 files changed, 467 insertions(+) create mode 100644 clang/lib/Driver/ToolChains/Serenity.cpp create mode 100644 clang/lib/Driver/ToolChains/Serenity.h diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp -index 2d6ef998485ae1404e561dc12f962ce1bef2996d..06abf1dfdd5b91c2a0051363e2f04ec9b3f3285f 100644 +index 8400774db..f105bed29 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp -@@ -151,6 +151,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, +@@ -153,6 +153,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, return new NetBSDTargetInfo(Triple, Opts); case llvm::Triple::OpenBSD: return new OpenBSDTargetInfo(Triple, Opts); @@ -32,7 +32,7 @@ index 2d6ef998485ae1404e561dc12f962ce1bef2996d..06abf1dfdd5b91c2a0051363e2f04ec9 case llvm::Triple::Win32: switch (Triple.getEnvironment()) { case llvm::Triple::GNU: -@@ -540,6 +542,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, +@@ -542,6 +544,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, return new MCUX86_32TargetInfo(Triple, Opts); case llvm::Triple::Hurd: return new HurdTargetInfo(Triple, Opts); @@ -41,7 +41,7 @@ index 2d6ef998485ae1404e561dc12f962ce1bef2996d..06abf1dfdd5b91c2a0051363e2f04ec9 default: return new X86_32TargetInfo(Triple, Opts); } -@@ -594,6 +598,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, +@@ -596,6 +600,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, return new PS4OSTargetInfo(Triple, Opts); case llvm::Triple::PS5: return new PS5OSTargetInfo(Triple, Opts); @@ -51,10 +51,10 @@ index 2d6ef998485ae1404e561dc12f962ce1bef2996d..06abf1dfdd5b91c2a0051363e2f04ec9 return new X86_64TargetInfo(Triple, Opts); } diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h -index a814f681b1468c7628daf6f5c9c6d723155821b0..927eeb66446a451b3cd9b08d9cdcfd6f8d4064ba 100644 +index fd372cb12..27a3f9797 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h -@@ -1013,6 +1013,24 @@ public: +@@ -1005,6 +1005,24 @@ public: } }; @@ -80,10 +80,10 @@ index a814f681b1468c7628daf6f5c9c6d723155821b0..927eeb66446a451b3cd9b08d9cdcfd6f } // namespace clang #endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt -index 18c9b2d042f6c6e27382a4c72119250533e93482..ed7178e510584a465e695f64716bd399f3b131db 100644 +index ba56a9323..4d0ffe88c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt -@@ -74,6 +74,7 @@ add_clang_library(clangDriver +@@ -78,6 +78,7 @@ add_clang_library(clangDriver ToolChains/OpenBSD.cpp ToolChains/PS4CPU.cpp ToolChains/RISCVToolchain.cpp @@ -92,7 +92,7 @@ index 18c9b2d042f6c6e27382a4c72119250533e93482..ed7178e510584a465e695f64716bd399 ToolChains/SPIRV.cpp ToolChains/TCE.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp -index 3f29afd359718a1c21e9c9911f0e6ad5f1002a3a..18433655172bc90a97a24b619f11a3d9eba0d327 100644 +index a268f2fa8..df54be3de 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -45,6 +45,7 @@ @@ -103,7 +103,7 @@ index 3f29afd359718a1c21e9c9911f0e6ad5f1002a3a..18433655172bc90a97a24b619f11a3d9 #include "ToolChains/SPIRV.h" #include "ToolChains/Solaris.h" #include "ToolChains/TCE.h" -@@ -6009,6 +6010,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, +@@ -6041,6 +6042,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, case llvm::Triple::Fuchsia: TC = std::make_unique(*this, Target, Args); break; @@ -114,10 +114,10 @@ index 3f29afd359718a1c21e9c9911f0e6ad5f1002a3a..18433655172bc90a97a24b619f11a3d9 TC = std::make_unique(*this, Target, Args); break; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp -index 7a4319ea680f97dde074b21afa2ee6f75c350091..8db07d9dd0754bffeddf00afe365fe7d011cc602 100644 +index bc70205a6..3d5c856ab 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp -@@ -452,6 +452,8 @@ StringRef ToolChain::getOSLibName() const { +@@ -482,6 +482,8 @@ StringRef ToolChain::getOSLibName() const { return "sunos"; case llvm::Triple::AIX: return "aix"; @@ -128,7 +128,7 @@ index 7a4319ea680f97dde074b21afa2ee6f75c350091..8db07d9dd0754bffeddf00afe365fe7d } diff --git a/clang/lib/Driver/ToolChains/Serenity.cpp b/clang/lib/Driver/ToolChains/Serenity.cpp new file mode 100644 -index 0000000000000000000000000000000000000000..4fdf45a19eb2704d00a03e7b2f34f87f63a0a074 +index 000000000..4fdf45a19 --- /dev/null +++ b/clang/lib/Driver/ToolChains/Serenity.cpp @@ -0,0 +1,336 @@ @@ -470,10 +470,10 @@ index 0000000000000000000000000000000000000000..4fdf45a19eb2704d00a03e7b2f34f87f +} diff --git a/clang/lib/Driver/ToolChains/Serenity.h b/clang/lib/Driver/ToolChains/Serenity.h new file mode 100644 -index 0000000000000000000000000000000000000000..d414f836601c8ea8b43d64e9b111bffa2b71cd54 +index 000000000..feb31a0d6 --- /dev/null +++ b/clang/lib/Driver/ToolChains/Serenity.h -@@ -0,0 +1,99 @@ +@@ -0,0 +1,100 @@ +//===---- Serenity.h - SerenityOS ToolChain Implementation ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -551,8 +551,9 @@ index 0000000000000000000000000000000000000000..d414f836601c8ea8b43d64e9b111bffa + + bool IsMathErrnoDefault() const override { return false; } + -+ bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { -+ return true; ++ UnwindTableLevel ++ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override { ++ return UnwindTableLevel::Asynchronous; + } + + bool useRelaxRelocations() const override { return true; } diff --git a/Toolchain/Patches/llvm/0004-Driver-Default-to-ftls-model-initial-exec-on-Serenit.patch b/Toolchain/Patches/llvm/0004-Driver-Default-to-ftls-model-initial-exec-on-Serenit.patch index 8baa8cf7f35..e8eda861ff0 100644 --- a/Toolchain/Patches/llvm/0004-Driver-Default-to-ftls-model-initial-exec-on-Serenit.patch +++ b/Toolchain/Patches/llvm/0004-Driver-Default-to-ftls-model-initial-exec-on-Serenit.patch @@ -1,7 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Thu, 14 Apr 2022 10:12:54 +0200 -Subject: [PATCH] [Driver] Default to -ftls-model=initial-exec on SerenityOS +Subject: [PATCH] [Driver] Default to -ftls-model=initial-exec on + SerenityOS This is a hack to make Clang use the initial-exec TLS model instead of the default local-exec when building code for Serenity. @@ -12,10 +13,10 @@ This patch should be removed when we implement proper TLS support. 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp -index 3704ed8586682677882acb8e1b82bfc14b1d07a5..cc7b598090a8795e5906abc7341f798be7dd638f 100644 +index ec6860113..c5c07e5ee 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp -@@ -6029,7 +6029,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, +@@ -6100,7 +6100,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden_static_local_var, options::OPT_fno_visibility_inlines_hidden_static_local_var); Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden); diff --git a/Toolchain/Patches/llvm/0005-libc-Add-support-for-SerenityOS.patch b/Toolchain/Patches/llvm/0005-libc-Add-support-for-SerenityOS.patch index dd16bbadb38..19138c5c4d3 100644 --- a/Toolchain/Patches/llvm/0005-libc-Add-support-for-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0005-libc-Add-support-for-SerenityOS.patch @@ -24,10 +24,10 @@ LibC, namely: create mode 100644 libcxx/include/__support/serenity/xlocale.h diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt -index f7c2d99e78b08ff823b9d510a8608ebf50031b82..8d3cb754ddf4c599708b2be38fab1574ce3a4923 100644 +index a12aa1de1..075ebbe81 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt -@@ -495,6 +495,7 @@ set(files +@@ -549,6 +549,7 @@ set(files __support/musl/xlocale.h __support/newlib/xlocale.h __support/openbsd/xlocale.h @@ -36,10 +36,10 @@ index f7c2d99e78b08ff823b9d510a8608ebf50031b82..8d3cb754ddf4c599708b2be38fab1574 __support/solaris/wchar.h __support/solaris/xlocale.h diff --git a/libcxx/include/__config b/libcxx/include/__config -index 8c2f7614af537e71a76cb5292d5765d6ff8cd279..c7ebf50cb5ebb3a96029cd9a8a38d836cf19a01e 100644 +index 5e30a4217..5dea34814 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config -@@ -912,7 +912,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD +@@ -930,7 +930,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD defined(__sun__) || \ defined(__MVS__) || \ defined(_AIX) || \ @@ -49,7 +49,7 @@ index 8c2f7614af537e71a76cb5292d5765d6ff8cd279..c7ebf50cb5ebb3a96029cd9a8a38d836 // clang-format on # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) -@@ -990,7 +991,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD +@@ -1008,7 +1009,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD # endif # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ @@ -59,10 +59,10 @@ index 8c2f7614af537e71a76cb5292d5765d6ff8cd279..c7ebf50cb5ebb3a96029cd9a8a38d836 # endif diff --git a/libcxx/include/__locale b/libcxx/include/__locale -index 40f9a3ff57c22635254be654227333b2a10eca6a..1c499c078b44a49abead17ce566801b4c34733f3 100644 +index e0ffa0ca0..33e994abe 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale -@@ -42,6 +42,8 @@ +@@ -44,6 +44,8 @@ # include <__support/musl/xlocale.h> #elif defined(_LIBCPP_HAS_MUSL_LIBC) # include <__support/musl/xlocale.h> @@ -73,7 +73,7 @@ index 40f9a3ff57c22635254be654227333b2a10eca6a..1c499c078b44a49abead17ce566801b4 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__support/serenity/xlocale.h b/libcxx/include/__support/serenity/xlocale.h new file mode 100644 -index 0000000000000000000000000000000000000000..0f939d2f6989e2ad617145308d079776fe87b6ce +index 000000000..0f939d2f6 --- /dev/null +++ b/libcxx/include/__support/serenity/xlocale.h @@ -0,0 +1,24 @@ @@ -102,10 +102,10 @@ index 0000000000000000000000000000000000000000..0f939d2f6989e2ad617145308d079776 + +#endif diff --git a/libcxx/include/locale b/libcxx/include/locale -index b01c66d0430f66ee74118e73296780bb864e920b..da29b7d00c709788facb049f417b6d5ccb5b70e1 100644 +index 874866f69..55632f101 100644 --- a/libcxx/include/locale +++ b/libcxx/include/locale -@@ -217,7 +217,7 @@ template class messages_byname; +@@ -216,7 +216,7 @@ template class messages_byname; #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. @@ -115,7 +115,7 @@ index b01c66d0430f66ee74118e73296780bb864e920b..da29b7d00c709788facb049f417b6d5c # include # endif diff --git a/libcxx/src/include/config_elast.h b/libcxx/src/include/config_elast.h -index bef26ec5019eccab758733eb85a1f8a6fc404968..fbb2899b1939a2f9ce7a39337c99e48c7749f7f2 100644 +index bef26ec50..fbb2899b1 100644 --- a/libcxx/src/include/config_elast.h +++ b/libcxx/src/include/config_elast.h @@ -35,6 +35,8 @@ diff --git a/Toolchain/Patches/llvm/0006-compiler-rt-Build-crtbegin.o-crtend.o-for-SerenityOS.patch b/Toolchain/Patches/llvm/0006-compiler-rt-Build-crtbegin.o-crtend.o-for-SerenityOS.patch index dd720d213ec..6a7f74e7518 100644 --- a/Toolchain/Patches/llvm/0006-compiler-rt-Build-crtbegin.o-crtend.o-for-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0006-compiler-rt-Build-crtbegin.o-crtend.o-for-SerenityOS.patch @@ -8,10 +8,10 @@ Subject: [PATCH] [compiler-rt] Build crtbegin.o/crtend.o for SerenityOS 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/cmake/crt-config-ix.cmake b/compiler-rt/cmake/crt-config-ix.cmake -index 78d1a0de1c8a7caab9d30cc8f445d5d8c485dfc0..c8622c458ea49c7ed656d2fb8d164576bba107f8 100644 +index 066a0edbc..62c2f050f 100644 --- a/compiler-rt/cmake/crt-config-ix.cmake +++ b/compiler-rt/cmake/crt-config-ix.cmake -@@ -43,7 +43,7 @@ if(NOT APPLE) +@@ -44,7 +44,7 @@ if(NOT APPLE) message(STATUS "Supported architectures for crt: ${CRT_SUPPORTED_ARCH}") endif() diff --git a/Toolchain/Patches/llvm/0007-cmake-Allow-undefined-symbols-on-SerenityOS.patch b/Toolchain/Patches/llvm/0007-cmake-Allow-undefined-symbols-on-SerenityOS.patch index 90829690bc2..443cd374446 100644 --- a/Toolchain/Patches/llvm/0007-cmake-Allow-undefined-symbols-on-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0007-cmake-Allow-undefined-symbols-on-SerenityOS.patch @@ -11,15 +11,15 @@ are built. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake -index 56d05f5b5fcedf692cae22ffbe10a047d5532635..8597d80d3afd3e70e1306fdb7c36963f8e6aede4 100644 +index 6119ecdce..59d2c7539 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake -@@ -228,7 +228,7 @@ endif() +@@ -226,7 +226,7 @@ endif() # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO # build might work on ELF but fail on MachO/COFF. --if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|SunOS|OS390" OR -+if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|SunOS|OS390|SerenityOS" OR +-if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" OR ++if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390|SerenityOS" OR WIN32 OR CYGWIN) AND NOT LLVM_USE_SANITIZER) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") diff --git a/Toolchain/Patches/llvm/0008-cmake-Support-building-shared-libLLVM-and-libClang-f.patch b/Toolchain/Patches/llvm/0008-cmake-Support-building-shared-libLLVM-and-libClang-f.patch index 89206a96b42..dfe9ffe23c7 100644 --- a/Toolchain/Patches/llvm/0008-cmake-Support-building-shared-libLLVM-and-libClang-f.patch +++ b/Toolchain/Patches/llvm/0008-cmake-Support-building-shared-libLLVM-and-libClang-f.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Mon, 18 Apr 2022 22:32:29 +0200 -Subject: [PATCH] [cmake] Support building shared libLLVM and libClang for - SerenityOS +Subject: [PATCH] [cmake] 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 @@ -16,10 +16,10 @@ it, and the ELF sections that store version data would just waste space. 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt -index c6b3b44a76334b86167971c48891db898d01f8d0..d43e0b4c1f7796c17c524626fba59e0dfaebf4b2 100644 +index 4f23065a2..f180d2229 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt -@@ -96,7 +96,7 @@ if(MSVC) +@@ -97,7 +97,7 @@ if(MSVC) set(LLVM_EXPORTED_SYMBOL_FILE) endif() @@ -29,18 +29,18 @@ index c6b3b44a76334b86167971c48891db898d01f8d0..d43e0b4c1f7796c17c524626fba59e0d 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 8e2b78f1b85c0f2664f84e24d7588bb60e37fe77..909018753e2e09cb3a46bae35e9aaa45cc7703bc 100644 +index 90e290435..f72ca9646 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt -@@ -39,6 +39,7 @@ if(LLVM_BUILD_LLVM_DYLIB) - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") +@@ -40,6 +40,7 @@ if(LLVM_BUILD_LLVM_DYLIB) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") + OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") + OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SerenityOS") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf" configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in -@@ -46,7 +47,7 @@ if(LLVM_BUILD_LLVM_DYLIB) +@@ -47,7 +48,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) diff --git a/Toolchain/Patches/llvm/0009-compiler-rt-llvm-Enable-profile-instrumentation-for-.patch b/Toolchain/Patches/llvm/0009-compiler-rt-llvm-Enable-profile-instrumentation-for-.patch index 0569f01e63a..d19842cb0a5 100644 --- a/Toolchain/Patches/llvm/0009-compiler-rt-llvm-Enable-profile-instrumentation-for-.patch +++ b/Toolchain/Patches/llvm/0009-compiler-rt-llvm-Enable-profile-instrumentation-for-.patch @@ -17,10 +17,10 @@ OS ABI for userspace binaries to 3, or GNU/Linux. 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake -index cd45176cf2ba761667793903daccd5f02b0e690c..ebaa74f4b5a21c20459af911e2aaede3ac3a8184 100644 +index 5f51befc1..6a7e45549 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake -@@ -756,7 +756,7 @@ else() +@@ -774,7 +774,7 @@ else() endif() if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND @@ -30,7 +30,7 @@ index cd45176cf2ba761667793903daccd5f02b0e690c..ebaa74f4b5a21c20459af911e2aaede3 else() set(COMPILER_RT_HAS_PROFILE FALSE) diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c -index 3af61d24948e7c9b6e8f3950a418516c603457a2..ee46741d47ead6c9e6931c8d3a6f16e8cd6407ae 100644 +index adf4132c6..1ed5bd295 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c @@ -8,7 +8,7 @@ @@ -43,7 +43,7 @@ index 3af61d24948e7c9b6e8f3950a418516c603457a2..ee46741d47ead6c9e6931c8d3a6f16e8 #if !defined(_AIX) #include diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c -index c7b6e842c9fac27b2885242d6c2cd48797bfe799..00fdf9ee6adc8e5fffda50cd981c901f02fddaf2 100644 +index c7b6e842c..00fdf9ee6 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c @@ -8,7 +8,7 @@ @@ -56,10 +56,10 @@ index c7b6e842c9fac27b2885242d6c2cd48797bfe799..00fdf9ee6adc8e5fffda50cd981c901f #include #include diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp -index 5b7aa304b9876fc027e251547340df56dcf0c343..b3b037a6fdf5ea2dd749c8eb5329c9a29b44f75c 100644 +index c04092062..e148cff6f 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp -@@ -822,7 +822,8 @@ static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) { +@@ -829,7 +829,8 @@ static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) { return false; // Use linker script magic to get data/cnts/name start/end. if (TT.isOSAIX() || TT.isOSLinux() || TT.isOSFreeBSD() || TT.isOSNetBSD() || diff --git a/Toolchain/Patches/llvm/0010-Add-SerenityOS-to-config.guess.patch b/Toolchain/Patches/llvm/0010-Add-SerenityOS-to-config.guess.patch index 36fd1b566a2..59685465dc6 100644 --- a/Toolchain/Patches/llvm/0010-Add-SerenityOS-to-config.guess.patch +++ b/Toolchain/Patches/llvm/0010-Add-SerenityOS-to-config.guess.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Add SerenityOS to config.guess 1 file changed, 3 insertions(+) diff --git a/llvm/cmake/config.guess b/llvm/cmake/config.guess -index 60d3f588d6f7e8b341b47b7b379a6b5be299b4b6..bdbd1e323d95a73307cf7f8188ca3c419cd8c0e8 100644 +index 71abbf939..f48962367 100644 --- a/llvm/cmake/config.guess +++ b/llvm/cmake/config.guess @@ -816,6 +816,9 @@ EOF diff --git a/Toolchain/Patches/llvm/0011-llvm-Prevent-the-use-of-POSIX-shm-on-SerenityOS.patch b/Toolchain/Patches/llvm/0011-llvm-Prevent-the-use-of-POSIX-shm-on-SerenityOS.patch index dafc4bfea6a..34f7d39afa8 100644 --- a/Toolchain/Patches/llvm/0011-llvm-Prevent-the-use-of-POSIX-shm-on-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0011-llvm-Prevent-the-use-of-POSIX-shm-on-SerenityOS.patch @@ -11,10 +11,10 @@ compilation error. 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp -index ee92e5191b507b5f3355a0a4bec494e7c3eb654d..94b90691086e9481f2d99d7354d8ed79947ecfb7 100644 +index b457c7297..5e2907f0c 100644 --- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp +++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp -@@ -196,7 +196,7 @@ SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) { +@@ -215,7 +215,7 @@ SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) { void SharedMemoryMapper::reserve(size_t NumBytes, OnReservedFunction OnReserved) { @@ -24,10 +24,10 @@ index ee92e5191b507b5f3355a0a4bec494e7c3eb654d..94b90691086e9481f2d99d7354d8ed79 EPC.callSPSWrapperAsync< rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>( diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp -index caa191cea899de4d0729028a62f8e49df1ba8580..a0bb8bbc68b5050aaa725555595c5616524f02e0 100644 +index 147f915f6..ca773e1ca 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp -@@ -52,7 +52,7 @@ namespace rt_bootstrap { +@@ -47,7 +47,7 @@ static DWORD getWindowsProtectionFlags(MemProt MP) { Expected> ExecutorSharedMemoryMapperService::reserve(uint64_t Size) { diff --git a/Toolchain/Patches/llvm/0012-cmake-Increase-the-default-stack-size-when-running-o.patch b/Toolchain/Patches/llvm/0012-cmake-Increase-the-default-stack-size-when-running-o.patch index 538bd920684..23d085f8ba1 100644 --- a/Toolchain/Patches/llvm/0012-cmake-Increase-the-default-stack-size-when-running-o.patch +++ b/Toolchain/Patches/llvm/0012-cmake-Increase-the-default-stack-size-when-running-o.patch @@ -9,10 +9,10 @@ Subject: [PATCH] cmake: Increase the default stack size when running on 1 file changed, 3 insertions(+) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake -index 8597d80d3afd3e70e1306fdb7c36963f8e6aede4..2b1609ad43fe65d3f0492cc9a590e38c62e99c22 100644 +index 59d2c7539..7c3b1ff6d 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake -@@ -444,6 +444,9 @@ elseif(MINGW) # FIXME: Also cygwin? +@@ -455,6 +455,9 @@ elseif(MINGW) # FIXME: Also cygwin? if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") append("-Wa,-mbig-obj" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif()