Skip to content

Commit 3af5907

Browse files
[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.
1 parent a6bdf3f commit 3af5907

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
816816
def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>,
817817
Group<gfortran_Group>;
818818
def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">,
819+
Visibility<[ClangOption, FlangOption]>,
819820
HelpText<"Search $prefix$file for executables, libraries, and data files. "
820821
"If $prefix is a directory, search $prefix/$file">;
821822
def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,

flang/test/Driver/B-opt.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! Check -B driver option.
2+
!
3+
! Target triple prefix is not detected for -B.
4+
! RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
5+
! RUN: -B %S/Inputs/B_opt_tree/dir1 -fuse-ld=ld 2>&1 \
6+
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
7+
! CHECK-B-OPT-TRIPLE-NOT: "{{.*}}/Inputs/B_opt_tree/dir1{{/|\\\\}}i386-unknown-linux-ld"
8+
!
9+
! RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
10+
! RUN: -B %S/Inputs/B_opt_tree/dir2 -fuse-ld=ld 2>&1 \
11+
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-DIR %s
12+
! CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2{{/|\\\\}}ld"
13+
!
14+
! RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
15+
! RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- -fuse-ld=ld 2>&1 \
16+
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-PREFIX %s
17+
! CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"
18+
!
19+
! RUN: %flang %s -### -o %t.o -target i386-unknown-linux \
20+
! RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- \
21+
! RUN: -B %S/Inputs/B_opt_tree/dir2 2>&1 -fuse-ld=ld \
22+
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-MULT %s
23+
! CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"

flang/test/Driver/Inputs/B_opt_tree/dir1/i386-unknown-linux-ld

Whitespace-only changes.

flang/test/Driver/Inputs/B_opt_tree/dir1/ld

Whitespace-only changes.

flang/test/Driver/Inputs/B_opt_tree/dir2/ld

Whitespace-only changes.

flang/test/Driver/Inputs/B_opt_tree/dir3/prefix-ld

Whitespace-only changes.

0 commit comments

Comments
 (0)