internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mesonbuild/meson

Issue:
pkgconfig: `dataonly` files should be installed in `datadir`/pkgconfig
**Describe the bug**
Since `dataonly` pkg-config files are architecture-independent they [should](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s11.html) get installed in `datadir`/pkgconfig, and not `libdir`/pkgconfig

**To Reproduce**

```meson
project('dataonly.pc')

import('pkgconfig').generate(
	name: 'dataonly',
	dataonly: true,
	description: 'Should be in $prefix/share/pkgconfig'
)
```

```sh
$ tree install_prefix
install_prefix
└── lib
   └── x86_64-linux-gnu
      └── pkgconfig
         └── dataonly.pc
```

**Expected behavior**
The .pc file should get installed in $prefix/share/pkgconfig

**system parameters**
* Build type: native
* OS: Debian Testing
* Python version: 3.9.10
* Meson version: 0.61.1
* Ninja version: 1.10.1



Discussion:
It probably should, but no one thought to mention that when #5775 was reviewed.
Maybe nobody noticed, but I don't think that installing the .pc file to the library dir would ever be correct

Resolving patch:
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -524,6 +524,7 @@ def generate(self, state: 'ModuleState', args, kwargs):
             blocked_vars = ['libraries', 'libraries_private', 'require_private', 'extra_cflags', 'subdirs']
             if any(k in kwargs for k in blocked_vars):
                 raise mesonlib.MesonException(f'Cannot combine dataonly with any of {blocked_vars}')
+            default_install_dir = os.path.join(state.environment.get_datadir(), 'pkgconfig')
 
         subdirs = mesonlib.stringlistify(kwargs.get('subdirs', default_subdirs))
         version = kwargs.get('version', default_version)


Test patch:
diff --git a/test cases/common/44 pkgconfig-gen/test.json b/test cases/common/44 pkgconfig-gen/test.json
--- a/test cases/common/44 pkgconfig-gen/test.json	
+++ b/test cases/common/44 pkgconfig-gen/test.json	
@@ -6,7 +6,6 @@
     {"type": "file", "file": "usr/lib/pkgconfig/libanswer.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/libfoo.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/libhello.pc"},
-    {"type": "file", "file": "usr/lib/pkgconfig/libhello_nolib.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/libvartest.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/libvartest2.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/simple2.pc"},
@@ -14,7 +13,8 @@
     {"type": "file", "file": "usr/lib/pkgconfig/simple5.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/simple6.pc"},
     {"type": "file", "file": "usr/lib/pkgconfig/ct.pc"},
