From: Saleem Abdulrasool Date: Fri, 17 Jun 2016 17:23:16 +0000 (+0000) Subject: Driver: introduce and use `-isystem-after` for cross-windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5e60a09dc912d559a672f959c8a8d79f0dc45a1;p=clang Driver: introduce and use `-isystem-after` for cross-windows This mirrors the many other -i*after options to insert a new system search directory at the end of the search path. This makes it possible to actually inject a search path after the resource dir. This option is similar in spirit to the /imsvc option in the clang-cl driver. This is needed to properly use the driver for Windows targets where the clang headers wrap some of the system headers. This concept is actually useful on other targets (e.g. Linux) and would be really easy to support on the core toolchain. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273016 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 5c240f36b4..00523666de 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1277,6 +1277,9 @@ def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group, Flags< def isystem : JoinedOrSeparate<["-"], "isystem">, Group, Flags<[CC1Option]>, HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"">; +def isystem_after : JoinedOrSeparate<["-"], "isystem-after">, + Group, Flags<[DriverOption]>, MetaVarName<"">, + HelpText<"Add directory to end of the SYSTEM include search path">; def iwithprefixbefore : JoinedOrSeparate<["-"], "iwithprefixbefore">, Group, HelpText<"Set directory to include search path with prefix">, MetaVarName<"">, Flags<[CC1Option]>; diff --git a/lib/Driver/CrossWindowsToolChain.cpp b/lib/Driver/CrossWindowsToolChain.cpp index 57bf896359..4ebbc53323 100644 --- a/lib/Driver/CrossWindowsToolChain.cpp +++ b/lib/Driver/CrossWindowsToolChain.cpp @@ -62,6 +62,8 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::sys::path::append(ResourceDir, "include"); addSystemInclude(DriverArgs, CC1Args, ResourceDir); } + for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after)) + addSystemInclude(DriverArgs, CC1Args, P); addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 62738e6699..b911c17e2b 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -502,6 +502,13 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, << A->getAsString(Args); } } + } else if (A->getOption().matches(options::OPT_isystem_after)) { + // Handling of paths which must come late. These entries are handled by + // the toolchain itself after the resource dir is inserted in the right + // search order. + // Do not claim the argument so that the use of the argument does not + // silently go unnoticed on toolchains which do not honour the option. + continue; } // Not translated, render as usual. diff --git a/test/Driver/windows-cross.c b/test/Driver/windows-cross.c index 083e4b0036..0b08762a4a 100644 --- a/test/Driver/windows-cross.c +++ b/test/Driver/windows-cross.c @@ -67,3 +67,10 @@ // CHECK-SANITIZE-TSAN: error: unsupported argument 'tsan' to option 'fsanitize=' // CHECK-SANITIZE-TSAN-NOT: "-fsanitize={{.*}}" +// RUN: %clang -### -target armv7-windows-itanium -isystem-after "Windows Kits/10/Include/10.0.10586.0/ucrt" -isystem-after "Windows Kits/10/Include/10.0.10586.0/um" -isystem-after "Windows Kits/10/Include/10.0.10586.0/shared" -c %s -o /dev/null 2>&1 \ +// RUN: | FileCheck %s --check-prefix CHECK-ISYSTEM-AFTER +// CHECK-ISYSTEM-AFTER: "-internal-isystem" "{{.*}}/clang/3.9.0/include" +// CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits/10/Include/10.0.10586.0/ucrt" +// CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits/10/Include/10.0.10586.0/um" +// CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits/10/Include/10.0.10586.0/shared" +