[clang] [Driver] Add linker options to support statical linking to shared flang-rt on AIX. (PR #131822)
Daniel Chen via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 3 07:43:47 PDT 2025
https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/131822
>From 28634f01af16c2d0eb9ac12d569d3393dbcc7edf Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Tue, 18 Mar 2025 11:09:41 -0400
Subject: [PATCH 1/3] [Driver] Add linker options to support statical linking
to shared flang-rt on AIX.
---
clang/lib/Driver/ToolChains/AIX.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 001f3a5178943..7ed26c42c80ce 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -127,8 +127,15 @@ 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");
+ // 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");
+ CmdArgs.push_back("-bI:/usr/lib/aio.exp");
+ CmdArgs.push_back("-bI:/usr/lib/threads.exp");
+ CmdArgs.push_back("-lcrypt");
+ }
// Add options for shared libraries.
if (Args.hasArg(options::OPT_shared)) {
>From 57f45fca1d9218f9d5e4eeab15e76aa171547c64 Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Sat, 29 Mar 2025 13:22:31 -0400
Subject: [PATCH 2/3] Make the addtional import list for static linking for
flang invocation only.
---
clang/lib/Driver/ToolChains/AIX.cpp | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 7ed26c42c80ce..2692ef75a2198 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -129,12 +129,15 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// Force static linking when "-static" is present.
if (Args.hasArg(options::OPT_static)) {
CmdArgs.push_back("-bnso");
- // 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");
- CmdArgs.push_back("-bI:/usr/lib/aio.exp");
- CmdArgs.push_back("-bI:/usr/lib/threads.exp");
- CmdArgs.push_back("-lcrypt");
+
+ 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");
+ CmdArgs.push_back("-bI:/usr/lib/aio.exp");
+ CmdArgs.push_back("-bI:/usr/lib/threads.exp");
+ CmdArgs.push_back("-lcrypt");
+ }
}
// Add options for shared libraries.
>From f165dfbe313306cd428bb4b2beadc0c0c7370cec Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Mon, 31 Mar 2025 12:17:13 -0400
Subject: [PATCH 3/3] Remove aio.exp as it is not needed.
---
clang/lib/Driver/ToolChains/AIX.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 2692ef75a2198..1c26b58db400f 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -134,7 +134,6 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// 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");
- CmdArgs.push_back("-bI:/usr/lib/aio.exp");
CmdArgs.push_back("-bI:/usr/lib/threads.exp");
CmdArgs.push_back("-lcrypt");
}
More information about the cfe-commits
mailing list