Follow-up to D106688 and D146431.
-b leads to a -Wunused-command-line-argument warning instead of an error
without linking phase.
-mxcoff-build-id= leads to a -Wunused-command-line-argument warning instead of
an error.
}
}
- if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
- A && !TC.getTriple().isOSAIX())
- D.Diag(diag::err_drv_unsupported_opt_for_target)
- << A->getAsString(Args) << TripleStr;
+ // Reject AIX-specific link options on other targets.
+ if (!TC.getTriple().isOSAIX()) {
+ for (const Arg *A : Args.filtered(options::OPT_b, options::OPT_K,
+ options::OPT_mxcoff_build_id_EQ)) {
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getSpelling() << TripleStr;
+ }
+ }
if (Args.getLastArg(options::OPT_fapple_kext) ||
(Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
// 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);
}
// RUN: -b one -b two %s 2> %t
// RUN: FileCheck -check-prefix=AIX < %t %s
-// RUN: %clang -target powerpc-unknown-linux -### \
-// RUN: -b one %s 2> %t
-// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
-
// 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"
// MINGW: "--no-demangle"
// 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.
// RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
--- /dev/null
+/// AIX-specific link options are rejected for other targets.
+// RUN: %clang -### --target=powerpc64-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree --unwindlib=libunwind --rtlib=compiler-rt \
+// RUN: -b one -K -mxcoff-build-id=a %s 2>&1 | FileCheck %s --implicit-check-not=error:
+// RUN: %clang -### --target=powerpc64-unknown-linux-gnu -c \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree --unwindlib=libunwind --rtlib=compiler-rt \
+// RUN: -b one -K -mxcoff-build-id=a %s 2>&1 | FileCheck %s --implicit-check-not=error:
+// CHECK: error: unsupported option '-b' for target '{{.*}}'
+// CHECK: error: unsupported option '-K' for target '{{.*}}'
+// CHECK: error: unsupported option '-mxcoff-build-id=' for target '{{.*}}'
+++ /dev/null
-// Check powerpc64-unknown-linux-gnu. -K not supported.
-// RUN: %clang %s 2>&1 -### \
-// RUN: --target=powerpc64-unknown-linux-gnu \
-// RUN: --sysroot %S/Inputs/aix_ppc_tree \
-// RUN: --unwindlib=libunwind \
-// RUN: -K \
-// RUN: | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
-// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'