-    {"type": "file", "file": "usr/lib/pkgconfig/ct0.pc"}
+    {"type": "file", "file": "usr/lib/pkgconfig/ct0.pc"},
+    {"type": "file", "file": "usr/share/pkgconfig/libhello_nolib.pc"}
   ],
   "stdout": [
     {
Repository: mesonbuild/meson

Issue:
find_program('python3', version: '>=3.5') fails on Windows
With meson 0.62 (tested with 0.61 as well), on Windows "VsDevCmd" shell environment

```
find_program('python3', version: '>=3.5')
```

Fails with
```
..\meson.build:3:0: ERROR: Command "C:\Program Files\Meson\meson.exe runpython --version" failed with status 2.
```

```
Running command: C:\Program Files\Meson\meson.exe runpython --version
--- stdout ---

--- stderr ---
usage: meson runpython [-h] [-c] script_file ...
meson runpython: error: the following arguments are required: script_file, script_args
```

NOTE: without `version: '>=3.5'`, works as expected.


Discussion:
See also https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2541 glib regression

Resolving patch:
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -18,6 +18,7 @@
 sys.modules['pathlib'] = _pathlib
 
 import os.path
+import platform
 import importlib
 import traceback
 import argparse
@@ -93,15 +94,18 @@ def add_command(self, name, add_arguments_func, run_func, help_msg, aliases=None
         for i in [name] + aliases:
             self.commands[i] = p
 
-    def add_runpython_arguments(self, parser):
+    def add_runpython_arguments(self, parser: argparse.ArgumentParser):
         parser.add_argument('-c', action='store_true', dest='eval_arg', default=False)
-        parser.add_argument('script_file')
+        parser.add_argument('--version', action='store_true')
+        parser.add_argument('script_file', nargs='?')
         parser.add_argument('script_args', nargs=argparse.REMAINDER)
 
     def run_runpython_command(self, options):
         import runpy
         if options.eval_arg:
             exec(options.script_file)
+        elif options.version:
+            print(platform.python_version())
         else:
             sys.argv[1:] = options.script_args
             sys.path.insert(0, os.path.dirname(options.script_file))


Test patch:
Repository: mesonbuild/meson

Issue:
-Dbuildtype=release fails on CompCert
**Describe the bug**
Building with CompCert on release mode fails. 
The error message is as follows:
```
ccomp: error: Unknown option `-03'
```
Note that this unknown option is "dash zero three" and not "dash O three". Maybe someone accidentally typed a zero where they wanted a letter "O"?

**To Reproduce**
The bug seems to trigger with any program.
Download this Meson "Hello, world!" program: [meson-compcert.zip](https://github.com/mesonbuild/meson/files/8468156/meson-compcert.zip).
Try to build it with:
```console
$ CC=ccomp meson setup -Dbuildtype=release build && meson compile -C build
```

**Expected behavior**
A successful build.

**system parameters**
I'm running Meson 0.62 from PyPi and my CompCert is the binary package of version 3.9 from the OpenBSD ports system.
My ninja is version 1.10.2 and my python is version 3.8.12.


Discussion:

Resolving patch:
diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py
--- a/mesonbuild/compilers/mixins/compcert.py
+++ b/mesonbuild/compilers/mixins/compcert.py
@@ -32,7 +32,7 @@
     'plain': [''],
     'debug': ['-O0', '-g'],
     'debugoptimized': ['-O0', '-g'],
-    'release': ['-03'],
+    'release': ['-O3'],
     'minsize': ['-Os'],
     'custom': ['-Obranchless'],
 }  # type: T.Dict[str, T.List[str]]


Test patch:
Repository: mesonbuild/meson

Issue:
compiler.has_argument doesn't work with clang-cl for warning flags
**Describe the bug**

The option `-Wimplicit-fallthrough=3` is unknown to clang-cl 12.0.1, and yet the `has_argument('-Wimplicit-fallthrough=3')` check passes, as can be seen [here](https://ci.appveyor.com/project/rizinorg/rizin/builds/43245228/job/x5rjqvh9bwub2a0k?fullLog=true#L62):

![fallthrough-check-passes](https://user-images.githubusercontent.com/12002672/163571080-31dcc693-817d-4dbc-a294-fb514e4ef81f.PNG)

and [here](https://ci.appveyor.com/project/rizinorg/rizin/builds/43245228/job/x5rjqvh9bwub2a0k?fullLog=true#L34051):

![fallthrough-warning](https://user-images.githubusercontent.com/12002672/163571452-65bb676a-f323-4ebf-96c9-1f6385c8a60e.PNG)

The relevant `meson-log.txt` lines appear to be:
```
Compiler stdout:
 
Compiler stderr:
 warning: unknown warning option '-Wimplicit-fallthrough=3'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
1 warning generated.

Compiler for C supports arguments -Wimplicit-fallthrough=3: YES 
```

so the issue appears to be the same as for #755 except that the compiler involved is now clang-cl.

**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)?

native build

* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)

Windows Server 2019

* what Python version are you using e.g. 3.8.0

Python 3.8

* what `meson --version`

0.62.0

* what `ninja --version` if it's a Ninja build

1.10.2



Discussion:
Seems like Meson needs to be passing `-Werror=unknown-warning-option` when it calls self.compiles() with your arguments.

Something similar is already being done: https://github.com/mesonbuild/meson/blob/ab5ed4db09331d8d182bcdda4a44fa88b9265acb/mesonbuild/compilers/mixins/visualstudio.py#L448

Conceivably, you could just submit a PR to add a string to this array.

Resolving patch:
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -445,7 +445,7 @@ def __init__(self, target: str):
 
     def has_arguments(self, args: T.List[str], env: 'Environment', code: str, mode: str) -> T.Tuple[bool, bool]:
         if mode != 'link':
-            args = args + ['-Werror=unknown-argument']
+            args = args + ['-Werror=unknown-argument', '-Werror=unknown-warning-option']
         return super().has_arguments(args, env, code, mode)
 
     def get_toolset_version(self) -> T.Optional[str]:


Test patch:
Repository: mesonbuild/meson

Issue:
Exclude `test` as project name for `meson init`.
**Describe the bug**
Please see "To Reproduce"

**To Reproduce**
Just execute the following steps:
```
$ mkdir test; cd test
$ meson init
Using "test" (name of current directory) as project name.
Using "test" (project name) as name of executable to build.
Defaulting to generating a C language project.
Sample project created. To build it run the
following commands:

meson setup builddir
meson compile -C builddir

$ meson setup builddir
The Meson build system
Version: 0.62.1
Source dir: /home/gerion/test
Build dir: /home/gerion/test/builddir
Build type: native build
Project name: test
Project version: 0.1
C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (Debian 10.2.1-6) 10.2.1 20210110")
C linker for the host machine: cc ld.bfd 2.35.2
Host machine cpu family: x86_64
Host machine cpu: x86_64

meson.build:5:0: ERROR: Target name 'test' is reserved for Meson's internal use. Please rename.

A full log can be found at /home/gerion/test/builddir/meson-logs/meson-log.txt
```

**Expected behavior**
`meson init` should rename the project if the folder is `test`.

**system parameters**
* what operating system: Debian 11
* what Python version are you using: 3.9.0
* what `meson --version`: 0.62.1



Discussion:
Maybe its better to just fail in `meson init` and say that "test" is for internal use.

Resolving patch:
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py
--- a/mesonbuild/minit.py
+++ b/mesonbuild/minit.py
@@ -23,6 +23,7 @@
 import re
 from glob import glob
 from mesonbuild import mesonlib
+from mesonbuild.coredata import FORBIDDEN_TARGET_NAMES
 from mesonbuild.environment import detect_ninja
 from mesonbuild.templates.samplefactory import sameple_generator
 import typing as T
@@ -81,6 +82,9 @@ def autodetect_options(options: 'argparse.Namespace', sample: bool = False) -> N
     if not options.executable:
         options.executable = options.name
         print(f'Using "{options.executable}" (project name) as name of executable to build.')
+    if options.executable in FORBIDDEN_TARGET_NAMES:
+        raise mesonlib.MesonException(f'Executable name {options.executable!r} is reserved for Meson internal use. '
+                                      'Refusing to init an invalid project.')
     if sample:
         # The rest of the autodetection is not applicable to generating sample projects.
         return


Test patch:
Repository: mesonbuild/meson

Issue:
Separator arg warning with meson version >= 0.62.0
**Describe the bug**
For a long time, I have used the `separator` kwarg when setting an environment variable in meson. Now, [v0.62.0](https://mesonbuild.com/Release-notes-for-0-62-0.html#new-method-and-separator-kwargs-on-environment-and-mesonadd_devenv) says this is a new feature...

A meson.build file that I've been using since before meson version 0.58.0 includes the line:
```
env.append('BAR', '0', separator: ':')
```

This has worked fine before, but after upgrading my meson version to 0.62.1, I now get this warning after running `meson build`:
```
meson.build:4: WARNING: Project targeting '>=0.58.0' but tried to use feature introduced in '0.62.0': separator arg in environment.append.
```

**To Reproduce**
1. With meson >= 0.62.0 installed, take the following meson.build:
```
project('foo', 'c', meson_version: '>=0.58.0')

env = environment()
env.append('BAR', '0', separator: ':')
```

2. Run `meson build`
3. See the warning

This warning doesn't occur with meson < 0.62.0

**Expected behavior**
I would not expect to receive a warning for a "new" feature that works with older meson versions.



Discussion:
This is incorrect and a regression from #10023

Resolving patch:
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -336,4 +336,4 @@ def _output_validator(outputs: T.List[str]) -> T.Optional[str]:
 ENV_METHOD_KW = KwargInfo('method', str, default='set', since='0.62.0',
     validator=in_set_validator({'set', 'prepend', 'append'}))
 
-ENV_SEPARATOR_KW = KwargInfo('separator', str, default=os.pathsep, since='0.62.0')
+ENV_SEPARATOR_KW = KwargInfo('separator', str, default=os.pathsep)


Test patch:
Repository: mesonbuild/meson

Issue:
Incorrect lld.ld argument check for --allow-shlib-undefined
The LLVM lld.ld linker in linkers.py checks if `--allow-shlib-undefined` is an argument, but the check has been incorrect since LLVM version 9 released. The unknown option is now quoted (`'`) in later versions.

Opening this in order to track it so it is not forgotten. Originally discussed between myself and @eli-schwartz on IRC.


Discussion:

Resolving patch:
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -846,7 +846,8 @@ def __init__(self, exelist: T.List[str],
 
         # Some targets don't seem to support this argument (windows, wasm, ...)
         _, _, e = mesonlib.Popen_safe(self.exelist + self._apply_prefix('--allow-shlib-undefined'))
-        self.has_allow_shlib_undefined = 'unknown argument: --allow-shlib-undefined' not in e
+        # Versions < 9 do not have a quoted argument
+        self.has_allow_shlib_undefined = ('unknown argument: --allow-shlib-undefined' not in e) and ("unknown argument: '--allow-shlib-undefined'" not in e)
 
     def get_allow_undefined_args(self) -> T.List[str]:
         if self.has_allow_shlib_undefined:


Test patch:
Repository: mesonbuild/meson

Issue:
ArchLinux meson cannot detect Qt Tools with pkg-config.
**Describe the bug**
ArchLinux meson cannot detect Qt Tools with pkg-config.

**To Reproduce**
Run ./run_project_tests.py --only frameworks/4 on ArchLinux

**Expected behavior**
Qt 6 Tools should be detectable.

**system parameters**
*Native
*ArchLinux
* Python 3.10.5
* master
* ninja 1.11.0


Discussion:

Resolving patch:
diff --git a/mesonbuild/dependencies/qt.py b/mesonbuild/dependencies/qt.py
--- a/mesonbuild/dependencies/qt.py
+++ b/mesonbuild/dependencies/qt.py
@@ -223,11 +223,18 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
             if prefix:
                 self.bindir = os.path.join(prefix, 'bin')
 
+        self.libexecdir = self.get_pkgconfig_host_libexecs(self)
+
     @staticmethod
     @abc.abstractmethod
     def get_pkgconfig_host_bins(core: PkgConfigDependency) -> T.Optional[str]:
         pass
 
+    @staticmethod
+    @abc.abstractmethod
+    def get_pkgconfig_host_libexecs(core: PkgConfigDependency) -> T.Optional[str]:
+        pass
+
     @abc.abstractmethod
     def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]:
         pass
@@ -405,6 +412,10 @@ def get_pkgconfig_host_bins(core: PkgConfigDependency) -> T.Optional[str]:
     def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]:
         return []
 
+    @staticmethod
+    def get_pkgconfig_host_libexecs(core: PkgConfigDependency) -> str:
+        return None
+
 
 class Qt5PkgConfigDependency(QtPkgConfigDependency):
 
@@ -412,15 +423,31 @@ class Qt5PkgConfigDependency(QtPkgConfigDependency):
     def get_pkgconfig_host_bins(core: PkgConfigDependency) -> str:
         return core.get_pkgconfig_variable('host_bins', [], None)
 
+    @staticmethod
+    def get_pkgconfig_host_libexecs(core: PkgConfigDependency) -> str:
+        return None
+
     def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]:
         return _qt_get_private_includes(mod_inc_dir, module, self.version)
 
 
 class Qt6PkgConfigDependency(QtPkgConfigDependency):
 
+    def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
+        super().__init__(name, env, kwargs)
+        if not self.libexecdir:
+            mlog.debug(f'detected Qt6 {self.version} pkg-config dependency does not '
+                       'have proper tools support, ignoring')
+            self.is_found = False
+
     @staticmethod
     def get_pkgconfig_host_bins(core: PkgConfigDependency) -> str:
-        return core.get_pkgconfig_variable('host_bins', [], None)
+        return core.get_pkgconfig_variable('bindir', [], None)
+
+    @staticmethod
+    def get_pkgconfig_host_libexecs(core: PkgConfigDependency) -> str:
+        # Qt6 pkg-config for Qt defines libexecdir from 6.3+
+        return core.get_pkgconfig_variable('libexecdir', [], None)
 
     def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]:
         return _qt_get_private_includes(mod_inc_dir, module, self.version)


