https://github.com/tarunprabhu updated https://github.com/llvm/llvm-project/pull/107472
>From acb5cf2af69f7941c24c4e53b67f9f2d4a18dbc8 Mon Sep 17 00:00:00 2001 From: Tarun Prabhu <tarun.pra...@gmail.com> Date: Thu, 5 Sep 2024 15:41:54 -0600 Subject: [PATCH 1/3] [flang][Driver] Support -Xlinker in flang --- clang/include/clang/Driver/Options.td | 1 + flang/test/Driver/xlinker.f90 | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 flang/test/Driver/xlinker.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1b9b3f2c6600a3..136d979ed7200e 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1051,6 +1051,7 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>, def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>, HelpText<"Use the new offloading linker to perform the link job.">; def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>, + Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>, HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">, Group<Link_Group>; def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">, diff --git a/flang/test/Driver/xlinker.f90 b/flang/test/Driver/xlinker.f90 new file mode 100644 index 00000000000000..8bb1f7e99ae238 --- /dev/null +++ b/flang/test/Driver/xlinker.f90 @@ -0,0 +1,6 @@ +! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck %s + +! CHECK: "-fc1" +! CHECK-NEXT: "-rpath=/not/a/real/path" + +end program >From fcfe90910382ded9e58868d8feef2195f00dd4f0 Mon Sep 17 00:00:00 2001 From: Tarun Prabhu <tarun.pra...@gmail.com> Date: Mon, 9 Sep 2024 09:22:44 -0600 Subject: [PATCH 2/3] Update test to address reviewer comments. Add test with multiple -instances of -Xlinker options --- flang/test/Driver/xlinker.f90 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flang/test/Driver/xlinker.f90 b/flang/test/Driver/xlinker.f90 index 8bb1f7e99ae238..071fc6e3dc9027 100644 --- a/flang/test/Driver/xlinker.f90 +++ b/flang/test/Driver/xlinker.f90 @@ -1,6 +1,8 @@ -! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck %s +! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck --check-prefix=SINGLE %s +! RUN: %flang -### -o /dev/null %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck --check-prefix=MULTIPLE %s -! CHECK: "-fc1" -! CHECK-NEXT: "-rpath=/not/a/real/path" + +! SINGLE: "-rpath=/not/a/real/path" +! MULTIPLE: "-rpath" "/not/a/real/path" end program >From e61e96045c2dce556afea6bcb9debe4dffa8d94a Mon Sep 17 00:00:00 2001 From: Tarun Prabhu <tarun.pra...@gmail.com> Date: Mon, 9 Sep 2024 09:51:31 -0600 Subject: [PATCH 3/3] Better tests. Do look for the linker executable name on the line and ensure that the passed arguments are present on that line. Test this for a variety of linkers and targets. --- flang/test/Driver/xlinker.f90 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/flang/test/Driver/xlinker.f90 b/flang/test/Driver/xlinker.f90 index 071fc6e3dc9027..feafadcfcec452 100644 --- a/flang/test/Driver/xlinker.f90 +++ b/flang/test/Driver/xlinker.f90 @@ -1,8 +1,21 @@ -! RUN: %flang -### -o /dev/null %s -Xlinker -rpath=/not/a/real/path 2>&1 | FileCheck --check-prefix=SINGLE %s -! RUN: %flang -### -o /dev/null %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck --check-prefix=MULTIPLE %s +! RUN: %flang -### --target=ppc64le-linux-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=aarch64-apple-darwin -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=sparc-sun-solaris2.11 -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-freebsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-netbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-openbsd -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-dragonfly -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-unknown-haiku %s -Xlinker -rpath -Xlinker /not/a/real/path 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=x86_64-windows-gnu -Xlinker -rpath -Xlinker /not/a/real/path %s 2>&1 | FileCheck %s --check-prefixes=UNIX +! RUN: %flang -### --target=aarch64-windows-msvc -Xlinker -rpath -Xlinker /not/a/real/path -o obscure.exe %s 2>&1 | FileCheck %s --check-prefixes=MSVC +! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}" +! UNIX-SAME: "-rpath" "/not/a/real/path" -! SINGLE: "-rpath=/not/a/real/path" -! MULTIPLE: "-rpath" "/not/a/real/path" +! The name of this file contains the word "link" which results in a match on +! the compiler line as well. Instead look for the final name of the executable +! to be created since that will only appear in the linker line. +! MSVC: -out:obscure.exe +! MSVC-SAME: "-rpath" "/not/a/real/path" end program _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits