[cfe-commits] r141692 - in /cfe/trunk: docs/tools/clang.pod include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/nostdlibinc.c

Daniel Dunbar daniel at zuster.org
Tue Oct 11 11:20:17 PDT 2011


Author: ddunbar
Date: Tue Oct 11 13:20:16 2011
New Revision: 141692

URL: http://llvm.org/viewvc/llvm-project?rev=141692&view=rev
Log:
Driver: Add support for a new -nostdlibinc option.
 - 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.

Added:
    cfe/trunk/test/Driver/nostdlibinc.c
Modified:
    cfe/trunk/docs/tools/clang.pod
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/docs/tools/clang.pod
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/clang.pod?rev=141692&r1=141691&r2=141692&view=diff
==============================================================================
--- cfe/trunk/docs/tools/clang.pod (original)
+++ cfe/trunk/docs/tools/clang.pod Tue Oct 11 13:20:16 2011
@@ -459,7 +459,13 @@
 
 =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>
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=141692&r1=141691&r2=141692&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Oct 11 13:20:16 2011
@@ -624,6 +624,7 @@
 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">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=141692&r1=141691&r2=141692&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 11 13:20:16 2011
@@ -1486,6 +1486,8 @@
     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);
   }

Added: cfe/trunk/test/Driver/nostdlibinc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlibinc.c?rev=141692&view=auto
==============================================================================
--- cfe/trunk/test/Driver/nostdlibinc.c (added)
+++ cfe/trunk/test/Driver/nostdlibinc.c Tue Oct 11 13:20:16 2011
@@ -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





More information about the cfe-commits mailing list