From 92e56e048bbb925ea3e8fde2e17b9fb10a961bb2 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sun, 3 May 2020 18:00:09 +0200
Subject: [PATCH 07/10] Link stage2 tools dynamically to libstd

Replaces an older patch by Samuel Holland. The RUSTC_NO_PREFER_DYNAMIC
env var was removed and replaced with the following logic in builder.rs.

The idea for this patch is to link stage2 tools dynamically as these will
be distributed (if built). Intermediate tools from previous stages will
be statically linked for convenience.

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
 src/bootstrap/builder.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 3d724c148422..1dd53d5fa696 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1404,6 +1404,8 @@ impl<'a> Builder<'a> {
         // linking all deps statically into the dylib.
         if matches!(mode, Mode::Std | Mode::Rustc) {
             rustflags.arg("-Cprefer-dynamic");
+        } else if stage >= 2 {
+            rustflags.arg("-Cprefer-dynamic");
         }
 
         // When building incrementally we default to a lower ThinLTO import limit
-- 
2.30.0

