From 295d429c4cdae14097e3d27bf7d99f3ea6334326 Mon Sep 17 00:00:00 2001 From: Daniel Kalmar <1355747+kalmard0@users.noreply.github.com> Date: Tue, 10 Mar 2026 16:49:14 +0000 Subject: [PATCH] Fix emsdk python path issue on Windows. Tested with bazel 8.6.0 with git bash as the main shell and `build --action_env=EM_FROZEN_CACHE=0`. Without this change, my build fails with the error: ``` The system cannot find the path specified. emcc: error: subprocess 1/1 failed (returned 1)! (cmdline: 'C:\bazel\build_root\pn2yxrdx\execroot\_main\external\emsdk++emscripten_deps+emscripten_bin_win\emscripten\em++.bat' -c -O2 -Wall -fno-unroll-loops -g -sSTRICT -Werror -sMEMORY64=1 '-ffile-prefix-map=C:\bazel\build_root\pn2yxrdx\execroot\_main\external\emsdk++emscripten_deps+emscripten_bin_win\emscripten=/emsdk/emscripten' '-ffile-prefix-map=..\..\..=/emsdk/emscripten' -fdebug-compilation-dir=/emsdk/emscripten -std=c++20 ../../../system/lib/embind/bind.cpp) ``` --- bazel/emscripten_toolchain/env.bat | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bazel/emscripten_toolchain/env.bat b/bazel/emscripten_toolchain/env.bat index c791ff7710..d5b5d5a691 100644 --- a/bazel/emscripten_toolchain/env.bat +++ b/bazel/emscripten_toolchain/env.bat @@ -4,3 +4,11 @@ set ROOT_DIR=%EXT_BUILD_ROOT% if "%ROOT_DIR%"=="" set ROOT_DIR=%CD% set EMSCRIPTEN=%ROOT_DIR%\%EM_BIN_PATH%\emscripten set EM_CONFIG=%ROOT_DIR%\%EM_CONFIG_PATH% + +:: If EMSDK_PYTHON is a relative path, make it absolute using ROOT_DIR. +:: This is needed because emscripten system library generation invokes compilers +:: from subdirectories inside its cache, where relative paths to python break. +if not "%EMSDK_PYTHON%"=="" ^ +if not "%EMSDK_PYTHON:~1,1%"==":" ^ +if not "%EMSDK_PYTHON:~0,1%"=="\" ^ + set "EMSDK_PYTHON=%ROOT_DIR%\%EMSDK_PYTHON%"