Work around missing lib on linux (Issue #4972) (#4975)

This commit is contained in:
Jack May 2019-07-08 22:24:57 -08:00 committed by GitHub
parent f9a2254688
commit 50c6b5d62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 15 deletions

View File

@ -16,6 +16,9 @@ solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version =
solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" } solana-sdk-bpf-no-std = { path = "../../../../sdk/bpf/rust/rust-no-std", version = "0.17.0" }
solana-bpf-rust-128bit-dep = { path = "../128bit_dep", version = "0.17.0" } solana-bpf-rust-128bit-dep = { path = "../128bit_dep", version = "0.17.0" }
[dev_dependencies]
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/rust-test", version = "0.17.0" }
[workspace] [workspace]
members = [] members = []

View File

@ -14,5 +14,8 @@ edition = "2018"
[dependencies] [dependencies]
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" } solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
[dev_dependencies]
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/rust-test", version = "0.17.0" }
[workspace] [workspace]
members = [] members = []

View File

@ -13,6 +13,18 @@ mod test {
extern crate std; extern crate std;
use super::*; use super::*;
#[test]
fn pull_in_externs() {
// Rust on Linux excludes the solana_sdk_bpf_test library unless there is a
// direct dependency, use this test to force the pull in of the library.
// This is not necessary on macos and unfortunate on Linux
// Issue #4972
extern crate solana_sdk_bpf_test;
use solana_sdk_bpf_test::*;
unsafe { sol_log_("X".as_ptr(), 1) };
sol_log_64_(1, 2, 3, 4, 5);
}
#[test] #[test]
fn test_work() { fn test_work() {
assert_eq!(3, work(1, 2)); assert_eq!(3, work(1, 2));

View File

@ -13,9 +13,9 @@ use solana_sdk_bpf_utils::info;
#[no_mangle] #[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> bool { pub extern "C" fn entrypoint(_input: *mut u8) -> bool {
info!("call same package"); info!("Call same package");
assert_eq!(crate::helper::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9), 45); assert_eq!(crate::helper::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9), 45);
info!("call another package"); info!("Call another package");
assert_eq!( assert_eq!(
solana_bpf_rust_many_args_dep::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9), solana_bpf_rust_many_args_dep::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9),
45 45

View File

@ -17,7 +17,7 @@ pub fn many_args(
arg8: u64, arg8: u64,
arg9: u64, arg9: u64,
) -> u64 { ) -> u64 {
info!("another package"); info!("Another package");
info!(arg1, arg2, arg3, arg4, arg5); info!(arg1, arg2, arg3, arg4, arg5);
info!(arg6, arg7, arg8, arg9, 0); info!(arg6, arg7, arg8, arg9, 0);
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
@ -25,20 +25,19 @@ pub fn many_args(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
extern crate solana_sdk_bpf_test;
extern crate std; extern crate std;
use super::*; use super::*;
#[no_mangle] #[test]
pub unsafe fn sol_log_(message: *const u8, length: u64) { fn pull_in_externs() {
let slice = std::slice::from_raw_parts(message, length as usize); // Rust on Linux excludes the solana_sdk_bpf_test library unless there is a
let string = std::str::from_utf8(&slice).unwrap(); // direct dependency, use this test to force the pull in of the library.
std::println!("{}", string); // This is not necessary on macos and unfortunate on Linux
} // Issue #4972
extern crate solana_sdk_bpf_test;
#[no_mangle] use solana_sdk_bpf_test::*;
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) { unsafe { sol_log_("X".as_ptr(), 1) };
std::println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5); sol_log_64_(1, 2, 3, 4, 5);
} }
#[test] #[test]

View File

@ -10,4 +10,4 @@ homepage = "https://solana.com/"
edition = "2018" edition = "2018"
[workspace] [workspace]
members = [] members = []