mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Also build host for size when using --opt-size
This commit is contained in:
parent
69b4e78ac7
commit
ec411b7a62
1 changed files with 22 additions and 10 deletions
|
@ -137,6 +137,8 @@ pub fn build_zig_host_native(
|
|||
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
|
@ -231,6 +233,8 @@ pub fn build_zig_host_native(
|
|||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
|
@ -282,6 +286,8 @@ pub fn build_zig_host_wasm32(
|
|||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.args(&["-O", "ReleaseSafe"]);
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.args(&["-O", "ReleaseSmall"]);
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
|
@ -317,7 +323,9 @@ pub fn build_c_host_native(
|
|||
command.args(&["-fPIC", "-c"]);
|
||||
}
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O2");
|
||||
command.arg("-O3");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-Os");
|
||||
}
|
||||
command.output().unwrap()
|
||||
}
|
||||
|
@ -351,6 +359,8 @@ pub fn build_swift_host_native(
|
|||
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-Osize");
|
||||
}
|
||||
|
||||
command.output().unwrap()
|
||||
|
@ -456,18 +466,18 @@ pub fn rebuild_host(
|
|||
} else if cargo_host_src.exists() {
|
||||
// Compile and link Cargo.toml, if it exists
|
||||
let cargo_dir = host_input_path.parent().unwrap();
|
||||
let cargo_out_dir =
|
||||
cargo_dir
|
||||
.join("target")
|
||||
.join(if matches!(opt_level, OptLevel::Optimize) {
|
||||
"release"
|
||||
} else {
|
||||
"debug"
|
||||
});
|
||||
let cargo_out_dir = cargo_dir.join("target").join(
|
||||
if matches!(opt_level, OptLevel::Optimize | OptLevel::Size) {
|
||||
"release"
|
||||
} else {
|
||||
"debug"
|
||||
},
|
||||
);
|
||||
|
||||
let mut command = Command::new("cargo");
|
||||
command.arg("build").current_dir(cargo_dir);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
// Rust doesn't expose size without editing the cargo.toml. Instead just use release.
|
||||
if matches!(opt_level, OptLevel::Optimize | OptLevel::Size) {
|
||||
command.arg("--release");
|
||||
}
|
||||
let source_file = if shared_lib_path.is_some() {
|
||||
|
@ -533,6 +543,8 @@ pub fn rebuild_host(
|
|||
]);
|
||||
if matches!(opt_level, OptLevel::Optimize) {
|
||||
command.arg("-O");
|
||||
} else if matches!(opt_level, OptLevel::Size) {
|
||||
command.arg("-C opt-level=s");
|
||||
}
|
||||
let output = command.output().unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue