Skip to content

[SYCL][Driver] Add option to specify the location of ocloc - #22912

Open
mdtoguchi wants to merge 19 commits into
intel:syclfrom
mdtoguchi:ocloc-location
Open

[SYCL][Driver] Add option to specify the location of ocloc#22912
mdtoguchi wants to merge 19 commits into
intel:syclfrom
mdtoguchi:ocloc-location

Conversation

@mdtoguchi

@mdtoguchi mdtoguchi commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The ocloc tool used for ahead of time compilation targeting Intel GPUs is
acquired externally, so it is not guaranteed to be placed in the PATH.
Add --ocloc-path=dir, allowing a user to specify the directory in which
ocloc resides. The user provided location always wins over any ocloc that
is otherwise visible via the program paths or the PATH environment
variable.

The option is honored for both the old and the new offloading model

  • Old model: the driver's Intel GPU backend compile job (SYCL.cpp) and
    the ocloc help emitted for -fsycl-help=gen.
  • New model: forwarded to clang-linker-wrapper, and to clang-sycl-linker
    for the --sycl-link path. Both tools also accept --ocloc-path=
    directly for standalone use.

Some new offload model tests within sycl-offload-jit.cpp will fail when
the corresponding device libraries are not built.  In those cases, the
test needs to pick up the internal variants so the driver does not error
due to not finding any.
The ocloc tool used for ahead of time compilation targeting Intel GPUs is
acquired externally, so it is not guaranteed to be placed in the PATH.
Add --ocloc-path=<dir>, allowing a user to specify the directory in which
ocloc resides.  The user provided location always wins over any ocloc that
is otherwise visible via the program paths or the PATH environment
variable.

The option is honored for both the old and the new offloading model:

 - Old model: the driver's Intel GPU backend compile job (SYCL.cpp) and
   the ocloc help emitted for -fsycl-help=gen.
 - New model: forwarded to clang-linker-wrapper, and to clang-sycl-linker
   for the --sycl-link path.  Both tools also accept --ocloc-path=
   directly for standalone use.
@mdtoguchi mdtoguchi changed the title Ocloc location [SYCL][Driver] Add option to specify the location of ocloc Aug 10, 2026
@mdtoguchi
mdtoguchi marked this pull request as ready for review August 11, 2026 01:11
@mdtoguchi
mdtoguchi requested review from a team as code owners August 11, 2026 01:11

@tahonermann tahonermann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks ok to me. I'd like to see more comments explaining what happens if ocloc is not at the specified path or not found elsewhere.

It's unfortunate that the logic for finding the right path is repeated in so many places, but that is a pre-existing issue that probably isn't easy to fix.

The help text for each of the three cases of the new option differs for each, but not in a meaningful way as far as I can tell. I suggest consolidating to one phrasing.

Comment thread clang/include/clang/Options/Options.td Outdated
Comment thread clang/lib/Driver/ToolChains/SYCL.h Outdated
Comment thread clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td Outdated
Comment thread clang/tools/clang-sycl-linker/SYCLLinkOpts.td Outdated

@YuriPlyakhin YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it make sense to submit it upstream first?

Comment thread clang/lib/Driver/Driver.cpp Outdated
@mdtoguchi

Copy link
Copy Markdown
Contributor Author

Does it make sense to submit it upstream first?

Probably not - the only tool where ocloc is even mentioned is the clang-sycl-linker. All other locations, no AOT behavior is available. This probably makes more sense to upstream when more AOT functionality is available.

Comment thread clang/lib/Driver/ToolChains/SYCL.h Outdated
Comment thread clang/lib/Driver/ToolChains/SYCL.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

@YuriPlyakhin YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: can we use -B instead of introducing new per-tool option?

Comment thread clang/lib/Driver/Driver.cpp Outdated
Comment thread clang/lib/Driver/Driver.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
Fixes a few items from review
 - Improved error handling with -fsycl-help=gen
 - Make getOclocPath a static helper
 - make --ocloc-path= usage consistent when no value provided
