Skip to content

Commit

Permalink
compilers: add Rustup libdir even if there is no other rpath argument
Browse files Browse the repository at this point in the history
RustCompiler.build_rpath_args works by appending the directory to the
arguments computed by self.linker.build_rpath_args.  This does not
work if there is no argument to begin with, which happens for example
in program crates.

Use the new extra_paths argument to force inclusion of the libdir into
the rpath of the binary, even in that case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Feb 5, 2025
1 parent e30bc27 commit ba7ae7c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mesonbuild/compilers/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
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]]:
args, to_remove = super().build_rpath_args(env, build_dir, from_dir, rpath_paths,
build_rpath, install_rpath)
# 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()])

# ... but then add rustc's sysroot to account for rustup
# installations
rustc_rpath_args = []
for arg in args:
rustc_rpath_args.append('-C')
rustc_rpath_args.append(f'link-arg={arg}:{self.get_target_libdir()}')
rustc_rpath_args.append('link-arg=' + arg)
return rustc_rpath_args, to_remove

def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str],
Expand Down

0 comments on commit ba7ae7c

Please sign in to comment.