Skip to content

Commit 5a26976

Browse files
authored
The compiler_builtins library is now a crates.io dependency of alloc (#23)
1 parent 2f53ecc commit 5a26976

File tree

1 file changed

+8
-45
lines changed

1 file changed

+8
-45
lines changed

src/sysroot.rs

+8-45
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ fn build(
4545
util::mkdir(&dst)?;
4646

4747
build_libcore(cmode, &ctoml, home, src, &dst, verbose)?;
48-
build_libcompiler_builtins(cmode, &ctoml, home, src, &dst, config, verbose)?;
49-
build_liballoc(cmode, &ctoml, home, src, &dst, verbose)?;
48+
build_liballoc(cmode, &ctoml, home, src, &dst, config, verbose)?;
5049

5150
// Create hash file
5251
util::write(&rustlib.parent().join(".hash"), &hash.to_string())?;
@@ -114,8 +113,7 @@ fn build_crate(
114113
}
115114

116115
cmd.arg("--");
117-
cmd.arg("--sysroot");
118-
cmd.arg(home.display().to_string());
116+
cmd.env("RUSTFLAGS", &format!("--sysroot {}", home.display()));
119117
cmd.arg("-Z");
120118
cmd.arg("force-unstable-if-unmarked");
121119

@@ -162,7 +160,7 @@ version = "0.0.0"
162160
build_crate("core", stoml, cmode, ctoml, home, dst, verbose)
163161
}
164162

165-
fn build_libcompiler_builtins(
163+
fn build_liballoc(
166164
cmode: &CompilationMode,
167165
ctoml: &cargo::Toml,
168166
home: &Home,
@@ -174,53 +172,18 @@ fn build_libcompiler_builtins(
174172
const TOML: &'static str = r#"
175173
[package]
176174
authors = ["The Rust Project Developers"]
177-
name = "sysroot"
175+
name = "alloc"
178176
version = "0.0.0"
177+
178+
[dependencies.compiler_builtins]
179+
version = "0.1.0"
179180
"#;
180181

181182
let mut stoml = TOML.to_owned();
182183

183-
let path = src.path()
184-
.join("libcompiler_builtins")
185-
.display()
186-
.to_string();
187-
let mut compiler_builtin_dep = Table::new();
188-
compiler_builtin_dep.insert("path".to_owned(), Value::String(path));
189-
190-
let mut features = vec![Value::String("compiler-builtins".to_owned())];
191184
if config.memcpy {
192-
features.push(Value::String("mem".to_owned()));
185+
stoml.push_str("features = [\"mem\"]\n");
193186
}
194-
compiler_builtin_dep.insert("default-features".to_owned(), Value::Boolean(false));
195-
compiler_builtin_dep.insert("features".to_owned(), Value::Array(features));
196-
let mut deps = Table::new();
197-
deps.insert(
198-
"compiler_builtins".to_owned(),
199-
Value::Table(compiler_builtin_dep),
200-
);
201-
let mut map = Table::new();
202-
map.insert("dependencies".to_owned(), Value::Table(deps));
203-
stoml.push_str(&Value::Table(map).to_string());
204-
205-
build_crate("compiler_builtins", stoml, cmode, ctoml, home, dst, verbose)
206-
}
207-
208-
fn build_liballoc(
209-
cmode: &CompilationMode,
210-
ctoml: &cargo::Toml,
211-
home: &Home,
212-
src: &Src,
213-
dst: &Path,
214-
verbose: bool,
215-
) -> Result<()> {
216-
const TOML: &'static str = r#"
217-
[package]
218-
authors = ["The Rust Project Developers"]
219-
name = "alloc"
220-
version = "0.0.0"
221-
"#;
222-
223-
let mut stoml = TOML.to_owned();
224187

225188
let path = src.path().join("liballoc/lib.rs").display().to_string();
226189
let mut map = Table::new();

0 commit comments

Comments
 (0)