From 538789bccfab4c63771a2459d99c44f5c4fe11b7 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 3 Apr 2021 23:23:24 +0200
Subject: MachO needs libunwind somehow, disable


diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4e561b..cd853a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -197,7 +197,9 @@ endif()
 add_subdirectory(docs)
 add_subdirectory(COFF)
 add_subdirectory(ELF)
+if (NOT HAIKU)
 add_subdirectory(MachO)
+endif()
 add_subdirectory(MinGW)
 add_subdirectory(wasm)
 
diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
index 5cff736..2d4907a 100644
--- a/tools/lld/CMakeLists.txt
+++ b/tools/lld/CMakeLists.txt
@@ -9,6 +9,17 @@ add_lld_tool(lld
   )
 export_executable_symbols_for_plugins(lld)
 
+if (HAIKU)
+target_link_libraries(lld
+  PRIVATE
+  lldCommon
+  lldCOFF
+  lldDriver
+  lldELF
+  lldMinGW
+  lldWasm
+  )
+else()
 target_link_libraries(lld
   PRIVATE
   lldCommon
@@ -19,6 +30,7 @@ target_link_libraries(lld
   lldMinGW
   lldWasm
   )
+endif()
 
 install(TARGETS lld
   RUNTIME DESTINATION bin)
diff --git a/tools/lld/lld.cpp b/tools/lld/lld.cpp
index 77d7792..973fbf3 100644
--- a/tools/lld/lld.cpp
+++ b/tools/lld/lld.cpp
@@ -153,10 +153,12 @@ static int lldMain(int argc, const char **argv, llvm::raw_ostream &stdoutOS,
     return !elf::link(args, exitEarly, stdoutOS, stderrOS);
   case WinLink:
     return !coff::link(args, exitEarly, stdoutOS, stderrOS);
+#ifndef __HAIKU__
   case Darwin:
     return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
   case DarwinNew:
     return !macho::link(args, exitEarly, stdoutOS, stderrOS);
+#endif
   case Wasm:
     return !lld::wasm::link(args, exitEarly, stdoutOS, stderrOS);
   default:
-- 
2.30.0

