From 6cf7d2492b634d08cf55ff22ca5106f4d8352838 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 28 Sep 2018 13:27:43 -0700 Subject: [PATCH] compilers/c: don't return -pthread for MacOS with any compiler With GCC, Clang, or ICC, and for C++ Fixes #2628 --- mesonbuild/compilers/c.py | 14 ++------------ run_unittests.py | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 2da627fc2..72b9f240b 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -986,12 +986,12 @@ class CCompiler(Compiler): return self.find_library_impl(libname, env, extra_dirs, code, libtype) def thread_flags(self, env): - if for_haiku(self.is_cross, env): + if for_haiku(self.is_cross, env) or for_darwin(self.is_cross, env): return [] return ['-pthread'] def thread_link_flags(self, env): - if for_haiku(self.is_cross, env): + if for_haiku(self.is_cross, env) or for_darwin(self.is_cross, env): return [] return ['-pthread'] @@ -1076,16 +1076,6 @@ class ClangCCompiler(ClangCompiler, CCompiler): 'none')}) return opts - def thread_flags(self, env): - if for_darwin(self.is_cross, env): - return [] - return super().thread_flags() - - def thread_link_flags(self, env): - if for_darwin(self.is_cross, env): - return [] - return super().thread_link_flags() - def get_option_compile_args(self, options): args = [] std = options['c_std'] diff --git a/run_unittests.py b/run_unittests.py index 8fe1c1165..8bea2d093 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -37,7 +37,7 @@ import mesonbuild.coredata import mesonbuild.modules.gnome from mesonbuild.interpreter import Interpreter, ObjectHolder from mesonbuild.mesonlib import ( - is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, + is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd, is_haiku, windows_proof_rmtree, python_command, version_compare, BuildDirLock, Version ) @@ -3270,17 +3270,17 @@ class LinuxlikeTests(BasePlatformTests): self.assertEqual(sorted(out), sorted(['libfoo >= 1.0'])) out = self._run(cmd + ['--cflags-only-other']).strip().split() - self.assertEqual(sorted(out), sorted(['-pthread', '-DCUSTOM'])) + self.check_pkg_flags_are_same(out, ['-pthread', '-DCUSTOM']) out = self._run(cmd + ['--libs-only-l', '--libs-only-other']).strip().split() - self.assertEqual(sorted(out), sorted(['-pthread', '-lcustom', - '-llibmain', '-llibexposed'])) + self.check_pkg_flags_are_same(out, ['-pthread', '-lcustom', + '-llibmain', '-llibexposed']) out = self._run(cmd + ['--libs-only-l', '--libs-only-other', '--static']).strip().split() - self.assertEqual(sorted(out), sorted(['-pthread', '-lcustom', - '-llibmain', '-llibexposed', - '-llibinternal', '-lcustom2', - '-lfoo'])) + self.check_pkg_flags_are_same(out, ['-pthread', '-lcustom', + '-llibmain', '-llibexposed', + '-llibinternal', '-lcustom2', + '-lfoo']) cmd = ['pkg-config', 'requires-test'] out = self._run(cmd + ['--print-requires']).strip().split('\n') @@ -3290,6 +3290,11 @@ class LinuxlikeTests(BasePlatformTests): out = self._run(cmd + ['--print-requires-private']).strip().split('\n') self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo >= 1.0', 'libhello'])) + def check_pkg_flags_are_same(self, output, expected): + if is_osx() or is_haiku(): + expected = [x for x in expected if x != '-pthread'] + self.assertEqual(sorted(output), sorted(expected)) + def test_pkg_unfound(self): testdir = os.path.join(self.unit_test_dir, '23 unfound pkgconfig') self.init(testdir)