Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -815,7 +815,9 @@ def bind__at__load : Flag<["-"], "bind_at_load">; def bundle__loader : Separate<["-"], "bundle_loader">; def bundle : Flag<["-"], "bundle">; -def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>; +def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>, + HelpText<"Pass -b to the linker on AIX (only).">, MetaVarName<"">, + Group; def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, Flags<[CC1Option]>, HelpText<"OpenCL only. This option disables all optimizations. By default optimizations are enabled.">; def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, Group, Flags<[CC1Option]>, Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -257,6 +257,17 @@ // 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.getAsString(Args); + } + // 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); Index: clang/test/Driver/Xlinker-args.c =================================================================== --- clang/test/Driver/Xlinker-args.c +++ clang/test/Driver/Xlinker-args.c @@ -11,10 +11,20 @@ // RUN: -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \ // RUN: -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t // RUN: FileCheck -check-prefix=LINUX < %t %s -// + +// RUN: %clang -target powerpc-unknown-aix -### \ +// RUN: -b one %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" +// AIX: "-b" "one" +// NOT-AIX: error: unsupported option '-b one' // Check that we forward '-Xlinker' and '-Wl,' on Windows. // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \