Skip to content

[clang][Driver][OpenMP][SPIR-V] Fix SPIR-V OpenMP DeviceRTL expected file name #141855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

sarnex
Copy link
Member

@sarnex sarnex commented May 28, 2025

The option name to specify the path is --libomptarget-spirv-bc-path so the existing error gives an invalid option name (--libomptarget-spirv64-bc-path) when it can't find the file. Also the expected file name is weird, we expect the file name to be libomptarget-spirv64.bc. and use the same prefix spirv64 to suggest the option to the user.

Also the nvptx triple is nvptx64 and the option/filename there is just nvptx, so we should be consistent.

…file name

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
@sarnex sarnex marked this pull request as ready for review May 29, 2025 14:18
@sarnex sarnex requested a review from jhuber6 May 29, 2025 14:18
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels May 29, 2025
@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)

Changes

The option name to specify the path is --libomptarget-spirv-bc-path so the existing error gives an invalid option name (--libomptarget-spirv64-bc-path) when it can't find the file. Also the expected file name is weird, we expect the file name to be libomptarget-spirv64.bc. and use the same prefix spirv64 to suggest the option to the user.

Also the nvptx triple is nvptx64 and the option/filename there is just nvptx, so we should be consistent.


Full diff: https://github.com/llvm/llvm-project/pull/141855.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1)
  • (renamed) clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc ()
  • (modified) clang/test/Driver/spirv-openmp-toolchain.c (+1-1)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 60db462d87342..937ee09cac7cc 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2811,7 +2811,7 @@ void tools::addOpenMPDeviceRTL(const Driver &D,
 
   StringRef ArchPrefix = Triple.isAMDGCN()  ? "amdgpu"
                          : Triple.isNVPTX() ? "nvptx"
-                                            : "spirv64";
+                                            : "spirv";
   std::string LibOmpTargetName = ("libomptarget-" + ArchPrefix + ".bc").str();
 
   // First check whether user specifies bc library
diff --git a/clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv64.bc b/clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc
similarity index 100%
rename from clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv64.bc
rename to clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc
diff --git a/clang/test/Driver/spirv-openmp-toolchain.c b/clang/test/Driver/spirv-openmp-toolchain.c
index 3fd6d94a1222b..a61f3bc2399eb 100644
--- a/clang/test/Driver/spirv-openmp-toolchain.c
+++ b/clang/test/Driver/spirv-openmp-toolchain.c
@@ -54,7 +54,7 @@
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel \
 // RUN: --sysroot=%S/Inputs/spirv-openmp/ %s 2>&1 | FileCheck --check-prefix=CHECK-GPULIB %s
-// CHECK-GPULIB: "-cc1" "-triple" "spirv64-intel"{{.*}}"-mlink-builtin-bitcode" "{{.*}}libomptarget-spirv64.bc"
+// CHECK-GPULIB: "-cc1" "-triple" "spirv64-intel"{{.*}}"-mlink-builtin-bitcode" "{{.*}}libomptarget-spirv.bc"
 
 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=spirv64-intel \
 // RUN:        --libomptarget-spirv-bc-path=%t/ -nogpulib %s 2>&1 \

@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-clang-driver

Author: Nick Sarnie (sarnex)

Changes

The option name to specify the path is --libomptarget-spirv-bc-path so the existing error gives an invalid option name (--libomptarget-spirv64-bc-path) when it can't find the file. Also the expected file name is weird, we expect the file name to be libomptarget-spirv64.bc. and use the same prefix spirv64 to suggest the option to the user.

Also the nvptx triple is nvptx64 and the option/filename there is just nvptx, so we should be consistent.


Full diff: https://github.com/llvm/llvm-project/pull/141855.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1)
  • (renamed) clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc ()
  • (modified) clang/test/Driver/spirv-openmp-toolchain.c (+1-1)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 60db462d87342..937ee09cac7cc 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2811,7 +2811,7 @@ void tools::addOpenMPDeviceRTL(const Driver &D,
 
   StringRef ArchPrefix = Triple.isAMDGCN()  ? "amdgpu"
                          : Triple.isNVPTX() ? "nvptx"
-                                            : "spirv64";
+                                            : "spirv";
   std::string LibOmpTargetName = ("libomptarget-" + ArchPrefix + ".bc").str();
 
   // First check whether user specifies bc library
diff --git a/clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv64.bc b/clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc
similarity index 100%
rename from clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv64.bc
rename to clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv.bc
diff --git a/clang/test/Driver/spirv-openmp-toolchain.c b/clang/test/Driver/spirv-openmp-toolchain.c
index 3fd6d94a1222b..a61f3bc2399eb 100644
--- a/clang/test/Driver/spirv-openmp-toolchain.c
+++ b/clang/test/Driver/spirv-openmp-toolchain.c
@@ -54,7 +54,7 @@
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=spirv64-intel \
 // RUN: --sysroot=%S/Inputs/spirv-openmp/ %s 2>&1 | FileCheck --check-prefix=CHECK-GPULIB %s
-// CHECK-GPULIB: "-cc1" "-triple" "spirv64-intel"{{.*}}"-mlink-builtin-bitcode" "{{.*}}libomptarget-spirv64.bc"
+// CHECK-GPULIB: "-cc1" "-triple" "spirv64-intel"{{.*}}"-mlink-builtin-bitcode" "{{.*}}libomptarget-spirv.bc"
 
 // RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=spirv64-intel \
 // RUN:        --libomptarget-spirv-bc-path=%t/ -nogpulib %s 2>&1 \

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .bc file for AMDGPU is unused, I'd imagine SPIR-V is as well since its compilation flow is like AMDGPU.

@sarnex
Copy link
Member Author

sarnex commented May 29, 2025

Right now we don't even build the DeviceRTL for SPIR-V, however I do have it built locally with some other modifications that seem to result in it being used and I ran into this issue there.

@sarnex sarnex merged commit 05c76e7 into llvm:main May 29, 2025
16 checks passed
svkeerthy pushed a commit that referenced this pull request May 29, 2025
…file name (#141855)

The option name to specify the path is `--libomptarget-spirv-bc-path` so
the existing error gives an invalid option name
(`--libomptarget-spirv64-bc-path`) when it can't find the file. Also the
expected file name is weird, we expect the file name to be
`libomptarget-spirv64.bc`. and use the same prefix `spirv64` to suggest
the option to the user.

Also the `nvptx` triple is `nvptx64` and the option/filename there is
just `nvptx`, so we should be consistent.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
…file name (llvm#141855)

The option name to specify the path is `--libomptarget-spirv-bc-path` so
the existing error gives an invalid option name
(`--libomptarget-spirv64-bc-path`) when it can't find the file. Also the
expected file name is weird, we expect the file name to be
`libomptarget-spirv64.bc`. and use the same prefix `spirv64` to suggest
the option to the user.

Also the `nvptx` triple is `nvptx64` and the option/filename there is
just `nvptx`, so we should be consistent.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…file name (llvm#141855)

The option name to specify the path is `--libomptarget-spirv-bc-path` so
the existing error gives an invalid option name
(`--libomptarget-spirv64-bc-path`) when it can't find the file. Also the
expected file name is weird, we expect the file name to be
`libomptarget-spirv64.bc`. and use the same prefix `spirv64` to suggest
the option to the user.

Also the `nvptx` triple is `nvptx64` and the option/filename there is
just `nvptx`, so we should be consistent.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants