Merge pull request #5225 from dcbaker/threads-is-not-special

Threads is not special
pull/5235/head
Jussi Pakkanen 6 years ago committed by GitHub
commit 54db2c9bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mesonbuild/backend/backends.py
  2. 5
      mesonbuild/backend/ninjabackend.py
  3. 1
      mesonbuild/build.py
  4. 4
      mesonbuild/compilers/c.py
  5. 4
      mesonbuild/dependencies/base.py
  6. 6
      mesonbuild/dependencies/boost.py
  7. 18
      mesonbuild/dependencies/dev.py
  8. 5
      mesonbuild/dependencies/misc.py

@ -643,8 +643,6 @@ class Backend:
commands += dep.get_exe_args(compiler) commands += dep.get_exe_args(compiler)
# For 'automagic' deps: Boost and GTest. Also dependency('threads'). # For 'automagic' deps: Boost and GTest. Also dependency('threads').
# pkg-config puts the thread flags itself via `Cflags:` # pkg-config puts the thread flags itself via `Cflags:`
if dep.need_threads():
commands += compiler.thread_flags(self.environment)
# Fortran requires extra include directives. # Fortran requires extra include directives.
if compiler.language == 'fortran': if compiler.language == 'fortran':
for lt in target.link_targets: for lt in target.link_targets:

@ -2511,7 +2511,6 @@ rule FORTRAN_DEP_HACK%s
if not isinstance(target, build.StaticLibrary): if not isinstance(target, build.StaticLibrary):
# For 'automagic' deps: Boost and GTest. Also dependency('threads'). # For 'automagic' deps: Boost and GTest. Also dependency('threads').
# pkg-config puts the thread flags itself via `Cflags:` # pkg-config puts the thread flags itself via `Cflags:`
need_threads = False
commands += target.link_args commands += target.link_args
# External deps must be last because target link libraries may depend on them. # External deps must be last because target link libraries may depend on them.
@ -2519,14 +2518,10 @@ rule FORTRAN_DEP_HACK%s
# Extend without reordering or de-dup to preserve `-L -l` sets # Extend without reordering or de-dup to preserve `-L -l` sets
# https://github.com/mesonbuild/meson/issues/1718 # https://github.com/mesonbuild/meson/issues/1718
commands.extend_preserving_lflags(dep.get_link_args()) commands.extend_preserving_lflags(dep.get_link_args())
need_threads |= dep.need_threads()
for d in target.get_dependencies(): for d in target.get_dependencies():
if isinstance(d, build.StaticLibrary): if isinstance(d, build.StaticLibrary):
for dep in d.get_external_deps(): for dep in d.get_external_deps():
need_threads |= dep.need_threads()
commands.extend_preserving_lflags(dep.get_link_args()) commands.extend_preserving_lflags(dep.get_link_args())
if need_threads:
commands += linker.thread_link_flags(self.environment)
# Add link args specific to this BuildTarget type that must not be overridden by dependencies # Add link args specific to this BuildTarget type that must not be overridden by dependencies
commands += self.get_target_type_link_args_post_dependencies(target, linker) commands += self.get_target_type_link_args_post_dependencies(target, linker)

