diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-04-05 16:41:08 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-04-05 16:41:08 -0700 |
commit | 6ad7fbf9509dd68792df7df08b785967a067d4c4 (patch) | |
tree | d4ed3b440daefa52c8fe9301c92505a53e96f49f /mesonbuild | |
parent | b842b0b04aa8678f98cbec5f7022e75636ddf4a3 (diff) | |
download | meson-6ad7fbf9509dd68792df7df08b785967a067d4c4.zip meson-6ad7fbf9509dd68792df7df08b785967a067d4c4.tar.gz meson-6ad7fbf9509dd68792df7df08b785967a067d4c4.tar.bz2 |
dependencies/misc: don't special case threads
Instad of having special casing of threads in the backends and
everywehre else, do what we did for openmp, create a real
dependency. Then make use of the fact that dependencies can now have
sub dependencies to add threads.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/backends.py | 2 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/base.py | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/boost.py | 6 | ||||
-rw-r--r-- | mesonbuild/dependencies/dev.py | 13 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 5 |
7 files changed, 9 insertions, 29 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index d752ac4..124d40f 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -643,8 +643,6 @@ class Backend: commands += dep.get_exe_args(compiler) # For 'automagic' deps: Boost and GTest. Also dependency('threads'). # pkg-config puts the thread flags itself via `Cflags:` - if dep.need_threads(): - commands += compiler.thread_flags(self.environment) # Fortran requires extra include directives. if compiler.language == 'fortran': for lt in target.link_targets: diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 64ea5a6..a3b9ce8 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2511,7 +2511,6 @@ rule FORTRAN_DEP_HACK%s if not isinstance(target, build.StaticLibrary): # For 'automagic' deps: Boost and GTest. Also dependency('threads'). # pkg-config puts the thread flags itself via `Cflags:` - need_threads = False commands += target.link_args # 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 # https://github.com/mesonbuild/meson/issues/1718 commands.extend_preserving_lflags(dep.get_link_args()) - need_threads |= dep.need_threads() for d in target.get_dependencies(): if isinstance(d, build.StaticLibrary): for dep in d.get_external_deps(): - need_threads |= dep.need_threads() 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 commands += self.get_target_type_link_args_post_dependencies(target, linker) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index bcf8243..0a6e3b3 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -433,13 +433,9 @@ class CCompiler(Compiler): for d in dependencies: # Add compile flags needed by dependencies args += d.get_compile_args() - if d.need_threads(): - args += self.thread_flags(env) if mode == 'link': # Add link flags needed to find dependencies args += d.get_link_args() - if d.need_threads(): - args += self.thread_link_flags(env) args += self._get_basic_compiler_args(env, mode) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 032fe60..aae2572 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -153,9 +153,6 @@ class Dependency: def get_exe_args(self, compiler): return [] - def need_threads(self): - return False - def get_pkgconfig_variable(self, variable_name, kwargs): raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name)) diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 6a8050d..62a652a 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -22,6 +22,7 @@ from .. import mesonlib from ..environment import detect_cpu_family from .base import (DependencyException, ExternalDependency) +from .misc import ThreadDependency # On windows 3 directory layouts are supported: # * The default layout (versioned) installed: @@ -103,6 +104,8 @@ class BoostDependency(ExternalDependency): self.is_multithreading = threading == "multi" 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_roots = [] @@ -488,9 +491,6 @@ class BoostDependency(ExternalDependency): def get_sources(self): return [] - def need_threads(self): - return 'thread' in self.requested_modules - # Generated with boost_names.py BOOST_LIBS = [ diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 57a6a96..fb7b017 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -26,6 +26,7 @@ from .base import ( DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency, strip_system_libdirs, ConfigToolDependency, ) +from .misc import ThreadDependency def get_shared_library_suffix(environment, native): @@ -45,6 +46,7 @@ class GTestDependency(ExternalDependency): self.main = kwargs.get('main', False) self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src'] self.detect() + self.ext_deps.append(ThreadDependency(environment, kwargs)) def detect(self): gtest_detect = self.clib_compiler.find_library("gtest", self.env, []) @@ -83,9 +85,6 @@ class GTestDependency(ExternalDependency): return True return False - def need_threads(self): - return True - def log_info(self): if self.prebuilt: return 'prebuilt' @@ -118,6 +117,7 @@ class GMockDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('gmock', environment, 'cpp', kwargs) self.main = kwargs.get('main', False) + self.ext_deps.append(ThreadDependency(environment, kwargs)) # If we are getting main() from GMock, we definitely # want to avoid linking in main() from GTest @@ -167,9 +167,6 @@ class GMockDependency(ExternalDependency): self.is_found = False - def need_threads(self): - return True - def log_info(self): if self.prebuilt: return 'prebuilt' @@ -262,6 +259,7 @@ class LLVMDependency(ConfigToolDependency): self._set_old_link_args() self.link_args = strip_system_libdirs(environment, self.link_args) self.link_args = self.__fix_bogus_link_args(self.link_args) + self.ext_deps.append(ThreadDependency(environment, kwargs)) @staticmethod def __fix_bogus_link_args(args): @@ -399,9 +397,6 @@ class LLVMDependency(ConfigToolDependency): self.module_details.append(mod + status) - def need_threads(self): - return True - def log_details(self): if self.module_details: return 'modules: ' + ', '.join(self.module_details) diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 76eccfb..5721cc3 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -385,9 +385,8 @@ class ThreadDependency(ExternalDependency): super().__init__('threads', environment, None, kwargs) self.name = 'threads' self.is_found = True - - def need_threads(self): - return True + self.compile_args = self.clib_compiler.thread_flags(environment) + self.link_args = self.clib_compiler.thread_link_flags(environment) class Python3Dependency(ExternalDependency): |