Skip to content

Commit 871e907

Browse files
authored
[SYCL][E2E] Better handle the Intel Compiler in standalone build (NFC) (#18627)
The proprietary Intel Compiler (ICX) uses a different installation layout then clang. It puts tools into a bin/compiler subdirectory (to not expose them on the PATH by default). Handle this by not assuming that the compiler is in the same directory as other llvm tools. Ask the compiler for the path to `llvm-config` for the tools directory, using the `-print-prog-name` option. `llvm-config` was choosen because lit already assumes it is in the tools directory see for example: [llvm/utils/lit/lit/llvm/config.py:285][1] [1]: https://github.com/llvm/llvm-project/blob/9cac4bf485e64f7992f2c01bb9517f6379e58164/llvm/utils/lit/lit/llvm/config.py#L285
1 parent c8667f5 commit 871e907

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

sycl/test-e2e/lit.cfg.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,9 @@ def open_check_file(file_name):
626626

627627
lit_config.note("Targeted devices: {}".format(", ".join(config.sycl_devices)))
628628

629-
sycl_ls = FindTool("sycl-ls").resolve(llvm_config, config.llvm_tools_dir)
629+
sycl_ls = FindTool("sycl-ls").resolve(
630+
llvm_config, os.pathsep.join([config.dpcpp_bin_dir, config.llvm_tools_dir])
631+
)
630632
if not sycl_ls:
631633
lit_config.fatal("can't find `sycl-ls`")
632634

@@ -809,12 +811,14 @@ def remove_level_zero_suffix(devices):
809811
ToolSubst("sycl-ls", command=sycl_ls, unresolved="ignore"),
810812
] + feature_tools
811813

812-
# Try and find each of these tools in the llvm tools directory or the PATH, in
813-
# that order. If found, they will be added as substitutions with the full path
814+
# Try and find each of these tools in the DPC++ bin directory, in the llvm tools directory
815+
# or the PATH, in that order. If found, they will be added as substitutions with the full path
814816
# to the tool. This allows us to support both in-tree builds and standalone
815817
# builds, where the tools may be externally defined.
818+
# The DPC++ bin directory is different from the LLVM bin directory when using
819+
# the Intel Compiler (icx), which puts tools into $dpcpp_root_dir/bin/compiler
816820
llvm_config.add_tool_substitutions(
817-
tools, [config.llvm_tools_dir, os.environ.get("PATH", "")]
821+
tools, [config.dpcpp_bin_dir, config.llvm_tools_dir, os.environ.get("PATH", "")]
818822
)
819823
for tool in feature_tools:
820824
if tool.was_resolved:

sycl/test-e2e/lit.site.cfg.py.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
import sys
44
import platform
5+
import subprocess
56

67
import site
78

89
site.addsitedir("@CMAKE_CURRENT_SOURCE_DIR@")
910

1011
config.dpcpp_compiler = lit_config.params.get("dpcpp_compiler", "@SYCL_CXX_COMPILER@")
1112
config.dpcpp_root_dir= os.path.dirname(os.path.dirname(config.dpcpp_compiler))
13+
config.dpcpp_bin_dir = os.path.join(config.dpcpp_root_dir, 'bin')
1214

13-
config.llvm_tools_dir = os.path.join(config.dpcpp_root_dir, 'bin')
15+
def get_dpcpp_tool_path(name):
16+
try:
17+
return subprocess.check_output([config.dpcpp_compiler, "-print-prog-name=" + name], text=True)
18+
except CalledProcessError:
19+
return os.path.join(config.dpcpp_bin_dir, tool)
20+
21+
config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-config"))
1422
config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@")
1523
config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False))
1624
config.sycl_tools_dir = config.llvm_tools_dir

0 commit comments

Comments
 (0)