1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
From: Shiz <hi@shiz.me>
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Wed, 12 Apr 2017 23:28:09 +0200
Subject: [PATCH] Force rpath on prefer-dynamic
When you build a dynamic binary with `-C prefer-dynamic`, rustc links
dynamically even Rust libraries, built as shared objects. These are
installed in /usr/lib/rustlib/<TARGET>/lib/, the location that is not
on standard LD path, at least on Alpine.
Therefore such binary would be unusable when not built with `-C rpath`
(or manually specifying LD_LIBRARY_PATH). For that reason we implicitly
enable rpath when `prefer-dynamic` is enabled.
Also note that Rust normally installs identical copy of *.so files from
/usr/lib/rustlib/<TARGET>/lib/, where <TARGET> equals host triple, to
/usr/lib. That's why such fully dynamic binary may work on other
systems even without rpath or having rustlib on the LD path. However,
since these *.so libraries don't keep stable ABI, they should not be on
LD path, and thus we do not install them here (see
change-rpath-to-rustlib.patch).
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -1368,6 +1368,11 @@
let mut cg = build_codegen_options(matches, error_format);
+ // Force rpath addition on prefer-dynamic output.
+ if cg.prefer_dynamic {
+ cg.rpath = true;
+ }
+
// Issue #30063: if user requests llvm-related output to one
// particular path, disable codegen-units.
if matches.opt_present("o") && cg.codegen_units != 1 {
|