Test patch:
Repository: mesonbuild/meson

Issue:
 Meson told me report an "Unhandled python exception".
While defining a cross build file for `Windows`, I wrote a section for `cmake`,
```ini
[cmake]
CMAKE_C_COMPILER_WORKS = 1
```
and I forgot to wrap "1" in single quotes and it threw this unhandled exception.
```bash
❯ meson setup --cross-file=cross-windows-x86_64.ini build-win
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 146, in run
    return options.run_func(options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 294, in run
    app.generate()
  File "/usr/lib/python3.10/site-packages/mesonbuild/msetup.py", line 180, in generate
    env = environment.Environment(self.source_dir, self.build_dir, self.options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/environment.py", line 536, in __init__
    cmakevars.host = CMakeVariables(config.get('cmake', {}))
  File "/usr/lib/python3.10/site-packages/mesonbuild/envconfig.py", line 442, in __init__
    assert isinstance(i, str)
AssertionError

ERROR: Unhandled python exception

    This is a Meson bug and should be reported!
```


Discussion:
@mensinda 

Resolving patch:
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -439,7 +439,8 @@ def __init__(self, variables: T.Optional[T.Dict[str, T.Any]] = None) -> None:
         for key, value in variables.items():
             value = mesonlib.listify(value)
             for i in value:
