Meson mangles MSVC flags beginning with L if specified with a dash
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 1.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 33
Description
**Describe the bug**
The `/LINKREPRO:xxx` flag [is needed](https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/language-compilers/troubleshoot-visual-c-compile-linker) to compile a linker test case for Microsoft.
However, specifying it with a dash (`-Dcpp_link_args=-LINKREPRO:msvc` or `cpp_link_args: '-LINKREPRO:MSVC'`) results in Meson thinking it's a library link flag, so it gets mangled into `LINK_ARGS = "/LIBPATH:INKREPRO:MSVC"`.
**To Reproduce**
meson.build:
```
project('doxygen test', 'cpp', version : '0.1.0')
spede_inc = include_directories('include')
spede_src = [ 'src/spede.cpp' ]
spede_lib = library('spede', spede_src, include_directories: spede_inc, link_args: ['-LINKREPRO:MSVC'])
```
srcs/spede.cpp
```
#include
/**
* \file spede.cpp
*
* This file contains the implementation of the king of comedy.
*/
/**
* \mainpage The Vast Comedian Project
*
* \section intro Introduction
*
* The purpose of this project is to model every single comedian
* who has ever lived.
*
* \section sched Project schedule
*
* There is no real estimate on when this will be finished.
*/
/**
* \namespace Comedy
*
* This contains everything that is funny.
*/
namespace Comedy {
/**
* Do all the delicate movements that lead to a comical sound
* emanating from a person.
*
* \param force how hard to move the hand.
* \return something or another
*/
int gesticulate(int force) {
// FIXME add implementation.
return 0;
}
Spede::Spede() : num_movies(100) {
}
void Spede::slap_forehead() {
gesticulate(42);
}
}
```
**Expected behavior**
Compilation should succeed once the MSVC folder is created in the `build` folder.
**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)? **No**
* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) **Windows 10 21H2**
* what Python version are you using e.g. 3.8.0 **3.10.7**
* what `meson --version` **1.0.1**
* what `ninja --version` if it's a Ninja build **1.10.2**
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided meson.build and reproduce the Windows 10 failure using link_args: ['-LINKREPRO:MSVC']; inspect Meson’s handling of MSVC linker arguments and how the leading dash is classified. Done means the example builds successfully and creates the MSVC folder without rewriting the flag as a /LIBPATH entry.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100