Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolchain: Update LLVM to 18.1.3 #23960

Merged
merged 8 commits into from
Apr 18, 2024
Merged
5 changes: 5 additions & 0 deletions AK/UBSanitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ struct PointerOverflowData {
SourceLocation location;
};

struct FunctionTypeMismatchData {
SourceLocation location;
TypeDescriptor const& type;
};

struct FloatCastOverflowData {
SourceLocation location;
TypeDescriptor const& from_type;
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif()

# Check for toolchain mismatch, user might need to rebuild toolchain
set(GCC_VERSION "13.2.0")
set(LLVM_VERSION "16.0.6")
set(LLVM_VERSION "18.1.3")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(EXPECTED_COMPILER_VERSION "${GCC_VERSION}")
else()
Expand Down
2 changes: 1 addition & 1 deletion Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ macro (set_new_alignment alignment)
endmacro()

if ("${SERENITY_ARCH}" STREQUAL "x86_64")
add_compile_options(-mcmodel=large -mno-red-zone)
add_compile_options(-mno-red-zone)
set_new_alignment(8)
endif()

Expand Down
6 changes: 6 additions & 0 deletions Kernel/Prekernel/UBSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,10 @@ void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandl
{
print_location(data.location);
}

void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const&, ValueHandle) __attribute__((used));
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const& data, ValueHandle)
{
print_location(data.location);
}
}
7 changes: 7 additions & 0 deletions Kernel/Security/UBSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,11 @@ void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandl
critical_dmesgln("KUBSAN: addition of unsigned offset to {:p} overflowed to {:p}", base, result);
print_location(data.location);
}

