[Flang][Driver] Enable the -B option (#109965)

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.
This commit is contained in:
Kiran Chandramohan 2024-10-01 15:01:32 +01:00 committed by GitHub
parent 2026501cf1
commit 28be39f174
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 24 additions and 0 deletions

View File

@ -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=">,

View File

@ -0,0 +1,23 @@
! 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"
!
! RUN: %flang %s -### -o %t.o --target=i386-unknown-linux \
! RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- -fuse-ld=ld 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-PREFIX %s
! CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"
!
! RUN: %flang %s -### -o %t.o --target=i386-unknown-linux \
! RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- \
! RUN: -B %S/Inputs/B_opt_tree/dir2 2>&1 -fuse-ld=ld \
! RUN: | FileCheck --check-prefix=CHECK-B-OPT-MULT %s
! CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"

View File

View File