rust-1.35.0.patchset revision df2d5291
1From 6a84247335859c1579850ab822ecdc5f75c26924 Mon Sep 17 00:00:00 2001
2From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
3Date: Sun, 9 Jun 2019 08:38:06 +0200
4Subject: Haiku-specific patches for Rust 1.35.0
5
6
7diff --git a/Cargo.lock b/Cargo.lock
8index f789033..1a3dd04 100644
9--- a/Cargo.lock
10+++ b/Cargo.lock
11@@ -375,7 +375,7 @@ dependencies = [
12  "cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
13  "clippy-mini-macro-test 0.2.0",
14  "clippy_lints 0.0.212",
15- "compiletest_rs 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
16+ "compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
17  "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
18  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
19  "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
20@@ -483,7 +483,7 @@ dependencies = [
21 
22 [[package]]
23 name = "compiletest_rs"
24-version = "0.3.21"
25+version = "0.3.22"
26 source = "registry+https://github.com/rust-lang/crates.io-index"
27 dependencies = [
28  "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
29@@ -1279,7 +1279,7 @@ dependencies = [
30  "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
31  "curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
32  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
33- "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
34+ "libssh2-sys 0.2.11 (git+https://github.com/alexcrichton/ssh2-rs?rev=74d7f04)",
35  "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
36  "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
37  "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
38@@ -1297,7 +1297,7 @@ dependencies = [
39 [[package]]
40 name = "libssh2-sys"
41 version = "0.2.11"
42-source = "registry+https://github.com/rust-lang/crates.io-index"
43+source = "git+https://github.com/alexcrichton/ssh2-rs?rev=74d7f04#74d7f04dbee9997510bdad5608bb06970c6b4c8a"
44 dependencies = [
45  "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
46  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
47@@ -1600,7 +1600,7 @@ dependencies = [
48  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
49  "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
50  "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
51- "compiletest_rs 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
52+ "compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
53  "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
54  "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
55  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
56@@ -4006,7 +4006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
57 "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
58 "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
59 "checksum compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d7de11892d9f9f1bc76d43011c8233d27d58300d629dc9dfb51b6626ef7f6077"
60-"checksum compiletest_rs 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)" = "17a60483b7d4d1534db7b77458a03d5d8a93a707432a04978dfe87ea43bb61b1"
61+"checksum compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f40ecc9332b68270998995c00f8051ee856121764a0d3230e64c9efd059d27b6"
62 "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
63 "checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
64 "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
65@@ -4091,7 +4091,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
66 "checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
67 "checksum libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48441cb35dc255da8ae72825689a95368bf510659ae1ad55dc4aa88cb1789bf1"
68 "checksum libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d75d7966bda4730b722d1eab8e668df445368a24394bae9fc1e8dc0ab3dbe4f4"
69-"checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d"
70+"checksum libssh2-sys 0.2.11 (git+https://github.com/alexcrichton/ssh2-rs?rev=74d7f04)" = "<none>"
71 "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
72 "checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
73 "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
74diff --git a/Cargo.toml b/Cargo.toml
75index cb3c0ee..1bb1bca 100644
76--- a/Cargo.toml
77+++ b/Cargo.toml
78@@ -59,6 +59,7 @@ cargo = { path = "src/tools/cargo" }
79 # that we're shipping as well (to ensure that the rustfmt in RLS and the
80 # `rustfmt` executable are the same exact version).
81 rustfmt-nightly = { path = "src/tools/rustfmt" }
82+libssh2-sys = { git = "https://github.com/alexcrichton/ssh2-rs", rev = "74d7f04" }
83 
84 # See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
85 # here
86diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
87index 5224663..0d94aab 100644
88--- a/src/bootstrap/builder.rs
89+++ b/src/bootstrap/builder.rs
90@@ -575,6 +575,25 @@ impl<'a> Builder<'a> {
91         })
92     }
93 
94+    /// Similar to `compiler`, except handles the full-bootstrap option to
95+    /// silently use the stage1 compiler instead of a stage2 compiler if one is
96+    /// requested.
97+    ///
98+    /// Note that this does *not* have the side effect of creating
99+    /// `compiler(stage, host)`, unlike `compiler` above which does have such
100+    /// a side effect. The returned compiler here can only be used to compile
101+    /// new artifacts, it can't be used to rely on the presence of a particular
102+    /// sysroot.
103+    ///
104+    /// See `force_use_stage1` for documentation on what each argument is.
105+    pub fn compiler_for(&self, stage: u32, host: Interned<String>, target: Interned<String>) -> Compiler {
106+        if self.build.force_use_stage1(Compiler { stage, host }, target) {
107+            self.compiler(1, self.config.build)
108+        } else {
109+            self.compiler(stage, host)
110+        }
111+    }
112+
113     pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
114         self.ensure(compile::Sysroot { compiler })
115     }
116@@ -748,11 +767,7 @@ impl<'a> Builder<'a> {
117         // This is for the original compiler, but if we're forced to use stage 1, then
118         // std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
119         // we copy the libs forward.
120-        let cmp = if self.force_use_stage1(compiler, target) {
121-            self.compiler(1, compiler.host)
122-        } else {
123-            compiler
124-        };
125+        let cmp = self.compiler_for(compiler.stage, compiler.host, target);
126 
127         let libstd_stamp = match cmd {
128             "check" => check::libstd_stamp(self, cmp, target),
129@@ -1351,7 +1366,7 @@ mod __test {
130         assert_eq!(
131             first(builder.cache.all::<dist::Std>()),
132             &[dist::Std {
133-                compiler: Compiler { host: a, stage: 2 },
134+                compiler: Compiler { host: a, stage: 1 },
135                 target: a,
136             },]
137         );
138@@ -1388,7 +1403,7 @@ mod __test {
139             first(builder.cache.all::<dist::Std>()),
140             &[
141                 dist::Std {
142-                    compiler: Compiler { host: a, stage: 2 },
143+                    compiler: Compiler { host: a, stage: 1 },
144                     target: a,
145                 },
146                 dist::Std {
147@@ -1435,11 +1450,11 @@ mod __test {
148             first(builder.cache.all::<dist::Std>()),
149             &[
150                 dist::Std {
151-                    compiler: Compiler { host: a, stage: 2 },
152+                    compiler: Compiler { host: a, stage: 1 },
153                     target: a,
154                 },
155                 dist::Std {
156-                    compiler: Compiler { host: a, stage: 2 },
157+                    compiler: Compiler { host: a, stage: 1 },
158                     target: b,
159                 },
160             ]
161@@ -1447,6 +1462,39 @@ mod __test {
162         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
163     }
164 
165+    #[test]
166+    fn dist_only_cross_host() {
167+        let a = INTERNER.intern_str("A");
168+        let b = INTERNER.intern_str("B");
169+        let mut build = Build::new(configure(&["B"], &[]));
170+        build.config.docs = false;
171+        build.hosts = vec![b];
172+        let mut builder = Builder::new(&build);
173+        builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
174+
175+        assert_eq!(
176+            first(builder.cache.all::<dist::Rustc>()),
177+            &[
178+                dist::Rustc {
179+                    compiler: Compiler { host: b, stage: 2 }
180+                },
181+            ]
182+        );
183+        assert_eq!(
184+            first(builder.cache.all::<compile::Rustc>()),
185+            &[
186+                compile::Rustc {
187+                    compiler: Compiler { host: a, stage: 0 },
188+                    target: a,
189+                },
190+                compile::Rustc {
191+                    compiler: Compiler { host: a, stage: 1 },
192+                    target: b,
193+                },
194+            ]
195+        );
196+    }
197+
198     #[test]
199     fn dist_with_targets_and_hosts() {
200         let build = Build::new(configure(&["B"], &["C"]));
201@@ -1488,11 +1536,11 @@ mod __test {
202             first(builder.cache.all::<dist::Std>()),
203             &[
204                 dist::Std {
205-                    compiler: Compiler { host: a, stage: 2 },
206+                    compiler: Compiler { host: a, stage: 1 },
207                     target: a,
208                 },
209                 dist::Std {
210-                    compiler: Compiler { host: a, stage: 2 },
211+                    compiler: Compiler { host: a, stage: 1 },
212                     target: b,
213                 },
214                 dist::Std {
215@@ -1537,11 +1585,11 @@ mod __test {
216             first(builder.cache.all::<dist::Std>()),
217             &[
218                 dist::Std {
219-                    compiler: Compiler { host: a, stage: 2 },
220+                    compiler: Compiler { host: a, stage: 1 },
221                     target: a,
222                 },
223                 dist::Std {
224-                    compiler: Compiler { host: a, stage: 2 },
225+                    compiler: Compiler { host: a, stage: 1 },
226                     target: b,
227                 },
228                 dist::Std {
229@@ -1588,11 +1636,11 @@ mod __test {
230             first(builder.cache.all::<dist::Std>()),
231             &[
232                 dist::Std {
233-                    compiler: Compiler { host: a, stage: 2 },
234+                    compiler: Compiler { host: a, stage: 1 },
235                     target: a,
236                 },
237                 dist::Std {
238-                    compiler: Compiler { host: a, stage: 2 },
239+                    compiler: Compiler { host: a, stage: 1 },
240                     target: b,
241                 },
242             ]
243@@ -1642,10 +1690,6 @@ mod __test {
244                     compiler: Compiler { host: a, stage: 1 },
245                     target: b,
246                 },
247-                compile::Test {
248-                    compiler: Compiler { host: a, stage: 2 },
249-                    target: b,
250-                },
251             ]
252         );
253         assert_eq!(
254@@ -1698,10 +1742,6 @@ mod __test {
255                     compiler: Compiler { host: b, stage: 2 },
256                     target: a,
257                 },
258-                compile::Rustc {
259-                    compiler: Compiler { host: a, stage: 0 },
260-                    target: b,
261-                },
262                 compile::Rustc {
263                     compiler: Compiler { host: a, stage: 1 },
264                     target: b,
265@@ -1736,10 +1776,6 @@ mod __test {
266                     compiler: Compiler { host: b, stage: 2 },
267                     target: a,
268                 },
269-                compile::Test {
270-                    compiler: Compiler { host: a, stage: 0 },
271-                    target: b,
272-                },
273                 compile::Test {
274                     compiler: Compiler { host: a, stage: 1 },
275                     target: b,
276@@ -1786,9 +1822,6 @@ mod __test {
277                 compile::Assemble {
278                     target_compiler: Compiler { host: a, stage: 1 },
279                 },
280-                compile::Assemble {
281-                    target_compiler: Compiler { host: b, stage: 1 },
282-                },
283                 compile::Assemble {
284                     target_compiler: Compiler { host: a, stage: 2 },
285                 },
286@@ -1808,10 +1841,6 @@ mod __test {
287                     compiler: Compiler { host: a, stage: 1 },
288                     target: a,
289                 },
290-                compile::Rustc {
291-                    compiler: Compiler { host: a, stage: 0 },
292-                    target: b,
293-                },
294                 compile::Rustc {
295                     compiler: Compiler { host: a, stage: 1 },
296                     target: b,
297@@ -1838,10 +1867,6 @@ mod __test {
298                     compiler: Compiler { host: b, stage: 2 },
299                     target: a,
300                 },
301-                compile::Test {
302-                    compiler: Compiler { host: a, stage: 0 },
303-                    target: b,
304-                },
305                 compile::Test {
306                     compiler: Compiler { host: a, stage: 1 },
307                     target: b,
308diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
309index 66443d4..3fd9641 100644
310--- a/src/bootstrap/compile.rs
311+++ b/src/bootstrap/compile.rs
312@@ -69,20 +69,20 @@ impl Step for Std {
313 
314         builder.ensure(StartupObjects { compiler, target });
315 
316-        if builder.force_use_stage1(compiler, target) {
317-            let from = builder.compiler(1, builder.config.build);
318+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
319+        if compiler_to_use != compiler {
320             builder.ensure(Std {
321-                compiler: from,
322+                compiler: compiler_to_use,
323                 target,
324             });
325-            builder.info(&format!("Uplifting stage1 std ({} -> {})", from.host, target));
326+            builder.info(&format!("Uplifting stage1 std ({} -> {})", compiler_to_use.host, target));
327 
328             // Even if we're not building std this stage, the new sysroot must
329             // still contain the third party objects needed by various targets.
330             copy_third_party_objects(builder, &compiler, target);
331 
332             builder.ensure(StdLink {
333-                compiler: from,
334+                compiler: compiler_to_use,
335                 target_compiler: compiler,
336                 target,
337             });
338@@ -374,15 +374,16 @@ impl Step for Test {
339             return;
340         }
341 
342-        if builder.force_use_stage1(compiler, target) {
343+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
344+        if compiler_to_use != compiler {
345             builder.ensure(Test {
346-                compiler: builder.compiler(1, builder.config.build),
347+                compiler: compiler_to_use,
348                 target,
349             });
350             builder.info(
351                 &format!("Uplifting stage1 test ({} -> {})", builder.config.build, target));
352             builder.ensure(TestLink {
353-                compiler: builder.compiler(1, builder.config.build),
354+                compiler: compiler_to_use,
355                 target_compiler: compiler,
356                 target,
357             });
358@@ -499,15 +500,16 @@ impl Step for Rustc {
359             return;
360         }
361 
362-        if builder.force_use_stage1(compiler, target) {
363+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
364+        if compiler_to_use != compiler {
365             builder.ensure(Rustc {
366-                compiler: builder.compiler(1, builder.config.build),
367+                compiler: compiler_to_use,
368                 target,
369             });
370             builder.info(&format!("Uplifting stage1 rustc ({} -> {})",
371                 builder.config.build, target));
372             builder.ensure(RustcLink {
373-                compiler: builder.compiler(1, builder.config.build),
374+                compiler: compiler_to_use,
375                 target_compiler: compiler,
376                 target,
377             });
378@@ -663,9 +665,10 @@ impl Step for CodegenBackend {
379             return;
380         }
381 
382-        if builder.force_use_stage1(compiler, target) {
383+        let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
384+        if compiler_to_use != compiler {
385             builder.ensure(CodegenBackend {
386-                compiler: builder.compiler(1, builder.config.build),
387+                compiler: compiler_to_use,
388                 target,
389                 backend,
390             });
391diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
392index 61a7705..27ac967 100644
393--- a/src/bootstrap/dist.rs
394+++ b/src/bootstrap/dist.rs
395@@ -647,7 +647,11 @@ impl Step for Std {
396 
397     fn make_run(run: RunConfig<'_>) {
398         run.builder.ensure(Std {
399-            compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
400+            compiler: run.builder.compiler_for(
401+                run.builder.top_stage,
402+                run.builder.config.build,
403+                run.target,
404+            ),
405             target: run.target,
406         });
407     }
408@@ -757,13 +761,10 @@ impl Step for Analysis {
409 
410         builder.ensure(Std { compiler, target });
411 
412-        // Package save-analysis from stage1 if not doing a full bootstrap, as the
413-        // stage2 artifacts is simply copied from stage1 in that case.
414-        let compiler = if builder.force_use_stage1(compiler, target) {
415-            builder.compiler(1, compiler.host)
416-        } else {
417-            compiler.clone()
418-        };
419+        // Find the actual compiler (handling the full bootstrap option) which
420+        // produced the save-analysis data because that data isn't copied
421+        // through the sysroot uplifting.
422+        let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
423 
424         let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
425 
426diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
427index d831d2f..401ce4e 100644
428--- a/src/bootstrap/doc.rs
429+++ b/src/bootstrap/doc.rs
430@@ -475,12 +475,7 @@ impl Step for Std {
431         builder.info(&format!("Documenting stage{} std ({})", stage, target));
432         let out = builder.doc_out(target);
433         t!(fs::create_dir_all(&out));
434-        let compiler = builder.compiler(stage, builder.config.build);
435-        let compiler = if builder.force_use_stage1(compiler, target) {
436-            builder.compiler(1, compiler.host)
437-        } else {
438-            compiler
439-        };
440+        let compiler = builder.compiler_for(stage, builder.config.build, target);
441 
442         builder.ensure(compile::Std { compiler, target });
443         let out_dir = builder.stage_out(compiler, Mode::Std)
444@@ -563,12 +558,7 @@ impl Step for Test {
445         builder.info(&format!("Documenting stage{} test ({})", stage, target));
446         let out = builder.doc_out(target);
447         t!(fs::create_dir_all(&out));
448-        let compiler = builder.compiler(stage, builder.config.build);
449-        let compiler = if builder.force_use_stage1(compiler, target) {
450-            builder.compiler(1, compiler.host)
451-        } else {
452-            compiler
453-        };
454+        let compiler = builder.compiler_for(stage, builder.config.build, target);
455 
456         // Build libstd docs so that we generate relative links
457         builder.ensure(Std { stage, target });
458@@ -632,12 +622,7 @@ impl Step for WhitelistedRustc {
459         builder.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target));
460         let out = builder.doc_out(target);
461         t!(fs::create_dir_all(&out));
462-        let compiler = builder.compiler(stage, builder.config.build);
463-        let compiler = if builder.force_use_stage1(compiler, target) {
464-            builder.compiler(1, compiler.host)
465-        } else {
466-            compiler
467-        };
468+        let compiler = builder.compiler_for(stage, builder.config.build, target);
469 
470         // Build libstd docs so that we generate relative links
471         builder.ensure(Std { stage, target });
472@@ -706,12 +691,7 @@ impl Step for Rustc {
473         t!(fs::create_dir_all(&out));
474 
475         // Get the correct compiler for this stage.
476-        let compiler = builder.compiler(stage, builder.config.build);
477-        let compiler = if builder.force_use_stage1(compiler, target) {
478-            builder.compiler(1, compiler.host)
479-        } else {
480-            compiler
481-        };
482+        let compiler = builder.compiler_for(stage, builder.config.build, target);
483 
484         if !builder.config.compiler_docs {
485             builder.info("\tskipping - compiler/librustdoc docs disabled");
486@@ -807,12 +787,7 @@ impl Step for Rustdoc {
487         t!(fs::create_dir_all(&out));
488 
489         // Get the correct compiler for this stage.
490-        let compiler = builder.compiler(stage, builder.config.build);
491-        let compiler = if builder.force_use_stage1(compiler, target) {
492-            builder.compiler(1, compiler.host)
493-        } else {
494-            compiler
495-        };
496+        let compiler = builder.compiler_for(stage, builder.config.build, target);
497 
498         if !builder.config.compiler_docs {
499             builder.info("\tskipping - compiler/librustdoc docs disabled");
500diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
501index 881bea5..39f912a 100644
502--- a/src/bootstrap/test.rs
503+++ b/src/bootstrap/test.rs
504@@ -1675,15 +1675,11 @@ impl Step for Crate {
505         builder.ensure(compile::Test { compiler, target });
506         builder.ensure(RemoteCopyLibs { compiler, target });
507 
508-        // If we're not doing a full bootstrap but we're testing a stage2 version of
509-        // libstd, then what we're actually testing is the libstd produced in
510-        // stage1. Reflect that here by updating the compiler that we're working
511-        // with automatically.
512-        let compiler = if builder.force_use_stage1(compiler, target) {
513-            builder.compiler(1, compiler.host)
514-        } else {
515-            compiler.clone()
516-        };
517+        // If we're not doing a full bootstrap but we're testing a stage2
518+        // version of libstd, then what we're actually testing is the libstd
519+        // produced in stage1. Reflect that here by updating the compiler that
520+        // we're working with automatically.
521+        let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
522 
523         let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
524         match mode {
525diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
526index 17523ae..15d52bf 100644
527--- a/src/librustc_interface/util.rs
528+++ b/src/librustc_interface/util.rs
529@@ -120,9 +120,13 @@ pub fn create_session(
530 }
531 
532 // Temporarily have stack size set to 32MB to deal with various crates with long method
533-// chains or deep syntax trees.
534+// chains or deep syntax trees, except when on Haiku
535 // FIXME(oli-obk): get https://github.com/rust-lang/rust/pull/55617 the finish line
536-const STACK_SIZE: usize = 32 * 1024 * 1024; // 32MB
537+#[cfg(not(target_os = "haiku"))]
538+const STACK_SIZE: usize = 32 * 1024 * 1024;
539+
540+#[cfg(target_os = "haiku")]
541+const STACK_SIZE: usize = 16 * 1024 * 1024;
542 
543 fn get_stack_size() -> Option<usize> {
544     // FIXME: Hacks on hacks. If the env is trying to override the stack size
545diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
546index feb15e8..653130b 100644
547--- a/src/libstd/sys/unix/thread.rs
548+++ b/src/libstd/sys/unix/thread.rs
549@@ -166,8 +166,7 @@ impl Thread {
550         unsafe {
551             let ret = libc::pthread_join(self.id, ptr::null_mut());
552             mem::forget(self);
553-            assert!(ret == 0,
554-                    "failed to join thread: {}", io::Error::from_raw_os_error(ret));
555+            debug_assert_eq!(ret, 0);
556         }
557     }
558 
559diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs
560index 518eccf..2aa5818 100644
561--- a/src/libstd/sys/windows/c.rs
562+++ b/src/libstd/sys/windows/c.rs
563@@ -268,7 +268,6 @@ pub const FILE_END: DWORD = 2;
564 
565 pub const WAIT_OBJECT_0: DWORD = 0x00000000;
566 pub const WAIT_TIMEOUT: DWORD = 258;
567-pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
568 
569 #[cfg(target_env = "msvc")]
570 #[cfg(feature = "backtrace")]
571diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs
572index 1b0a811..8c2bf15 100644
573--- a/src/libstd/sys/windows/thread.rs
574+++ b/src/libstd/sys/windows/thread.rs
575@@ -59,11 +59,7 @@ impl Thread {
576     }
577 
578     pub fn join(self) {
579-        let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) };
580-        if rc == c::WAIT_FAILED {
581-            panic!("failed to join on thread: {}",
582-                   io::Error::last_os_error());
583-        }
584+        unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE); }
585     }
586 
587     pub fn yield_now() {
588diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
589index cb50797..5a0850e 100644
590--- a/src/libstd/thread/mod.rs
591+++ b/src/libstd/thread/mod.rs
592@@ -1436,11 +1436,6 @@ impl<T> JoinHandle<T> {
593     /// [`panic`]: ../../std/macro.panic.html
594     /// [atomic memory orderings]: ../../std/sync/atomic/index.html
595     ///
596-    /// # Panics
597-    ///
598-    /// This function may panic on some platforms if a thread attempts to join
599-    /// itself or otherwise may create a deadlock with joining threads.
600-    ///
601     /// # Examples
602     ///
603     /// ```
604diff --git a/src/llvm-project/llvm/lib/Support/Unix/Signals.inc b/src/llvm-project/llvm/lib/Support/Unix/Signals.inc
605index ad88d5e..9d320b7 100644
606--- a/src/llvm-project/llvm/lib/Support/Unix/Signals.inc
607+++ b/src/llvm-project/llvm/lib/Support/Unix/Signals.inc
608@@ -47,7 +47,9 @@
609 #include "llvm/Support/raw_ostream.h"
610 #include <algorithm>
611 #include <string>
612+#define _BSD_SOURCE
613 #include <sysexits.h>
614+#undef _BSD_SOURCE
615 #ifdef HAVE_BACKTRACE
616 # include BACKTRACE_HEADER         // For backtrace().
617 #endif
618-- 
6192.19.0
620
621