Pull in LLVM with stack location fixes (#5732)
This commit is contained in:
parent
57f778bcdb
commit
50214f059f
|
@ -76,7 +76,7 @@ fn main() {
|
|||
"external_spend",
|
||||
"noop",
|
||||
"panic",
|
||||
"stack_bug",
|
||||
"param_passing",
|
||||
"tick_height",
|
||||
];
|
||||
for program in rust_programs.iter() {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# Note: This crate must be built using build.sh
|
||||
|
||||
[package]
|
||||
name = "solana-bpf-rust-stack-bug"
|
||||
name = "solana-bpf-rust-param-passing"
|
||||
version = "0.19.0-pre0"
|
||||
description = "Solana BPF iter program written in Rust"
|
||||
description = "Solana BPF test program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
|
@ -14,7 +14,7 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.19.0-pre0" }
|
||||
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.19.0-pre0" }
|
||||
solana-bpf-rust-stack-bug-dep = { path = "../stack_bug_dep", version = "0.19.0-pre0" }
|
||||
solana-bpf-rust-param-passing-dep = { path = "../param_passing_dep", version = "0.19.0-pre0" }
|
||||
|
||||
[dev_dependencies]
|
||||
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/rust-test", version = "0.19.0-pre0" }
|
||||
|
@ -24,4 +24,4 @@ members = []
|
|||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
name = "solana_bpf_rust_stack_bug"
|
||||
name = "solana_bpf_rust_param_passing"
|
|
@ -0,0 +1,28 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_bpf_rust_param_passing_dep::{Data, TestDep};
|
||||
use solana_sdk_bpf_utils::info;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn entrypoint(_input: *mut u8) -> bool {
|
||||
let array = [0xA, 0xB, 0xC, 0xD, 0xE, 0xF];
|
||||
let data = Data {
|
||||
twentyone: 21u64,
|
||||
twentytwo: 22u64,
|
||||
twentythree: 23u64,
|
||||
twentyfour: 24u64,
|
||||
twentyfive: 25u32,
|
||||
array: &array,
|
||||
};
|
||||
|
||||
let test_dep = TestDep::new(&data, 1, 2, 3, 4, 5);
|
||||
info!(0, 0, 0, 0, test_dep.thirty);
|
||||
test_dep.thirty == 30
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
# Note: This crate must be built using build.sh
|
||||
|
||||
[package]
|
||||
name = "solana-bpf-rust-stack-bug-dep"
|
||||
name = "solana-bpf-rust-param-passing-dep"
|
||||
version = "0.19.0-pre0"
|
||||
description = "Solana BPF program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
|
@ -0,0 +1,26 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
pub struct Data<'a> {
|
||||
pub twentyone: u64,
|
||||
pub twentytwo: u64,
|
||||
pub twentythree: u64,
|
||||
pub twentyfour: u64,
|
||||
pub twentyfive: u32,
|
||||
pub array: &'a [u8],
|
||||
}
|
||||
|
||||
pub struct TestDep {
|
||||
pub thirty: u32,
|
||||
}
|
||||
impl<'a> TestDep {
|
||||
pub fn new(data: &Data<'a>, _one: u64, _two: u64, _three: u64, _four: u64, five: u64) -> Self {
|
||||
Self {
|
||||
thirty: data.twentyfive + five as u32,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
#[cfg(not(test))]
|
||||
extern crate solana_sdk_bpf_no_std;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use solana_bpf_rust_stack_bug_dep::{InitPollData, PollData};
|
||||
use solana_sdk_bpf_utils::entrypoint;
|
||||
use solana_sdk_bpf_utils::entrypoint::{SolClusterInfo, SolKeyedAccount};
|
||||
use solana_sdk_bpf_utils::info;
|
||||
|
||||
entrypoint!(process_instruction);
|
||||
fn process_instruction(_ka: &mut [SolKeyedAccount], _info: &SolClusterInfo, _data: &[u8]) -> bool {
|
||||
let header = vec![1u8; 6];
|
||||
let option_a = vec![1u8; 1];
|
||||
let option_b = vec![1u8; 1];
|
||||
let init_poll = InitPollData {
|
||||
timeout: 10u32,
|
||||
header_len: 6,
|
||||
header: &header,
|
||||
option_a_len: 1,
|
||||
option_a: &option_a,
|
||||
option_b_len: 1,
|
||||
option_b: &option_b,
|
||||
};
|
||||
|
||||
let key1 = [1u8; 32];
|
||||
let key2 = [1u8; 32];
|
||||
let key3 = [1u8; 32];
|
||||
let poll_data = PollData::init(init_poll, &key1, &key2, &key3, 5000);
|
||||
poll_data.to_bytes();
|
||||
|
||||
info!("Success");
|
||||
true
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
extern crate alloc;
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use solana_sdk_bpf_utils::entrypoint::SolPubkey;
|
||||
|
||||
pub struct InitPollData<'a> {
|
||||
pub timeout: u32,
|
||||
pub header_len: u32,
|
||||
pub header: &'a [u8],
|
||||
pub option_a_len: u32,
|
||||
pub option_a: &'a [u8],
|
||||
pub option_b_len: u32,
|
||||
pub option_b: &'a [u8],
|
||||
}
|
||||
|
||||
pub struct PollData<'a> {
|
||||
pub creator_key: &'a SolPubkey,
|
||||
pub last_block: u64,
|
||||
pub header_len: u32,
|
||||
pub header: &'a [u8],
|
||||
pub option_a: PollOptionData<'a>,
|
||||
pub option_b: PollOptionData<'a>,
|
||||
}
|
||||
|
||||
impl<'a> PollData<'a> {
|
||||
pub fn length(&self) -> usize {
|
||||
(32 + 8 + 4 + self.header_len) as usize + self.option_a.length() + self.option_b.length()
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = Vec::with_capacity(self.length());
|
||||
bytes.extend_from_slice(self.creator_key);
|
||||
bytes.extend_from_slice(&self.last_block.to_be_bytes());
|
||||
bytes.extend_from_slice(&self.header_len.to_be_bytes());
|
||||
bytes.extend_from_slice(self.header);
|
||||
bytes.extend(self.option_a.to_bytes().into_iter());
|
||||
bytes.extend(self.option_b.to_bytes().into_iter());
|
||||
bytes
|
||||
}
|
||||
|
||||
pub fn init(
|
||||
init: InitPollData<'a>,
|
||||
creator_key: &'a SolPubkey,
|
||||
tally_a_key: &'a SolPubkey,
|
||||
tally_b_key: &'a SolPubkey,
|
||||
slot: u64,
|
||||
) -> Self {
|
||||
assert_eq!(init.timeout, 10);
|
||||
Self {
|
||||
creator_key,
|
||||
last_block: slot + u64::from(init.timeout),
|
||||
header_len: init.header_len,
|
||||
header: init.header,
|
||||
option_a: PollOptionData {
|
||||
text_len: init.option_a_len,
|
||||
text: init.option_a,
|
||||
tally_key: tally_a_key,
|
||||
quantity: 0,
|
||||
},
|
||||
option_b: PollOptionData {
|
||||
text_len: init.option_b_len,
|
||||
text: init.option_b,
|
||||
tally_key: tally_b_key,
|
||||
quantity: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PollOptionData<'a> {
|
||||
pub text_len: u32,
|
||||
pub text: &'a [u8],
|
||||
pub tally_key: &'a SolPubkey,
|
||||
pub quantity: u64,
|
||||
}
|
||||
|
||||
impl<'a> PollOptionData<'a> {
|
||||
pub fn length(&self) -> usize {
|
||||
(4 + self.text_len + 32 + 8) as usize
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = Vec::with_capacity(self.length());
|
||||
bytes.extend_from_slice(&self.text_len.to_be_bytes());
|
||||
bytes.extend_from_slice(self.text);
|
||||
bytes.extend_from_slice(self.tally_key);
|
||||
bytes.extend_from_slice(&self.quantity.to_be_bytes());
|
||||
bytes
|
||||
}
|
||||
}
|
|
@ -97,8 +97,7 @@ mod bpf {
|
|||
("solana_bpf_rust_external_spend", false),
|
||||
("solana_bpf_rust_noop", true),
|
||||
("solana_bpf_rust_panic", false),
|
||||
// ISSUE: https://github.com/solana-labs/solana/issues/5602
|
||||
// ("solana_bpf_rust_stack_bug", true),
|
||||
("solana_bpf_rust_param_passing", true),
|
||||
];
|
||||
for program in programs.iter() {
|
||||
let filename = create_bpf_path(program.0);
|
||||
|
|
|
@ -54,7 +54,7 @@ if [[ ! -r criterion-$machine-$version.md ]]; then
|
|||
fi
|
||||
|
||||
# Install LLVM
|
||||
version=v0.0.13
|
||||
version=v0.0.14
|
||||
if [[ ! -f llvm-native-$machine-$version.md ]]; then
|
||||
(
|
||||
filename=solana-llvm-$machine.tar.bz2
|
||||
|
@ -80,7 +80,7 @@ if [[ ! -f llvm-native-$machine-$version.md ]]; then
|
|||
fi
|
||||
|
||||
# Install Rust-BPF
|
||||
version=v0.1.4
|
||||
version=v0.1.5
|
||||
if [[ ! -f rust-bpf-$machine-$version.md ]]; then
|
||||
(
|
||||
filename=solana-rust-bpf-$machine.tar.bz2
|
||||
|
|
Loading…
Reference in New Issue