I know little about Rust and less about Windows, thus I am not sure whether this is just surprising behavior or a bug.
To setup the Rust compiler, Meson detects the available linker and then passes it to rustc via the -C liker= command line flag. On Windows systems where GCC is installed, this picks up cc as the linker and Meson tries to use rustc -C linker=cc as the Rust compiler. However, rustc on Windows assumes MSVS style command line arguments, thus linking fails when cc receives MSVC style command line arguments. In principle, this could be fixed passing the -C lin ker-flavor= command line option to rustc. However, rustc (at least the version I tried) only works with MSVS style compilers on Windows (see #16021 for an attempt at doing exactly this).
All this is fixed passing the --vsenv options to meson setup to setup the Visual Studio build environment.
The question are: What is the default linker for rustc on Windows? Should Meson try to use that despite the fact that other linkers are found? If MSVC link.exe is the default liker on Windows, does rustc require to be run in a Visual Studio environment? Should the fact that a linker incompatible with rustc has been detected result in a better error message than ERROR: Compiler rustc -C linker=cc cannot compile programs.?
This has been tested on GitHub Actions windows-latest runners.
I know little about Rust and less about Windows, thus I am not sure whether this is just surprising behavior or a bug.
To setup the Rust compiler, Meson detects the available linker and then passes it to
rustcvia the-C liker=command line flag. On Windows systems where GCC is installed, this picks upccas the linker and Meson tries to userustc -C linker=ccas the Rust compiler. However,rustcon Windows assumes MSVS style command line arguments, thus linking fails whenccreceives MSVC style command line arguments. In principle, this could be fixed passing the-C lin ker-flavor=command line option torustc. However,rustc(at least the version I tried) only works with MSVS style compilers on Windows (see #16021 for an attempt at doing exactly this).All this is fixed passing the
--vsenvoptions tomeson setupto setup the Visual Studio build environment.The question are: What is the default linker for
rustcon Windows? Should Meson try to use that despite the fact that other linkers are found? If MSVClink.exeis the default liker on Windows, doesrustcrequire to be run in a Visual Studio environment? Should the fact that a linker incompatible withrustchas been detected result in a better error message thanERROR: Compiler rustc -C linker=cc cannot compile programs.?This has been tested on GitHub Actions
windows-latestrunners.