https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/109965
>From 3af5907719193ebc5b251b4681c137827550a1d0 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Wed, 25 Sep 2024 11:43:40 +0000 Subject: [PATCH 1/2] [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 | 23 +++++++++++++++++++ .../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 .../Driver/Inputs/B_opt_tree/dir3/prefix-ld | 0 6 files changed, 24 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..a749b5e08e8d52 --- /dev/null +++ b/flang/test/Driver/B-opt.f90 @@ -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" 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 >From 76e8842e0d0bdd6fc1882d8d22a1efa1c86b13a5 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Thu, 26 Sep 2024 09:34:34 +0000 Subject: [PATCH 2/2] Use --target instead of target --- clang/test/Driver/B-opt.c | 10 +++++----- flang/test/Driver/B-opt.f90 | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/test/Driver/B-opt.c b/clang/test/Driver/B-opt.c index df85dee4b70407..48139e71a90011 100644 --- a/clang/test/Driver/B-opt.c +++ b/clang/test/Driver/B-opt.c @@ -1,28 +1,28 @@ // Check -B driver option. /// Target triple prefix is not detected for -B. -// RUN: %clang %s -### -o %t.o -target i386-unknown-linux \ +// RUN: %clang %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: %clang %s -### -o %t.o -target i386-unknown-linux \ +// RUN: %clang %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: %clang %s -### -o %t.o -target i386-unknown-linux \ +// RUN: %clang %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: %clang %s -### -o %t.o -target i386-unknown-linux \ +// RUN: %clang %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" // // RUN: %clang -B %S/Inputs/does_not_exist -print-search-dirs \ -// RUN: -target aarch64-linux-gnu \ +// RUN: --target=aarch64-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-B-OPT-INVALID %s // CHECK-B-OPT-INVALID-NOT: /..//bin diff --git a/flang/test/Driver/B-opt.f90 b/flang/test/Driver/B-opt.f90 index a749b5e08e8d52..f5cd58fa97d08b 100644 --- a/flang/test/Driver/B-opt.f90 +++ b/flang/test/Driver/B-opt.f90 @@ -1,22 +1,22 @@ ! Check -B driver option. ! ! Target triple prefix is not detected for -B. -! RUN: %flang %s -### -o %t.o -target i386-unknown-linux \ +! 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: %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: %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: %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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits