[clang] [flang] [flang][Driver] Support -Xlinker in flang (PR #107472)
Tarun Prabhu via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 9 08:23:34 PDT 2024
https://github.com/tarunprabhu updated https://github.com/llvm/llvm-project/pull/107472
>From acb5cf2af69f7941c24c4e53b67f9f2d4a18dbc8 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Thu, 5 Sep 2024 15:41:54 -0600
Subject: [PATCH 1/2] [flang][Driver] Support -Xlinker in flang
---
clang/include/clang/Driver/Options.td | 1 +
flang/test/Driver/xlinker.f90 | 6 ++++++
2 files changed, 7 insertions(+)
create mode 100644 flang/test/Driver/xlinker.f90
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1b9b3f2c6600a3..136d979ed7200e 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<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 <arg> to the linker">, MetaVarName<"<arg>">,
Group<Link_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 00000000000000..8bb1f7e99ae238
--- /dev/null
+++ b/flang/test/Driver/xlinker.f90
@@ -0,0 +1,6 @@
+! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck %s
+
+! CHECK: "-fc1"
+! CHECK-NEXT: "-rpath=/not/a/real/path"
+
+end program
>From fcfe90910382ded9e58868d8feef2195f00dd4f0 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Mon, 9 Sep 2024 09:22:44 -0600
Subject: [PATCH 2/2] Update test to address reviewer comments. Add test with
multiple -instances of -Xlinker options
---
flang/test/Driver/xlinker.f90 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/flang/test/Driver/xlinker.f90 b/flang/test/Driver/xlinker.f90
index 8bb1f7e99ae238..071fc6e3dc9027 100644
--- a/flang/test/Driver/xlinker.f90
+++ b/flang/test/Driver/xlinker.f90
@@ -1,6 +1,8 @@
-! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck %s
+! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck --check-prefix=SINGLE %s
+! RUN: %flang -### -o /dev/null %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck --check-prefix=MULTIPLE %s
-! CHECK: "-fc1"
-! CHECK-NEXT: "-rpath=/not/a/real/path"
+
+! SINGLE: "-rpath=/not/a/real/path"
+! MULTIPLE: "-rpath" "/not/a/real/path"
end program
More information about the cfe-commits
mailing list