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

via flang-commits flang-commits at lists.llvm.org
Wed Sep 25 04:53:14 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kiran Chandramohan (kiranchandramohan)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/109965.diff


6 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+1) 
- (added) flang/test/Driver/B-opt.c (+12) 
- (added) flang/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld () 
- (added) flang/test/Driver/Inputs/B_opt_tree/dir1/ld () 
- (added) flang/test/Driver/Inputs/B_opt_tree/dir2/ld () 
- (added) flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld () 


``````````diff
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.c b/flang/test/Driver/B-opt.c
new file mode 100644
index 00000000000000..16f3b87aee65e6
--- /dev/null
+++ b/flang/test/Driver/B-opt.c
@@ -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

``````````

</details>


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


More information about the flang-commits mailing list