Skip to content

Fix ARM64 cross-compilation and improve NuGet pipeline#1244

Open
gugavaro wants to merge 1 commit intodevfrom
users/gustavovaro/fix-arm64-cross-compile
Open

Fix ARM64 cross-compilation and improve NuGet pipeline#1244
gugavaro wants to merge 1 commit intodevfrom
users/gustavovaro/fix-arm64-cross-compile

Conversation

@gugavaro
Copy link
Collaborator

@gugavaro gugavaro commented Mar 13, 2026

Why

When cross-compiling mimalloc for ARM64 on an x64 host (e.g., cmake .. -A ARM64), the architecture detection logic incorrectly resolved to x64. This caused the x64 mimalloc-redirect.lib to be linked instead of the ARM64 variant, resulting in linker errors (LNK2019/LNK1120).

The NuGet pipeline also had several issues: incorrect nuspec file paths after the move to contrib/nuget, missing BasePath for nuget pack, wrong lib names in the nuspec, and no branch selection or auto-versioning.

What

  • Fixed MI_ARCH detection to correctly identify ARM64 during cross-compilation
  • Fixed nuspec paths and lib names (mimalloc.lib + mimalloc.dll.lib instead of mimalloc-static.lib)
  • Added BasePath to nuget pack command
  • Added branch parameter (default: dev) with version prefix for non-dev branches
  • Added auto-increment patch version using counter()
  • Removed buildConfig parameter (always Release)
  • Enabled publishToFeed by default

How

  • Added AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL ARM64 guard to the x64 elseif condition so that -A ARM64 on an x64 host correctly resolves MI_ARCH to arm64
  • Changed nuspec file src paths to be relative to repo root and added -BasePath to nuget pack
  • Used ADO counter() expression scoped per branch+version for auto-incrementing patch number

@gugavaro gugavaro force-pushed the users/gustavovaro/fix-arm64-cross-compile branch from da1cce3 to e6bbec0 Compare March 13, 2026 21:41
@daanx
Copy link
Collaborator

daanx commented Mar 13, 2026

Thanks Gustavo. However, we do not need list(APPEND mi_cflags "/volatile:ms") since mimalloc does not use any volatile declarations (and always uses explicit atomic memory operations). Can you remove that?

@gugavaro gugavaro force-pushed the users/gustavovaro/fix-arm64-cross-compile branch 6 times, most recently from 309d778 to bf0eb11 Compare March 14, 2026 03:52
@gugavaro
Copy link
Collaborator Author

Thanks Gustavo. However, we do not need list(APPEND mi_cflags "/volatile:ms") since mimalloc does not use any volatile declarations (and always uses explicit atomic memory operations). Can you remove that?

Done!

@gugavaro gugavaro force-pushed the users/gustavovaro/fix-arm64-cross-compile branch from bf0eb11 to cf17fc5 Compare March 14, 2026 03:52
@gugavaro gugavaro changed the title Fix ARM64 cross-compilation and add /volatile:ms for ARM64 Fix ARM64 cross-compilation and improve NuGet pipeline Mar 14, 2026
@gugavaro gugavaro force-pushed the users/gustavovaro/fix-arm64-cross-compile branch 2 times, most recently from ca639cb to 4e8bfdc Compare March 14, 2026 03:58
Fix MI_ARCH detection when cross-compiling for ARM64 on an x64 host.
CMAKE_SYSTEM_PROCESSOR (AMD64) was matching the x64 condition before
reaching ARM64, causing the wrong redirect lib to be linked.

Also fix NuGet pipeline: correct nuspec paths, add BasePath, add branch
parameter with auto-increment versioning, remove buildConfig parameter,
and enable publishToFeed by default.
@gugavaro gugavaro force-pushed the users/gustavovaro/fix-arm64-cross-compile branch from 4e8bfdc to a445bd7 Compare March 14, 2026 04:08
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.

2 participants