Skip to content

Commit 1bb89f1

Browse files
committed
rustc_driver: get rid of extra thread on Windows
1 parent e85c922 commit 1bb89f1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/librustc_driver/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,11 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
14881488
}
14891489
};
14901490

1491-
#[cfg(not(unix))]
1491+
// We set the stack size at link time. See src/rustc/rustc.rs.
1492+
#[cfg(windows)]
1493+
let spawn_thread = false;
1494+
1495+
#[cfg(not(any(windows,unix)))]
14921496
let spawn_thread = true;
14931497

14941498
// The or condition is added from backward compatibility.

src/rustc/rustc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
// except according to those terms.
1010

1111
#![feature(rustc_private)]
12+
#![feature(link_args)]
13+
14+
// Set the stack size at link time on Windows. See rustc_driver::in_rustc_thread
15+
// for the rationale.
16+
#[cfg_attr(all(windows, target_env = "msvc"), link_args = "/STACK:16777216")]
17+
// We only build for msvc and gnu now, but we use a exhaustive condition here
18+
// so we can expect either the stack size to be set or the build fails.
19+
#[cfg_attr(all(windows, not(target_env = "msvc")), link_args = "-Wl,--stack,16777216")]
20+
extern {}
1221

1322
extern crate rustc_driver;
1423

0 commit comments

Comments
 (0)