Skip to content

Commit 4e3be3a

Browse files
elebihantpetazzoni
authored andcommitted
package/rust: bump version to 1.33.0
Bump rust to 1.33.0 with the following changes: - drop support for jemalloc - add dependency on host-openssl - add a patch to fix bootstraping with rust 1.33.0 [1] [1] rust-lang/rust#57765 Signed-off-by: Eric Le Bihan <[email protected]> Signed-off-by: Thomas Petazzoni <[email protected]>
1 parent 317e75b commit 4e3be3a

File tree

3 files changed

+269
-12
lines changed

3 files changed

+269
-12
lines changed
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
From 2d21df8a3fd7a68ba9f52389ead7f06f13190c12 Mon Sep 17 00:00:00 2001
2+
From: Mark Rousskov <[email protected]>
3+
Date: Mon, 21 Jan 2019 17:47:57 -0700
4+
Subject: [PATCH] Workaround presence of LLVM library in stage0/lib
5+
6+
This commit works around the newly-introduced LLVM shared library.
7+
8+
This is needed such that llvm-config run from
9+
librustc_llvm's build script can correctly locate it's own LLVM, not the
10+
one in stage0/lib. The LLVM build system uses the DT_RUNPATH/RUNPATH
11+
header within the llvm-config binary, which we want to use, but because
12+
Cargo always adds the host compiler's "libdir" (stage0/lib in our
13+
case) to the dynamic linker's search path, we weren't properly finding
14+
the freshly-built LLVM in llvm/lib. By restoring the environment
15+
variable setting the search path to what bootstrap sees, the problem is
16+
resolved and librustc_llvm correctly links and finds the appropriate
17+
LLVM.
18+
19+
Several run-make-fulldeps tests are also updated with similar handling.
20+
21+
Signed-off-by: Eric Le Bihan <[email protected]>
22+
---
23+
src/bootstrap/builder.rs | 9 ++++++++-
24+
src/bootstrap/compile.rs | 1 +
25+
src/bootstrap/util.rs | 6 +++++-
26+
src/build_helper/lib.rs | 19 +++++++++++++++++++
27+
src/librustc_asan/build.rs | 2 ++
28+
src/librustc_llvm/build.rs | 2 ++
29+
src/librustc_lsan/build.rs | 2 ++
30+
src/librustc_msan/build.rs | 2 ++
31+
src/librustc_tsan/build.rs | 2 ++
32+
.../cross-lang-lto-upstream-rlibs/Makefile | 4 ++--
33+
.../run-make-fulldeps/cross-lang-lto/Makefile | 19 ++++++++++---------
34+
11 files changed, 55 insertions(+), 13 deletions(-)
35+
36+
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
37+
index a69ba20749..f742bce180 100644
38+
--- a/src/bootstrap/builder.rs
39+
+++ b/src/bootstrap/builder.rs
40+
@@ -21,7 +21,7 @@ use crate::install;
41+
use crate::native;
42+
use crate::test;
43+
use crate::tool;
44+
-use crate::util::{add_lib_path, exe, libdir};
45+
+use crate::util::{self, add_lib_path, exe, libdir};
46+
use crate::{Build, DocTests, Mode, GitRepo};
47+
48+
pub use crate::Compiler;
49+
@@ -791,6 +791,13 @@ impl<'a> Builder<'a> {
50+
.env("CARGO_TARGET_DIR", out_dir)
51+
.arg(cmd);
52+
53+
+ // See comment in librustc_llvm/build.rs for why this is necessary, largely llvm-config
54+
+ // needs to not accidentally link to libLLVM in stage0/lib.
55+
+ cargo.env("REAL_LIBRARY_PATH_VAR", &util::dylib_path_var());
56+
+ if let Some(e) = env::var_os(util::dylib_path_var()) {
57+
+ cargo.env("REAL_LIBRARY_PATH", e);
58+
+ }
59+
+
60+
if cmd != "install" {
61+
cargo.arg("--target")
62+
.arg(target);
63+
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
64+
index b581271663..ec04dee6c3 100644
65+
--- a/src/bootstrap/compile.rs
66+
+++ b/src/bootstrap/compile.rs
67+
@@ -712,6 +712,7 @@ pub fn build_codegen_backend(builder: &Builder,
68+
if builder.is_rust_llvm(target) && backend != "emscripten" {
69+
cargo.env("LLVM_RUSTLLVM", "1");
70+
}
71+
+
72+
cargo.env("LLVM_CONFIG", &llvm_config);
73+
if backend != "emscripten" {
74+
let target_config = builder.config.target_config.get(&target);
75+
diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs
76+
index 2880f1a084..37c6c040da 100644
77+
--- a/src/bootstrap/util.rs
78+
+++ b/src/bootstrap/util.rs
79+
@@ -70,7 +70,11 @@ pub fn dylib_path_var() -> &'static str {
80+
/// Parses the `dylib_path_var()` environment variable, returning a list of
81+
/// paths that are members of this lookup path.
82+
pub fn dylib_path() -> Vec<PathBuf> {
83+
- env::split_paths(&env::var_os(dylib_path_var()).unwrap_or_default()).collect()
84+
+ let var = match env::var_os(dylib_path_var()) {
85+
+ Some(v) => v,
86+
+ None => return vec![],
87+
+ };
88+
+ env::split_paths(&var).collect()
89+
}
90+
91+
/// `push` all components to `buf`. On windows, append `.exe` to the last component.
92+
diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs
93+
index 5a704e5577..c66c5c9249 100644
94+
--- a/src/build_helper/lib.rs
95+
+++ b/src/build_helper/lib.rs
96+
@@ -23,6 +23,25 @@ macro_rules! t {
97+
};
98+
}
99+
100+
+// Because Cargo adds the compiler's dylib path to our library search path, llvm-config may
101+
+// break: the dylib path for the compiler, as of this writing, contains a copy of the LLVM
102+
+// shared library, which means that when our freshly built llvm-config goes to load it's
103+
+// associated LLVM, it actually loads the compiler's LLVM. In particular when building the first
104+
+// compiler (i.e., in stage 0) that's a problem, as the compiler's LLVM is likely different from
105+
+// the one we want to use. As such, we restore the environment to what bootstrap saw. This isn't
106+
+// perfect -- we might actually want to see something from Cargo's added library paths -- but
107+
+// for now it works.
108+
+pub fn restore_library_path() {
109+
+ println!("cargo:rerun-if-env-changed=REAL_LIBRARY_PATH_VAR");
110+
+ println!("cargo:rerun-if-env-changed=REAL_LIBRARY_PATH");
111+
+ let key = env::var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR");
112+
+ if let Some(env) = env::var_os("REAL_LIBRARY_PATH") {
113+
+ env::set_var(&key, &env);
114+
+ } else {
115+
+ env::remove_var(&key);
116+
+ }
117+
+}
118+
+
119+
pub fn run(cmd: &mut Command) {
120+
println!("running: {:?}", cmd);
121+
run_silent(cmd);
122+
diff --git a/src/librustc_asan/build.rs b/src/librustc_asan/build.rs
123+
index 2d921b6669..b42d775deb 100644
124+
--- a/src/librustc_asan/build.rs
125+
+++ b/src/librustc_asan/build.rs
126+
@@ -8,6 +8,8 @@ use cmake::Config;
127+
128+
fn main() {
129+
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
130+
+ build_helper::restore_library_path();
131+
+
132+
let (native, target) = match sanitizer_lib_boilerplate("asan") {
133+
Ok(native) => native,
134+
_ => return,
135+
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
136+
index ec3dff783c..cd91fcb299 100644
137+
--- a/src/librustc_llvm/build.rs
138+
+++ b/src/librustc_llvm/build.rs
139+
@@ -24,6 +24,8 @@ fn main() {
140+
return;
141+
}
142+
143+
+ build_helper::restore_library_path();
144+
+
145+
let target = env::var("TARGET").expect("TARGET was not set");
146+
let llvm_config = env::var_os("LLVM_CONFIG")
147+
.map(PathBuf::from)
148+
diff --git a/src/librustc_lsan/build.rs b/src/librustc_lsan/build.rs
149+
index 470f2bb3e5..ad528bb039 100644
150+
--- a/src/librustc_lsan/build.rs
151+
+++ b/src/librustc_lsan/build.rs
152+
@@ -8,6 +8,8 @@ use cmake::Config;
153+
154+
fn main() {
155+
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
156+
+ build_helper::restore_library_path();
157+
+
158+
let (native, target) = match sanitizer_lib_boilerplate("lsan") {
159+
Ok(native) => native,
160+
_ => return,
161+
diff --git a/src/librustc_msan/build.rs b/src/librustc_msan/build.rs
162+
index e1140278f2..085514b5a0 100644
163+
--- a/src/librustc_msan/build.rs
164+
+++ b/src/librustc_msan/build.rs
165+
@@ -8,6 +8,8 @@ use cmake::Config;
166+
167+
fn main() {
168+
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
169+
+ build_helper::restore_library_path();
170+
+
171+
let (native, target) = match sanitizer_lib_boilerplate("msan") {
172+
Ok(native) => native,
173+
_ => return,
174+
diff --git a/src/librustc_tsan/build.rs b/src/librustc_tsan/build.rs
175+
index f63bb46b87..0db3db392d 100644
176+
--- a/src/librustc_tsan/build.rs
177+
+++ b/src/librustc_tsan/build.rs
178+
@@ -8,6 +8,8 @@ use cmake::Config;
179+
180+
fn main() {
181+
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
182+
+ build_helper::restore_library_path();
183+
+
184+
let (native, target) = match sanitizer_lib_boilerplate("tsan") {
185+
Ok(native) => native,
186+
_ => return,
187+
diff --git a/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile b/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile
188+
index 0a6f226a02..6992dab1a1 100644
189+
--- a/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile
190+
+++ b/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile
191+
@@ -9,7 +9,7 @@ all: staticlib.rs upstream.rs
192+
193+
# Check No LTO
194+
$(RUSTC) staticlib.rs -Z cross-lang-lto -Ccodegen-units=1 -L. -o $(TMPDIR)/staticlib.a
195+
- (cd $(TMPDIR); llvm-ar x ./staticlib.a)
196+
+ (cd $(TMPDIR); $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x ./staticlib.a)
197+
# Make sure the upstream object file was included
198+
ls $(TMPDIR)/upstream.*.rcgu.o
199+
200+
@@ -19,5 +19,5 @@ all: staticlib.rs upstream.rs
201+
# Check ThinLTO
202+
$(RUSTC) upstream.rs -Z cross-lang-lto -Ccodegen-units=1 -Clto=thin
203+
$(RUSTC) staticlib.rs -Z cross-lang-lto -Ccodegen-units=1 -Clto=thin -L. -o $(TMPDIR)/staticlib.a
204+
- (cd $(TMPDIR); llvm-ar x ./staticlib.a)
205+
+ (cd $(TMPDIR); $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x ./staticlib.a)
206+
ls $(TMPDIR)/upstream.*.rcgu.o
207+
diff --git a/src/test/run-make-fulldeps/cross-lang-lto/Makefile b/src/test/run-make-fulldeps/cross-lang-lto/Makefile
208+
index 1d072e03de..4d1fb7b953 100644
209+
--- a/src/test/run-make-fulldeps/cross-lang-lto/Makefile
210+
+++ b/src/test/run-make-fulldeps/cross-lang-lto/Makefile
211+
@@ -5,8 +5,9 @@
212+
# LLVM bitcode files (as used by linker LTO plugins) when compiling with
213+
# -Z cross-lang-lto.
214+
215+
-ASSERT_IS_BITCODE_OBJ=llvm-bcanalyzer # this only succeeds for bitcode files
216+
-EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; llvm-ar x $(1))
217+
+# this only succeeds for bitcode files
218+
+ASSERT_IS_BITCODE_OBJ=($(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-bcanalyzer $(1))
219+
+EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; $(LD_LIB_PATH_ENVVAR)=$(REAL_LD_LIBRARY_PATH) llvm-ar x $(1))
220+
221+
BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Z cross-lang-lto=on -Ccodegen-units=1
222+
BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Z cross-lang-lto=on -Ccodegen-units=1 --emit=obj
223+
@@ -16,31 +17,31 @@ all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib
224+
staticlib: lib.rs
225+
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a
226+
$(call EXTRACT_OBJS, liblib.a)
227+
- for file in $(TMPDIR)/liblib.*.rcgu.o; do $(ASSERT_IS_BITCODE_OBJ) $$file; done
228+
+ for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
229+
230+
staticlib-fat-lto: lib.rs
231+
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat
232+
$(call EXTRACT_OBJS, liblib-fat-lto.a)
233+
- for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(ASSERT_IS_BITCODE_OBJ) $$file; done
234+
+ for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
235+
236+
staticlib-thin-lto: lib.rs
237+
$(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin
238+
$(call EXTRACT_OBJS, liblib-thin-lto.a)
239+
- for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(ASSERT_IS_BITCODE_OBJ) $$file; done
240+
+ for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
241+
242+
rlib: lib.rs
243+
$(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib
244+
$(call EXTRACT_OBJS, liblib.rlib)
245+
- for file in $(TMPDIR)/liblib.*.rcgu.o; do $(ASSERT_IS_BITCODE_OBJ) $$file; done
246+
+ for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
247+
248+
cdylib: lib.rs
249+
$(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o
250+
- $(ASSERT_IS_BITCODE_OBJ) $(TMPDIR)/cdylib.o
251+
+ $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o)
252+
253+
rdylib: lib.rs
254+
$(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o
255+
- $(ASSERT_IS_BITCODE_OBJ) $(TMPDIR)/rdylib.o
256+
+ $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o)
257+
258+
exe: lib.rs
259+
$(BUILD_EXE) -o $(TMPDIR)/exe.o
260+
- $(ASSERT_IS_BITCODE_OBJ) $(TMPDIR)/exe.o
261+
+ $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o)
262+
--
263+
2.17.2
264+

package/rust/rust.hash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# From https://static.rust-lang.org/dist/rustc-1.29.2-src.tar.xz.sha256
2-
sha256 bc7b9d4c041fe8454892a4211a116a4d5243cb04583a18c5292914fc829cb2f6 rustc-1.29.2-src.tar.xz
1+
# From https://static.rust-lang.org/dist/rustc-1.33.0-src.tar.xz.sha256
2+
# Verified using https://static.rust-lang.org/dist/rustc-1.33.0-src.tar.xz.asc
3+
sha256 f4b1a72f1a29b23dcc9d7be5f60878f0434560513273906aa93dcd5c0de39b71 rustc-1.33.0-src.tar.xz
34
# Locally generated
45
sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
56
sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT

package/rust/rust.mk

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
################################################################################
66

7-
RUST_VERSION = 1.29.2
7+
RUST_VERSION = 1.33.0
88
RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz
99
RUST_SITE = https://static.rust-lang.org/dist
1010
RUST_LICENSE = Apache-2.0 or MIT
@@ -16,17 +16,10 @@ HOST_RUST_DEPENDENCIES = \
1616
toolchain \
1717
host-rust-bin \
1818
host-cargo-bin \
19+
host-openssl \
1920
host-python \
2021
$(BR2_CMAKE_HOST_DEPENDENCY)
2122

22-
ifeq ($(BR2_PACKAGE_JEMALLOC),y)
23-
HOST_RUST_DEPENDENCIES += jemalloc
24-
HOST_RUST_JEMALLOC_ENABLED = true
25-
HOST_RUST_JEMALLOC_CONF = 'jemalloc = "$(STAGING_DIR)/usr/lib/libjemalloc_pic.a"'
26-
else
27-
HOST_RUST_JEMALLOC_ENABLED = false
28-
endif
29-
3023
HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0)
3124

3225
# Some vendor crates contain Cargo.toml.orig files. The associated
@@ -60,7 +53,6 @@ define HOST_RUST_CONFIGURE_CMDS
6053
echo '[install]'; \
6154
echo 'prefix = "$(HOST_DIR)"'; \
6255
echo '[rust]'; \
63-
echo 'use-jemalloc = $(HOST_RUST_JEMALLOC_ENABLED)'; \
6456
echo 'channel = "stable"'; \
6557
echo '[target.$(RUSTC_TARGET_NAME)]'; \
6658
echo 'cc = "$(TARGET_CROSS)gcc"'; \

0 commit comments

Comments
 (0)