-                assert isinstance(i, str)
+                if not isinstance(i, str):
+                    raise EnvironmentException(f"Value '{i}' of CMake variable '{key}' defined in a machine file is a {type(i).__name__} and not a str")
             self.variables[key] = value
 
     def get_variables(self) -> T.Dict[str, T.List[str]]:


Test patch:
Repository: mesonbuild/meson

Issue:
MSVC __cplusplus fix used Visual Studio version rather than Visual C++ Compiler version
**Describe the bug**
A change was made to meson to specify /Zc:__cplusplus which makes MSVC correctly define __cplusplus to a meaningful value (see https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160), but the meson check whether to include it or not seems to be comparing against a Visual Studio version number rather than a Visual C++ compiler version number. See commit https://github.com/mesonbuild/meson/commit/04c728a126cc484cda21d21d672630d298cae9b8

```
        if version_compare(self.version, '>= 15.7') and '/Zc:__cplusplus' not in args:
            return args + ['/Zc:__cplusplus']
        return args
```
The comparison should be something like the following, according to the version on this website https://walbourn.github.io/vs-2017-15-7-update
```
        if version_compare(self.version, '>= 19.14.26428') and '/Zc:__cplusplus' not in args:
            return args + ['/Zc:__cplusplus']
        return args
```
Visual Studio 2012 version is emitting the following complaint with each compilation unit:
cl : Command line warning D9002 : ignoring unknown option '/Zc:__cplusplus'

**To Reproduce**
Any C++ project targeting Visual Studio 2012 exhibits the above behaviour.

**Expected behavior**
No warnings when building with versions of Visual Studio/C++ which don't support this.

**system parameters**
* Native
* Windows 10
* Python 3.10.1
* `meson --version`: 0.63.0
* `ninja --version`: 1.10.2.git.kitware.jobserver-1



Discussion:
Could you submit a PR? cc @dcbaker @eli-schwartz @xclaesse since y'all had a hand in the original commit.
> the meson check whether to include it or not seems to be comparing against a Visual Studio version number rather than a Visual C++ compiler version number

Thank you, your analysis makes sense. My apologies. :(



Resolving patch:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -740,7 +740,7 @@ def get_always_args(self) -> T.List[str]:
         # By default, MSVC has a broken __cplusplus define that pretends to be c++98:
         # https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
         # Pass the flag to enable a truthful define, if possible.
-        if version_compare(self.version, '>= 15.7') and '/Zc:__cplusplus' not in args:
+        if version_compare(self.version, '>= 19.14.26428') and '/Zc:__cplusplus' not in args:
             return args + ['/Zc:__cplusplus']
         return args
 


Test patch: