[clang] [Driver] Add linker options to support statical linking to shared flang-rt on AIX. (PR #131822)
David Tenty via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 2 06:45:10 PDT 2025
================
@@ -127,9 +127,18 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
// Force static linking when "-static" is present.
- if (Args.hasArg(options::OPT_static))
+ if (Args.hasArg(options::OPT_static)) {
CmdArgs.push_back("-bnso");
+ if (D.IsFlangMode()) {
+ // The folllowing linker options are needed to statically link to the
+ // shared libflang_rt.runtime.a on AIX
+ CmdArgs.push_back("-bI:/usr/lib/syscalls.exp");
----------------
daltenty wrote:
I think this is a bit misplaced, IIUC these options are needed to link `libc` statically, not `flang_rt` itself (`-static` just happens to mean we link both).
Thus, I think this belongs where we push_back `-lc` for the AIX toolchain, not here:
https://github.com/llvm/llvm-project/blob/28907a624a8d9561badc20d77254791918ba6210/clang/lib/Driver/ToolChains/AIX.cpp#L357
Also, I don't think this really belongs under the `-static` option, that is really an `ld` option which says, only link to static libs. Typically there are separate options to link particular runtimes statically. Since this is really for `libc`, I'd suggest `-static-libc`.
https://github.com/llvm/llvm-project/pull/131822
More information about the cfe-commits
mailing list