[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 13 07:04:58 PST 2024


================
@@ -1247,6 +1247,19 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
   CLOptions = std::make_unique<InputArgList>(
       ParseArgStrings(ArgList.slice(1), /*UseDriverMode=*/true, ContainsError));
 
+  // We want to determine the triple early so that we load the correct config.
+  if (IsCLMode()) {
+    // clang-cl targets MSVC-style Win32.
+    llvm::Triple T(TargetTriple);
+    T.setOS(llvm::Triple::Win32);
+    T.setVendor(llvm::Triple::PC);
+    T.setEnvironment(llvm::Triple::MSVC);
+    T.setObjectFormat(llvm::Triple::COFF);
+    if (CLOptions->hasArg(options::OPT__SLASH_arm64EC))
+      T.setArch(llvm::Triple::aarch64, llvm::Triple::AArch64SubArch_arm64ec);
----------------
zmodem wrote:

I thought normally the arguments in the config file should get processed *before* the command-line arguments? What are the rules for this really?

https://github.com/llvm/llvm-project/pull/111397


More information about the cfe-commits mailing list