diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/docs/tools/clang.pod | 8 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.td | 1 | ||||
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 2 | ||||
-rw-r--r-- | clang/test/Driver/nostdlibinc.c | 10 |
4 files changed, 20 insertions, 1 deletions
diff --git a/clang/docs/tools/clang.pod b/clang/docs/tools/clang.pod index 704cc8743ba..964b143ac9e 100644 --- a/clang/docs/tools/clang.pod +++ b/clang/docs/tools/clang.pod @@ -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> diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index a0520f0beaf..ae8c7945cb9 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -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">; diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 07d2a681898..e0efe822864 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -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/clang/test/Driver/nostdlibinc.c b/clang/test/Driver/nostdlibinc.c new file mode 100644 index 00000000000..f7ee712d866 --- /dev/null +++ b/clang/test/Driver/nostdlibinc.c @@ -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 |