Skip to content

[SPIRV] Properly discover LLVM tools that live next to the compiler#178779

Merged
jhuber6 merged 1 commit intollvm:mainfrom
jhuber6:FixSPIRVToolchain
Jan 30, 2026
Merged

[SPIRV] Properly discover LLVM tools that live next to the compiler#178779
jhuber6 merged 1 commit intollvm:mainfrom
jhuber6:FixSPIRVToolchain

Conversation

@jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Jan 29, 2026

Summary:
When we compile with -emit-llvm it will try to use llvm-link. The
toolchain does not properly add the driver directory as a valid path so
this will default to the user's search path. This, like other tools,
should prioritize the binaries living next to the compiler.

Side note, why is this not default behavior?

Summary:
When we compile with `-emit-llvm` it will try to use `llvm-link`. The
toolchain does not properly add the driver directory as a valid path so
this will default to the user's search path. This, like other tools,
should prioritize the binaries living next to the compiler.

Side note, why is this not default behavior?
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' backend:SPIR-V labels Jan 29, 2026
@llvmbot
Copy link
Member

llvmbot commented Jan 29, 2026

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-backend-spir-v

Author: Joseph Huber (jhuber6)

Changes

Summary:
When we compile with -emit-llvm it will try to use llvm-link. The
toolchain does not properly add the driver directory as a valid path so
this will default to the user's search path. This, like other tools,
should prioritize the binaries living next to the compiler.

Side note, why is this not default behavior?


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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/SPIRV.cpp (+3)
diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp
index 81fd2afc6e9c7..c1ccb1e7d8508 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -172,6 +172,9 @@ SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
   // TODO: Revisit need/use of --sycl-link option once SYCL toolchain is
   // available and SYCL linking support is moved there.
   NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
+
+  // Lookup binaries into the driver directory.
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 bool SPIRVToolChain::HasNativeLLVMSupport() const { return NativeLLVMSupport; }

@jdoerfert
Copy link
Member

Can you add a test? Otherwise, this seems sensible.

@jhuber6
Copy link
Contributor Author

jhuber6 commented Jan 30, 2026

Can you add a test? Otherwise, this seems sensible.

Not sure off of the top of my head how you'd test this, since in the test environments the path is going to point to the build's binary directory anyways AFAIK.

@jdoerfert
Copy link
Member

Can you add a test? Otherwise, this seems sensible.

Not sure off of the top of my head how you'd test this, since in the test environments the path is going to point to the build's binary directory anyways AFAIK.

Hmm... Let me verify it solves the build issue of the device runtime and then we go ahead as is.

Copy link
Member

@jdoerfert jdoerfert left a comment

Choose a reason for hiding this comment

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

This makes the SPIRV OpenMP device runtime build succeed even if the PATH llvm-link is old.

@jhuber6 jhuber6 merged commit e05ce8f into llvm:main Jan 30, 2026
14 checks passed
@jhuber6 jhuber6 deleted the FixSPIRVToolchain branch January 30, 2026 14:03
sshrestha-aa pushed a commit to sshrestha-aa/llvm-project that referenced this pull request Feb 4, 2026
…lvm#178779)

Summary:
When we compile with `-emit-llvm` it will try to use `llvm-link`. The
toolchain does not properly add the driver directory as a valid path so
this will default to the user's search path. This, like other tools,
should prioritize the binaries living next to the compiler.

Side note, why is this not default behavior?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:SPIR-V 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