summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2025-05-01 10:19:46 -0400
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-08-01 15:54:21 +0300
commit8cccad4f8b4e41a48e59fdbd8e3a18042e1245f8 (patch)
tree049adc3ba5114eb1300f94a592a98b0cb52068e1 /mesonbuild/compilers
parentc554ca55e7493921728645bd082565604f7e17db (diff)
downloadmeson-8cccad4f8b4e41a48e59fdbd8e3a18042e1245f8.tar.gz
call determine_rpath_dirs only when linker requires it
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/compilers.py7
-rw-r--r--mesonbuild/compilers/cuda.py7
-rw-r--r--mesonbuild/compilers/d.py11
-rw-r--r--mesonbuild/compilers/mixins/islinker.py5
-rw-r--r--mesonbuild/compilers/rust.py9
5 files changed, 16 insertions, 23 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 3b7f066f7..f32205db9 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -936,11 +936,10 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
"""
return None
- def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
- rpath_paths: T.Tuple[str, ...], build_rpath: str,
- install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ def build_rpath_args(self, env: Environment, build_dir: str, from_dir: str,
+ target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
return self.linker.build_rpath_args(
- env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
+ env, build_dir, from_dir, target, extra_paths)
def get_archive_name(self, filename: str) -> str:
return self.linker.get_archive_name(filename)
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 94bace6c5..7e050f140 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -731,11 +731,10 @@ class CudaCompiler(Compiler):
def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
return self._to_host_flags(self.host_compiler.get_optimization_link_args(optimization_level), Phase.LINKER)
- def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
- rpath_paths: T.Tuple[str, ...], build_rpath: str,
- install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ def build_rpath_args(self, env: Environment, build_dir: str, from_dir: str,
+ target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
(rpath_args, rpath_dirs_to_remove) = self.host_compiler.build_rpath_args(
- env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
+ env, build_dir, from_dir, target, extra_paths)
return (self._to_host_flags(rpath_args, Phase.LINKER), rpath_dirs_to_remove)
def linker_to_compiler_args(self, args: T.List[str]) -> T.List[str]:
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 51f2436a1..9f662add3 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -26,7 +26,7 @@ from .mixins.gnu import gnu_common_warning_args
if T.TYPE_CHECKING:
from . import compilers
- from ..build import DFeatures
+ from ..build import BuildTarget, DFeatures
from ..dependencies import Dependency
from ..envconfig import MachineInfo
from ..environment import Environment
@@ -175,9 +175,8 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
def gen_import_library_args(self, implibname: str) -> T.List[str]:
return self.linker.import_library_args(implibname)
- def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
- rpath_paths: T.Tuple[str, ...], build_rpath: str,
- install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ def build_rpath_args(self, env: Environment, build_dir: str, from_dir: str,
+ target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
if self.info.is_windows():
return ([], set())
@@ -188,7 +187,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
# split into two separate arguments both prefaced with the -L=.
args: T.List[str] = []
(rpath_args, rpath_dirs_to_remove) = super().build_rpath_args(
- env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
+ env, build_dir, from_dir, target)
for r in rpath_args:
if ',' in r:
a, b = r.split(',', maxsplit=1)
@@ -199,7 +198,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
return (args, rpath_dirs_to_remove)
return super().build_rpath_args(
- env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
+ env, build_dir, from_dir, target)
@classmethod
def _translate_args_to_nongnu(cls, args: T.List[str], info: MachineInfo, link_id: str) -> T.List[str]:
diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py
index 3f3561972..e359fb353 100644
--- a/mesonbuild/compilers/mixins/islinker.py
+++ b/mesonbuild/compilers/mixins/islinker.py
@@ -101,9 +101,8 @@ class BasicLinkerIsCompilerMixin(Compiler):
darwin_versions: T.Tuple[str, str]) -> T.List[str]:
raise MesonException("This linker doesn't support soname args")
- def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
- rpath_paths: T.Tuple[str, ...], build_rpath: str,
- install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ def build_rpath_args(self, env: Environment, build_dir: str, from_dir: str,
+ target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
return ([], set())
def get_asneeded_args(self) -> T.List[str]:
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index aef88eb45..bc2777990 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -197,13 +197,10 @@ class RustCompiler(Compiler):
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return rust_optimization_args[optimization_level]
- def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
- rpath_paths: T.Tuple[str, ...], build_rpath: str,
- install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ def build_rpath_args(self, env: Environment, build_dir: str, from_dir: str,
+ target: BuildTarget, extra_paths: T.Optional[T.List[str]] = None) -> T.Tuple[T.List[str], T.Set[bytes]]:
# add rustc's sysroot to account for rustup installations
- args, to_remove = self.linker.build_rpath_args(env, build_dir, from_dir, rpath_paths,
- build_rpath, install_rpath,
- [self.get_target_libdir()])
+ args, to_remove = super().build_rpath_args(env, build_dir, from_dir, target, [self.get_target_libdir()])
rustc_rpath_args = []
for arg in args: