Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reduce dev opt-level #88

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ aarch64 = "0.0.7"
cc = "1.0"
nasm-rs = "0.2"

[profile.dev]
opt-level = 1 # `opt-level = 0` makes bootloader to large for bootstrapping
# TODO: Use cargo's `opt-level = 0` instead of this:
# https://github.com/hermitcore/rusty-loader/issues/45
[profile.x86_64-dev]
inherits = "dev"

[profile.x86_64-dev.package]
goblin = { opt-level = 1 }
rusty-loader = { opt-level = 1 }

[profile.release]
strip = "debuginfo"
Expand Down
28 changes: 20 additions & 8 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ impl flags::Build {
arch => bail!("Unsupported arch: {arch}"),
};

// TODO: Use cargo's `opt-level = 0` instead of this:
// https://github.com/hermitcore/rusty-loader/issues/45
if self.profile() == "x86_64-dev" {
rustflags.push("-Cdebug-assertions=y");
rustflags.push("-Clto=n");
}

Ok(rustflags.join("\x1f"))
}

Expand All @@ -88,10 +95,7 @@ impl flags::Build {
}

fn profile_args(&self) -> Vec<&str> {
match self.profile.as_deref() {
Some(profile) => vec!["--profile", profile],
None => vec![],
}
vec!["--profile", self.profile()]
}

fn convert_object(&self) -> Result<()> {
Expand All @@ -112,9 +116,17 @@ impl flags::Build {
}

fn profile(&self) -> &str {
self.profile
.as_deref()
.unwrap_or(if self.release { "release" } else { "dev" })
let profile =
self.profile
.as_deref()
.unwrap_or(if self.release { "release" } else { "dev" });

// TODO: Use cargo's `opt-level = 0` instead of this:
// https://github.com/hermitcore/rusty-loader/issues/45
match profile {
"dev" if self.arch == "x86_64" => "x86_64-dev",
profile => profile,
}
}

fn target_dir(&self) -> &Path {
Expand All @@ -137,7 +149,7 @@ impl flags::Build {
let mut out_dir = self.target_dir().to_path_buf();
out_dir.push(&self.arch);
out_dir.push(match self.profile() {
"dev" => "debug",
"dev" | "x86_64-dev" => "debug",
profile => profile,
});
out_dir
Expand Down