From 53e2eb5ceae404e8a6d1f7b0d49156adcd4eff53 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 20 Jan 2016 21:13:28 +0000
Subject: llvm-config: use /develop/headers instead of /include

* don't provide obj-root and src-root.

diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 08b096a..739213c 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -332,11 +332,16 @@ int main(int argc, char **argv) {
         ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
     ActivePrefix = CurrentExecPrefix;
+#ifdef __HAIKU__
+    ActiveIncludeDir = ActivePrefix + "/develop/headers";
+    ActiveLibDir = ActivePrefix + "/develop/lib" + LLVM_LIBDIR_SUFFIX;
+#else
     ActiveIncludeDir = ActivePrefix + "/include";
+    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
+#endif
     SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
     sys::fs::make_absolute(ActivePrefix, path);
     ActiveBinDir = path.str();
-    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
     ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
     ActiveIncludeOption = "-I" + ActiveIncludeDir;
   }
@@ -556,10 +561,16 @@ int main(int argc, char **argv) {
         OS << (LLVM_HAS_GLOBAL_ISEL ? "ON" : "OFF") << '\n';
       } else if (Arg == "--shared-mode") {
         PrintSharedMode = true;
-      } else if (Arg == "--obj-root") {
-        OS << ActivePrefix << '\n';
-      } else if (Arg == "--src-root") {
-        OS << LLVM_SRC_ROOT << '\n';
+      } else if (Arg == "--obj-root" || Arg == "--src-root") {
+        if (IsInDevelopmentTree) {
+          if (Arg == "--obj-root")
+            OS << ActivePrefix << '\n';
+          else
+            OS << LLVM_SRC_ROOT << '\n';
+        } else {
+          llvm::errs() << "llvm-config: sources not installed\n";
+          exit(1);
+        }
       } else if (Arg == "--ignore-libllvm") {
         LinkDyLib = false;
         LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto;
-- 
2.28.0


From 067ab4ceab5dea9125e33cb24f3c3bda04f85b1d Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 16 Sep 2017 15:02:46 +0200
Subject: Haiku doesn't expose whether a FS is local or remote.


diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index 45097eb..1790a0a 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -381,6 +381,9 @@ static bool is_local_impl(struct STATVFS &Vfs) {
 #elif defined(__CYGWIN__)
   // Cygwin doesn't expose this information; would need to use Win32 API.
   return false;
+#elif defined(__HAIKU__)
+  // Haiku doesn't expose this information
+  return false;
 #elif defined(__sun)
   // statvfs::f_basetype contains a null-terminated FSType name of the mounted target
   StringRef fstype(Vfs.f_basetype);
-- 
2.28.0


From 03fdaf9dbfadbe7b708dcb9e6fdbeb8dc5db04ff Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 7 Jun 2018 21:43:47 +1000
Subject: Fix header dir suffix


diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 739213c..ab7b46c 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,7 +333,7 @@ int main(int argc, char **argv) {
   } else {
     ActivePrefix = CurrentExecPrefix;
 #ifdef __HAIKU__
-    ActiveIncludeDir = ActivePrefix + "/develop/headers";
+    ActiveIncludeDir = ActivePrefix + "/develop/headers" + LLVM_LIBDIR_SUFFIX;
     ActiveLibDir = ActivePrefix + "/develop/lib" + LLVM_LIBDIR_SUFFIX;
 #else
     ActiveIncludeDir = ActivePrefix + "/include";
-- 
2.28.0


From 1f728f5ace9298bd0e6b481e83e2634a5505cbe2 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Mon, 21 Dec 2020 18:10:43 +0000
Subject: Fix building with gcc8

Taken from https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2deb2d52d186165bf0d2d45405438e91f6a9a6de

diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
index da02250..bed472e 100644
--- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
+++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
@@ -713,8 +713,8 @@ private:
 
   uint32_t getTrampolineSize() const { return RemoteTrampolineSize; }
 
-  Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src,
-                                      uint64_t Size) {
+  Expected<std::vector<uint8_t>> readMem(char *Dst, JITTargetAddress Src,
+                                         uint64_t Size) {
     // Check for an 'out-of-band' error, e.g. from an MM destructor.
     if (ExistingError)
       return std::move(ExistingError);
-- 
2.28.0

