Skip to content

Commit d084bc2

Browse files
korlipetrhosek
andauthored
[compiler-rt][profile] Add support for LLVM profile for Haiku (llvm#107575)
Haiku uses typical UNIX interfaces. All tests pass except instrprof-error.c Posix/gcov-dlopen.c Posix/gcov-destructor.c Posix/instrprof-dlopen-norpath.test --------- Co-authored-by: Petr Hosek <[email protected]>
1 parent 283273f commit d084bc2

File tree

12 files changed

+25
-9
lines changed

12 files changed

+25
-9
lines changed

compiler-rt/cmake/config-ix.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
3737
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
3838
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
3939
if (COMPILER_RT_HAS_LIBC)
40-
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
40+
if (HAIKU)
41+
list(APPEND CMAKE_REQUIRED_LIBRARIES root)
42+
else()
43+
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
44+
endif()
4145
endif ()
4246
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
4347
# TODO: remote this check once we address PR51389.
@@ -826,7 +830,7 @@ else()
826830
endif()
827831

828832
if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
829-
OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
833+
OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI|Haiku")
830834
set(COMPILER_RT_HAS_PROFILE TRUE)
831835
else()
832836
set(COMPILER_RT_HAS_PROFILE FALSE)

compiler-rt/lib/profile/InstrProfilingPlatformLinux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
1010
(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
11-
defined(_AIX) || defined(__wasm__)
11+
defined(_AIX) || defined(__wasm__) || defined(__HAIKU__)
1212

1313
#if !defined(_AIX) && !defined(__wasm__)
1414
#include <elf.h>

compiler-rt/lib/profile/InstrProfilingPlatformOther.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
1010
!defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \
1111
!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) && \
12-
!defined(__wasm__)
12+
!defined(__wasm__) && !defined(__HAIKU__)
1313

1414
#include <stdlib.h>
1515
#include <stdio.h>

compiler-rt/test/builtins/Unit/ctor_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: crt
22

33
// RUN: %clang -fno-use-init-array -g -c %s -o %t.o
4-
// RUN: %clang -o %t -no-pie -nostdlib %crt1 %crti %crtbegin %t.o -lc %libgcc %crtend %crtn
4+
// RUN: %clang -o %t -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libc %libgcc %crtend %crtn
55
// RUN: %run %t 2>&1 | FileCheck %s
66

77
#include <stdio.h>

compiler-rt/test/builtins/Unit/dso_handle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
// RUN: %clangxx -g -fno-exceptions -DCRT_SHARED -c %s -fPIC -o %tshared.o
44
// RUN: %clangxx -g -fno-exceptions -c %s -fPIC -o %t.o
5-
// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx -lc -lm %libgcc %crtend %crtn
6-
// RUN: %clangxx -g -o %t -fno-pic -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn
5+
// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx %libc -lm %libgcc %crtend %crtn
6+
// RUN: %clangxx -g -o %t -fno-pic -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx %libc -lm %libgcc %t.so %crtend %crtn
77
// RUN: %run %t 2>&1 | FileCheck %s
88

99
// UNSUPPORTED: target={{(arm|aarch64).*}}

compiler-rt/test/builtins/Unit/lit.cfg.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ def get_libgcc_file_name():
104104
if sys.platform in ["win32"] and execute_external:
105105
# Don't pass dosish path separator to msys bash.exe.
106106
base_lib = base_lib.replace("\\", "/")
107-
config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
107+
if config.host_os == "Haiku":
108+
config.substitutions.append(("%librt ", base_lib + " -lroot "))
109+
else:
110+
config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
108111

109112
builtins_build_crt = get_required_attr(config, "builtins_build_crt")
110113
if builtins_build_crt:
@@ -123,6 +126,9 @@ def get_libgcc_file_name():
123126
config.substitutions.append(("%crtn", get_library_path("crtn.o")))
124127

125128
config.substitutions.append(("%libgcc", get_libgcc_file_name()))
129+
config.substitutions.append(
130+
("%libc", "-lroot" if sys.platform.startswith("haiku") else "-lc")
131+
)
126132

127133
config.substitutions.append(
128134
("%libstdcxx", "-l" + config.sanitizer_cxx_lib.lstrip("lib"))

compiler-rt/test/lit.common.cfg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def push_dynamic_library_lookup_path(config, new_path):
8282
dynamic_library_lookup_var = "PATH"
8383
elif platform.system() == "Darwin":
8484
dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
85+
elif platform.system() == "Haiku":
86+
dynamic_library_lookup_var = "LIBRARY_PATH"
8587
else:
8688
dynamic_library_lookup_var = "LD_LIBRARY_PATH"
8789

@@ -275,7 +277,6 @@ def push_dynamic_library_lookup_path(config, new_path):
275277
"COMPILER_PATH",
276278
"RC_DEBUG_OPTIONS",
277279
"CINDEXTEST_PREAMBLE_FILE",
278-
"LIBRARY_PATH",
279280
"CPATH",
280281
"C_INCLUDE_PATH",
281282
"CPLUS_INCLUDE_PATH",

compiler-rt/test/profile/Posix/gcov-destructor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// Test that destructors and destructors whose priorities are greater than 100 are tracked.
2+
// XFAIL: target={{.*haiku.*}}
23
// RUN: mkdir -p %t.dir && cd %t.dir
34
// RUN: %clang --coverage %s -o %t -dumpdir ./
45
// RUN: rm -f gcov-destructor.gcda && %run %t

compiler-rt/test/profile/Posix/gcov-dlopen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// atexit(3) not supported in dlopen(3)ed+dlclose(3)d DSO
22
// XFAIL: target={{.*netbsd.*}}
3+
// XFAIL: target={{.*haiku.*}}
34

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

compiler-rt/test/profile/Posix/instrprof-dlopen-norpath.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
XFAIL: target={{.*haiku.*}}
12
RUN: rm -rf %t && split-file %s %t && cd %t
23
RUN: %clang_pgogen -fprofile-update=atomic -fPIC foo.c -c -Xclang -fprofile-instrument-path="default_foo_%m.profraw"
34
RUN: %clang_pgogen -fprofile-update=atomic -fPIC foo2.c -c -Xclang -fprofile-instrument-path="default_foo2_%m.profraw"

compiler-rt/test/profile/instrprof-error.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// XFAIL: target={{.*haiku.*}}
12
// RUN: %clang_profgen -o %t -O3 %s
23
// RUN: env LLVM_PROFILE_FILE=%t/ %run %t 1 2>&1 | FileCheck %s
34

compiler-rt/test/profile/lit.cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def exclude_unsupported_files_for_aix(dirname):
162162
"NetBSD",
163163
"SunOS",
164164
"AIX",
165+
"Haiku",
165166
]:
166167
config.unsupported = True
167168

0 commit comments

Comments
 (0)