Remove O2 option for compiling BPF programs (#17865)
rustc default compiler optimization level is O3. This change removes the option that overrides the default optimization level, because it is safe to do so. The code generation is incorrect in some cases because of link-time optimizations, which remain disabled for compiling BPF programs. In addition, this commit updates the expected instruction counts for assert_instruction_count test.
This commit is contained in:
parent
269d995832
commit
2fe211c5e0
|
@ -1277,11 +1277,11 @@ fn assert_instruction_count() {
|
||||||
("alloc", 1137),
|
("alloc", 1137),
|
||||||
("bpf_to_bpf", 13),
|
("bpf_to_bpf", 13),
|
||||||
("multiple_static", 8),
|
("multiple_static", 8),
|
||||||
("noop", 42),
|
("noop", 5),
|
||||||
("noop++", 42),
|
("noop++", 5),
|
||||||
("relative_call", 10),
|
("relative_call", 10),
|
||||||
("sanity", 174),
|
("sanity", 169),
|
||||||
("sanity++", 174),
|
("sanity++", 168),
|
||||||
("sha", 1040),
|
("sha", 1040),
|
||||||
("struct_pass", 8),
|
("struct_pass", 8),
|
||||||
("struct_ret", 22),
|
("struct_ret", 22),
|
||||||
|
@ -1291,19 +1291,19 @@ fn assert_instruction_count() {
|
||||||
{
|
{
|
||||||
programs.extend_from_slice(&[
|
programs.extend_from_slice(&[
|
||||||
("solana_bpf_rust_128bit", 584),
|
("solana_bpf_rust_128bit", 584),
|
||||||
("solana_bpf_rust_alloc", 8906),
|
("solana_bpf_rust_alloc", 7082),
|
||||||
("solana_bpf_rust_custom_heap", 539),
|
("solana_bpf_rust_custom_heap", 522),
|
||||||
("solana_bpf_rust_dep_crate", 2),
|
("solana_bpf_rust_dep_crate", 2),
|
||||||
("solana_bpf_rust_external_spend", 521),
|
("solana_bpf_rust_external_spend", 504),
|
||||||
("solana_bpf_rust_iter", 724),
|
("solana_bpf_rust_iter", 724),
|
||||||
("solana_bpf_rust_many_args", 237),
|
("solana_bpf_rust_many_args", 233),
|
||||||
("solana_bpf_rust_mem", 3166),
|
("solana_bpf_rust_mem", 3096),
|
||||||
("solana_bpf_rust_membuiltins", 4069),
|
("solana_bpf_rust_membuiltins", 4065),
|
||||||
("solana_bpf_rust_noop", 495),
|
("solana_bpf_rust_noop", 478),
|
||||||
("solana_bpf_rust_param_passing", 46),
|
("solana_bpf_rust_param_passing", 46),
|
||||||
("solana_bpf_rust_rand", 498),
|
("solana_bpf_rust_rand", 481),
|
||||||
("solana_bpf_rust_sanity", 917),
|
("solana_bpf_rust_sanity", 873),
|
||||||
("solana_bpf_rust_sha", 32384),
|
("solana_bpf_rust_sha", 32295),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,4 @@ export AR="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-ar"
|
||||||
export OBJDUMP="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objdump"
|
export OBJDUMP="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objdump"
|
||||||
export OBJCOPY="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objcopy"
|
export OBJCOPY="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objcopy"
|
||||||
|
|
||||||
export RUSTFLAGS="-C lto=no -C opt-level=2"
|
export RUSTFLAGS="-C lto=no"
|
||||||
|
|
|
@ -383,9 +383,7 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m
|
||||||
env::set_var("AR", llvm_bin.join("llvm-ar"));
|
env::set_var("AR", llvm_bin.join("llvm-ar"));
|
||||||
env::set_var("OBJDUMP", llvm_bin.join("llvm-objdump"));
|
env::set_var("OBJDUMP", llvm_bin.join("llvm-objdump"));
|
||||||
env::set_var("OBJCOPY", llvm_bin.join("llvm-objcopy"));
|
env::set_var("OBJCOPY", llvm_bin.join("llvm-objcopy"));
|
||||||
let mut rust_flags = String::from("-C lto=no");
|
env::set_var("RUSTFLAGS", "-C lto=no");
|
||||||
rust_flags.push_str(" -C opt-level=2");
|
|
||||||
env::set_var("RUSTFLAGS", rust_flags);
|
|
||||||
let cargo_build = PathBuf::from("cargo");
|
let cargo_build = PathBuf::from("cargo");
|
||||||
let mut cargo_build_args = vec![
|
let mut cargo_build_args = vec![
|
||||||
"+bpf",
|
"+bpf",
|
||||||
|
|
Loading…
Reference in New Issue