[llvm] 5c1cea6 - [Support] Fix build for Haiku
Serge Pavlov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 19:53:12 PST 2021
Author: Serge Pavlov
Date: 2021-01-28T10:50:04+07:00
New Revision: 5c1cea6f406366b85f3c200a1c48f713da4450ba
URL: https://github.com/llvm/llvm-project/commit/5c1cea6f406366b85f3c200a1c48f713da4450ba
DIFF: https://github.com/llvm/llvm-project/commit/5c1cea6f406366b85f3c200a1c48f713da4450ba.diff
LOG: [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.
Added:
Modified:
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/Unix/Program.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index cdee11412eb5..1c805e3af2a2 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -36,6 +36,10 @@ elseif( CMAKE_HOST_UNIX )
if( FUCHSIA )
set(system_libs ${system_libs} zircon)
endif()
+ if ( HAIKU )
+ add_definitions(-D_BSD_SOURCE)
+ set(system_libs ${system_libs} bsd)
+ endif()
endif( MSVC OR MINGW )
# Delay load shell32.dll if possible to speed up process startup.
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index fb56fa4b0d1d..d42681f5dc6b 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -452,8 +452,12 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
if (ProcStat) {
std::chrono::microseconds UserT = toDuration(Info.ru_utime);
std::chrono::microseconds KernelT = toDuration(Info.ru_stime);
+#ifndef __HAIKU__
uint64_t PeakMemory = static_cast<uint64_t>(Info.ru_maxrss);
*ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory};
+#else
+ *ProcStat = ProcessStatistics{UserT + KernelT, UserT, 0};
+#endif
}
// Return the proper exit status. Detect error conditions
More information about the llvm-commits
mailing list