diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1b9b3f2c6600a..136d979ed7200 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1051,6 +1051,7 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>, def offload_link : Flag<["--"], "offload-link">, Group, HelpText<"Use the new offloading linker to perform the link job.">; def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>, + Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>, HelpText<"Pass to the linker">, MetaVarName<"">, Group; def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">, diff --git a/flang/test/Driver/xlinker.f90 b/flang/test/Driver/xlinker.f90 new file mode 100644 index 0000000000000..feafadcfcec45 --- /dev/null +++ b/flang/test/Driver/xlinker.f90 @@ -0,0 +1,21 @@ +! RUN: %flang -### --target=ppc64le-linux-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=aarch64-apple-darwin -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=sparc-sun-solaris2.11 -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-freebsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-netbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-openbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-dragonfly -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-haiku %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-windows-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=aarch64-windows-msvc -Xlinker -rpath -Xlinker /not/a/real/path -o obscure.exe %s 2>&1 | FileCheck %s --check-prefixes=MSVC + +! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}" +! UNIX-SAME: "-rpath" "/not/a/real/path" + +! The name of this file contains the word "link" which results in a match on +! the compiler line as well. Instead look for the final name of the executable +! to be created since that will only appear in the linker line. +! MSVC: -out:obscure.exe +! MSVC-SAME: "-rpath" "/not/a/real/path" + +end program