Skip to content

[compiler-rt][profile] Add support for LLVM profile for Haiku #107575

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

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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.
Expand Down Expand Up @@ -826,7 +830,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|WASI")
OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI|Haiku")
set(COMPILER_RT_HAS_PROFILE TRUE)
else()
set(COMPILER_RT_HAS_PROFILE FALSE)
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
defined(_AIX) || defined(__wasm__)
defined(_AIX) || defined(__wasm__) || defined(__HAIKU__)

#if !defined(_AIX) && !defined(__wasm__)
#include <elf.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/profile/InstrProfilingPlatformOther.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && \
!defined(__wasm__)
!defined(__wasm__) && !defined(__HAIKU__)

#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/builtins/Unit/ctor_dtor.c
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/builtins/Unit/dso_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).*}}
Expand Down
8 changes: 7 additions & 1 deletion compiler-rt/test/builtins/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def get_libgcc_file_name():
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:
Expand All @@ -123,6 +126,9 @@ def get_libgcc_file_name():
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"))
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/test/lit.common.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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"

Expand Down Expand Up @@ -275,7 +277,6 @@ def push_dynamic_library_lookup_path(config, new_path):
"COMPILER_PATH",
"RC_DEBUG_OPTIONS",
"CINDEXTEST_PREAMBLE_FILE",
"LIBRARY_PATH",
"CPATH",
"C_INCLUDE_PATH",
"CPLUS_INCLUDE_PATH",
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/profile/Posix/gcov-destructor.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Test that destructors and destructors whose priorities are greater than 100 are tracked.
// XFAIL: target={{.*haiku.*}}
// RUN: mkdir -p %t.dir && cd %t.dir
// RUN: %clang --coverage %s -o %t -dumpdir ./
// RUN: rm -f gcov-destructor.gcda && %run %t
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/profile/Posix/gcov-dlopen.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// atexit(3) not supported in dlopen(3)ed+dlclose(3)d DSO
// XFAIL: target={{.*netbsd.*}}
// XFAIL: target={{.*haiku.*}}

// RUN: mkdir -p %t.d && cd %t.d

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
XFAIL: target={{.*haiku.*}}
RUN: rm -rf %t && split-file %s %t && cd %t
RUN: %clang_pgogen -fprofile-update=atomic -fPIC foo.c -c -Xclang -fprofile-instrument-path="default_foo_%m.profraw"
RUN: %clang_pgogen -fprofile-update=atomic -fPIC foo2.c -c -Xclang -fprofile-instrument-path="default_foo2_%m.profraw"
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/profile/instrprof-error.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: target={{.*haiku.*}}
// RUN: %clang_profgen -o %t -O3 %s
// RUN: env LLVM_PROFILE_FILE=%t/ %run %t 1 2>&1 | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/profile/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def exclude_unsupported_files_for_aix(dirname):
"NetBSD",
"SunOS",
"AIX",
"Haiku",
]:
config.unsupported = True

Expand Down
Loading