Fix async backend selection for Emscripten and wasm64 (#25042) Found this while building IREE's WebGPU runtime with Emscripten for wasm32 and wasm64 to run MLIR programs in JupyterLite. IREE_ARCH is empty for Emscripten, so the generated CMake condition selects POSIX. Update the converter and regenerate the async CMake file to recognize Emscripten and wasm64. Signed-off-by: anutosh491 <andersonbhat491@gmail.com>
diff --git a/build_tools/bazel/BUILD.bazel b/build_tools/bazel/BUILD.bazel index afffddd..2518532 100644 --- a/build_tools/bazel/BUILD.bazel +++ b/build_tools/bazel/BUILD.bazel
@@ -4,6 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +load("@bazel_skylib//lib:selects.bzl", "selects") load("@bazel_skylib//rules:common_settings.bzl", "string_flag") package( @@ -75,10 +76,29 @@ ) config_setting( - name = "iree_is_wasm", + name = "iree_is_wasm32", constraint_values = ["@platforms//cpu:wasm32"], ) +config_setting( + name = "iree_is_wasm64", + constraint_values = ["@platforms//cpu:wasm64"], +) + +config_setting( + name = "iree_is_emscripten", + constraint_values = ["@platforms//os:emscripten"], +) + +selects.config_setting_group( + name = "iree_is_wasm", + match_any = [ + ":iree_is_wasm32", + ":iree_is_wasm64", + ":iree_is_emscripten", + ], +) + # Selects a user-provided system allocator. Users must provide # IREE_ALLOCATOR_SYSTEM_CTL, and optionally IREE_ALLOCATOR_SYSTEM_SELF, via # their own copts/defines and link the implementation into final binaries.
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py index 7c91884..31e0e1d 100644 --- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py +++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -169,7 +169,10 @@ def _convert_platform_condition(self, constraint_label): """Returns a CMake condition string for a platform constraint label.""" if constraint_label == "//build_tools/bazel:iree_is_wasm": - return 'IREE_ARCH STREQUAL "wasm_32"' + return ( + 'EMSCRIPTEN OR IREE_ARCH STREQUAL "wasm_32" ' + 'OR IREE_ARCH STREQUAL "wasm_64"' + ) cmake_name = _PLATFORM_CMAKE_SYSTEM_NAME.get(constraint_label) if not cmake_name: return None
diff --git a/runtime/src/iree/async/CMakeLists.txt b/runtime/src/iree/async/CMakeLists.txt index 309440e..87d5d3d 100644 --- a/runtime/src/iree/async/CMakeLists.txt +++ b/runtime/src/iree/async/CMakeLists.txt
@@ -100,7 +100,7 @@ list(APPEND _platform_platform_deps iree::async::platform::posix) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") list(APPEND _platform_platform_deps iree::async::platform::iocp) -elseif(IREE_ARCH STREQUAL "wasm_32") +elseif(EMSCRIPTEN OR IREE_ARCH STREQUAL "wasm_32" OR IREE_ARCH STREQUAL "wasm_64") list(APPEND _platform_platform_deps iree::async::platform::js::proactor) elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic") else()