Skip to content

Commit 8394685

Browse files
authored
Auto merge of #36441 - alexcrichton:rustbuild-target, r=brson
rustbuild: Fix cross-compiles to MinGW on Linux Closes #36290 Closes #36291
2 parents 89500e9 + 5841678 commit 8394685

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

src/bootstrap/compile.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
128128
return
129129
}
130130
let compiler = Compiler::new(0, &build.config.build);
131-
let compiler = build.compiler_path(&compiler);
131+
let compiler_path = build.compiler_path(&compiler);
132132

133133
for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
134134
let file = t!(file);
135-
build.run(Command::new(&compiler)
136-
.arg("--emit=obj")
137-
.arg("--out-dir").arg(into)
138-
.arg(file.path()));
135+
let mut cmd = Command::new(&compiler_path);
136+
build.add_bootstrap_key(&compiler, &mut cmd);
137+
build.run(cmd.arg("--target").arg(target)
138+
.arg("--emit=obj")
139+
.arg("--out-dir").arg(into)
140+
.arg(file.path()));
139141
}
140142

141143
for obj in ["crt2.o", "dllcrt2.o"].iter() {

src/rtstartup/rsbegin.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@
2222
// object (usually called `crtX.o), which then invokes initialization callbacks
2323
// of other runtime components (registered via yet another special image section).
2424

25+
#![feature(no_core, lang_items)]
2526
#![crate_type="rlib"]
26-
#![no_std]
27+
#![no_core]
2728
#![allow(non_camel_case_types)]
2829

30+
#[lang = "sized"]
31+
trait Sized {}
32+
#[lang = "sync"]
33+
trait Sync {}
34+
#[lang = "copy"]
35+
trait Copy {}
36+
impl<T> Sync for T {}
37+
2938
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
3039
pub mod eh_frames {
3140
#[no_mangle]

src/rtstartup/rsend.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010

1111
// See rsbegin.rs for details.
1212

13+
#![feature(no_core, lang_items)]
1314
#![crate_type="rlib"]
14-
#![no_std]
15+
#![no_core]
16+
17+
#[lang = "sized"]
18+
trait Sized {}
19+
#[lang = "sync"]
20+
trait Sync {}
21+
impl<T> Sync for T {}
1522

1623
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
1724
pub mod eh_frames {

src/rustc/std_shim/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rustc/std_shim/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ debug-assertions = false
4141

4242
[dependencies]
4343
std = { path = "../../libstd" }
44+
core = { path = "../../libcore" }
4445

4546
# Reexport features from std
4647
[features]

src/rustc/std_shim/lib.rs

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

1111
// See comments in Cargo.toml for why this exists
12+
13+
// There's a bug right now where if we pass --extern std=... and we're cross
14+
// compiling then this doesn't work with `#[macro_use] extern crate std;`. Work
15+
// around this by not having `#[macro_use] extern crate std;`
16+
#![no_std]
17+
extern crate std;

0 commit comments

Comments
 (0)