[flang-commits] [clang] [flang] [Flang][Driver] Enable the -B option (PR #109965)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Sep 25 05:17:04 PDT 2024


https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/109965

>From 322ff8178ae23b43168d88fe8ab314e5ac3ffb72 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Wed, 25 Sep 2024 11:43:40 +0000
Subject: [PATCH] [Flang][Driver] Enable the -B option

The option provides the search prefix for executables, libraries
and data files.

The option is implemented in the common portion of the Driver and
only needs to be enabled in Flang. Test added is a copy of the
relevant test in Clang.
---
 clang/include/clang/Driver/Options.td                |  1 +
 flang/test/Driver/B-opt.f90                          | 12 ++++++++++++
 .../Inputs/B_opt_tree/dir1/i386-unknown-linux-ld     |  0
 flang/test/Driver/Inputs/B_opt_tree/dir1/ld          |  0
 flang/test/Driver/Inputs/B_opt_tree/dir2/ld          |  0
 flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld   |  0
 6 files changed, 13 insertions(+)
 create mode 100644 flang/test/Driver/B-opt.f90
 create mode 100755 flang/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld
 create mode 100755 flang/test/Driver/Inputs/B_opt_tree/dir1/ld
 create mode 100755 flang/test/Driver/Inputs/B_opt_tree/dir2/ld
 create mode 100755 flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 002f60350543d9..020f4f92e8735a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -816,6 +816,7 @@ def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
 def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>,
   Group<gfortran_Group>;
 def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">,
+    Visibility<[ClangOption, FlangOption]>,
     HelpText<"Search $prefix$file for executables, libraries, and data files. "
     "If $prefix is a directory, search $prefix/$file">;
 def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
diff --git a/flang/test/Driver/B-opt.f90 b/flang/test/Driver/B-opt.f90
new file mode 100644
index 00000000000000..16f3b87aee65e6
--- /dev/null
+++ b/flang/test/Driver/B-opt.f90
@@ -0,0 +1,12 @@
+// Check -B driver option.
+
+/// Target triple prefix is not detected for -B.
+// RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir1 -fuse-ld=ld 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
+// CHECK-B-OPT-TRIPLE-NOT: "{{.*}}/Inputs/B_opt_tree/dir1{{/|\\\\}}i386-unknown-linux-ld"
+//
+// RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
+// RUN:     -B %S/Inputs/B_opt_tree/dir2 -fuse-ld=ld 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-B-OPT-DIR %s
+// CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2{{/|\\\\}}ld" 
diff --git a/flang/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld b/flang/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld
new file mode 100755
index 00000000000000..e69de29bb2d1d6
diff --git a/flang/test/Driver/Inputs/B_opt_tree/dir1/ld b/flang/test/Driver/Inputs/B_opt_tree/dir1/ld
new file mode 100755
index 00000000000000..e69de29bb2d1d6
diff --git a/flang/test/Driver/Inputs/B_opt_tree/dir2/ld b/flang/test/Driver/Inputs/B_opt_tree/dir2/ld
new file mode 100755
index 00000000000000..e69de29bb2d1d6
diff --git a/flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld b/flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld
new file mode 100755
index 00000000000000..e69de29bb2d1d6



More information about the flang-commits mailing list