mesonbuild / mesonbuild/meson

How to cross compile for ARM with MSVC?

Open
#4,402 16 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cross machine files
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

Normally when compiling with MSVC, you select the cross compilation target ("host" in the cross file) by running a script that sets up the environment (`PATH`, `LIB`) according to the desired host environment; the `cl.exe` in path is then the one for the chosen architecture, and `LIB` points to the directories containing libraries for this architecture.

If trying to run meson in such an environment, the default native compiler is also detected as `cl` from the path, a dialog box saying "The image file c:\...\sanitycheckc.exe is valid, but is for a machine type other than the current machine" appears, and meson fails with the following error message:

```
meson.build:25:0: ERROR: Could not invoke sanity test executable: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
```

How is one supposed to set up cross compilation with Meson with the MSVC compiler, when you can only have one compiler in `PATH` and one `LIB` set of directories in the environment at a time?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cross-file setup and the sanity-check invocation reported at meson.build:25. Review how Meson handles the MSVC environment and target executable, then document a supported ARM cross-compilation workflow or clarify the limitation; the issue is done when the setup and expected behavior are clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.