Skip to content

Commit 3625f9f

Browse files
authored
[Flang][Driver][Offload] Support -Xoffload-linker argument in Flang (#109907)
The -Xoffload-linker command allows forwarding of linker commands to the clang-linker-wrapper used for linking offload libraries into the resulting offload binaries amongst other tasks. This is a rather useful command to have to support the offloading programming models flang-new currently aims to support (OpenMP/OpenACC). Currently this flag is utilised in the check-offload tests after a recent addition and is used in conjunction with the Fortran OpenMP test suite there, which fails at the moment due to flang-new not recognizing the command, this fixes the issue. The alternative to this would of course be to setup the test config to avoid using this flag with Fortran, but I believe adding support of the flag to flang-new has more merit as having the same compatability/communication capabilities as Clang to the clang-linker-wrapper is important as it's a critical component of the offload pipeline, and the command will likely see more use in the near future.
1 parent f78009a commit 3625f9f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
10551055
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
10561056
Group<Link_Group>;
10571057
def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
1058+
Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
10581059
HelpText<"Pass <arg> to the offload linkers or the ones identified by -<triple>">,
10591060
MetaVarName<"<triple> <arg>">, Group<Link_Group>;
10601061
def Xpreprocessor : Separate<["-"], "Xpreprocessor">, Group<Preprocessor_Group>,

flang/test/Driver/xoffload-linker.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
! Test the -Xoffload-linker flag that forwards link commands to the clang-linker-wrapper used
2+
! to help link offloading device libraries
3+
4+
! RUN: %flang -### %s -o %t 2>&1 -fopenmp --offload-arch=gfx90a --target=aarch64-unknown-linux-gnu -nogpulib -Xoffload-linker a | FileCheck %s --check-prefix=CHECK-XLINKER
5+
6+
! CHECK-XLINKER: "{{[^"]*}}clang-linker-wrapper{{.*}}"{{.*}}"--device-linker=a"{{.*}}
7+
8+
! RUN: %flang -### %s -o %t 2>&1 -fopenmp --offload-arch=gfx90a --target=aarch64-unknown-linux-gnu -nogpulib -Xoffload-linker a -Xoffload-linker-amdgcn-amd-amdhsa b | FileCheck %s --check-prefix=CHECK-XLINKER-AMDGCN
9+
10+
! CHECK-XLINKER-AMDGCN: "{{[^"]*}}clang-linker-wrapper{{.*}}"{{.*}}"--device-linker=a"{{.*}}"--device-linker=amdgcn-amd-amdhsa=b"{{.*}}

0 commit comments

Comments
 (0)