[Patch] CloudABI: Add default header path

Ed Schouten ed at nuxi.nl
Mon Mar 9 03:14:51 PDT 2015


Hello,

A couple of days ago I sent out a patch for LLVM to add support for
Nuxi CloudABI, a POSIX-like environment based on the principles of
capability-based security. Background:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150302/264362.html
https://github.com/NuxiNL/cloudlibc

Once the patch for LLVM has landed, I would also like to push in the
small number of changes I made to Clang to allow it to target CloudABI
as well.

The first change I'd like to make is to let Clang use the proper
include path. For now we should only treat CloudABI as a
cross-compilation target. We should not include directories such as
/usr/include. Only <sysroot>/<triple>/include.

Attached is a patch for InitHeaderSearch to test against
llvm::Triple::CloudABI and do the right thing.

-- 
Ed Schouten <ed at nuxi.nl>
-------------- next part --------------
Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp	(revision 231636)
+++ lib/Frontend/InitHeaderSearch.cpp	(working copy)
@@ -227,6 +227,7 @@
 
   if (HSOpts.UseStandardSystemIncludes) {
     switch (os) {
+    case llvm::Triple::CloudABI:
     case llvm::Triple::FreeBSD:
     case llvm::Triple::NetBSD:
     case llvm::Triple::OpenBSD:
@@ -270,6 +271,14 @@
   case llvm::Triple::Linux:
     llvm_unreachable("Include management is handled in the driver.");
 
+  case llvm::Triple::CloudABI: {
+    // <sysroot>/<triple>/include
+    SmallString<128> P = StringRef(HSOpts.ResourceDir);
+    llvm::sys::path::append(P, "../../..", triple.str(), "include");
+    AddPath(P.str(), System, false);
+    break;
+  }
+
   case llvm::Triple::Haiku:
     AddPath("/boot/common/include", System, false);
     AddPath("/boot/develop/headers/os", System, false);
@@ -340,8 +349,14 @@
     break;
   }
 
-  if ( os != llvm::Triple::RTEMS )
+  switch (os) {
+  case llvm::Triple::CloudABI:
+  case llvm::Triple::RTEMS:
+    break;
+  default:
     AddPath("/usr/include", ExternCSystem, false);
+    break;
+  }
 }
 
 void InitHeaderSearch::


More information about the cfe-commits mailing list