[PATCH] D87920: [Support] Fix build for Haiku

Niels Sascha Reedijk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 11:04:07 PDT 2020


nielx created this revision.
nielx added a reviewer: chandlerc.
Herald added subscribers: llvm-commits, hiraditya, mgorny.
Herald added a project: LLVM.
nielx requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87920

Files:
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Unix/Program.inc


Index: llvm/lib/Support/Unix/Program.inc
===================================================================
--- llvm/lib/Support/Unix/Program.inc
+++ llvm/lib/Support/Unix/Program.inc
@@ -448,8 +448,12 @@
   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
Index: llvm/lib/Support/CMakeLists.txt
===================================================================
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -36,6 +36,10 @@
   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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87920.292848.patch
Type: text/x-patch
Size: 1129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200918/9b91566a/attachment.bin>


More information about the llvm-commits mailing list