MSVC/Ninja: b_pgo=generate inserts /link before source files
Author: ngoldbaumCreated Sep 18, 2026Updated Sep 18, 2026
Describe the bug
With MSVC and the Ninja backend, enabling b_pgo=generate together with b_lto=true allows configuration to succeed, but compilation fails with:
cl : Command line error D8003 : missing source filenameTo Reproduce
Create repro/meson.build:
project('msvc-pgo-repro', 'c')
executable('msvc-pgo-repro', 'main.c')Create repro/main.c:
int main(void) { return 0; }Run on Windows with MSVC installed:
meson setup builddir repro --vsenv --backend=ninja --buildtype=release -Db_lto=true -Db_pgo=generate
meson compile -C builddir -vConfiguration succeeds. The first compilation command has this argument order, abbreviated:
cl ... /GL /link /GENPROFILE ... /Fo... /c ../repro/main.c
cl : Command line error D8003 : missing source filename
ninja: build stopped: subcommand failed.Expected behavior The project should compile and link an instrumented executable.
system parameters
- Build type: Native x86-64 build.
- Operating system: Windows 11 Home, version 10.0.26200.
- CPU: Intel Core i5-8600K.
- Python: 3.14.6, 64-bit.
- Meson: 1.12.0 and master
626d1e26325195f9cfdb288d7e413157b4f8bcb4(1.12.99). - Ninja:
1.13.2.git.kitware.jobserver-pipe-1. - Visual Studio: Community 18.10.0.
- Compiler: MSVC
cl19.51.36257 for x64. - Linker:
link14.51.36257.0.
Source: mesonbuild/meson