[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
mikaoP wrote: Maybe the discussing topic is, as you said, if we allow specifying `x86_64` as target. Or fixing the rpath format if we support that. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
mikaoP wrote: Maybe I'm not getting what you say. I see that when you use `-fopenmp-targets=x86-64-unknown-linux-gnu` then no gcc command is issued. In any case, a clang command is run with `-rpath ` or `-Wl,-rpath,`. The last is what this patch does only for CPU offloading. I guess that does not affect with nvlink, since this is npvtx offloading, right? In the end, clang will understand both rpath formats, but the flag is forwarded to gcc, which only understand the `-Wl` one. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
jhuber6 wrote: If you really need this, perhaps you can check if the Triple will invoke the fallback toolchain or something? Would be a lack of vendor in the Triple. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
jhuber6 wrote: > > I thought that clang accepted `-rpath `? I see that format when I try > > CPU offloading. > > Yeah, but when running `--target=x86_64` and underlying gcc command is issued > and complains about `-rpath ` Oh, I see. When using `-fopenmp-targets=x86_64` it goes through the default GCC toolchain because you gave it no information. I'm wondering if we should bother supporting that since it's supposed to be `-fopenmp-targets=x86-64-unknown-linux-gnu` or similar. The GCC fallback isn't really guaranteed to work. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
mikaoP wrote: > I thought that clang accepted `-rpath `? I see that format when I try > CPU offloading. Yeah, but when running `--target=x86_64` and underlying gcc command is issued and complains about `-rpath ` https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
jhuber6 wrote: I remember intentionally using the clang argument format instead of `-Wl,-rpath,` because the `-Wl` format would try to forward it to things like `nvlink` which don't support it. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
mikaoP wrote: Ah, right. I'll remove the folder then https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
jhuber6 wrote: The tests use an option that causes nothing to actually run, so it only uses the filename. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
mikaoP wrote: Ah, since in the test I had to put an rpath I though that for the test we needed a valid folder https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
jhuber6 wrote: What is this? https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
https://github.com/jhuber6 commented: I thought that clang accepted `-rpath `? I see that format when I try CPU offloading. https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
https://github.com/jhuber6 edited https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag to the correct format in CPU offloading (PR #95763)
https://github.com/mikaoP edited https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag in the correct format in CPU offloading (PR #95763)
https://github.com/mikaoP updated https://github.com/llvm/llvm-project/pull/95763 >From 9710628fb49e941bc43b1a4fb11a9d03470b8d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Pe=C3=B1acoba=20Veigas?= Date: Mon, 17 Jun 2024 10:34:10 + Subject: [PATCH] [Clang] Forward -rpath flag in the correct format in CPU offloading --- clang/test/Driver/Inputs/linker-wrapper/.keep | 0 clang/test/Driver/linker-wrapper.c | 1 + clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 3 +++ 3 files changed, 4 insertions(+) create mode 100644 clang/test/Driver/Inputs/linker-wrapper/.keep diff --git a/clang/test/Driver/Inputs/linker-wrapper/.keep b/clang/test/Driver/Inputs/linker-wrapper/.keep new file mode 100644 index 0..e69de29bb2d1d diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index 0d05f913aad63..9ed43343bf8d7 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -57,6 +57,7 @@ __attribute__((visibility("protected"), used)) int x; // RUN: llvm-ar rcs %t.a %t.o // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \ // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \ +// RUN: -rpath %S/Inputs/linker-wrapper // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK // CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 07a8d53c04b16..6705a4635b4cd 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -500,6 +500,9 @@ Expected clang(ArrayRef InputFiles, const ArgList ) { LinkerArgs.push_back(Args.MakeArgString("-Wl,--whole-archive")); else if (Arg->getOption().matches(OPT_no_whole_archive)) LinkerArgs.push_back(Args.MakeArgString("-Wl,--no-whole-archive")); + else if (Arg->getOption().matches(OPT_rpath)) +LinkerArgs.push_back( +Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; else Arg->render(Args, LinkerArgs); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag in the correct format in CPU offloading (PR #95763)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 657ec7320d8a28171755ba0dd5afc570a5a16791 eb1145aa4faea37806780823cc55daaba1340f36 -- clang/test/Driver/linker-wrapper.c clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 0023899513..6705a4635b 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -501,7 +501,8 @@ Expected clang(ArrayRef InputFiles, const ArgList ) { else if (Arg->getOption().matches(OPT_no_whole_archive)) LinkerArgs.push_back(Args.MakeArgString("-Wl,--no-whole-archive")); else if (Arg->getOption().matches(OPT_rpath)) -LinkerArgs.push_back(Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; +LinkerArgs.push_back( +Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; else Arg->render(Args, LinkerArgs); } `` https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag in the correct format in CPU offloading (PR #95763)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (mikaoP) Changes `clang-linker-wrapper` gets flags in linker format. In CPU offloading we need to format some of them as compiler flags, like it is already done with `--no-whole-archine`. This patch does the same with `-rpath` --- Full diff: https://github.com/llvm/llvm-project/pull/95763.diff 3 Files Affected: - (added) clang/test/Driver/Inputs/linker-wrapper/.keep () - (modified) clang/test/Driver/linker-wrapper.c (+1) - (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+2) ``diff diff --git a/clang/test/Driver/Inputs/linker-wrapper/.keep b/clang/test/Driver/Inputs/linker-wrapper/.keep new file mode 100644 index 0..e69de29bb2d1d diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index 0d05f913aad63..9ed43343bf8d7 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -57,6 +57,7 @@ __attribute__((visibility("protected"), used)) int x; // RUN: llvm-ar rcs %t.a %t.o // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \ // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \ +// RUN: -rpath %S/Inputs/linker-wrapper // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK // CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 07a8d53c04b16..0023899513dd9 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -500,6 +500,8 @@ Expected clang(ArrayRef InputFiles, const ArgList ) { LinkerArgs.push_back(Args.MakeArgString("-Wl,--whole-archive")); else if (Arg->getOption().matches(OPT_no_whole_archive)) LinkerArgs.push_back(Args.MakeArgString("-Wl,--no-whole-archive")); + else if (Arg->getOption().matches(OPT_rpath)) +LinkerArgs.push_back(Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; else Arg->render(Args, LinkerArgs); } `` https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag in the correct format in CPU offloading (PR #95763)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: None (mikaoP) Changes `clang-linker-wrapper` gets flags in linker format. In CPU offloading we need to format some of them as compiler flags, like it is already done with `--no-whole-archine`. This patch does the same with `-rpath` --- Full diff: https://github.com/llvm/llvm-project/pull/95763.diff 3 Files Affected: - (added) clang/test/Driver/Inputs/linker-wrapper/.keep () - (modified) clang/test/Driver/linker-wrapper.c (+1) - (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+2) ``diff diff --git a/clang/test/Driver/Inputs/linker-wrapper/.keep b/clang/test/Driver/Inputs/linker-wrapper/.keep new file mode 100644 index 0..e69de29bb2d1d diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index 0d05f913aad63..9ed43343bf8d7 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -57,6 +57,7 @@ __attribute__((visibility("protected"), used)) int x; // RUN: llvm-ar rcs %t.a %t.o // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \ // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \ +// RUN: -rpath %S/Inputs/linker-wrapper // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK // CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 07a8d53c04b16..0023899513dd9 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -500,6 +500,8 @@ Expected clang(ArrayRef InputFiles, const ArgList ) { LinkerArgs.push_back(Args.MakeArgString("-Wl,--whole-archive")); else if (Arg->getOption().matches(OPT_no_whole_archive)) LinkerArgs.push_back(Args.MakeArgString("-Wl,--no-whole-archive")); + else if (Arg->getOption().matches(OPT_rpath)) +LinkerArgs.push_back(Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; else Arg->render(Args, LinkerArgs); } `` https://github.com/llvm/llvm-project/pull/95763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Forward -rpath flag in the correct format in CPU offloading (PR #95763)
https://github.com/mikaoP created https://github.com/llvm/llvm-project/pull/95763 `clang-linker-wrapper` gets flags in linker format. In CPU offloading we need to format some of them as compiler flags, like it is already done with `--no-whole-archine`. This patch does the same with `-rpath` >From eb1145aa4faea37806780823cc55daaba1340f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Pe=C3=B1acoba=20Veigas?= Date: Mon, 17 Jun 2024 10:34:10 + Subject: [PATCH] [Clang] Forward -rpath flag in the correct format in CPU offloading --- clang/test/Driver/Inputs/linker-wrapper/.keep | 0 clang/test/Driver/linker-wrapper.c | 1 + clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 2 ++ 3 files changed, 3 insertions(+) create mode 100644 clang/test/Driver/Inputs/linker-wrapper/.keep diff --git a/clang/test/Driver/Inputs/linker-wrapper/.keep b/clang/test/Driver/Inputs/linker-wrapper/.keep new file mode 100644 index 0..e69de29bb2d1d diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index 0d05f913aad63..9ed43343bf8d7 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -57,6 +57,7 @@ __attribute__((visibility("protected"), used)) int x; // RUN: llvm-ar rcs %t.a %t.o // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \ // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \ +// RUN: -rpath %S/Inputs/linker-wrapper // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK // CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 07a8d53c04b16..0023899513dd9 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -500,6 +500,8 @@ Expected clang(ArrayRef InputFiles, const ArgList ) { LinkerArgs.push_back(Args.MakeArgString("-Wl,--whole-archive")); else if (Arg->getOption().matches(OPT_no_whole_archive)) LinkerArgs.push_back(Args.MakeArgString("-Wl,--no-whole-archive")); + else if (Arg->getOption().matches(OPT_rpath)) +LinkerArgs.push_back(Args.MakeArgString("-Wl,-rpath," + Twine(Arg->getValue(; else Arg->render(Args, LinkerArgs); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits