[clang] 41e3ac3 - [AIX]: Fix option processing for -b
Ettore Tiotto via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 9 17:07:23 PDT 2021
Author: Ettore Tiotto
Date: 2021-08-09T19:52:31-04:00
New Revision: 41e3ac398c3ae9dfba5a57d80c420c122c1ec700
URL: https://github.com/llvm/llvm-project/commit/41e3ac398c3ae9dfba5a57d80c420c122c1ec700
DIFF: https://github.com/llvm/llvm-project/commit/41e3ac398c3ae9dfba5a57d80c420c122c1ec700.diff
LOG: [AIX]: Fix option processing for -b
Code added by D106688 has a problem. It passes the option -bxyz to the system linker as -b xyz xyz (duplication of the string 'xyz' is incorrect). This patch fixes that oversight.
Reviewed by: hubert.reinterpretcast, jsji
Differential Revision: https://reviews.llvm.org/D107786
Added:
Modified:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/Xlinker-args.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 00bc92a1933b7..5fcf3c504633c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,16 +257,6 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
// Otherwise, this is a linker input argument.
const Arg &A = II.getInputArg();
- if (A.getOption().matches(options::OPT_b)) {
- const llvm::Triple &T = TC.getTriple();
- if (!T.isOSAIX()) {
- TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
- << A.getSpelling() << T.str();
- }
- // Pass -b prefix for AIX linker.
- A.claim();
- A.render(Args, CmdArgs);
- }
// Handle reserved library options.
if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
@@ -276,6 +266,15 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
// Pass -z prefix for gcc linker compatibility.
A.claim();
A.render(Args, CmdArgs);
+ } else if (A.getOption().matches(options::OPT_b)) {
+ const llvm::Triple &T = TC.getTriple();
+ if (!T.isOSAIX()) {
+ TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+ << A.getSpelling() << T.str();
+ }
+ // Pass -b prefix for AIX linker.
+ A.claim();
+ A.render(Args, CmdArgs);
} else {
A.renderAsInput(Args, CmdArgs);
}
diff --git a/clang/test/Driver/Xlinker-args.c b/clang/test/Driver/Xlinker-args.c
index 0ae5cb386672d..0fba8e711bd06 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -13,7 +13,7 @@
// RUN: FileCheck -check-prefix=LINUX < %t %s
// RUN: %clang -target powerpc-unknown-aix -### \
-// RUN: -b one %s 2> %t
+// RUN: -b one -b two %s 2> %t
// RUN: FileCheck -check-prefix=AIX < %t %s
// RUN: %clang -target powerpc-unknown-linux -### \
@@ -23,7 +23,7 @@
// DARWIN-NOT: --no-demangle
// DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
-// AIX: "-b" "one"
+// AIX: "-b" "one" "-b" "two"
// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
// Check that we forward '-Xlinker' and '-Wl,' on Windows.
More information about the cfe-commits
mailing list