summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-12 10:16:49 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 10:48:48 -0800
commita5c703c9e068366a6331b23227529fabd35e42cd (patch)
tree005ed7b0d79e1eab4ae08c36bbeb21e14320b555
parentdf0139510791507181051d865472833f5fc2b442 (diff)
downloadmeson-a5c703c9e068366a6331b23227529fabd35e42cd.tar.gz
compilers: Remove Environment parameter from Compiler.thread_flags
Same logic as the openmp flags
-rw-r--r--mesonbuild/compilers/compilers.py6
-rw-r--r--mesonbuild/compilers/cuda.py4
-rw-r--r--mesonbuild/compilers/mixins/arm.py3
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py3
-rw-r--r--mesonbuild/compilers/mixins/clike.py7
-rw-r--r--mesonbuild/compilers/mixins/compcert.py3
-rw-r--r--mesonbuild/compilers/mixins/emscripten.py4
-rw-r--r--mesonbuild/compilers/mixins/islinker.py4
-rw-r--r--mesonbuild/compilers/mixins/microchip.py4
-rw-r--r--mesonbuild/compilers/mixins/pgi.py3
-rw-r--r--mesonbuild/compilers/mixins/ti.py3
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py2
-rw-r--r--mesonbuild/compilers/vala.py4
-rw-r--r--mesonbuild/dependencies/misc.py4
-rw-r--r--mesonbuild/linkers/linkers.py14
15 files changed, 31 insertions, 37 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 046c5b157..e9446b3b8 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -964,11 +964,11 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
return []
return self.linker.get_command_to_archive_shlib()
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
- def thread_link_flags(self, env: 'Environment') -> T.List[str]:
- return self.linker.thread_flags(env)
+ def thread_link_flags(self) -> T.List[str]:
+ return self.linker.thread_flags()
def openmp_flags(self) -> T.List[str]:
raise EnvironmentException('Language %s does not support OpenMP flags.' % self.get_display_language())
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 17ab054c9..5fb0522d7 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -494,8 +494,8 @@ class CudaCompiler(Compiler):
def needs_static_linker(self) -> bool:
return False
- def thread_link_flags(self, environment: 'Environment') -> T.List[str]:
- return self._to_host_flags(self.host_compiler.thread_link_flags(environment), Phase.LINKER)
+ def thread_link_flags(self) -> T.List[str]:
+ return self._to_host_flags(self.host_compiler.thread_link_flags(), Phase.LINKER)
def sanity_check(self, work_dir: str) -> None:
mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist))
diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py
index a70ec4ff9..e1212a280 100644
--- a/mesonbuild/compilers/mixins/arm.py
+++ b/mesonbuild/compilers/mixins/arm.py
@@ -15,7 +15,6 @@ from ..compilers import clike_debug_args
from .clang import clang_color_args
if T.TYPE_CHECKING:
- from ...environment import Environment
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
@@ -90,7 +89,7 @@ class ArmCompiler(Compiler):
# PCH files."
return 'pch'
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self,) -> T.List[str]:
return []
def get_coverage_args(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index d1badaa1c..a0406186a 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -12,7 +12,6 @@ from ...mesonlib import EnvironmentException
if T.TYPE_CHECKING:
from ...envconfig import MachineInfo
- from ...environment import Environment
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
@@ -67,7 +66,7 @@ class CcrxCompiler(Compiler):
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def get_coverage_args(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 2f6ca6eab..3b91c1d7e 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1276,12 +1276,11 @@ class CLikeCompiler(Compiler):
# TODO: does this belong here or in GnuLike or maybe PosixLike?
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
# TODO: does this belong here or in GnuLike or maybe PosixLike?
- host_m = env.machines[self.for_machine]
- if host_m.is_haiku() or host_m.is_darwin():
+ if self.info.is_haiku() or self.info.is_darwin():
return []
- if host_m.is_os2():
+ if self.info.is_os2():
return ['-lpthread']
return ['-pthread']
diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py
index 86d20a0d6..522b31ea2 100644
--- a/mesonbuild/compilers/mixins/compcert.py
+++ b/mesonbuild/compilers/mixins/compcert.py
@@ -11,7 +11,6 @@ import typing as T
if T.TYPE_CHECKING:
from ...envconfig import MachineInfo
- from ...environment import Environment
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
@@ -85,7 +84,7 @@ class CompCertCompiler(Compiler):
patched_args.append(arg)
return patched_args
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def get_preprocess_only_args(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py
index 1af2236e9..5698ebef3 100644
--- a/mesonbuild/compilers/mixins/emscripten.py
+++ b/mesonbuild/compilers/mixins/emscripten.py
@@ -48,9 +48,9 @@ class EmscriptenMixin(Compiler):
suffix = 'o'
return os.path.join(dirname, 'output.' + suffix)
- def thread_link_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_link_flags(self) -> T.List[str]:
args = ['-pthread']
- count = env.coredata.optstore.get_value_for(OptionKey(f'{self.language}_thread_count', machine=self.for_machine))
+ count = self.environment.coredata.optstore.get_value_for(OptionKey(f'{self.language}_thread_count', machine=self.for_machine))
assert isinstance(count, int)
if count:
args.append(f'-sPTHREAD_POOL_SIZE={count}')
diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py
index 9832cc74c..f8c6c0b13 100644
--- a/mesonbuild/compilers/mixins/islinker.py
+++ b/mesonbuild/compilers/mixins/islinker.py
@@ -114,8 +114,8 @@ class BasicLinkerIsCompilerMixin(Compiler):
def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]:
return None
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
- def thread_link_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_link_flags(self) -> T.List[str]:
return []
diff --git a/mesonbuild/compilers/mixins/microchip.py b/mesonbuild/compilers/mixins/microchip.py
index 14ebb4cf8..22cc040e1 100644
--- a/mesonbuild/compilers/mixins/microchip.py
+++ b/mesonbuild/compilers/mixins/microchip.py
@@ -72,7 +72,7 @@ class Xc16Compiler(Compiler):
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def get_coverage_args(self) -> T.List[str]:
@@ -135,7 +135,7 @@ class Xc32Compiler(CompilerBase):
def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]:
return None
- def thread_flags(self, env: Environment) -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def openmp_flags(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index 92a995b70..7bb78a8ee 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -13,7 +13,6 @@ from ..compilers import clike_debug_args, clike_optimization_args
from ...options import OptionKey
if T.TYPE_CHECKING:
- from ...environment import Environment
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
@@ -89,6 +88,6 @@ class PGICompiler(Compiler):
else:
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
# PGI cannot accept -pthread, it's already threaded
return []
diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py
index 99a0120da..bdab3e48c 100644
--- a/mesonbuild/compilers/mixins/ti.py
+++ b/mesonbuild/compilers/mixins/ti.py
@@ -12,7 +12,6 @@ from ...mesonlib import EnvironmentException
if T.TYPE_CHECKING:
from ...envconfig import MachineInfo
- from ...environment import Environment
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
@@ -71,7 +70,7 @@ class TICompiler(Compiler):
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def get_coverage_args(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 9ed35bd1b..db9a76dd9 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -211,7 +211,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return []
# FIXME, no idea what these should be.
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
@classmethod
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py
index 6968cb9d5..046ea8c4b 100644
--- a/mesonbuild/compilers/vala.py
+++ b/mesonbuild/compilers/vala.py
@@ -142,10 +142,10 @@ class ValaCompiler(Compiler):
mlog.debug(f'Searched {extra_dirs!r} and {libname!r} wasn\'t found')
return None
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
- def thread_link_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_link_flags(self) -> T.List[str]:
return []
def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> T.List[str]:
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 0e55ad620..cae00844d 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -176,8 +176,8 @@ class ThreadDependency(SystemDependency):
self.compile_args = []
self.link_args = []
else:
- self.compile_args = self.clib_compiler.thread_flags(environment)
- self.link_args = self.clib_compiler.thread_link_flags(environment)
+ self.compile_args = self.clib_compiler.thread_flags()
+ self.link_args = self.clib_compiler.thread_link_flags()
class BlocksDependency(SystemDependency):
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index bb4b2f7dc..6c447ffa7 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -70,7 +70,7 @@ class StaticLinker:
target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
return ([], set())
- def thread_link_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def openmp_flags(self) -> T.List[str]:
@@ -271,7 +271,7 @@ class DynamicLinker(metaclass=abc.ABCMeta):
"""
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
def no_undefined_args(self) -> T.List[str]:
@@ -703,8 +703,8 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
def import_library_args(self, implibname: str) -> T.List[str]:
return self._apply_prefix('--out-implib=' + implibname)
- def thread_flags(self, env: 'Environment') -> T.List[str]:
- if env.machines[self.for_machine].is_haiku():
+ def thread_flags(self) -> T.List[str]:
+ if self.environment.machines[self.for_machine].is_haiku():
return []
return ['-pthread']
@@ -1154,7 +1154,7 @@ class Xc32DynamicLinker(GnuDynamicLinker):
def get_pie_args(self) -> T.List[str]:
return DynamicLinker.get_pie_args(self)
- def thread_flags(self, env: Environment) -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return []
@@ -1665,7 +1665,7 @@ class AIXDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
all_paths.update(extra_paths)
return (self._apply_prefix('-blibpath:' + ':'.join(all_paths)), set())
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return ['-pthread']
@@ -1846,7 +1846,7 @@ class OS2DynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
def get_allow_undefined_args(self) -> T.List[str]:
return []
- def thread_flags(self, env: 'Environment') -> T.List[str]:
+ def thread_flags(self) -> T.List[str]:
return ['-lpthread']
def get_std_shared_lib_args(self) -> T.List[str]: