]> granicus.if.org Git - clang/commitdiff
Driver: Add support for a new -nostdlibinc option.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 11 Oct 2011 18:20:16 +0000 (18:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 11 Oct 2011 18:20:16 +0000 (18:20 +0000)
 - This disables the system include directories, but not the compiler builtin
   directories. Useful for projects that want to use things like the intrinsic
   headers, but are otherwise freestanding.

 - I'm willing to reconsider the option naming, I also considered providing an
   explicit -builtinc (which would match -nobuiltininc), but this is more
   consistent with existing options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141692 91177308-0d34-0410-b5e6-96231b3b80d8

docs/tools/clang.pod
include/clang/Driver/Options.td
lib/Driver/Tools.cpp
test/Driver/nostdlibinc.c [new file with mode: 0644]

index 704cc8743ba6fa00f394e6a1ed3d188468b294f0..964b143ac9ebcf5e5a31a8fb60c98a9f2b814a81 100644 (file)
@@ -459,7 +459,13 @@ Add the specified directory to the search path for framework include files.
 
 =item B<-nostdinc>
 
-Do not search the standard system directories for include files.
+Do not search the standard system directories or compiler builtin directories
+for include files.
+
+=item B<-nostdlibinc>
+
+Do not search the standard system directories for include files, but do search
+compiler builting include directories.
 
 =item B<-nobuiltininc>
 
index a0520f0beaf65bcfc9f5633d9be8d3e9ef5bb969..ae8c7945cb93971ff02562228605661ccd7a3bf0 100644 (file)
@@ -624,6 +624,7 @@ def noprebind : Flag<"-noprebind">;
 def noseglinkedit : Flag<"-noseglinkedit">;
 def nostartfiles : Flag<"-nostartfiles">;
 def nostdinc : Flag<"-nostdinc">;
+def nostdlibinc : Flag<"-nostdlibinc">;
 def nostdincxx : Flag<"-nostdinc++">;
 def nostdlib : Flag<"-nostdlib">;
 def object : Flag<"-object">;
index 07d2a681898526e39c7f0f7323fa0f8ea560259c..e0efe822864ac59d1c4c84c84fbcd3e6ab345455 100644 (file)
@@ -1486,6 +1486,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-nostdsysteminc");
     CmdArgs.push_back("-nobuiltininc");
   } else {
+    if (Args.hasArg(options::OPT_nostdlibinc))
+        CmdArgs.push_back("-nostdsysteminc");
     Args.AddLastArg(CmdArgs, options::OPT_nostdincxx);
     Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
   }
diff --git a/test/Driver/nostdlibinc.c b/test/Driver/nostdlibinc.c
new file mode 100644 (file)
index 0000000..f7ee712
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang -ccc-host-triple x86_64-unknown-unknown \
+// RUN:   -nostdlibinc -ffreestanding -fsyntax-only %s
+
+#if !__has_include("stddef.h")
+#error "expected to be able to find compiler builtin headers!"
+#endif
+
+#if __has_include("stdlib.h")
+#error "expected to *not* be able to find standard C headers"
+#endif