Skip to content

Commit 23e443a

Browse files
committed
support enable rpath in each target independently
1 parent f5559e3 commit 23e443a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

config.example.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,10 @@ changelog-seen = 2
750750
# This option will override the same option under [build] section.
751751
#profiler = build.profiler (bool)
752752

753+
# This option supports enable `rpath` in each target independently,
754+
# and will override the same option under [rust] section. It only works on Unix platforms
755+
#rpath = rust.rpath (bool)
756+
753757
# Force static or dynamic linkage of the standard library for this target. If
754758
# this target is a host for rustc, this will also affect the linkage of the
755759
# compiler itself. This is useful for building rustc on targets that normally

src/bootstrap/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ impl<'a> Builder<'a> {
16101610
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
16111611
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
16121612
// to change a flag in a binary?
1613-
if self.config.rust_rpath && util::use_host_linker(target) {
1613+
if self.config.rpath_enabled(target) && util::use_host_linker(target) {
16141614
let rpath = if target.contains("apple") {
16151615
// Note that we need to take one extra step on macOS to also pass
16161616
// `-Wl,-instal_name,@rpath/...` to get things to work right. To

src/bootstrap/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ pub struct Target {
455455
pub ndk: Option<PathBuf>,
456456
pub sanitizers: Option<bool>,
457457
pub profiler: Option<bool>,
458+
pub rpath: Option<bool>,
458459
pub crt_static: Option<bool>,
459460
pub musl_root: Option<PathBuf>,
460461
pub musl_libdir: Option<PathBuf>,
@@ -800,6 +801,7 @@ define_config! {
800801
android_ndk: Option<String> = "android-ndk",
801802
sanitizers: Option<bool> = "sanitizers",
802803
profiler: Option<bool> = "profiler",
804+
rpath: Option<bool> = "rpath",
803805
crt_static: Option<bool> = "crt-static",
804806
musl_root: Option<String> = "musl-root",
805807
musl_libdir: Option<String> = "musl-libdir",
@@ -1301,6 +1303,7 @@ impl Config {
13011303
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
13021304
target.sanitizers = cfg.sanitizers;
13031305
target.profiler = cfg.profiler;
1306+
target.rpath = cfg.rpath;
13041307

13051308
config.target_config.insert(TargetSelection::from_user(&triple), target);
13061309
}
@@ -1610,6 +1613,10 @@ impl Config {
16101613
self.target_config.values().any(|t| t.profiler == Some(true)) || self.profiler
16111614
}
16121615

1616+
pub fn rpath_enabled(&self, target: TargetSelection) -> bool {
1617+
self.target_config.get(&target).map(|t| t.rpath).flatten().unwrap_or(self.rust_rpath)
1618+
}
1619+
16131620
pub fn llvm_enabled(&self) -> bool {
16141621
self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
16151622
}

0 commit comments

Comments
 (0)