VS backend has serious cross-compiling issues
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 1.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 33
Description
**Describe the bug**
When setting up cross-compiling, you're supposed to use `host_machine` to indicate what will be running the resulting binaries, and `target_machine` if you're building a compiler which might target a different machine. The VS2010 backend uses `target_machine` to populate the `.vcxproj` file's architecture, not `host_machine`.
What's worse is that the compiler binary that was pointed to during the VS solution generation step is completely ignored. So, if you just specify `cl.exe` as the compiler, then as long as there's *any* `cl.exe` in your path, that's what the generation step will use for running all of its tests. Then, after the project is created and you load it in VS, the `target_machine` you used ends up selecting which actual compiler will be used.
**To Reproduce**
Attempt to cross-compile with `--backend=vs2019` and a `--cross-file` pointing to something that looks like:
```
[host_machine]
system = 'windows'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'
[binaries]
c = 'cl'
cpp = 'cl'
c_ld = 'link'
cpp_ld = 'link'
cmake = 'cmake'
pkgconfig = 'pkg-config'
```
**Expected behavior**
Some form of error, because the `cl.exe` that gets invoked identifies itself as:
```
C++ compiler for the host machine: cl (msvc 19.28.29913 "Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29913 for x64")
```
Which is wrong when the `host_machine` in the cross file is supposed to be arm64/aarch64.
**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)?: Yes
* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Windows 10
* what Python version are you using e.g. 3.8.0: 3.8.2
* what `meson --version`: 0.57.999
* what `ninja --version` if it's a Ninja build: N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with --backend=vs2019 and the shown --cross-file, then trace the VS backend's architecture selection and compiler discovery. Done means the backend respects host_machine for the generated project and does not silently ignore the configured compiler when validating the cross build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100