mesonbuild / meson

The Meson Build System

Home Page:http://mesonbuild.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Meson not generating correct configuration for ninja

dtromb opened this issue · comments

Describe the bug
I'm attempting to compile an unmodified version of the head of https:/. I installed a fresh Visual Studio 2022, with C++ develpment package (first uninstalling all other VS versions to be sure), and running 'vcvarsall.bat x64' in a PS window, which executed sucessfully.

Then, meson setup <path to thorvg> source runs successfully and produces:

The Meson build system
Version: 1.4.1
Source dir: <path redacted>
Build dir: <path redacted>
Build type: native build
Project name: thorvg
Project version: 0.13.99
Activating VS 17.10.1
C++ compiler for the host machine: cl (msvc 19.40.33811 "Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64")
C++ linker for the host machine: link link 14.40.33811.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Configuring config.h using configuration
Did not find pkg-config by name 'pkg-config'
Found pkg-config: NO

In particular, notice it finds the compiler successfully.

When I run 'ninja' on the resulting build instructions, however, it fails on the very first file:

[1/242] Compiling C++ object src/thorvg-0.dll.p/renderer_tvgAccessor.cpp.obj
FAILED: src/thorvg-0.dll.p/renderer_tvgAccessor.cpp.obj
"cl" "-Isrc\thorvg-0.dll.p" "-Isrc" "-I....\thorvg\src" "-Iinc" "-I....\thorvg\inc" "-I." "-I....\thorvg" "-Isrc\loaders\lottie" "-I....\thorvg\src\loaders\lottie" "-Isrc\renderer" "-I....\thorvg
src\renderer" "-Isrc\renderer\sw_engine" "-I....\thorvg\src\renderer\sw_engine" "-Isrc\common" "-I....\thorvg\src\common" "-Isrc\loaders" "-I....\thorvg\src\loaders" "-Isrc\loaders\tvg" "-I....\tho
rvg\src\loaders\tvg" "-Isrc\loaders\svg" "-I....\thorvg\src\loaders\svg" "-Isrc\loaders\ttf" "-I....\thorvg\src\loaders\ttf" "-Isrc\loaders\lottie\jerryscript\jerry-core\api" "-I....\thorvg\src\load
ers\lottie\jerryscript\jerry-core\api" "-Isrc\loaders\lottie\jerryscript\jerry-core\include" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\include" "-Isrc\loaders\lottie\jerryscript\jerry-c
ore\ecma\base" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\ecma\base" "-Isrc\loaders\lottie\jerryscript\jerry-core\ecma\builtin-objects\typedarray" "-I....\thorvg\src\loaders\lottie\jerr
yscript\jerry-core\ecma\builtin-objects\typedarray" "-Isrc\loaders\lottie\jerryscript\jerry-core\ecma\builtin-objects" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\ecma\builtin-objects" "-
Isrc\loaders\lottie\jerryscript\jerry-core\ecma\operations" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\ecma\operations" "-Isrc\loaders\lottie\jerryscript\jerry-core\jcontext" "-I....\th
orvg\src\loaders\lottie\jerryscript\jerry-core\jcontext" "-Isrc\loaders\lottie\jerryscript\jerry-core\jmem" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\jmem" "-Isrc\loaders\lottie\jerrysc
ript\jerry-core\jrt" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\jrt" "-Isrc\loaders\lottie\jerryscript\jerry-core\lit" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\lit" "-Is
rc\loaders\lottie\jerryscript\jerry-core\parser\js" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\parser\js" "-Isrc\loaders\lottie\jerryscript\jerry-core\parser\regexp" "-I....\thorvg\src
loaders\lottie\jerryscript\jerry-core\parser\regexp" "-Isrc\loaders\lottie\jerryscript\jerry-core\vm" "-I....\thorvg\src\loaders\lottie\jerryscript\jerry-core\vm" "-Isrc\loaders\raw" "-I....\thorvg\s
rc\loaders\raw" "-Isrc\savers" "-I....\thorvg\src\savers" "/MD" "/nologo" "/showIncludes" "/utf-8" "/Zc:__cplusplus" "/W2" "/EHsc" "/std:c++14" "/permissive-" "/O1" "/Gw" "/Zi" "-DEXAMPLE_DIR="" "-DTEST_DIR=""" "-DTVG_EXPORT" "-DTVG_BUILD" "/Fdsrc\thorvg-0.dll.p\renderer_tvgAccessor.cpp.pdb" /Fosrc/thorvg-0.dll.p/renderer_tvgAccessor.cpp.obj "/c" ../../thorvg/src/renderer/tvgAccessor.cpp
CreateProcess failed: The system cannot find the file specified.

It seems to me this must be a bug in meson - the compiler is located but not indicated correctly to ninja. Is that correct, or am I doing something wrong?

To Reproduce

Just follow the report above as instructions - fresh install of VC2022, clone the repo indicated, set up a PS dev prompt with the command I showed, then run the build with the two commands I indicated.

Expected behavior
ninja should find the compiler at the path meson found it after being configured by msoon.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    No, native build

  • 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
    Python is 3.12.4

  • what meson --version
    meson is 1.4.1

  • what ninja --version if it's a Ninja build
    ninja is 1.11.1

Let me add that I'm fairly confident that the dev environment is installed correctly - this project is one of two dependencies, and the other (cmake-based) compiles just fine with the same shell. (I've tried running the two builds in both possible orders...)

I installed a fresh Visual Studio 2022, with C++ develpment package (first uninstalling all other VS versions to be sure), and running 'vcvarsall.bat x64' in a PS window, which executed sucessfully.

And yet, ninja is saying it was unable to find the file cl to start it as a process -- which indicates somehow ninja was run in an environment that did not have an activated vcvars.

Meson also printed this log:

Activating VS 17.10.1
C++ compiler for the host machine: cl (msvc 19.40.33811 "Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64")
C++ linker for the host machine: link link 14.40.33811.0

The "activating" message is supposed to mean that meson didn't find an existing MSVC dev command shell environment, so it ran vswhere.exe, used it to find a suitable vcvars64.bat, ran it and parsed its output to figure out what environment variables it sets, then loaded those vars into meson.

Which is a lengthy and complicated way of saying, it basically did the equivalent of running vcvars for you, but only inside the meson subprocess itself.

As for why ninja doesn't load the VS environment as well: this is a missing ninja feature tracked at ninja-build/ninja#1610

Meson is supposed to warn you at the end:

Visual Studio environment is needed to run Ninja. It is recommended to use Meson wrapper:
meson compile -C source/

The meson wrapper doesn't really do anything that ninja can't do already, EXCEPT that since meson code runs before ninja is launched, we have the opportunity to work around the missing ninja feature, and do the VS environment loading for you.

I actually ran vcvars64.bat, just as I indicated. I didn't include the output of that portion but just said it "run successfully", here is what was output:

PS <path redated> & 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat' x64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.10.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

This was run just before meson was invoked.

Are you able to run cl from that shell? If so then I don't have a good guess as to why ninja is unable to.

@eli-schwartz - meson compile actually works, TYVM. I was not aware of this usage! Looks like the problem lies with ninja, and meson can tell it what to do properly!