[clang] [Clang][Driver] Valid `-march` value is not mandatory in AArch64 multilib (PR #151103)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 01:40:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Victor Campos (vhscampos)

<details>
<summary>Changes</summary>

If a user passed an invalid value to `-march`, an assertion failure happened in the AArch64 multilib logic.

But an invalid `-march` value is an expected case that should be handled via error messages.

This patch removes the requirement that the `-march` value must be valid.

---
Full diff: https://github.com/llvm/llvm-project/pull/151103.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChain.cpp (+4-3) 


``````````diff
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 1d7dad0d7d12b..496c0dc1780e4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -191,9 +191,10 @@ static void getAArch64MultilibFlags(const Driver &D,
   for (const auto &ArchInfo : AArch64::ArchInfos)
     if (FeatureSet.contains(ArchInfo->ArchFeature))
       ArchName = ArchInfo->Name;
-  assert(!ArchName.empty() && "at least one architecture should be found");
-  MArch.insert(MArch.begin(), ("-march=" + ArchName).str());
-  Result.push_back(llvm::join(MArch, "+"));
+  if (!ArchName.empty()) {
+    MArch.insert(MArch.begin(), ("-march=" + ArchName).str());
+    Result.push_back(llvm::join(MArch, "+"));
+  }
 
   const Arg *BranchProtectionArg =
       Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ);

``````````

</details>


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


More information about the cfe-commits mailing list