@ -1035,6 +1035,7 @@ This will become a hard error in a future Meson release.''')
if dep not in self.external_deps: if dep not in self.external_deps:
self.external_deps.append(dep) self.external_deps.append(dep)
self.process_sourcelist(dep.get_sources()) self.process_sourcelist(dep.get_sources())
self.add_deps(dep.ext_deps)
elif isinstance(dep, BuildTarget): elif isinstance(dep, BuildTarget):
raise InvalidArguments('''Tried to use a build target as a dependency. raise InvalidArguments('''Tried to use a build target as a dependency.
You probably should put it in link_with instead.''') You probably should put it in link_with instead.''')

@ -433,13 +433,9 @@ class CCompiler(Compiler):
for d in dependencies: for d in dependencies:
# Add compile flags needed by dependencies # Add compile flags needed by dependencies
args += d.get_compile_args() args += d.get_compile_args()
if d.need_threads():
args += self.thread_flags(env)
if mode == 'link': if mode == 'link':
# Add link flags needed to find dependencies # Add link flags needed to find dependencies
args += d.get_link_args() args += d.get_link_args()
if d.need_threads():
args += self.thread_link_flags(env)
args += self._get_basic_compiler_args(env, mode) args += self._get_basic_compiler_args(env, mode)

@ -115,6 +115,7 @@ class Dependency:
self.raw_link_args = None self.raw_link_args = None
self.sources = [] self.sources = []
self.methods = self._process_method_kw(kwargs) self.methods = self._process_method_kw(kwargs)
self.ext_deps = [] # type: List[Dependency]
def __repr__(self): def __repr__(self):
s = '<{0} {1}: {2}>' s = '<{0} {1}: {2}>'
@ -152,9 +153,6 @@ class Dependency:
def get_exe_args(self, compiler): def get_exe_args(self, compiler):
return [] return []
def need_threads(self):
return False
def get_pkgconfig_variable(self, variable_name, kwargs): def get_pkgconfig_variable(self, variable_name, kwargs):
raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name)) raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name))

@ -22,6 +22,7 @@ from .. import mesonlib
from ..environment import detect_cpu_family from ..environment import detect_cpu_family
from .base import (DependencyException, ExternalDependency) from .base import (DependencyException, ExternalDependency)
from .misc import ThreadDependency
# On windows 3 directory layouts are supported: # On windows 3 directory layouts are supported:
# * The default layout (versioned) installed: # * The default layout (versioned) installed:
@ -103,6 +104,8 @@ class BoostDependency(ExternalDependency):
self.is_multithreading = threading == "multi" self.is_multithreading = threading == "multi"
self.requested_modules = self.get_requested(kwargs) self.requested_modules = self.get_requested(kwargs)
if 'thread' in self.requested_modules:
self.ext_deps.append(ThreadDependency(environment, kwargs))
self.boost_root = None self.boost_root = None
self.boost_roots = [] self.boost_roots = []
@ -488,9 +491,6 @@ class BoostDependency(ExternalDependency):
def get_sources(self): def get_sources(self):
return [] return []
def need_threads(self):
return 'thread' in self.requested_modules
# Generated with boost_names.py # Generated with boost_names.py
BOOST_LIBS = [ BOOST_LIBS = [

@ -26,6 +26,7 @@ from .base import (
DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency, DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
strip_system_libdirs, ConfigToolDependency, strip_system_libdirs, ConfigToolDependency,
) )
from .misc import ThreadDependency
def get_shared_library_suffix(environment, native): def get_shared_library_suffix(environment, native):
@ -45,6 +46,7 @@ class GTestDependency(ExternalDependency):
self.main = kwargs.get('main', False) self.main = kwargs.get('main', False)
self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src'] self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src']
self.detect() self.detect()
self.ext_deps.append(ThreadDependency(environment, kwargs))
def detect(self): def detect(self):
gtest_detect = self.clib_compiler.find_library("gtest", self.env, []) gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
@ -83,9 +85,6 @@ class GTestDependency(ExternalDependency):
return True return True
return False return False
def need_threads(self):
return True
def log_info(self): def log_info(self):
if self.prebuilt: if self.prebuilt:
return 'prebuilt' return 'prebuilt'
@ -118,6 +117,7 @@ class GMockDependency(ExternalDependency):
def __init__(self, environment, kwargs): def __init__(self, environment, kwargs):
super().__init__('gmock', environment, 'cpp', kwargs) super().__init__('gmock', environment, 'cpp', kwargs)
self.main = kwargs.get('main', False) self.main = kwargs.get('main', False)
self.ext_deps.append(ThreadDependency(environment, kwargs))
# If we are getting main() from GMock, we definitely # If we are getting main() from GMock, we definitely
# want to avoid linking in main() from GTest # want to avoid linking in main() from GTest
@ -132,10 +132,7 @@ class GMockDependency(ExternalDependency):
if not gtest_dep.is_found: if not gtest_dep.is_found:
self.is_found = False self.is_found = False
return return
self.ext_deps.append(gtest_dep)
self.compile_args = gtest_dep.compile_args
self.link_args = gtest_dep.link_args
self.sources = gtest_dep.sources
# GMock may be a library or just source. # GMock may be a library or just source.
# Work with both. # Work with both.
@ -167,9 +164,6 @@ class GMockDependency(ExternalDependency):
self.is_found = False self.is_found = False
def need_threads(self):
return True
def log_info(self): def log_info(self):
if self.prebuilt: if self.prebuilt:
return 'prebuilt' return 'prebuilt'
@ -262,6 +256,7 @@ class LLVMDependency(ConfigToolDependency):
self._set_old_link_args() self._set_old_link_args()
self.link_args = strip_system_libdirs(environment, self.link_args) self.link_args = strip_system_libdirs(environment, self.link_args)
self.link_args = self.__fix_bogus_link_args(self.link_args) self.link_args = self.__fix_bogus_link_args(self.link_args)
self.ext_deps.append(ThreadDependency(environment, kwargs))
@staticmethod @staticmethod
def __fix_bogus_link_args(args): def __fix_bogus_link_args(args):
@ -399,9 +394,6 @@ class LLVMDependency(ConfigToolDependency):
self.module_details.append(mod + status) self.module_details.append(mod + status)
def need_threads(self):
return True
def log_details(self): def log_details(self):
if self.module_details: if self.module_details:
return 'modules: ' + ', '.join(self.module_details) return 'modules: ' + ', '.join(self.module_details)

@ -388,9 +388,8 @@ class ThreadDependency(ExternalDependency):
super().__init__('threads', environment, None, kwargs) super().__init__('threads', environment, None, kwargs)
self.name = 'threads' self.name = 'threads'
self.is_found = True self.is_found = True
self.compile_args = self.clib_compiler.thread_flags(environment)
def need_threads(self): self.link_args = self.clib_compiler.thread_link_flags(environment)
return True
class Python3Dependency(ExternalDependency): class Python3Dependency(ExternalDependency):

Loading…
Cancel
Save