summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-12 10:05:11 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 10:48:48 -0800
commit0e6fd84db2299b45d9abbe42cb461fa7e49b27c3 (patch)
tree5c33b2030593ada2b55d26e5fa48852ad89bc621 /mesonbuild
parent198156295899ddb5e9c91f1c889d50f27e8a7692 (diff)
downloadmeson-0e6fd84db2299b45d9abbe42cb461fa7e49b27c3.tar.gz
compilers: Remove Environment parameter from Compiler.get_language_stdlib_only_link_flags
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py6
-rw-r--r--mesonbuild/compilers/compilers.py2
-rw-r--r--mesonbuild/compilers/cpp.py11
-rw-r--r--mesonbuild/compilers/fortran.py16
4 files changed, 16 insertions, 19 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 7562fea53..138f1ae03 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1665,7 +1665,7 @@ class BuildTarget(Target):
# If the user set the link_language, just return that.
if self.link_language:
comp = self.all_compilers[self.link_language]
- return comp, comp.language_stdlib_only_link_flags(self.environment)
+ return comp, comp.language_stdlib_only_link_flags()
# Since dependencies could come from subprojects, they could have
# languages we don't have in self.all_compilers. Use the global list of
@@ -1695,7 +1695,7 @@ class BuildTarget(Target):
for l in clink_langs:
try:
comp = self.all_compilers[l]
- return comp, comp.language_stdlib_only_link_flags(self.environment)
+ return comp, comp.language_stdlib_only_link_flags()
except KeyError:
pass
@@ -1710,7 +1710,7 @@ class BuildTarget(Target):
# We need to use all_compilers here because
# get_langs_used_by_deps could return a language from a
# subproject
- stdlib_args.extend(all_compilers[dl].language_stdlib_only_link_flags(self.environment))
+ stdlib_args.extend(all_compilers[dl].language_stdlib_only_link_flags())
return stdlib_args
def uses_rust(self) -> bool:
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 9795668fc..929274ae4 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -976,7 +976,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def openmp_link_flags(self, env: Environment) -> T.List[str]:
return self.openmp_flags(env)
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
return []
def gnu_symbol_visibility_args(self, vistype: str) -> T.List[str]:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 5f97c566a..233a28b63 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -190,7 +190,7 @@ class _StdCPPLibMixin(CompilerMixinBase):
return lib
@functools.lru_cache(None)
- def language_stdlib_only_link_flags(self, env: Environment) -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
"""Detect the C++ stdlib and default search dirs
As an optimization, this method will cache the value, to avoid building the same values over and over
@@ -203,13 +203,10 @@ class _StdCPPLibMixin(CompilerMixinBase):
# be passed to a different compiler with a different set of default
# search paths, such as when using Clang for C/C++ and gfortran for
# fortran.
- search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')]
+ search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(self.environment, 'libraries')]
- machine = env.machines[self.for_machine]
- assert machine is not None, 'for mypy'
-
- lib = self.language_stdlib_provider(env)
- if self.find_library(lib, env, []) is not None:
+ lib = self.language_stdlib_provider(self.environment)
+ if self.find_library(lib, self.environment, []) is not None:
return search_dirs + [f'-l{lib}']
# TODO: maybe a bug exception?
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index c5e8dc549..3668f24a0 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -299,13 +299,13 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler):
def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-J' + path]
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
# We need to apply the search prefix here, as these link arguments may
# be passed to a different compiler with a different set of default
# search paths, such as when using Clang for C/C++ and gfortran for
# fortran,
search_dirs: T.List[str] = []
- for d in self.get_compiler_dirs(env, 'libraries'):
+ for d in self.get_compiler_dirs(self.environment, 'libraries'):
search_dirs.append(f'-L{d}')
return search_dirs + ['-lgfortran', '-lm']
@@ -427,7 +427,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
def get_werror_args(self) -> T.List[str]:
return ['-warn', 'errors']
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
# TODO: needs default search path added
return ['-lifcore', '-limf']
@@ -526,7 +526,7 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler):
'3': default_warn_args + ['-Mdclchk'],
'everything': default_warn_args + ['-Mdclchk']}
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
# TODO: needs default search path added
return ['-lpgf90rtl', '-lpgf90', '-lpgf90_rpm1', '-lpgf902',
'-lpgf90rtl', '-lpgftnrtl', '-lrt']
@@ -568,14 +568,14 @@ class ClassicFlangFortranCompiler(ClangCompiler, FortranCompiler):
'3': default_warn_args,
'everything': default_warn_args}
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
# We need to apply the search prefix here, as these link arguments may
# be passed to a different compiler with a different set of default
# search paths, such as when using Clang for C/C++ and gfortran for
# fortran,
# XXX: Untested....
search_dirs: T.List[str] = []
- for d in self.get_compiler_dirs(env, 'libraries'):
+ for d in self.get_compiler_dirs(self.environment, 'libraries'):
search_dirs.append(f'-L{d}')
return search_dirs + ['-lflang', '-lpgmath']
@@ -620,10 +620,10 @@ class LlvmFlangFortranCompiler(ClangCompiler, FortranCompiler):
# https://github.com/llvm/llvm-project/issues/92459
return []
- def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
+ def language_stdlib_only_link_flags(self) -> T.List[str]:
# matching setup from ClassicFlangFortranCompiler
search_dirs: T.List[str] = []
- for d in self.get_compiler_dirs(env, 'libraries'):
+ for d in self.get_compiler_dirs(self.environment, 'libraries'):
search_dirs.append(f'-L{d}')
# does not automatically link to Fortran_main anymore after
# https://github.com/llvm/llvm-project/commit/9d6837d595719904720e5ff68ec1f1a2665bdc2f