Skip to content

[UR][CMake] Use pkg-config include dirs for preinstalled Level Zero - #23056

Open
arcusbuilds wants to merge 1 commit into
intel:syclfrom
arcusbuilds:fix-l0-pkgconfig-include-dirs
Open

[UR][CMake] Use pkg-config include dirs for preinstalled Level Zero#23056
arcusbuilds wants to merge 1 commit into
intel:syclfrom
arcusbuilds:fix-l0-pkgconfig-include-dirs

Conversation

@arcusbuilds

@arcusbuilds arcusbuilds commented Aug 29, 2026

Copy link
Copy Markdown

level-zero ships two pkg-config files: level-zero.pc has -I${includedir}/level_zero and requires libze_loader.pc, which adds -I${includedir}. We were ignoring the cflags and rebuilding the first path by hand from includedir, so the second one never reached the compiler.

That's fine when L0 is in /usr, since pkg-config drops -I/usr/include and the compiler finds the headers anyway. With L0 installed anywhere else, anything including <level_zero/...> either doesn't build, or quietly picks up an older system L0 and mixes headers from two versions, which is what #23045 hit.

I didn't just assign level-zero_INCLUDE_DIRS to LEVEL_ZERO_INCLUDE_DIR, because sycl-trace appends /ze_api.h to that variable and would break if it became a list. Put the extra dirs in their own variable instead.

Tested with L0 v1.33.1 installed to a custom prefix and no system L0: before the change the L0 conformance test that includes <level_zero/ze_api.h> fails with No such file or directory, after it builds. A /usr install is unaffected either way.

Closes: #23045

pkg_check_modules reports the parsed -I directories in
level-zero_INCLUDE_DIRS. Level Zero publishes two of them: level-zero.pc
contributes -I${includedir}/level_zero and, through Requires: libze_loader,
libze_loader.pc contributes -I${includedir}.

Reading the raw includedir variable and appending /level_zero reconstructs
only the first, so headers included as <level_zero/ze_api.h> are not found
in the Level Zero installation. For an L0 under /usr this is masked, because
pkg-config omits -I/usr/include as a default search path and the compiler
finds the header anyway. For an L0 installed elsewhere the include either
fails outright or silently resolves against an older system-wide install,
mixing headers from two Level Zero versions.

Carry the pkg-config-reported directories in a new
LEVEL_ZERO_EXTRA_INCLUDE_DIRS variable and add them to the
LevelZeroLoader-Headers target alongside LEVEL_ZERO_INCLUDE_DIR, which is
left unchanged.

LEVEL_ZERO_INCLUDE_DIR deliberately stays a single directory that directly
contains ze_api.h, as it is in all three branches of this file. Making it a
;-list would break sycl/tools/sycl-trace/CMakeLists.txt, which concatenates
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h unquoted as both a COMMAND argument and a
DEPENDS entry; a two-element value expands there into a bare directory
followed by a path, and generate_ze_pretty_printers.py would be handed the
directory as sys.argv[1]. The CACHE PATH publication in this file and the
file(GLOB) in the fetch branch rely on the same single-directory assumption.

LEVEL_ZERO_EXTRA_INCLUDE_DIRS is empty in the other two branches; an empty
$<BUILD_INTERFACE:> entry is dropped, verified on CMake 3.20.6, 3.28.3,
3.31.6 and 4.0.3, so those paths are unchanged.

Fixes: intel#23045
@arcusbuilds
arcusbuilds requested a review from a team as a code owner August 29, 2026 08:42
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.

dpclang fails to build with custom installed L0 in parallel to system installed one

1 participant