Skip to content

feat(litert): Windows-arm64 shared + Windows static-debug + Android-static (container)#3

Merged
vackva merged 9 commits into
mainfrom
feat/litert-win-arm64-shared
Jun 14, 2026
Merged

feat(litert): Windows-arm64 shared + Windows static-debug + Android-static (container)#3
vackva merged 9 commits into
mainfrom
feat/litert-win-arm64-shared

Conversation

@vackva

@vackva vackva commented Jun 14, 2026

Copy link
Copy Markdown
Member

Closes the archive-count gap vs the other engines (litert 15 -> up to 19):

  • Windows-arm64-shared: build libLiteRt.dll from source (no prebuilt exists) with the same
    clang-cl + LLVM 20 + cpuinfo-override + XNNPACK-off setup as the static leg; synthesize the import lib.
  • Windows-{x86_64,arm64}-static-debug: Bazel -c dbg (debug CRT /MDd) variants.
  • Android-arm64-v8a-static: attempt via LiteRT's public ml-build container (provisions the
    cuda_redist/rules_ml_toolchain externals a bare runner lacks); NDK r25b, build + archive-merge.

Android-x86_64-static + the multi-ABI static bundle follow if the arm64 container leg works.

vackva added 9 commits June 14, 2026 12:34
No upstream windows_arm64 prebuilt exists, so the shared lib must be built from
source like the static leg. Add a self-contained Windows-arm64 shared path: same
clang-cl + LLVM 20 woa64 + cpuinfo override + XNNPACK-off setup, but build the
//litert/c:libLiteRt DLL cc_binary and synthesize its import lib (LiteRt.lib)
from the exports. Adds the litert-windows-arm64-shared preset (source=build).
Closes the last achievable archive gap vs the other engines (Android-static
stays Bazel-blocked).
Match the other engines' Windows static Debug variant: Bazel -c dbg overrides
LiteRT's .bazelrc -c opt so objects link against the debug CRT (/MDd). Adds
litert-windows-{x86_64,arm64}-static-debug presets. With windows-arm64-shared,
this brings litert to 18 archives (Android-static remains Bazel-blocked).
A bare-runner Android Bazel build fails at the TF-workspace cuda_redist /
rules_ml_toolchain external-load (no static prebuilt to fall back on). Run the
build inside LiteRT's public ml-build container (which provisions those externals)
via docker run: android-build.sh installs the NDK (r25b, per LiteRT's
ci/tflite-android Dockerfile), configures the Android workspace, builds the C API
impl closure for the ABI, and merges its transitive archives into libLiteRt.a.
Adds the litert-android-arm64-v8a-static preset (arm64-v8a first to prove it).
- android-build.sh: point ANDROID_NDK_HOME directly at the extracted android-ndk-*
  dir (the prior ln -s glob failed: 'ln: target /android/ndk: No such file').
- LLVM 20 woa64 download: add curl --retry 5 --retry-all-errors (the
  windows-arm64-shared leg hit curl(23) write-error mid-download, likely Defender
  scanning the .exe; the identical static-debug install succeeded).
- android-build.sh: ANDROID_NDK_HOME via find -type d (the bare android-ndk-* glob
  also matched the .zip -> 'NDK missing at <dir> <zip>'). Got past the 530MB NDK
  download + unzip; this was the last blocker before the actual Bazel build.
- stage.sh (both win-arm64 LLVM installs): download to llvm20.pkg then rename to
  .exe. curl(23) write-error persisted through all retries on the shared leg —
  Defender real-time-scanning the streaming .exe write; a non-.exe download dodges
  the race, the rename is atomic.
…download

- android-build.sh: set TF_NEED_CLANG=1 + CLANG_COMPILER_PATH so configure.py
  doesn't error 'Invalid CLANG_COMPILER_PATH ... 10 times' in the ml-build
  container (which builds with clang). Now reaches the actual Bazel build.
- stage.sh (both win-arm64 LLVM installs): download via PowerShell Invoke-WebRequest
  instead of curl — curl(23) 'error on write' flaked persistently on a WoA runner
  regardless of extension/retries.
… 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.
The android-static docker run exited 2 with no container output — the ml-build
image's ENTRYPOINT swallows the 'bash /android-build.sh' command. Override with
--entrypoint bash and pass the script as the arg; add docker/version + script-ls
diagnostics. (windows-arm64-shared now green; only android-static remains for 19.)
… add x86_64 + bundle

The probe proved it: in the ml-build container with clang + Android NDK/SDK
installed, the Bazel build clears the cuda_redist wall and produces a 34MB arm64
libLiteRt.a (379 archives merged). Port the recipe to the real leg (run the script
directly — no entrypoint), add the android-x86_64-static ABI, and enable the
multi-ABI static bundle (android_bundle_kinds += static) -> the Android-static
archive. This closes the last gap: litert reaches 19.
@vackva vackva merged commit 27d4880 into main Jun 14, 2026
69 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant