r273016 - Driver: introduce and use `-isystem-after` for cross-windows

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 10:23:16 PDT 2016


Author: compnerd
Date: Fri Jun 17 12:23:16 2016
New Revision: 273016

URL: http://llvm.org/viewvc/llvm-project?rev=273016&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/CrossWindowsToolChain.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=273016&r1=273015&r2=273016&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jun 17 12:23:16 2016
@@ -1277,6 +1277,9 @@ def isysroot : JoinedOrSeparate<["-"], "
 def isystem : JoinedOrSeparate<["-"], "isystem">, Group<clang_i_Group>,
   Flags<[CC1Option]>,
   HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"<directory>">;
+def isystem_after : JoinedOrSeparate<["-"], "isystem-after">,
+  Group<clang_i_Group>, Flags<[DriverOption]>, MetaVarName<"<directory>">,
+  HelpText<"Add directory to end of the SYSTEM include search path">;
 def iwithprefixbefore : JoinedOrSeparate<["-"], "iwithprefixbefore">, Group<clang_i_Group>,
   HelpText<"Set directory to include search path with prefix">, MetaVarName<"<dir>">,
   Flags<[CC1Option]>;

Modified: cfe/trunk/lib/Driver/CrossWindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CrossWindowsToolChain.cpp?rev=273016&r1=273015&r2=273016&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/CrossWindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/CrossWindowsToolChain.cpp Fri Jun 17 12:23:16 2016
@@ -62,6 +62,8 @@ AddClangSystemIncludeArgs(const llvm::op
     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");
 }
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=273016&r1=273015&r2=273016&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jun 17 12:23:16 2016
@@ -502,6 +502,13 @@ void Clang::AddPreprocessingOptions(Comp
                                                        << 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.

Modified: cfe/trunk/test/Driver/windows-cross.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=273016&r1=273015&r2=273016&view=diff
==============================================================================
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Fri Jun 17 12:23:16 2016
@@ -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"
+




More information about the cfe-commits mailing list