https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/180104
It does't need to compare the march/mabi with multilib's before adding such string into Flags. The negative one (!march/!mabi) has no effect during multilib selection. We can select either a multilib with identical march and mabi, or one with a subset of march and the same mabi. >From 221358003a70dae9396b164df9908dea0fe7be50 Mon Sep 17 00:00:00 2001 From: Jim Lin <[email protected]> Date: Thu, 5 Feb 2026 13:57:02 +0800 Subject: [PATCH] [RISCV] Simply add the march/mabi strings to Flags for selecting multilib It does't need to compare the march/mabi with multilib's before adding such string into Flags. The negative one (!march/!mabi) has no effect during multilib selection. We can select either a multilib with identical march and mabi, or one with a subset of march and the same mabi. --- clang/lib/Driver/ToolChains/Gnu.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index ac31a45b557f1..215a50612a31d 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -1631,7 +1631,7 @@ selectRISCVMultilib(const Driver &D, const MultilibSet &RISCVMultilibSet, // Collect all flags except march=* for (StringRef Flag : Flags) { - if (Flag.starts_with("!march=") || Flag.starts_with("-march=")) + if (Flag.starts_with("-march=")) continue; NewFlags.push_back(Flag.str()); @@ -1753,15 +1753,8 @@ static void findRISCVBareMetalMultilibs(const Driver &D, llvm::StringSet<> Added_ABIs; StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple); std::string MArch = tools::riscv::getRISCVArch(Args, TargetTriple); - for (auto Element : RISCVMultilibSet) { - addMultilibFlag(MArch == Element.march, - Twine("-march=", Element.march).str(), Flags); - if (!Added_ABIs.count(Element.mabi)) { - Added_ABIs.insert(Element.mabi); - addMultilibFlag(ABIName == Element.mabi, - Twine("-mabi=", Element.mabi).str(), Flags); - } - } + Flags.push_back("-march=" + MArch); + Flags.push_back("-mabi=" + ABIName.str()); if (selectRISCVMultilib(D, RISCVMultilibs, MArch, Flags, Result.SelectedMultilibs)) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
