From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 4 Mar 2022 15:13:42 -0700 Subject: [PATCH] [compiler-rt/llvm] Enable profile instrumentation for SerenityOS Treat SerenityOS the same as other *NIX platforms that behave close enough to linux to use the pre-canned InstrProfiling implementation. Curiously, enabling profiling for the SerenityOS target changes the ELF OS ABI for userspace binaries to 3, or GNU/Linux. --- compiler-rt/cmake/config-ix.cmake | 2 +- compiler-rt/lib/profile/InstrProfilingPlatformLinux.c | 2 +- compiler-rt/lib/profile/InstrProfilingPlatformOther.c | 2 +- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 3 ++- 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 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -756,7 +756,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|SerenityOS") 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 3af61d24948e7c9b6e8f3950a418516c603457a2..ee46741d47ead6c9e6931c8d3a6f16e8cd6407ae 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(__serenity__) #if !defined(_AIX) #include diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c index c7b6e842c9fac27b2885242d6c2cd48797bfe799..00fdf9ee6adc8e5fffda50cd981c901f02fddaf2 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(__serenity__) #include #include diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 5b7aa304b9876fc027e251547340df56dcf0c343..b3b037a6fdf5ea2dd749c8eb5329c9a29b44f75c 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) { return false; // Use linker script magic to get data/cnts/name start/end. if (TT.isOSAIX() || TT.isOSLinux() || TT.isOSFreeBSD() || TT.isOSNetBSD() || - TT.isOSSolaris() || TT.isOSFuchsia() || TT.isPS() || TT.isOSWindows()) + TT.isOSSolaris() || TT.isOSFuchsia() || TT.isPS() || TT.isOSWindows() || + TT.isOSSerenity()) return false; return true;