intellikit icon indicating copy to clipboard operation
intellikit copied to clipboard

kerncap misses compile_commands.json in build directories not named build/

Open coleramos425 opened this issue 2 weeks ago • 0 comments

kerncap extract --source-dir only finds compile_commands.json in the source directory, one of its parent directories, or a subdirectory of those named exactly build/ (_find_compile_commands_from_source_dir in kerncap/kerncap/source_finder.py). When a CMake build lives in a differently named directory, such as build-mi300x/, build/release/ or CLion's cmake-build-debug/, the lookup fails. Kerncap then warns "No compile command found" and leaves out the make recompile, run-variant and validate-variant targets, even when the file sits next to the binary passed in --cmd.

Reproduce

Run this on mixbench (ROCm 7.2.3, MI300X and MI210):

cmake -S mixbench-hip -B build-mi300x -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake --build build-mi300x
cd build-mi300x
kerncap extract "benchmark_func<int, 256, 8u, 512u>" --cmd ./mixbench-hip \
  --source-dir ../mixbench-hip --output ./isolated/bf
# WARNING: No compile command found ... The 'make recompile' target will not be available.

build-mi300x/compile_commands.json exists and has an entry for mix_kernels_hip.cpp.

Suggested fix

When the source-dir lookup finds nothing, fall back to _find_compile_commands(binary_path), which already walks up from the binary. Today it is used only to pick up -D and -I flags. Add a unit test for the build-<name>/ layout.

coleramos425 avatar Nov 18 '26 00:11 coleramos425