Skip to content

Commit

Permalink
fix(build.rs): always compile staticlib with release profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Mar 25, 2024
1 parent da2fc5c commit cccd970
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
8 changes: 2 additions & 6 deletions rftrace/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ fn build_backend() {
// Get envvars from cargo
let out_dir = env::var("OUT_DIR").unwrap();
let full_target_dir = format!("{}/target_static", out_dir);
let profile = env::var("PROFILE").expect("PROFILE was not set");

let target = "x86_64-unknown-none";

Expand Down Expand Up @@ -71,10 +70,7 @@ fn build_backend() {
"-Zbuild-std-features=compiler-builtins-mem",
]);

// Compile staticlib as release if included in release build.
if profile == "release" {
cmd.arg("--release");
}
cmd.arg("--release");

// Ensure rustflags does NOT contain instrument-mcount!
let rustflags = env::var("RUSTFLAGS").unwrap_or_default();
Expand All @@ -96,7 +92,7 @@ fn build_backend() {
assert!(status.success(), "Unable to build tracer's static lib!");
println!("Sub-cargo successful!");

let dist_dir = format!("{}/{}/{}", &full_target_dir, &target, &profile);
let dist_dir = format!("{}/{}/release", &full_target_dir, &target);

retain_symbols(
Path::new(&format!("{}/librftrace_backend.a", &dist_dir)),
Expand Down
3 changes: 0 additions & 3 deletions rftrace/staticlib/Cargo.nottoml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ path = "../src/lib.rs"

[profile.dev]
panic = "abort"
# we have to build with at least opt-level 1. Might aswell do always 3, since mcount() is in the hotpath!
opt-level = 3

[profile.release]
panic = "abort"
opt-level = 3

0 comments on commit cccd970

Please sign in to comment.