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

Issue:
scanbuild.py doesn't handle scan-build-{7,8}
Here: https://github.com/mesonbuild/meson/blob/1e7aea65e68a43b0319a4a28908daddfec621548/mesonbuild/scripts/scanbuild.py#L39

As with other LLVM/Clang tools (e.g. `llvm-config`), the version number suffix is just the major component since LLVM 7. The LLVM dependency support handles this correctly here: https://github.com/mesonbuild/meson/blob/54db2c9babe6391bba525f92573ceeadb8303e78/mesonbuild/dependencies/dev.py#L208


Discussion:

Resolving patch:
diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py
--- a/mesonbuild/scripts/scanbuild.py
+++ b/mesonbuild/scripts/scanbuild.py
@@ -38,14 +38,17 @@ def run(args):
     shutil.rmtree(logdir, ignore_errors=True)
     tools = [
         'scan-build',  # base
-        'scan-build-5.0', 'scan-build50',  # latest stable release
-        'scan-build-4.0', 'scan-build40',  # old stable releases
+        'scan-build-8.0', 'scan-build80',
+        'scan-build-7.0', 'scan-build70',
+        'scan-build-6.0', 'scan-build60',
+        'scan-build-5.0', 'scan-build50',
+        'scan-build-4.0', 'scan-build40',
         'scan-build-3.9', 'scan-build39',
         'scan-build-3.8', 'scan-build38',
         'scan-build-3.7', 'scan-build37',
         'scan-build-3.6', 'scan-build36',
         'scan-build-3.5', 'scan-build35',
-        'scan-build-6.0', 'scan-build-devel',  # development snapshot
+        'scan-build-9.0', 'scan-build-devel',  # development snapshot
     ]
     toolname = 'scan-build'
     for tool in tools:


Test patch:
Repository: mesonbuild/meson

Issue:
dependency('appleframeworks') should work on Linux (but fail)
Currently, I have to put this in a `'darwin'` check, because it fails to run on Linux. I think it's reasonable for it to be outside a darwin check, so long as `required:false`.

```
cocoa_dep = dependency('appleframeworks', modules: 'Cocoa', required: false)
```


