Skip to content

Commit

Permalink
Strip source paths from release binaries (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth authored Aug 12, 2024
1 parent 9c68df9 commit da66721
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
8 changes: 7 additions & 1 deletion aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_no_asm, option_env, target, target_arch,
target_env, target_os, target_underscored, target_vendor, OutputLibType,
target_env, target_family, target_os, target_underscored, target_vendor, OutputLibType,
};
use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -102,6 +102,12 @@ impl CmakeBuilder {
cmake_cfg.define("CMAKE_BUILD_TYPE", "relwithdebinfo");
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "release");
if target_family() == "unix" || target_env() == "gnu" {
cmake_cfg.cflag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}
} else if target_os() == "windows" {
// The Windows/FIPS build rejects "debug" profile
Expand Down
4 changes: 4 additions & 0 deletions aws-lc-fips-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ fn emit_warning(message: &str) {
println!("cargo:warning={message}");
}

fn target_family() -> String {
cargo_env("CARGO_CFG_TARGET_FAMILY")
}

fn target_os() -> String {
cargo_env("CARGO_CFG_TARGET_OS")
}
Expand Down
12 changes: 12 additions & 0 deletions aws-lc-sys/builder/cc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ impl CcBuilder {
.define("BORINGSSL_IMPLEMENTATION", "1")
.define("BORINGSSL_PREFIX", prefix.as_str());
}

let opt_level = cargo_env("OPT_LEVEL");
match opt_level.as_str() {
"0" | "1" | "2" => {}
_ => {
cc_build.flag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}

self.add_includes(&mut cc_build);
cc_build
}
Expand Down
11 changes: 9 additions & 2 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, option_env, target,
target_arch, target_env, target_os, target_underscored, target_vendor, OutputLibType,
target_arch, target_env, target_family, target_os, target_underscored, target_vendor,
OutputLibType,
};
use std::env;
use std::ffi::OsString;
Expand Down Expand Up @@ -85,12 +86,18 @@ impl CmakeBuilder {
cmake_cfg.define("BUILD_SHARED_LIBS", "0");
}

let opt_level = env::var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
let opt_level = cargo_env("OPT_LEVEL");
if opt_level.ne("0") {
if opt_level.eq("1") || opt_level.eq("2") {
cmake_cfg.define("CMAKE_BUILD_TYPE", "relwithdebinfo");
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "release");
if target_family() == "unix" || target_env() == "gnu" {
cmake_cfg.cflag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "debug");
Expand Down
4 changes: 4 additions & 0 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ fn emit_warning(message: &str) {
println!("cargo:warning={message}");
}

fn target_family() -> String {
cargo_env("CARGO_CFG_TARGET_FAMILY")
}

fn target_os() -> String {
cargo_env("CARGO_CFG_TARGET_OS")
}
Expand Down

0 comments on commit da66721

Please sign in to comment.