================
@@ -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) {
----------------
statham-arm wrote:

Done. In my early drafts I had the whole thing in `getARMMultilibFlags`, but 
moved it out once I realised that PIC needed to be handled as well as 
ROPI/RWPI. I've kept the calculation of the relocation model in the top-level 
function, and just passed the answer down into `getARMMultilibFlags` where it 
can add the Arm-specific options.

https://github.com/llvm/llvm-project/pull/149132
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to