[clang] [flang] [Flang] [Driver] Add -fplt and -fno-plt options (PR #235622)
Tarun Prabhu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 27 06:07:47 PDT 2026
================
@@ -1438,6 +1438,18 @@ 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())
+ continue;
+ func.addFnAttr(llvm::Attribute::NonLazyBind);
----------------
tarunprabhu wrote:
Could we invert the condition so we add the attribute only if the condition is true. IMO, it is more readable than a `continue` followed by an unconditional assignment.
https://github.com/llvm/llvm-project/pull/235622
More information about the cfe-commits
mailing list