mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Toolchain: Build Clang with RISC-V support
This commit is contained in:
parent
e21af23754
commit
0b91d36a1e
Notes:
sideshowbarker
2024-07-17 06:35:23 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/0b91d36a1e Pull-request: https://github.com/SerenityOS/serenity/pull/20482 Reviewed-by: https://github.com/BertalanD ✅
6 changed files with 28 additions and 14 deletions
|
@ -15,7 +15,7 @@ echo "$DIR"
|
|||
PREFIX="$DIR/Local/clang/"
|
||||
BUILD="$DIR/../Build/"
|
||||
USERLAND_ARCHS="x86_64"
|
||||
ARCHS="$USERLAND_ARCHS aarch64"
|
||||
ARCHS="$USERLAND_ARCHS aarch64 riscv64"
|
||||
|
||||
MD5SUM="md5sum"
|
||||
REALPATH="realpath"
|
||||
|
@ -296,6 +296,7 @@ pushd "$DIR/Build/clang"
|
|||
-G Ninja \
|
||||
-DSERENITY_x86_64-pc-serenity_SYSROOT="$BUILD/x86_64clang/Root" \
|
||||
-DSERENITY_aarch64-pc-serenity_SYSROOT="$BUILD/aarch64clang/Root" \
|
||||
-DSERENITY_riscv64-pc-serenity_SYSROOT="$BUILD/riscv64clang/Root" \
|
||||
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||
-DSERENITY_MODULE_PATH="$DIR/CMake" \
|
||||
-C "$DIR/CMake/LLVMConfig.cmake" \
|
||||
|
|
|
@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${SERENITY_MODULE_PATH}" CACHE STRIN
|
|||
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
|
||||
set(LLVM_TARGETS_TO_BUILD "X86;AArch64" CACHE STRING "")
|
||||
set(LLVM_TARGETS_TO_BUILD "X86;AArch64;RISCV" CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_PROJECTS "llvm;clang;lld;clang-tools-extra" CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "")
|
||||
|
@ -25,7 +25,7 @@ set(LLVM_INSTALL_BINUTILS_SYMLINKS OFF CACHE BOOL "")
|
|||
set(CLANG_ENABLE_CLANGD OFF CACHE BOOL "")
|
||||
|
||||
set(compiler_flags "-nostdlib -nostdlib++")
|
||||
foreach(target x86_64-pc-serenity;aarch64-pc-serenity)
|
||||
foreach(target x86_64-pc-serenity;aarch64-pc-serenity;riscv64-pc-serenity)
|
||||
list(APPEND targets "${target}")
|
||||
|
||||
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
|
|
|
@ -2,25 +2,30 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Date: Thu, 14 Apr 2022 10:09:50 +0200
|
||||
Subject: [PATCH] [Driver] Add support for SerenityOS
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
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 position-independent code by default.
|
||||
|
||||
Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
---
|
||||
clang/lib/Basic/Targets.cpp | 6 +
|
||||
clang/lib/Basic/Targets.cpp | 8 +
|
||||
clang/lib/Basic/Targets/OSTargets.h | 18 ++
|
||||
clang/lib/Driver/CMakeLists.txt | 1 +
|
||||
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 | 100 +++++++
|
||||
7 files changed, 467 insertions(+)
|
||||
7 files changed, 469 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 8400774db..f105bed29 100644
|
||||
index 8400774db..f82618dc8 100644
|
||||
--- a/clang/lib/Basic/Targets.cpp
|
||||
+++ b/clang/lib/Basic/Targets.cpp
|
||||
@@ -153,6 +153,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
|
@ -32,7 +37,16 @@ index 8400774db..f105bed29 100644
|
|||
case llvm::Triple::Win32:
|
||||
switch (Triple.getEnvironment()) {
|
||||
case llvm::Triple::GNU:
|
||||
@@ -542,6 +544,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
@@ -424,6 +426,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new FuchsiaTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Linux:
|
||||
return new LinuxTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
||||
+ case llvm::Triple::Serenity:
|
||||
+ return new SerenityTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
||||
default:
|
||||
return new RISCV64TargetInfo(Triple, Opts);
|
||||
}
|
||||
@@ -542,6 +546,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new MCUX86_32TargetInfo(Triple, Opts);
|
||||
case llvm::Triple::Hurd:
|
||||
return new HurdTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
||||
|
@ -41,7 +55,7 @@ index 8400774db..f105bed29 100644
|
|||
default:
|
||||
return new X86_32TargetInfo(Triple, Opts);
|
||||
}
|
||||
@@ -596,6 +600,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
@@ -596,6 +602,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new PS4OSTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::PS5:
|
||||
return new PS5OSTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
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.
|
||||
|
@ -13,7 +12,7 @@ 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 ec6860113..c5c07e5ee 100644
|
||||
index 77554aa2c..84eebee36 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -6100,7 +6100,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
|
|
@ -36,7 +36,7 @@ index a12aa1de1..075ebbe81 100644
|
|||
__support/solaris/wchar.h
|
||||
__support/solaris/xlocale.h
|
||||
diff --git a/libcxx/include/__config b/libcxx/include/__config
|
||||
index 5e30a4217..5dea34814 100644
|
||||
index 108153883..e4434809c 100644
|
||||
--- a/libcxx/include/__config
|
||||
+++ b/libcxx/include/__config
|
||||
@@ -930,7 +930,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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] [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
|
||||
|
|
Loading…
Reference in a new issue