alibaba / alibaba/zvec

[Bug]: Windows ARM64 (MSVC): ailego CMake returns early and never creates zvec_ailego

Open
#622 1 comment 1 reaction 1 assignee Assigned to @JalinWang View on GitHub
Dominant language
C++
Stars
15.9k
Forks
998
Avg merge
4d 7h
Merged PRs (30d)
34

Description

### Description

Configuring zvec for **Windows ARM64 with MSVC** fails at CMake configure (before any compile of `zvec_c_api`).

`src/ailego/CMakeLists.txt` enters the ARM path correctly (`HOST_ARCH` matches `arm|arm64`), then does:

```cmake
elseif (HOST_ARCH MATCHES ^(arm|arm64)$)
if(MSVC)
return()
endif()
set(MATH_MARCH_FLAG_NEON -march=armv8-a)
...
endif()

cc_library(
NAME zvec_ailego STATIC STRICT PACKED
...
)
```

The `return()` exits **this** CMakeLists before `cc_library`, so target `zvec_ailego` is never created.

Meanwhile `src/CMakeLists.txt` still has `BUILD_ZVEC_AILEGO_SHARED=ON` (default) and calls `zvec_add_all_in_one_shared(zvec_ailego_shared ... LIBS zvec_ailego)`, which fatals:

```text
CMake Error at src/CMakeLists.txt:31 (message):
Target zvec_ailego is required by zvec_ailego_shared
```

So ARM64 itself works for non-MSVC compilers; **MSVC ARM64 is aborted without disabling the shared target that depends on ailego**.

### Contrast (same zvec pin, same CI matrix)

On the same desktop native workflow:

| Target | Compiler | Result |
|--------|----------|--------|
| linux-arm64 | GCC/Clang | success |
| osx-arm64 (Apple Silicon) | AppleClang | success |
| win-arm64 | MSVC | configure FATAL above |

All three hit `HOST_ARCH` arm/arm64; only MSVC hits `return()`.

Public job: https://github.com/ahmedSamir50/AdamSystems.ZVec.NET/actions/runs/30286685888/job/90046139977

### Steps to Reproduce

On Windows with the MSVC arm64 toolset (x64 host → arm64 target is enough; a native Windows ARM MSVC build should hit the same `return()`):

```bat
cmake -B build -G Ninja ^
-DCMAKE_SYSTEM_NAME=Windows ^
-DCMAKE_SYSTEM_PROCESSOR=ARM64 ^
-DBUILD_C_BINDINGS=ON ^
-DBUILD_ZVEC_AILEGO_SHARED=ON
```

Configure ends with `Target zvec_ailego is required by zvec_ailego_shared`.

Log excerpts from CI:

```text
-- BUILD_ZVEC_AILEGO_SHARED:ON
-- turbo: ARM64 detected, skipping x86-specific optimizations
CMake Error at external/zvec/src/CMakeLists.txt:31 (message):
Target zvec_ailego is required by zvec_ailego_shared
-- Configuring incomplete, errors occurred!
```

### Suggested fix

1. **Preferred:** Remove the MSVC `return()` and wire MSVC-compatible ARM64 / NEON flags (instead of GCC-style `-march=armv8-a`) so `cc_library(zvec_ailego)` still runs on MSVC ARM64.
2. Or, if MSVC ARM64 ailego is intentionally unsupported for now: emit a clear error and turn off `BUILD_ZVEC_AILEGO_SHARED` / skip `zvec_add_all_in_one_shared` when the static target was not created (do not FATAL after silently skipping the library).

A silent `return()` that leaves the shared graph enabled is what bites consumers.

### Additional Context

- zvec ~**0.5.1** (C bindings / all-in-one shared defaults).
- Hit while packaging the C API for .NET ([AdamSystems.ZVec.NET](https://github.com/ahmedSamir50/AdamSystems.ZVec.NET)); host win64 `protoc` was injected correctly — failure is earlier, in ailego CMake.
- Ruled out binding / runtime teardown (not #619-class): this is configure-only; managed code never runs. Linux and Apple Silicon ARM64 natives on the same matrix are green.
- Happy to test a PR.

### Operating System

Windows (MSVC arm64 toolset; CI: windows-2025 x64 host + amd64→arm64 cross).

### Build & Runtime Environment

- Generator: Ninja
- Compiler: MSVC 19.51.x (`Hostx64/arm64`)
- Flags: `-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64`, `BUILD_C_BINDINGS=ON`, `BUILD_ZVEC_AILEGO_SHARED=ON`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.