Skip to content

Commit

Permalink
ubuntu 22 cryptonight use O2
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Oct 25, 2023
1 parent e191f32 commit 6a08426
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,5 @@ starcoin-vm-runtime.debug = 1
[profile.release.package."*"]
debug = false

[profile.release.package.cryptonight-rs]
opt-level = 2
#[profile.release.package.cryptonight-rs]
#opt-level = 2
1 change: 1 addition & 0 deletions consensus/cryptonight-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name = "bench"

[build-dependencies]
cc = "1.0"
os_info = { version = "3", default-features = false }

[dependencies]
libc = { workspace = true }
Expand Down
17 changes: 16 additions & 1 deletion consensus/cryptonight-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ fn main() {
config.flag("-maes").flag("-msse2");
}
if target_os.contains("linux") || target_os.contains("macos") {
config.flag("-fexceptions").flag("-std=gnu99");
let info = os_info::get();
let opt_level = env::var("OPT_LEVEL").expect("fetching OPT_LEVEL");
if info.os_type() == os_info::Type::Ubuntu
&& info.version() == &os_info::Version::Custom("22.04".into())
{
if opt_level == "3" {
config.flag("-O2").flag("-fexceptions").flag("-std=gnu99");
} else {
config.flag("-fexceptions").flag("-std=gnu99");
}
} else {
config
.flag("-Ofast")
.flag("-fexceptions")
.flag("-std=gnu99");
}
}
config.compile("cryptonight");
}

0 comments on commit 6a08426

Please sign in to comment.