[PATCH] D49480: Haiku: support for secondary arch

Alexander von Gluck IV via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 18 06:53:27 PDT 2018


kallisti5 created this revision.
Herald added subscribers: cfe-commits, mgorny.

Enables Haiku to build llvm for secondary architectures.


Repository:
  rC Clang

https://reviews.llvm.org/D49480

Files:
  CMakeLists.txt
  lib/Driver/ToolChains/Haiku.cpp
  lib/Frontend/InitHeaderSearch.cpp


Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -238,7 +238,19 @@
   if (HSOpts.UseBuiltinIncludes) {
     // Ignore the sys root, we *always* look for clang headers relative to
     // supplied path.
+#ifdef HAIKU_HYBRID_SECONDARY
+    // Remove version from foo/lib/clang/version
+    StringRef Ver = llvm::sys::path::filename(HSOpts.ResourceDir);
+    StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
+    // Remove clang from foo/lib/clang
+    StringRef Clang = llvm::sys::path::filename(NoVer);
+    SmallString<128> P = llvm::sys::path::parent_path(NoVer);
+
+    // Get foo/include/c++/v1
+    llvm::sys::path::append(P, HAIKU_HYBRID_SECONDARY, Clang, Ver);
+#else
     SmallString<128> P = StringRef(HSOpts.ResourceDir);
+#endif
     llvm::sys::path::append(P, "include");
     AddUnmappedPath(P, ExternCSystem, false);
   }
@@ -272,7 +284,12 @@
   }
 
   case llvm::Triple::Haiku:
+#ifdef HAIKU_HYBRID_SECONDARY
+    AddPath("/boot/system/non-packaged/develop/headers/" HAIKU_HYBRID_SECONDARY,
+            System, false);
+#else
     AddPath("/boot/system/non-packaged/develop/headers", System, false);
+#endif
     AddPath("/boot/system/develop/headers/os", System, false);
     AddPath("/boot/system/develop/headers/os/app", System, false);
     AddPath("/boot/system/develop/headers/os/arch", System, false);
@@ -304,6 +321,13 @@
     AddPath("/boot/system/develop/headers/bsd", System, false);
     AddPath("/boot/system/develop/headers/glibc", System, false);
     AddPath("/boot/system/develop/headers/posix", System, false);
+#ifdef HAIKU_HYBRID_SECONDARY
+    AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY, System, false);
+    AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY "/os", System,
+            false);
+    AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY "/os/opengl",
+            System, false);
+#endif
     AddPath("/boot/system/develop/headers",  System, false);
     break;
   case llvm::Triple::RTEMS:
Index: lib/Driver/ToolChains/Haiku.cpp
===================================================================
--- lib/Driver/ToolChains/Haiku.cpp
+++ lib/Driver/ToolChains/Haiku.cpp
@@ -20,6 +20,13 @@
 Haiku::Haiku(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
   : Generic_ELF(D, Triple, Args) {
 
+#ifdef HAIKU_HYBRID_SECONDARY
+  getProgramPaths().insert(getProgramPaths().begin(), getDriver().SysRoot
+                           + "/system/bin/" HAIKU_HYBRID_SECONDARY);
+  getFilePaths().clear();
+  getFilePaths().push_back(getDriver().SysRoot + "/system/lib/"
+                           HAIKU_HYBRID_SECONDARY);
+#endif
 }
 
 void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
@@ -30,6 +37,13 @@
 
 void Haiku::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
                                      llvm::opt::ArgStringList &CC1Args) const {
+
+#ifdef HAIKU_HYBRID_SECONDARY
+  addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers"
+                     HAIKU_HYBRID_SECONDARY "/c++", getTriple().str(), "", "", "",
+                     DriverArgs, CC1Args);
+#else
   addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers/c++",
                            getTriple().str(), "", "", "", DriverArgs, CC1Args);
+#endif
 }
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -412,6 +412,10 @@
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
 endif()
 
+if(DEFINED HAIKU_HYBRID_SECONDARY)
+  add_definitions(-DHAIKU_HYBRID_SECONDARY=${HAIKU_HYBRID_SECONDARY})
+endif()
+
 if(CLANG_ANALYZER_BUILD_Z3)
   find_package(Z3 4.5)
   if(Z3_FOUND)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49480.156060.patch
Type: text/x-patch
Size: 3891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180718/710b020a/attachment.bin>


More information about the cfe-commits mailing list