================
@@ -343,6 +343,16 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C,
const JobAction &JA,
CmdArgs.push_back("--no-relax");
}
+ // Default-enable LLD's --relax-gp for RISC-V on Linux when LLD is used and
+ // linker relaxation is not disabled by -mno-relax.
+ if (Triple.isRISCV() && Triple.isOSLinux()) {
+ bool IsLLD = false;
+ ToolChain.GetLinkerPath(&IsLLD);
+ if (IsLLD &&
+ Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+ CmdArgs.push_back("--relax-gp");
+ }
----------------
kito-cheng wrote:
Passing the `gp relax` flag and sending it to `-shared` shouldn't cause any
problems, since the linker mainly checks whether the `__global_pointer$` symbol
is defined and whether relocation is supported.
So I would incline just pass without checking it's
-shared/-static/-fPIE/&$%^$^, that may just complicate the condition here.
https://github.com/llvm/llvm-project/pull/201265
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits