llvm18: enable profile for Haiku

This commit is contained in:
Jérôme Duval
2024-09-02 17:46:14 +02:00
parent 50fdcb4bc4
commit d8bb561bb8
2 changed files with 189 additions and 24 deletions

View File

@@ -30,7 +30,7 @@ other than the ones listed above.
HOMEPAGE="https://www.llvm.org/"
COPYRIGHT="2003-2024 University of Illinois at Urbana-Champaign"
LICENSE="Apache v2 with LLVM Exception"
REVISION="2"
REVISION="3"
SOURCE_URI="https://github.com/llvm/llvm-project/releases/download/llvmorg-$portVersion/llvm-project-$portVersion.src.tar.xz"
CHECKSUM_SHA256="74446ab6943f686391954cbda0d77ae92e8a60c432eff437b8666e121d748ec4"
SOURCE_DIR="llvm-project-$portVersion.src"
@@ -793,5 +793,5 @@ TEST()
else
export LIBRARY_PATH=$LIBRARY_PATH:$sourceDir/build/lib
fi
ninja -C build check-llvm
ninja -C build check-llvm check-compiler-rt
}

View File

@@ -1,4 +1,4 @@
From 83b666a5d5782b4836adfe204c3beb8dd503995f Mon Sep 17 00:00:00 2001
From 4a32e3434770e23d0b633db6a168242f9a5081d4 Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Sun, 9 Sep 2018 16:11:42 +0100
Subject: llvm: import header dir suffix patch from 3dEyes
@@ -21,10 +21,10 @@ index d5b76b1..df3fb59 100644
SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
sys::fs::make_absolute(ActivePrefix, Path);
--
2.45.1
2.45.2
From e45dae794e5afe859b599fac3b89ab3b62ae8d0f Mon Sep 17 00:00:00 2001
From d7c1eec10cc400f21d66763d3210fe49ae67d2c9 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 3 Apr 2021 23:23:24 +0200
Subject: lld: MachO needs libunwind somehow, disable
@@ -115,10 +115,10 @@ index d6800fa..d2bac9f 100644
int lld_main(int argc, char **argv, const llvm::ToolContext &) {
--
2.45.1
2.45.2
From 236a61d17d3b8794e1e290904540ee539138b108 Mon Sep 17 00:00:00 2001
From 5fb1e0b269b1d88198709dc92c5a99c936affbc0 Mon Sep 17 00:00:00 2001
From: Trung Nguyen <trungnt282910@gmail.com>
Date: Thu, 7 Jul 2022 22:19:34 +0700
Subject: libunwind: Haiku: Initial support
@@ -168,10 +168,10 @@ index 780430b..2ffaf45 100644
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
--
2.45.1
2.45.2
From 229a2eb579cb257d9223c88bccbf1a02d6ab5bed Mon Sep 17 00:00:00 2001
From f3dbda4b0ca0b249fbb65fcb3e3a992c615cb392 Mon Sep 17 00:00:00 2001
From: X512 <danger_mail@list.ru>
Date: Wed, 16 Mar 2022 07:04:18 +0900
Subject: libunwind: Haiku: Signal frame unwinding support
@@ -298,10 +298,10 @@ index 7753936..d7e4344 100644
result = this->stepThroughSigReturn();
} else
--
2.45.1
2.45.2
From d955c25b4980b0414705978ce1a2aec058d5bb14 Mon Sep 17 00:00:00 2001
From 7d62fd071eb21ca11ef4fc8bbff223d7bc3bf9a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Mon, 18 Jul 2016 14:13:19 +0200
Subject: clang: support for secondary arch.
@@ -393,10 +393,10 @@ index e0d9403..3b9e9ee 100644
"/boot/system/develop/headers"));
}
--
2.45.1
2.45.2
From ea19be817aabb3e6f304a47be0e88cdca89148ae Mon Sep 17 00:00:00 2001
From 246062b05e97f102d1bc84468f4c07be0e4bbcd2 Mon Sep 17 00:00:00 2001
From: David Karoly <karolyd577@gmail.com>
Date: Thu, 21 Sep 2023 17:44:12 +0000
Subject: fix build on x86 secondary arch
@@ -416,10 +416,10 @@ index b9a966b..81277dc 100644
set(generated_files)
--
2.45.1
2.45.2
From cfa6680a8b0d39d38e6791362767ed23dee1e151 Mon Sep 17 00:00:00 2001
From 70b5acf2b8bd7de402f90f38199010a25a582608 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Mon, 6 Nov 2023 14:24:21 +0100
Subject: clang: Haiku: patch for analyzer scripts
@@ -478,10 +478,10 @@ index d01aebb..43ba8c3 100755
# Otherwise look relative to the source
share = os.path.dirname(__file__) + "/../../scan-view/share"
--
2.45.1
2.45.2
From 220c5e6edadffa2ee86b0906f70f0b332ba2fab9 Mon Sep 17 00:00:00 2001
From 3f21b8119674b6c7ee6f42085c183ed6bf538841 Mon Sep 17 00:00:00 2001
From: David Karoly <karolyd577@gmail.com>
Date: Sun, 3 Mar 2024 21:58:38 +0100
Subject: Link libnetwork on Haiku in llvm-jitlink
@@ -500,10 +500,10 @@ index c9d1d23..702090c 100644
+ endif()
export_executable_symbols(llvm-jitlink)
--
2.45.1
2.45.2
From 51ee759fdde10bc9da34100b44aee30b1a750fde Mon Sep 17 00:00:00 2001
From 2fa91219ac9f7fce878d1c91975c0c34a9337886 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Mon, 10 Jun 2024 11:13:29 +0200
Subject: A slightly better llvm-config diff that doesn't use #ifdef.
@@ -546,10 +546,10 @@ index df3fb59..30cb748 100644
SharedExt = "dll";
SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
--
2.45.1
2.45.2
From c673cac7374e2a5895f0be337775c1074237f7e0 Mon Sep 17 00:00:00 2001
From 0179f30af73bc9e3583b91bbfdd9cb31c7e85b65 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 19 May 2024 10:31:55 +0200
Subject: Allow linking gcc compiled code with lld
@@ -557,10 +557,10 @@ Subject: Allow linking gcc compiled code with lld
https://github.com/haikuports/haikuports/issues/10445
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index c2059c7..31541a4 100644
index 8b2c32b..c8ad6c3 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -186,8 +186,8 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef emul) {
@@ -193,8 +193,8 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef emul) {
.Case("elf64lriscv", {ELF64LEKind, EM_RISCV})
.Case("elf64ppc", {ELF64BEKind, EM_PPC64})
.Case("elf64lppc", {ELF64LEKind, EM_PPC64})
@@ -572,5 +572,170 @@ index c2059c7..31541a4 100644
.Case("elf64_sparc", {ELF64BEKind, EM_SPARCV9})
.Case("msp430elf", {ELF32LEKind, EM_MSP430})
--
2.43.2
2.45.2
From 56179ddca46cc0357842122c5fad5a4fee4d2d33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Mon, 2 Sep 2024 17:41:04 +0200
Subject: Add support for LLVM profile for Haiku
Haiku uses typical UNIX interfaces.
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 2ca18eb..99127df 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -38,7 +38,11 @@ check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
if (COMPILER_RT_HAS_LIBC)
- list(APPEND CMAKE_REQUIRED_LIBRARIES c)
+ if (HAIKU)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES root)
+ else ()
+ list(APPEND CMAKE_REQUIRED_LIBRARIES c)
+ endif ()
endif ()
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
# TODO: remote this check once we address PR51389.
@@ -795,7 +799,7 @@ else()
endif()
if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
- OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
+ OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|Haiku")
set(COMPILER_RT_HAS_PROFILE TRUE)
else()
set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
index 19266ab..fdad350 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -8,7 +8,7 @@
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
- defined(_AIX)
+ defined(_AIX) || defined(__HAIKU__)
#if !defined(_AIX)
#include <elf.h>
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
index 5319ca8..3521db5 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
@@ -8,7 +8,7 @@
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
- !defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX)
+ !defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && !defined(__HAIKU__)
#include <stdlib.h>
#include <stdio.h>
diff --git a/compiler-rt/test/builtins/Unit/ctor_dtor.c b/compiler-rt/test/builtins/Unit/ctor_dtor.c
index 4756072..58dffba 100644
--- a/compiler-rt/test/builtins/Unit/ctor_dtor.c
+++ b/compiler-rt/test/builtins/Unit/ctor_dtor.c
@@ -1,7 +1,7 @@
// REQUIRES: crt
// RUN: %clang -fno-use-init-array -g -c %s -o %t.o
-// RUN: %clang -o %t -no-pie -nostdlib %crt1 %crti %crtbegin %t.o -lc %libgcc %crtend %crtn
+// RUN: %clang -o %t -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libc %libgcc %crtend %crtn
// RUN: %run %t 2>&1 | FileCheck %s
#include <stdio.h>
diff --git a/compiler-rt/test/builtins/Unit/dso_handle.cpp b/compiler-rt/test/builtins/Unit/dso_handle.cpp
index 7967469..183e29b 100644
--- a/compiler-rt/test/builtins/Unit/dso_handle.cpp
+++ b/compiler-rt/test/builtins/Unit/dso_handle.cpp
@@ -2,8 +2,8 @@
// RUN: %clangxx -g -fno-exceptions -DCRT_SHARED -c %s -fPIC -o %tshared.o
// RUN: %clangxx -g -fno-exceptions -c %s -fPIC -o %t.o
-// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx -lc -lm %libgcc %crtend %crtn
-// RUN: %clangxx -g -o %t -fno-pic -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn
+// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx %libc -lm %libgcc %crtend %crtn
+// RUN: %clangxx -g -o %t -fno-pic -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx %libc -lm %libgcc %t.so %crtend %crtn
// RUN: %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: target={{(arm|aarch64).*}}
diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py
index f63d159..f1f63df 100644
--- a/compiler-rt/test/builtins/Unit/lit.cfg.py
+++ b/compiler-rt/test/builtins/Unit/lit.cfg.py
@@ -104,7 +104,10 @@ else:
if sys.platform in ["win32"] and execute_external:
# Don't pass dosish path separator to msys bash.exe.
base_lib = base_lib.replace("\\", "/")
- config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
+ if config.host_os == "Haiku":
+ config.substitutions.append(("%librt ", base_lib + " -lroot "))
+ else:
+ config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
builtins_build_crt = get_required_attr(config, "builtins_build_crt")
if builtins_build_crt:
@@ -123,6 +126,7 @@ if builtins_build_crt:
config.substitutions.append(("%crtn", get_library_path("crtn.o")))
config.substitutions.append(("%libgcc", get_libgcc_file_name()))
+ config.substitutions.append(("%libc", "-lroot" if sys.platform.startswith("haiku") else "-lc"))
config.substitutions.append(
("%libstdcxx", "-l" + config.sanitizer_cxx_lib.lstrip("lib"))
diff --git a/compiler-rt/test/builtins/Unit/test b/compiler-rt/test/builtins/Unit/test
index e068379..7f3e43f 100755
--- a/compiler-rt/test/builtins/Unit/test
+++ b/compiler-rt/test/builtins/Unit/test
@@ -13,7 +13,11 @@ if test `uname` = "Darwin"; then
LIBS="-lSystem"
fi
else
- LIBS="-lc -lm"
+ if test `uname` = "Haiku"; then
+ LIBS="-lroot"
+ else
+ LIBS="-lc -lm"
+ fi
fi
for ARCH in $ARCHS; do
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 113777b..4eaf50e 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -81,6 +81,8 @@ def push_dynamic_library_lookup_path(config, new_path):
dynamic_library_lookup_var = "PATH"
elif platform.system() == "Darwin":
dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
+ elif platform.system() == "Haiku":
+ dynamic_library_lookup_var = "LIBRARY_PATH"
else:
dynamic_library_lookup_var = "LD_LIBRARY_PATH"
@@ -219,7 +221,6 @@ possibly_dangerous_env_vars = [
"COMPILER_PATH",
"RC_DEBUG_OPTIONS",
"CINDEXTEST_PREAMBLE_FILE",
- "LIBRARY_PATH",
"CPATH",
"C_INCLUDE_PATH",
"CPLUS_INCLUDE_PATH",
diff --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py
index d3ba115..c9a272e 100644
--- a/compiler-rt/test/profile/lit.cfg.py
+++ b/compiler-rt/test/profile/lit.cfg.py
@@ -166,6 +166,7 @@ if config.host_os not in [
"NetBSD",
"SunOS",
"AIX",
+ "Haiku",
]:
config.unsupported = True
--
2.45.2