Skip to content

Commit 41e3ac3

Browse files
author
Ettore Tiotto
committed
[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
1 parent a350089 commit 41e3ac3

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
257257
// Otherwise, this is a linker input argument.
258258
const Arg &A = II.getInputArg();
259259

260-
if (A.getOption().matches(options::OPT_b)) {
261-
const llvm::Triple &T = TC.getTriple();
262-
if (!T.isOSAIX()) {
263-
TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
264-
<< A.getSpelling() << T.str();
265-
}
266-
// Pass -b prefix for AIX linker.
267-
A.claim();
268-
A.render(Args, CmdArgs);
269-
}
270260
// Handle reserved library options.
271261
if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
272262
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
@@ -276,6 +266,15 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
276266
// Pass -z prefix for gcc linker compatibility.
277267
A.claim();
278268
A.render(Args, CmdArgs);
269+
} else if (A.getOption().matches(options::OPT_b)) {
270+
const llvm::Triple &T = TC.getTriple();
271+
if (!T.isOSAIX()) {
272+
TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
273+
<< A.getSpelling() << T.str();
274+
}
275+
// Pass -b prefix for AIX linker.
276+
A.claim();
277+
A.render(Args, CmdArgs);
279278
} else {
280279
A.renderAsInput(Args, CmdArgs);
281280
}

clang/test/Driver/Xlinker-args.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// RUN: FileCheck -check-prefix=LINUX < %t %s
1414

1515
// RUN: %clang -target powerpc-unknown-aix -### \
16-
// RUN: -b one %s 2> %t
16+
// RUN: -b one -b two %s 2> %t
1717
// RUN: FileCheck -check-prefix=AIX < %t %s
1818

1919
// RUN: %clang -target powerpc-unknown-linux -### \
@@ -23,7 +23,7 @@
2323
// DARWIN-NOT: --no-demangle
2424
// DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
2525
// LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
26-
// AIX: "-b" "one"
26+
// AIX: "-b" "one" "-b" "two"
2727
// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
2828

2929
// Check that we forward '-Xlinker' and '-Wl,' on Windows.

0 commit comments

Comments
 (0)