[clang] [flang] [Flang] [Driver] Add -fplt and -fno-plt options (PR #235622)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 27 22:03:12 PDT 2026


================
@@ -1438,6 +1438,16 @@ void CodeGenAction::executeAction() {
   llvmModule->setTargetTriple(theTriple);
   llvmModule->setDataLayout(theTriple.computeDataLayout(targetOpts.abi));
 
+  // -fno-plt: external calls use the GOT instead of the PLT. The module
+  // requests GOT for compiler-rt, and declarations that are not defined in
+  // this translation unit are marked nonlazybind.
+  if (codeGenOpts.NoPLT) {
+    llvmModule->setRtLibUseGOT();
+    for (llvm::Function &func : *llvmModule)
+      if (func.isDeclaration() && !func.isIntrinsic())
+        func.addFnAttr(llvm::Attribute::NonLazyBind);
+  }
----------------
shivaramaarao wrote:

Thanks for pointing it out. THe change is not expected to kick in for IR inputs. Changed the code and also added a testcase.

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


More information about the cfe-commits mailing list