Skip to content

Commit 5f74671

Browse files
authored
[flang][Driver] Support -Xlinker in flang (#107472)
Partially addresses: #89888
1 parent 0f349b7 commit 5f74671

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
10511051
def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
10521052
HelpText<"Use the new offloading linker to perform the link job.">;
10531053
def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
1054+
Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
10541055
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
10551056
Group<Link_Group>;
10561057
def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,

flang/test/Driver/xlinker.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: %flang -### --target=ppc64le-linux-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
2+
! RUN: %flang -### --target=aarch64-apple-darwin -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
3+
! RUN: %flang -### --target=sparc-sun-solaris2.11 -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
4+
! RUN: %flang -### --target=x86_64-unknown-freebsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
5+
! RUN: %flang -### --target=x86_64-unknown-netbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
6+
! RUN: %flang -### --target=x86_64-unknown-openbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
7+
! RUN: %flang -### --target=x86_64-unknown-dragonfly -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
8+
! RUN: %flang -### --target=x86_64-unknown-haiku %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck %s --check-prefixes=UNIX
9+
! RUN: %flang -### --target=x86_64-windows-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX
10+
! RUN: %flang -### --target=aarch64-windows-msvc -Xlinker -rpath -Xlinker /not/a/real/path -o obscure.exe %s 2>&1 | FileCheck %s --check-prefixes=MSVC
11+
12+
! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}"
13+
! UNIX-SAME: "-rpath" "/not/a/real/path"
14+
15+
! The name of this file contains the word "link" which results in a match on
16+
! the compiler line as well. Instead look for the final name of the executable
17+
! to be created since that will only appear in the linker line.
18+
! MSVC: -out:obscure.exe
19+
! MSVC-SAME: "-rpath" "/not/a/real/path"
20+
21+
end program

0 commit comments

Comments
 (0)