[clang] [Clang][Driver] Expose relocation model as multilib flags (PR #149132)

Victor Campos via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 16 09:24:04 PDT 2025


================
@@ -376,6 +378,41 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList &Args) const {
   else
     Result.push_back("-fexceptions");
 
+  // A difference of relocation model (absolutely addressed data, PIC, Arm
+  // ROPI/RWPI) is likely to change whether a particular multilib variant is
+  // compatible with a given link. Determine the relocation model of the
+  // current link, and add appropriate 
+  {
+    RegisterEffectiveTriple TripleRAII(
+        *this, llvm::Triple(ComputeEffectiveClangTriple(Args)));
+
+    auto [RelocationModel, PICLevel, IsPIE] = tools::ParsePICArgs(*this, Args);
+
+    // ROPI and RWPI are only meaningful on Arm, so for other architectures, we
+    // expect never to find out they're enabled. But it seems confusing to add
+    // -fno-ropi and -fno-rwpi unconditionally to every other architecture's
+    // multilib flags, so instead we leave them out completely.
+    if (IsARM) {
----------------
vhscampos wrote:

Is there any way to move this Arm-only segment into `getARMMultilibFlags`? In theory, that function handles everything that is only relevant to Arm. So it's a more natural place to host this segment here.

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


More information about the cfe-commits mailing list