mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.6k forks source link

MSys64 meson cannot compile MSVC 2019 projects when changed compiler #12828

Open ggarra13 opened 7 months ago

ggarra13 commented 7 months ago

Describe the bug MSys64 meson (installed with pacman -S meson) cannot compile MSVC 2019 projects. Native meson from github works fine, but it is impossible to have it be automatically installed.

To Reproduce The problem is in the compiler check. I set the msys environment with a .bat file, like:

@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
@call C:\msys64\msys2_shell.cmd -use-full-path

Then in a MSYS shell script, for the dav1d codec project, I do:

export CC=`which cl.exe`
meson setup -Denable_tests=false --default-library=static -Dlibdir=$INSTALL_DIR/lib --prefix=$INSTALL_DIR build

Expected behavior The compilation should work. meson should be smart to detect the compiler change.

The problem, is this (the /flags are being passed as MSys64 files):

Sanity testing C compiler: '/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe'
Is cross compiler: False.
Sanity check compiler command line: '/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe' sanitycheckc.c /Fesanitycheckc.exe /MD /nologo /showIncludes /utf-8 /link
Sanity check compile stdout:
sanitycheckc.c
Microsoft (R) Incremental Linker Version 14.29.30153.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:sanitycheckc.exe 
sanitycheckc.obj 
C:/msys64/Fesanitycheckc.exe 
C:/msys64/MD 
C:/msys64/nologo 
C:/msys64/showIncludes 
C:/msys64/utf-8 
C:/msys64/link 
LINK : fatal error LNK1181: no se puede abrir el archivo de entrada 'C:\msys64\Fesanitycheckc.exe'

system parameters

Plain build on same computer.

Windows. Any version.

3.11

1.3.1

1.11.1

eli-schwartz commented 7 months ago

/cc @lazka

lazka commented 7 months ago

Use mingw python meson: https://packages.msys2.org/package/mingw-w64-ucrt-x86_64-meson and use the ucrt64 shell

Otherwise meson will pass unix paths to msvc which doesn't work.