Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Add BPF rustc option to reduce the optimizations to safer level (backport #17590) #17594

Merged
merged 1 commit into from
May 31, 2021
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
22 changes: 11 additions & 11 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,19 +1269,19 @@ fn assert_instruction_count() {
#[cfg(feature = "bpf_rust")]
{
programs.extend_from_slice(&[
("solana_bpf_rust_128bit", 584),
("solana_bpf_rust_alloc", 5072),
("solana_bpf_rust_custom_heap", 367),
("solana_bpf_rust_128bit", 572),
("solana_bpf_rust_alloc", 8906),
("solana_bpf_rust_custom_heap", 539),
("solana_bpf_rust_dep_crate", 2),
("solana_bpf_rust_external_spend", 336),
("solana_bpf_rust_iter", 279),
("solana_bpf_rust_many_args", 191),
("solana_bpf_rust_mem", 1670),
("solana_bpf_rust_noop", 324),
("solana_bpf_rust_external_spend", 521),
("solana_bpf_rust_iter", 724),
("solana_bpf_rust_many_args", 237),
("solana_bpf_rust_mem", 2297),
("solana_bpf_rust_noop", 495),
("solana_bpf_rust_param_passing", 46),
("solana_bpf_rust_rand", 327),
("solana_bpf_rust_sanity", 595),
("solana_bpf_rust_sha", 22417),
("solana_bpf_rust_rand", 498),
("solana_bpf_rust_sanity", 917),
("solana_bpf_rust_sha", 29099),
]);
}

Expand Down
2 changes: 2 additions & 0 deletions sdk/bpf/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export CC="$bpf_sdk/dependencies/bpf-tools/llvm/bin/clang"
export AR="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-ar"
export OBJDUMP="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objdump"
export OBJCOPY="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objcopy"

export RUSTFLAGS="-C lto=no -C opt-level=2"
4 changes: 3 additions & 1 deletion sdk/cargo-build-bpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m
env::set_var("AR", llvm_bin.join("llvm-ar"));
env::set_var("OBJDUMP", llvm_bin.join("llvm-objdump"));
env::set_var("OBJCOPY", llvm_bin.join("llvm-objcopy"));

let mut rust_flags = String::from("-C lto=no");
rust_flags.push_str(" -C opt-level=2");
env::set_var("RUSTFLAGS", rust_flags);
let cargo_build = PathBuf::from("cargo");
let mut cargo_build_args = vec![
"+bpf",
Expand Down