xtask: ensure loader is build with lto,codegenunits=1

If the loader is not build with these two parameters, then Weird Things
happen with the font table.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-07-04 22:33:38 +08:00
parent 4d416ce4c6
commit c1e585c37c

View file

@ -876,6 +876,14 @@ fn build_hw_image(
pkg_path.push(pkg);
init.push(pkg_path);
}
let existing_lto = std::env::var("CARGO_PROFILE_RELEASE_LTO")
.map(|v| Some(v))
.unwrap_or(None);
let existing_codegen_units = std::env::var("CARGO_PROFILE_RELEASE_CODEGEN_UNITS")
.map(|v| Some(v))
.unwrap_or(None);
std::env::set_var("CARGO_PROFILE_RELEASE_LTO", "true");
std::env::set_var("CARGO_PROFILE_RELEASE_CODEGEN_UNITS", "1");
let mut loader = build(
&["loader"],
debug,
@ -884,6 +892,12 @@ fn build_hw_image(
None,
loader_features,
)?;
if let Some(existing) = existing_lto {
std::env::set_var("CARGO_PROFILE_RELEASE_LTO", existing);
}
if let Some(existing) = existing_codegen_units {
std::env::set_var("CARGO_PROFILE_RELEASE_CODEGEN_UNITS", existing);
}
loader.push(PathBuf::from("loader"));
let output_bundle = create_image(&kernel, &init, debug, MemorySpec::SvdFile(svd_file))?;