Prevent stub inclusion when building shared objects (#10875)

This commit is contained in:
Jack May
2020-07-01 13:15:30 -07:00
committed by GitHub
parent 2669ccb864
commit 52526a9bc2
12 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,6 @@
//! @brief Stubs for syscalls when building tests for x86
//! @brief Syscall stubs when building for non-BPF targets
#[cfg(not(target_arch = "bpf"))]
fn print_line_to_stdout(_message: &str) {
#[cfg(not(feature = "program"))]
{
@ -11,6 +12,7 @@ fn print_line_to_stdout(_message: &str) {
}
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
/// # Safety
pub unsafe fn sol_log_(message: *const u8, length: u64) {
@ -19,11 +21,13 @@ pub unsafe fn sol_log_(message: *const u8, length: u64) {
print_line_to_stdout(string);
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
print_line_to_stdout(&format!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5));
}
#[cfg(not(target_arch = "bpf"))]
#[no_mangle]
pub fn sol_invoke_signed_rust() {
print_line_to_stdout("sol_invoke_signed_rust()");
@ -32,6 +36,7 @@ pub fn sol_invoke_signed_rust() {
#[macro_export]
macro_rules! program_stubs {
() => {
#[cfg(not(target_arch = "bpf"))]
#[test]
fn pull_in_externs() {
use solana_sdk::program_stubs::{sol_invoke_signed_rust, sol_log_, sol_log_64_};