[UR][CMake] Use pkg-config include dirs for preinstalled Level Zero - #23056
Open
arcusbuilds wants to merge 1 commit into
Open
[UR][CMake] Use pkg-config include dirs for preinstalled Level Zero#23056arcusbuilds wants to merge 1 commit into
arcusbuilds wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
level-zero ships two pkg-config files:
level-zero.pchas-I${includedir}/level_zeroand requireslibze_loader.pc, which adds-I${includedir}. We were ignoring the cflags and rebuilding the first path by hand fromincludedir, so the second one never reached the compiler.That's fine when L0 is in
/usr, since pkg-config drops-I/usr/includeand 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_DIRStoLEVEL_ZERO_INCLUDE_DIR, because sycl-trace appends/ze_api.hto 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 withNo such file or directory, after it builds. A/usrinstall is unaffected either way.Closes: #23045