Skip to content

Commit 30070f5

Browse files
committed
fix(litert): cpuinfo clone path (win-arm64-shared) + robust container clang
- win-arm64-shared: MSYS2_ARG_CONV_EXCL='*' was exported before the cpuinfo git clone, mangling its path (bazel: 'no such package @@cpuinfo, path does not exist'). Set it only just before the bazel build, after the clone + cygpath (mirrors why the static block works). The DLL build now reached 732+ targets. - android-build.sh: locate clang robustly (command -v / llvm-*/bin / apt install) instead of guessing /usr/lib/llvm-18 — base ml-build image's path differed, so CLANG_COMPILER_PATH was invalid and configure.py kept prompting.
1 parent a5908e7 commit 30070f5

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

engines/litert/android-build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ cd /src
3838
# ("Invalid CLANG_COMPILER_PATH ... 10 times") if `yes ""` just feeds blanks — set it from env.
3939
export PYTHON_BIN_PATH="$(python3 -c 'import sys; print(sys.executable)')"
4040
export TF_NEED_ROCM=0 TF_NEED_CUDA=0 CC_OPT_FLAGS='-Wno-sign-compare'
41-
export TF_NEED_CLANG=1 CLANG_COMPILER_PATH="$(command -v clang || echo /usr/lib/llvm-18/bin/clang)"
4241
export TF_SET_ANDROID_WORKSPACE=1
42+
export TF_NEED_CLANG=1
43+
# Locate clang robustly (path varies across ml-build image versions); install as a last resort.
44+
clang_path="$(command -v clang || command -v clang-18 || command -v clang-17 || true)"
45+
[ -x "$clang_path" ] || clang_path="$(ls /usr/lib/llvm-*/bin/clang 2>/dev/null | sort -V | tail -1)"
46+
[ -x "$clang_path" ] || { apt-get update -qq && apt-get install -y -qq clang; clang_path="$(command -v clang)"; }
47+
[ -x "$clang_path" ] || { echo "ERROR: no clang in container"; exit 1; }
48+
export CLANG_COMPILER_PATH="$clang_path"
49+
echo "using CLANG_COMPILER_PATH=$CLANG_COMPILER_PATH"
4350
{ set +o pipefail; yes "" | python3 configure.py; } # yes SIGPIPEs (141) under pipefail
4451

4552
defines=(--define=litert_disable_gpu=true --define=litert_disable_npu=true)

engines/litert/stage.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ defines=(--define=litert_disable_gpu=true --define=litert_disable_npu=true)
123123
# Same clang-cl + dep-override setup as the static leg, but build the libLiteRt.dll cc_binary and
124124
# synthesize its import lib. Self-contained (kept out of the static path it mirrors).
125125
if [ "$PLATFORM" = "windows" ] && [ "$ARCH" = "arm64" ] && [ "$KIND" = "shared" ]; then
126-
export USE_CLANG_CL=1 MSYS2_ARG_CONV_EXCL='*' MSYS_NO_PATHCONV=1
126+
export USE_CLANG_CL=1 # NB: set MSYS2_ARG_CONV_EXCL only just before bazel — it mangles git/cygpath paths
127127
cfg+=(--cpu=arm64_windows)
128128
llvm_dir='C:/LLVM20' # native arm64 LLVM (the runner's default x64 LLVM trips bazel#17863)
129129
if [ ! -x "$llvm_dir/bin/clang-cl.exe" ]; then
@@ -140,6 +140,8 @@ if [ "$PLATFORM" = "windows" ] && [ "$ARCH" = "arm64" ] && [ "$KIND" = "shared"
140140
[ -d "$cpu/.git" ] || git clone --depth 1 https://github.com/pytorch/cpuinfo "$cpu"
141141
cpuw="$cpu"; command -v cygpath >/dev/null 2>&1 && cpuw="$(cygpath -w "$cpu")"
142142
cfg+=("--override_repository=cpuinfo=$cpuw")
143+
# Now safe to disable MSYS arg conversion (keeps //bazel:labels intact for the build below).
144+
export MSYS2_ARG_CONV_EXCL='*' MSYS_NO_PATHCONV=1
143145
# The windows DLL target (cc_binary linkshared=1 + windows_exported_symbols.def).
144146
( cd "$SRC" && bazel build "${cfg[@]}" "${defines[@]}" //litert/c:libLiteRt )
145147
dll="$(find -L "$SRC/bazel-bin" -maxdepth 6 -name 'libLiteRt.dll' 2>/dev/null | head -1)"

0 commit comments

Comments
 (0)