Skip to content

Commit 5c1cea6

Browse files
committed
[Support] Fix build for Haiku
This change fixes two issues with building LLVM on Haiku. The first issue is that LLVM requires wait4(), which on Haiku is hidden behind the _BSD_SOURCE feature flag when using the --std=c++14 flag. Additionally, the wait4() function is only available in libbsd.so, so this is now a dependency. The other fix is that Haiku does not have the (non-standard) rusage.maxrss member, so by default the used memory info will be set to 0 on this platform. Reviewed By: sepavloff Differential Revision: https://reviews.llvm.org/D87920 Patch by Niels Sascha Reedijk.
1 parent 2b9ed4f commit 5c1cea6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

llvm/lib/Support/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ elseif( CMAKE_HOST_UNIX )
3636
if( FUCHSIA )
3737
set(system_libs ${system_libs} zircon)
3838
endif()
39+
if ( HAIKU )
40+
add_definitions(-D_BSD_SOURCE)
41+
set(system_libs ${system_libs} bsd)
42+
endif()
3943
endif( MSVC OR MINGW )
4044

4145
# Delay load shell32.dll if possible to speed up process startup.

llvm/lib/Support/Unix/Program.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,12 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
452452
if (ProcStat) {
453453
std::chrono::microseconds UserT = toDuration(Info.ru_utime);
454454
std::chrono::microseconds KernelT = toDuration(Info.ru_stime);
455+
#ifndef __HAIKU__
455456
uint64_t PeakMemory = static_cast<uint64_t>(Info.ru_maxrss);
456457
*ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory};
458+
#else
459+
*ProcStat = ProcessStatistics{UserT + KernelT, UserT, 0};
460+
#endif
457461
}
458462

459463
// Return the proper exit status. Detect error conditions

0 commit comments

Comments
 (0)