mesonbuild / mesonbuild/meson

build.ninja not generated with correct command line when path to (eg. clang) has a space in it (eg. "Program Files")

Open
#8,780 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-info OS:windows
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

Describe the bug
The build.ninja file generated has the spaces in the path removed:

rule cpp_COMPILER
 command = "C:\Program" "Files\LLVM\bin\clang++.exe" $ARGS -MD -MQ $out -MF $DEPFILE -o $out "-c" $in
                       ^ if you change this to just a space instead of (" ") it works

This results in this error:

[1/2] Compiling C++ object ex.exe.p/main.cpp.obj
FAILED: ex.exe.p/main.cpp.obj
"C:\Program" "Files\LLVM\bin\clang++.exe" "-Iex.exe.p" "-I." "-I.." "-fcolor-diagnostics" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-Wnon-virtual-dtor" 
"-g" -MD -MQ ex.exe.p/main.cpp.obj -MF "ex.exe.p\main.cpp.obj.d" -o ex.exe.p/main.cpp.obj "-c" ../main.cpp
CreateProcess failed: The system cannot find the file specified.
ninja: build stopped: subcommand failed.

The spaces are formatted incorrectly in the compile_commands.json as well.

To Reproduce
meson.build:

project('example', 'cpp', version: '1')
executable('ex', 'main.cpp')

main.cpp:

#include <iostream>
int main() { std::cout << "Hello world!" << std::endl; }

Expected behavior
It should compile.

system parameters

  • Not a cross build
  • Windows 10
  • Python 3.9.4
  • Meson 0.58.0
  • Ninja 1.10.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the shown meson.build and main.cpp on Windows with a compiler path containing spaces. Inspect the generated build.ninja command and compile_commands.json quoting, then verify that both generated commands invoke clang++ successfully and the example compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.