void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const&) __attribute__((used));
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const& data)
{
critical_dmesgln("KUBSAN: call to function through pointer to incorrect function type {}", data.type.name());
print_location(data.location);
}
}
60 changes: 31 additions & 29 deletions Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,42 +1724,44 @@ struct PropertyMetadata {
// this process reduces over 1 million entries (0x10ffff) to ~44,030.
//
// For much more in-depth reading, see: https://icu.unicode.org/design/struct/utrie
static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
static constexpr auto MAX_CODE_POINT = 0x10ffffu;

template<typename T>
static ErrorOr<void> update_tables(u32 code_point, CodePointTables<T>& tables, auto& metadata, auto const& values)
{
static constexpr auto MAX_CODE_POINT = 0x10ffffu;
static constexpr auto BLOCK_SIZE = CODE_POINT_TABLES_LSB_MASK + 1;

size_t unique_properties_index = 0;
if (auto block_index = tables.unique_properties.find_first_index(values); block_index.has_value()) {
unique_properties_index = *block_index;
} else {
unique_properties_index = tables.unique_properties.size();
TRY(tables.unique_properties.try_append(values));
}

auto update_tables = [&](auto code_point, auto& tables, auto& metadata, auto const& values) -> ErrorOr<void> {
static constexpr auto BLOCK_SIZE = CODE_POINT_TABLES_LSB_MASK + 1;
TRY(metadata.current_block.try_append(unique_properties_index));

size_t unique_properties_index = 0;
if (auto block_index = tables.unique_properties.find_first_index(values); block_index.has_value()) {
unique_properties_index = *block_index;
if (metadata.current_block.size() == BLOCK_SIZE || code_point == MAX_CODE_POINT) {
size_t stage2_index = 0;
if (auto block_index = metadata.unique_blocks.get(metadata.current_block); block_index.has_value()) {
stage2_index = *block_index;
} else {
unique_properties_index = tables.unique_properties.size();
TRY(tables.unique_properties.try_append(values));
}

TRY(metadata.current_block.try_append(unique_properties_index));

if (metadata.current_block.size() == BLOCK_SIZE || code_point == MAX_CODE_POINT) {
size_t stage2_index = 0;
if (auto block_index = metadata.unique_blocks.get(metadata.current_block); block_index.has_value()) {
stage2_index = *block_index;
} else {
stage2_index = tables.stage2.size();
TRY(tables.stage2.try_extend(metadata.current_block));

TRY(metadata.unique_blocks.try_set(metadata.current_block, stage2_index));
}
stage2_index = tables.stage2.size();
TRY(tables.stage2.try_extend(metadata.current_block));

TRY(tables.stage1.try_append(stage2_index));
metadata.current_block.clear_with_capacity();
TRY(metadata.unique_blocks.try_set(metadata.current_block, stage2_index));
}

return {};
};
TRY(tables.stage1.try_append(stage2_index));
metadata.current_block.clear_with_capacity();
}

return {};
}

auto update_casing_tables = [&](auto code_point, auto& tables, auto& metadata) -> ErrorOr<void> {
static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
{
auto update_casing_tables = [&]<typename T>(u32 code_point, CodePointTables<T>& tables, CasingMetadata& metadata) -> ErrorOr<void> {
CasingTable casing {};

while (metadata.iterator != metadata.end) {
Expand All @@ -1778,7 +1780,7 @@ static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
return {};
};

auto update_property_tables = [&](auto code_point, auto& tables, auto& metadata) -> ErrorOr<void> {
auto update_property_tables = [&]<typename T>(u32 code_point, CodePointTables<T>& tables, PropertyMetadata& metadata) -> ErrorOr<void> {
static Unicode::CodePointRangeComparator comparator {};

for (auto& property_values : metadata.property_values) {
Expand Down
2 changes: 1 addition & 1 deletion Ports/AvailablePorts.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`libzip`](libzip/) | libzip | 1.10.1 | https://libzip.org/ |
| [`links`](links/) | Links web browser | 2.29 | http://links.twibright.com/ |
| [`lite-xl`](lite-xl/) | Lite-XL | 2.1.3 | https://lite-xl.com/ |
| [`llvm`](llvm/) | LLVM | 16.0.6 | https://llvm.org/ |
| [`llvm`](llvm/) | LLVM | 18.1.3 | 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.6 | https://www.lua.org/ |
Expand Down
6 changes: 3 additions & 3 deletions Ports/llvm/package.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env -S bash ../.port_include.sh
port='llvm'
useconfigure='true'
version='16.0.6'
version='18.1.3'
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#ce5e71081d17ce9e86d7cbcfa28c4b04b9300f8fb7e78422b1feb6bc52c3028e"
"https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz#2929f62d69dec0379e529eb632c40e15191e36f3bd58c2cb2df0413a0dc48651"
)
depends=(
"ncurses"
Expand Down Expand Up @@ -54,7 +54,7 @@ configure() {
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
-DLLVM_OCAML_INSTALL_PATH="${SERENITY_INSTALL_ROOT}/usr/local/ocaml" \
-DLLVM_PTHREAD_LIB=pthread \
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_TARGETS_TO_BUILD="X86;AArch64;RISCV"
}

build() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <[email protected]>
Date: Thu, 14 Apr 2022 09:54:22 +0200
Subject: [PATCH] [Support] Add support for building LLVM on SerenityOS

Adds SerenityOS `#ifdef`s for platform-specific code.

We stub out wait4, as SerenityOS doesn't support querying a child
process's resource usage information.
---
llvm/include/llvm/Support/SwapByteOrder.h | 2 +-
llvm/lib/Support/Unix/Path.inc | 5 ++++-
llvm/lib/Support/Unix/Program.inc | 9 ++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h
index 9dd08665b..8915f92e8 100644
--- a/llvm/include/llvm/Support/SwapByteOrder.h
+++ b/llvm/include/llvm/Support/SwapByteOrder.h
@@ -20,7 +20,7 @@
#include <type_traits>

#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>
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
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__) || \
- defined(__MVS__)
+ defined(__MVS__) || defined(__serenity__)
#define STATVFS_F_FLAG(vfs) (vfs).f_flag
#else
#define STATVFS_F_FLAG(vfs) (vfs).f_flags
@@ -506,6 +506,9 @@ static bool is_local_impl(struct STATVFS &Vfs) {
#elif defined(__HAIKU__)
// Haiku doesn't expose this information.
return false;
+#elif defined(__serenity__)
+ // 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
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 897e22711..23965a1a1 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -340,7 +340,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);
@@ -383,6 +383,13 @@ pid_t(llvm::sys::wait4)(pid_t pid, int *status, int options,
}
#endif

+#ifdef __serenity__
+pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
+ struct rusage*) {
+ return ::waitpid(pid, status, options);
+}
+#endif
+
ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
std::optional<unsigned> SecondsToWait,
std::string *ErrMsg,

This file was deleted.

56 changes: 56 additions & 0 deletions Ports/zig/patches/0002-Triple-Add-triple-for-SerenityOS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <[email protected]>
Date: Thu, 14 Apr 2022 09:51:24 +0200
Subject: [PATCH] [Triple] Add triple for SerenityOS

---
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/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
- LastOSType = ShaderModel
+ Serenity,
+ LastOSType = Serenity
};
enum EnvironmentType {
UnknownEnvironment,
@@ -670,6 +671,11 @@ public:
return getOS() == Triple::AIX;
}

+ /// Tests whether the OS is SerenityOS
+ bool isOSSerenity() const {
+ return getOS() == Triple::Serenity;
+ }
+
/// Tests whether the OS uses the ELF binary format.
bool isOSBinFormatELF() const {
return getObjectFormat() == Triple::ELF;
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";
+ case Serenity: return "serenity";
case TvOS: return "tvos";
case WASI: return "wasi";
case WatchOS: return "watchos";
@@ -596,6 +597,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("wasi", Triple::WASI)
.StartsWith("emscripten", Triple::Emscripten)
.StartsWith("shadermodel", Triple::ShaderModel)
+ .StartsWith("serenity", Triple::Serenity)
.Default(Triple::UnknownOS);
}

This file was deleted.

Loading
Loading