Discussion:
More generally, the set of valid dependency methods varies depending on the host machine.
(See also https://github.com/mesonbuild/meson/pull/4453#issuecomment-434661768)

Resolving patch:
diff --git a/mesonbuild/dependencies/platform.py b/mesonbuild/dependencies/platform.py
--- a/mesonbuild/dependencies/platform.py
+++ b/mesonbuild/dependencies/platform.py
@@ -16,7 +16,7 @@
 # platform-specific (generally speaking).
 
 from .base import ExternalDependency, DependencyException
-
+from ..mesonlib import MesonException
 
 class AppleFrameworks(ExternalDependency):
     def __init__(self, env, kwargs):
@@ -31,7 +31,16 @@ def __init__(self, env, kwargs):
             raise DependencyException('No C-like compilers are available, cannot find the framework')
         self.is_found = True
         for f in self.frameworks:
-            args = self.clib_compiler.find_framework(f, env, [])
+            try:
+                args = self.clib_compiler.find_framework(f, env, [])
+            except MesonException as e:
+                if 'non-clang' in str(e):
+                    self.is_found = False
+                    self.link_args = []
+                    self.compile_args = []
+                    return
+                raise
+
             if args is not None:
                 # No compile args are needed for system frameworks
                 self.link_args += args
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2996,6 +2996,7 @@ def dependency_impl(self, name, display_name, kwargs):
             self._handle_featurenew_dependencies(name)
             kwargs['required'] = required and not has_fallback
             dep = dependencies.find_external_dependency(name, self.environment, kwargs)
+
             kwargs['required'] = required
             # Only store found-deps in the cache
             # Never add fallback deps to self.coredata.deps since we


Test patch:
diff --git a/test cases/objc/2 nsstring/meson.build b/test cases/objc/2 nsstring/meson.build
--- a/test cases/objc/2 nsstring/meson.build	
+++ b/test cases/objc/2 nsstring/meson.build	
@@ -15,3 +15,6 @@ else
 endif
 exe = executable('stringprog', 'stringprog.m', dependencies : dep)
 test('stringtest', exe)
+
+# Ensure that a non-required dep that is not found does not cause an error
+dependency('appleframeworks', modules: 'nonexisting', required: false)
Repository: mesonbuild/meson

Issue:
Broken meson after 60969d9
`meson` is totally broken after https://github.com/mesonbuild/meson/commit/60969d99d33001317c569a9b37d3b9efae08d387: every meson call triggers the following error
https://paste.ofcode.org/yFytL9HLtXJQEKz8WYfVKN

meson.sh:
```bash
#!/bin/bash
/usr/bin/python3 /home/theqwertiest/meson_trunk/meson.py "$@"  
```

Python version:
```
> python3 --version
> Python 3.5.2
```


Discussion:
Ping @dcbaker (related https://github.com/mesonbuild/meson/pull/5265)
I'll look at it, it probably means we need to make some type annotation a string.

Resolving patch:
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -134,7 +134,7 @@ def get_root(self) -> typing.Optional[typing.Union[str, typing.List[str]]]:
     def get_sys_root(self) -> typing.Optional[typing.Union[str, typing.List[str]]]:
         return self.properties.get('sys_root', None)
 
-    def __eq__(self, other: typing.Any) -> typing.Union[bool, 'NotImplemented']:
+    def __eq__(self, other: typing.Any) -> 'typing.Union[bool, NotImplemented]':
         if isinstance(other, type(self)):
             return self.properties == other.properties
         return NotImplemented
@@ -159,7 +159,7 @@ def __init__(self, system: str, cpu_family: str, cpu: str, endian: str):
         self.endian = endian
         self.is_64_bit = cpu_family in CPU_FAMILES_64_BIT  # type: bool
 
-    def __eq__(self, other: typing.Any) -> typing.Union[bool, 'NotImplemented']:
+    def __eq__(self, other: typing.Any) -> 'typing.Union[bool, NotImplemented]':
         if self.__class__ is not other.__class__:
             return NotImplemented
         return \
@@ -168,7 +168,7 @@ def __eq__(self, other: typing.Any) -> typing.Union[bool, 'NotImplemented']:
             self.cpu == other.cpu and \
             self.endian == other.endian
 
-    def __ne__(self, other: typing.Any) -> typing.Union[bool, 'NotImplemented']:
+    def __ne__(self, other: typing.Any) -> 'typing.Union[bool, NotImplemented]':
         if self.__class__ is not other.__class__:
             return NotImplemented
         return not self.__eq__(other)
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -922,7 +922,8 @@ def extract_as_list(dict_object, *keys, pop=False, **kwargs):
         result.append(listify(fetch(key, []), **kwargs))
     return result
 
-def typeslistify(item: typing.Union[_T, typing.List[_T]], types: typing.Union[typing.Type[_T], typing.Tuple[typing.Type[_T]]]) -> typing.List[_T]:
+def typeslistify(item: 'typing.Union[_T, typing.List[_T]]',
+                 types: 'typing.Union[typing.Type[_T], typing.Tuple[typing.Type[_T]]]') -> typing.List[_T]:
     '''
     Ensure that type(@item) is one of @types or a
     list of items all of which are of type @types


Test patch:
Repository: mesonbuild/meson

Issue:
llvm broken on windows with static linking
I bisected to dd2c44cdf6f8ed8a969d0666cafb08aaf78a919d, so this is a regression between 0.50 and 0.51, and should be resolved before 0.51 is realeased. I'm actively working on this, but wanted to have a tracker bug.


Discussion:

Resolving patch:
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -260,19 +260,25 @@ def __init__(self, environment, kwargs):
         self.link_args = self.__fix_bogus_link_args(self.link_args)
         self._add_sub_dependency(ThreadDependency, environment, kwargs)
 
-    @staticmethod
-    def __fix_bogus_link_args(args):
+    def __fix_bogus_link_args(self, args):
         """This function attempts to fix bogus link arguments that llvm-config
         generates.
 
         Currently it works around the following:
             - FreeBSD: when statically linking -l/usr/lib/libexecinfo.so will
               be generated, strip the -l in cases like this.
+            - Windows: We may get -LIBPATH:... which is later interpreted as
+              "-L IBPATH:...", if we're using an msvc like compilers convert
+              that to "/LIBPATH", otherwise to "-L ..."
         """
+        cpp = self.env.coredata.compilers['cpp']
+
         new_args = []
         for arg in args:
             if arg.startswith('-l') and arg.endswith('.so'):
                 new_args.append(arg.lstrip('-l'))
+            elif arg.startswith('-LIBPATH:'):
+                new_args.extend(cpp.get_linker_search_args(arg.lstrip('-LIBPATH:')))
             else:
                 new_args.append(arg)
         return new_args


Test patch:
Repository: mesonbuild/meson

Issue:
xcode 11's clang not recognized
Xcode 11 beta 1 (e.g. on Mac OS 10.15) has changed its spots.

The meson.build
```
project('simple', 'objc')
```
fails with
```
meson.build:1:0: ERROR: Unknown compiler(s): ['cc']
```
in both oldish and latest meson.  Fix easy, coming shortly.


Discussion:

Resolving patch:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -952,7 +952,7 @@ def detect_objc_compiler(self, for_machine):
                 compiler_type = self.get_gnu_compiler_type(defines)
                 version = self.get_gnu_version_from_defines(defines)
                 return GnuObjCCompiler(ccache + compiler, version, compiler_type, for_machine, is_cross, exe_wrap, defines)
-            if out.startswith('Apple LLVM'):
+            if out.startswith('Apple LLVM') or out.startswith('Apple clang'):
                 return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, for_machine, is_cross, exe_wrap)
             if 'windows' in out:
                 return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_MINGW, for_machine, is_cross, exe_wrap)
@@ -982,7 +982,7 @@ def detect_objcpp_compiler(self, for_machine):
                 compiler_type = self.get_gnu_compiler_type(defines)
                 version = self.get_gnu_version_from_defines(defines)
                 return GnuObjCPPCompiler(ccache + compiler, version, compiler_type, for_machine, is_cross, exe_wrap, defines)
-            if out.startswith('Apple LLVM'):
+            if out.startswith('Apple LLVM') or out.startswith('Apple clang'):
                 return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, for_machine, is_cross, exe_wrap)
             if 'windows' in out:
                 return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_MINGW, for_machine, is_cross, exe_wrap)


Test patch:
Repository: mesonbuild/meson

Issue:
"Unknown linker(s)" failure because `ar --version` produces unexpected output
Distro: OpenIndiana Hipster 2018.10 (powered by illumos)
Compiler: gcc (OpenIndiana 6.4.0-OI-3) 6.4.0
Note that this is a Solaris fork.

When running `meson` to configure the build it fails with this output:

```
meson.build:1:0: ERROR: Unknown linker(s): [['gcc-ar'], ['ar']]
```

The problem is that `ar --version` produces the following output which meson doesn't recognize:

```
ar: bad option: --
usage: ar -d[-SvV] archive file ...
       ar -m[-abiSvV] [posname] archive file ...
       ar -p[-vV][-sS] archive [file ...]
       ar -q[-cuvSV] [-abi] [posname] [file ...]
       ar -r[-cuvSV] [-abi] [posname] [file ...]
       ar -t[-vV][-sS] archive [file ...]
       ar -x[-vV][-sSCT] archive [file ...]
```

This diff fixes the problem:

```
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index bf2cce93..da6bdb51 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -1217,6 +1217,8 @@ class Environment:
                 return ArLinker(linker)
             if p.returncode == 1 and err.startswith('Usage'): # AIX
                 return ArLinker(linker)
+            if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
+                return ArLinker(linker)
         self._handle_exceptions(popen_exceptions, linkers, 'linker')
         raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linkers))
```


Discussion:
Ugh! Using gcc 6.4.0 causes other build failures of the Korn shell [project]() even with that fix. So it is not obvious the aforementioned fix is justified.

Resolving patch:
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1978,6 +1978,8 @@ def get_allow_undefined_link_args(self):
         elif self.compiler_type.is_windows_compiler:
             # For PE/COFF this is impossible
             return []
+        elif mesonlib.is_sunos():
+            return []
         else:
             # GNU ld and LLVM lld
             return ['-Wl,--allow-shlib-undefined']
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -1245,6 +1245,8 @@ def detect_static_linker(self, compiler):
                 return ArLinker(linker)
             if p.returncode == 1 and err.startswith('Usage'): # AIX
                 return ArLinker(linker)
+            if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
+                return ArLinker(linker)
         self._handle_exceptions(popen_exceptions, linkers, 'linker')
         raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linkers))
 


Test patch:
Repository: mesonbuild/meson

Issue:
detect_c_or_cpp_compiler cl compiler check return wrong result on non-english windows
detect_c_or_cpp_compiler cl compiler check return wrong result on non-english windows

https://github.com/mesonbuild/meson/blob/fa431dddbc45fa539373c932dec650e1e26a9a5c/mesonbuild/environment.py#L779

hardcode ' for (.*)$', in non-english windows,its depend system lcid(1033,2052).
For example, in zh-CHS chinese env,it is "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.16.27030.1 版".

So we can't compile x86_64,because it force return "x86" if can't find ' for (.*)$' string.


Discussion:
workaround
replace ' for (.*)$' with '(:x86|x64|ARM|ARM64)'
Your workaround is probably a better solution than what we have now anyway.

Resolving patch:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -776,7 +776,7 @@ def sanitize(p):
                 else:
                     m = 'Failed to detect MSVC compiler version: stderr was\n{!r}'
                     raise EnvironmentException(m.format(err))
-                match = re.search(' for (.*)$', lookat.split('\n')[0])
+                match = re.search('.*(x86|x64|ARM|ARM64).*', lookat.split('\n')[0])
                 if match:
                     target = match.group(1)
                 else:


Test patch:
Repository: mesonbuild/meson

Issue:
apple clang does not have visibility "protected"
This results in the attribute check function returning false on apple clang, but symbol visibility otherwise working.

so something like:
```meson
args = []
if cc.has_function_attribute('visibility')
  args += '-DEXPORT=__attribute__((visibility("default")))
endif

library(
  'foo.c',
  c_args : args,
  gnu_symbol_visibility : 'hidden',
)
```

will fail with missing symbols because args is `[]`


Discussion:
See [this bug in bzip2](https://gitlab.com/federicomenaquintero/bzip2/issues/18)

Resolving patch:
diff --git a/mesonbuild/compilers/c_function_attributes.py b/mesonbuild/compilers/c_function_attributes.py
--- a/mesonbuild/compilers/c_function_attributes.py
+++ b/mesonbuild/compilers/c_function_attributes.py
@@ -93,8 +93,15 @@
     'visibility': '''
         int foo_def(void) __attribute__((visibility("default")));
         int foo_hid(void) __attribute__((visibility("hidden")));
-        int foo_int(void) __attribute__((visibility("internal")));
-        int foo_pro(void) __attribute__((visibility("protected")));''',
+        int foo_int(void) __attribute__((visibility("internal")));''',
+    'visibility:default':
+        'int foo(void) __attribute__((visibility("default")));',
+    'visibility:hidden':
+        'int foo(void) __attribute__((visibility("hidden")));',
+    'visibility:internal':
+        'int foo(void) __attribute__((visibility("internal")));',
+    'visibility:protected':
+        'int foo(void) __attribute__((visibility("protected")));',
     'warning':
         'int foo(void) __attribute__((warning("")));',
     'warn_unused_result':


Test patch:
Repository: mesonbuild/meson

Issue:
cross compiler needs_exe_wrapper is ignored
I tried to compile mesa with meson 0.51 with an x86_64 -> x86 cross compile, and it fails because one of our generators is host compiled, which will run just fine but meson asserts and dies instead. Looks pretty trivial, I'll fix it.

Related to #5509


Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -70,7 +70,7 @@ def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install
 
 class ExecutableSerialisation:
     def __init__(self, name, fname, cmd_args, env, is_cross, exe_wrapper,
-                 workdir, extra_paths, capture):
+                 workdir, extra_paths, capture, needs_exe_wrapper: bool):
         self.name = name
         self.fname = fname
         self.cmd_args = cmd_args
@@ -79,6 +79,7 @@ def __init__(self, name, fname, cmd_args, env, is_cross, exe_wrapper,
         if exe_wrapper is not None:
             assert(isinstance(exe_wrapper, dependencies.ExternalProgram))
         self.exe_runner = exe_wrapper
+        self.needs_exe_wrapper = needs_exe_wrapper
         self.workdir = workdir
         self.extra_paths = extra_paths
         self.capture = capture
@@ -372,7 +373,8 @@ def serialize_executable(self, tname, exe, cmd_args, workdir, env=None,
                 exe_wrapper = None
             es = ExecutableSerialisation(basename, exe_cmd, cmd_args, env,
                                          is_cross_built, exe_wrapper, workdir,
-                                         extra_paths, capture)
+                                         extra_paths, capture,
+                                         self.environment.need_exe_wrapper())
             pickle.dump(es, f)
         return exe_data
 
diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py
--- a/mesonbuild/scripts/meson_exe.py
+++ b/mesonbuild/scripts/meson_exe.py
@@ -47,12 +47,12 @@ def run_exe(exe):
     elif not exe.is_cross and run_with_mono(exe.fname[0]):
         cmd = ['mono'] + exe.fname
     else:
-        if exe.is_cross:
+        if exe.is_cross and exe.needs_exe_wrapper:
             if exe.exe_runner is None:
-                raise AssertionError('BUG: Can\'t run cross-compiled exe {!r}'
+                raise AssertionError('BUG: Can\'t run cross-compiled exe {!r} '
                                      'with no wrapper'.format(exe.name))
             elif not exe.exe_runner.found():
-                raise AssertionError('BUG: Can\'t run cross-compiled exe {!r} with not-found'
+                raise AssertionError('BUG: Can\'t run cross-compiled exe {!r} with not-found '
                                      'wrapper {!r}'.format(exe.name, exe.exe_runner.get_path()))
             else:
                 cmd = exe.exe_runner.get_command() + exe.fname


Test patch:
Repository: mesonbuild/meson

Issue:
Meson 0.51.0 Xcode backend is not working.
The backend for Xcode doesn’t work for some reason.

I’m using Meson version 0.51.0.
![A331EFB7-3CAC-4949-8B24-E7C3FA00FEFF](https://user-images.githubusercontent.com/42789598/60283549-3e6c3d80-98be-11e9-8d84-91364a16e373.jpeg)


Discussion:
I've figured out what's going on. Patch incoming.

Resolving patch:
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -738,7 +738,7 @@ def generate_xc_build_configuration(self):
                 ldstr = ' '.join(ldargs)
                 valid = self.buildconfmap[target_name][buildtype]
                 langargs = {}
-                for lang in self.environment.coredata.compilers:
+                for lang in self.environment.coredata.compilers[target.for_machine]:
                     if lang not in langnamemap:
                         continue
                     # Add compile args added using add_project_arguments()


Test patch:
Repository: mesonbuild/meson

Issue:
ccache cannot work on dist builds
Due to how the dist build is implemented in Meson, it will always result in ccache being unable to work.

The reason for this is the forced use of `mkdtemp` for directories within the `check_dist` function (in `dist.py`). The source is unpacked into `$tmpdir/tmp$string` which is random and thus unable to produce cache hits for subsequent builds. If I am trying to do e.g., a CI dist build, this is not ideal since it makes the build very long.

There are two possible solutions I've come up with which could solve the issue:
* Add a `DISTBUILDDIR` (or similar) environment variable which is used instead of `mkdtemp` during a dist build; this directory would take the place of the `mkdtemp` directories and would not be deleted when the build stopped
* Add a `TMPBUILDSTRING` (or similar) environment variable which is used in place of the random part of the tempdir string (resulting in e.g., /tmp/tmp$string); this directory can still be created and deleted normally, or even deleted if it already exists since we can assume this should only be used for meson dist builds

Other solutions would be great too, as long as ccache becomes usable.


Discussion:
A simpler solution would be to always do the test in a specific directory under `meson-private`.
Er do you maybe mean do the dist in a specific directory in `meson-private`? This would also work as long as it was a consistent path.

I had thought that using `mkdtemp` was intentional/fundamental for this build.

Resolving patch:
diff --git a/mesonbuild/scripts/dist.py b/mesonbuild/scripts/dist.py
--- a/mesonbuild/scripts/dist.py
+++ b/mesonbuild/scripts/dist.py
@@ -144,11 +144,15 @@ def create_dist_hg(dist_name, src_root, bld_root, dist_sub, dist_scripts):
     return (xzname, )
 
 
-def check_dist(packagename, meson_command):
+def check_dist(packagename, meson_command, privdir):
     print('Testing distribution package %s' % packagename)
-    unpackdir = tempfile.mkdtemp()
-    builddir = tempfile.mkdtemp()
-    installdir = tempfile.mkdtemp()
+    unpackdir = os.path.join(privdir, 'dist-unpack')
+    builddir = os.path.join(privdir, 'dist-build')
+    installdir = os.path.join(privdir, 'dist-install')
+    for p in (unpackdir, builddir, installdir):
+        if os.path.exists(p):
+            shutil.rmtree(p)
+        os.mkdir(p)
     ninja_bin = detect_ninja()
     try:
         tf = tarfile.open(packagename)
@@ -200,7 +204,7 @@ def run(args):
         return 1
     error_count = 0
     for name in names:
-        rc = check_dist(name, meson_command) # Check only one.
+        rc = check_dist(name, meson_command, priv_dir) # Check only one.
         if rc == 0:
             create_hash(name)
         error_count += rc


Test patch: