Skip to content

Commit c36b06a

Browse files
[Vulkan] Fix Ninja build failure by removing wildcard dependencies (pytorch#16394)
### Summary Fixes Ninja build support for the Vulkan backend by removing wildcard usage in `DEPENDS`. Fixes pytorch#16354 Fixes pytorch#14984 The [backends/vulkan/cmake/ShaderLibrary.cmake](cci:7://file:///Users/srirambharadwaj/Documents/iiitb/moonlight/executorch/backends/vulkan/cmake/ShaderLibrary.cmake:0:0-0:0) file previously used a wildcard (`${shaders_path}/*`) in the `DEPENDS` clause of a custom command. Ninja does not support wildcard expansion in dependencies, which caused the build to fail with: `ninja: error: '.../glsl/*', needed by 'vk_compute_shaders/spv.cpp', missing and no known rule to make it`. This PR replaces the wildcard usage with an explicit [file(GLOB ...)](cci:1://file:///Users/srirambharadwaj/Documents/iiitb/moonlight/executorch/examples/portable/executor_runner/executor_runner.cpp:165:0-180:1) command to resolve the source files before passing them to `DEPENDS`, making the build compatible with the Ninja generator. ### Test plan Verified the fix by rebuilding the Android `executor_runner` using Ninja: 1. **Clean Build:** `rm -rf cmake-out-android` 2. **Configure:** ```bash cmake . -G Ninja -DCMAKE_INSTALL_PREFIX=cmake-out-android \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM=android-26 \ -DEXECUTORCH_BUILD_VULKAN=ON \ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \ -DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \ -DEXECUTORCH_BUILD_EXTENSION_LLM=OFF \ -DPYTHON_EXECUTABLE=$(which python) \ -Bcmake-out-android ``` 3. **Build:** `ninja -C cmake-out-android` -> **Success** (previously failed). 4. **Runtime Verification:** Pushed the built `executor_runner` to an Android device and executed a MobileNetV2 model to ensure the binary loads and runs (confirmed same runtime behavior as the Make build). cc @SS-JIA @manuelcandales @digantdesai @cbilgin
1 parent 09b5bdb commit c36b06a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎backends/vulkan/cmake/ShaderLibrary.cmake‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ function(gen_vulkan_shader_lib_cpp shaders_path)
6060
)
6161
endif()
6262

63+
# Ninja cannot expand wildcards (*) in DEPENDS lists.
64+
file(GLOB VULKAN_SHADERS "${shaders_path}/*.glsl" "${shaders_path}/*.glslh"
65+
"${shaders_path}/*.yaml" "${shaders_path}/*.h"
66+
)
67+
6368
add_custom_command(
6469
COMMENT "Generating Vulkan Compute Shaders"
6570
OUTPUT ${VULKAN_SHADERGEN_OUT_PATH}/spv.cpp
@@ -70,7 +75,7 @@ function(gen_vulkan_shader_lib_cpp shaders_path)
7075
--glslc-path=${GLSLC_PATH}
7176
--tmp-dir-path=${VULKAN_SHADERGEN_OUT_PATH}/shader_cache/ --env
7277
${VULKAN_GEN_ARG_ENV} ${GEN_SPV_ARGS}
73-
DEPENDS ${shaders_path}/*
78+
DEPENDS ${VULKAN_SHADERS}
7479
${EXECUTORCH_ROOT}/backends/vulkan/runtime/gen_vulkan_spv.py
7580
)
7681

0 commit comments

Comments
 (0)