@mdtoguchi

Copy link
Copy Markdown
Contributor Author

Question: can we use -B instead of introducing new per-tool option?

Use of -B<dir> already works (when using the old model), but it is a general application and impacts all GetProgramPath lookups. There is already precedence of using a specific option for the specific tool to locate.

@mdtoguchi
mdtoguchi requested a review from a team as a code owner August 14, 2026 00:08

@sarnex sarnex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mostly lgtm, just some minor questions

Comment thread clang/lib/Driver/ToolChains/Clang.cpp
Comment thread clang/lib/Driver/Driver.cpp
Comment thread clang/lib/Driver/Driver.cpp Outdated

@sarnex sarnex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks!

Comment thread clang/lib/Driver/Driver.cpp Outdated

@sarnex sarnex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thx

@YuriPlyakhin YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new SYCL driver/user-facing option, --ocloc-path=<dir>, to let users specify where the externally-provided Intel GPU AOT tool ocloc resides, and wires it through both the old and new offloading flows (including -fsycl-help=gen tool help emission).

Changes:

  • Introduces --ocloc-path=<dir> as a clang driver option and forwards it to clang-linker-wrapper and clang-sycl-linker as needed.
  • Implements lookup precedence so the user-provided directory is used ahead of program paths / PATH, and rejects empty values early in the driver.
  • Adds/updates tests and documentation for the new option across driver, tools, and manuals.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
sycl/doc/UsersManual.md Documents the new --ocloc-path user option.
clang/include/clang/Options/Options.td Defines the new clang driver option.
clang/lib/Driver/Driver.cpp Rejects empty --ocloc-path= and avoids running external tools on already-rejected command lines; uses shared ocloc resolution for help emission.
clang/lib/Driver/ToolChains/SYCL.h Declares shared getOclocPath helper for ocloc resolution.
clang/lib/Driver/ToolChains/SYCL.cpp Implements getOclocPath and uses it for old-model Intel GPU backend compilation.
clang/lib/Driver/ToolChains/Clang.cpp Forwards --ocloc-path to clang-linker-wrapper under the new offload driver.
clang/lib/Driver/ToolChains/SPIRV.cpp Forwards --ocloc-path to clang-sycl-linker for --sycl-link.
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td Adds --ocloc-path option to the linker-wrapper tool.
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Implements ocloc lookup honoring --ocloc-path.
clang/tools/clang-sycl-linker/SYCLLinkOpts.td Adds --ocloc-path option to the sycl-linker tool.
clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp Implements ocloc lookup honoring --ocloc-path.
clang/docs/ClangLinkerWrapper.rst Documents --ocloc-path for clang-linker-wrapper.
clang/docs/ClangSYCLLinker.rst Documents --ocloc-path for clang-sycl-linker.
clang/test/Driver/sycl-ocloc-path.cpp New driver tests covering old/new model behavior, forwarding, diagnostics, and quoting.
clang/test/Driver/clang-linker-wrapper.cpp Adds a linker-wrapper test for --ocloc-path.
clang/test/OffloadTools/clang-sycl-linker/basic.ll Adds sycl-linker tests for --ocloc-path and diagnostics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread clang/include/clang/Options/Options.td
Comment thread sycl/doc/UsersManual.md
Comment thread clang/tools/clang-sycl-linker/SYCLLinkOpts.td
Comment thread clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
Comment thread clang/docs/ClangSYCLLinker.rst Outdated
Comment thread clang/docs/ClangLinkerWrapper.rst Outdated
Comment thread clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/test/OffloadTools/clang-sycl-linker/basic.ll
Comment thread clang/test/Driver/clang-linker-wrapper.cpp

@tahonermann tahonermann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good to me; I don't have any further requests. Thanks @mdtoguchi!

@mdtoguchi

Copy link
Copy Markdown
Contributor Author

@intel/dpcpp-clang-driver-reviewers, please take a look.

@hchilama hchilama left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants