Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-linux compilation warnings. #248

Merged
merged 10 commits into from
Jan 31, 2025
10 changes: 10 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ jobs:
run: ./ci/jobs/build-and-test.sh
- name: Build and test (macOS-only)
run: ./ci/jobs/build-and-test-macos.sh
clippy-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install clippy (base toolchain)
run: rustup component add clippy
- name: Install clippy (zygote toolchain)
run: cd crates/polkavm-zygote && rustup component add clippy
- name: Run clippy
run: ./ci/jobs/clippy.sh
build-and-test-windows:
runs-on: windows-latest
steps:
Expand Down
58 changes: 35 additions & 23 deletions crates/polkavm/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ use alloc::vec::Vec;
use polkavm_common::abi::{MemoryMap, MemoryMapBuilder, VM_ADDR_RETURN_TO_HOST};
use polkavm_common::cast::cast;
use polkavm_common::program::{
build_static_dispatch_table, FrameKind, ISA32_V1_NoSbrk, ISA64_V1_NoSbrk, Imports, InstructionSet, Instructions, JumpTable, Opcode,
ProgramBlob, Reg, ISA32_V1, ISA64_V1,
FrameKind, ISA32_V1_NoSbrk, Imports, InstructionSet, Instructions, JumpTable, Opcode, ProgramBlob, Reg, ISA32_V1, ISA64_V1,
};
use polkavm_common::utils::{ArcBytes, AsUninitSliceMut};

if_compiler_is_supported! {
use polkavm_common::program::{
build_static_dispatch_table, ISA64_V1_NoSbrk,
};
}

use crate::config::{BackendKind, Config, GasMeteringKind, ModuleConfig, SandboxKind};
use crate::error::{bail, bail_static, Error};
use crate::interpreter::{InterpretedInstance, InterpretedModule};
Expand Down Expand Up @@ -226,6 +231,7 @@ impl CompiledModuleKind {
}

pub(crate) struct ModulePrivate {
#[allow(dead_code)]
engine_state: Option<Arc<EngineState>>,
crosscheck: bool,

Expand Down Expand Up @@ -282,8 +288,10 @@ impl Module {
self.state().dynamic_paging
}

pub(crate) fn compiled_module(&self) -> &CompiledModuleKind {
&self.state().compiled_module
if_compiler_is_supported! {
pub(crate) fn compiled_module(&self) -> &CompiledModuleKind {
&self.state().compiled_module
}
}

pub(crate) fn interpreted_module(&self) -> Option<&InterpretedModule> {
Expand Down Expand Up @@ -340,8 +348,10 @@ impl Module {
self.round_to_page_size_down(value) + (u32::from((value & self.state().page_size_mask) != 0) << self.state().page_shift)
}

pub(crate) fn address_to_page(&self, address: u32) -> u32 {
address >> self.state().page_shift
if_compiler_is_supported! {
pub(crate) fn address_to_page(&self, address: u32) -> u32 {
address >> self.state().page_shift
}
}

/// Creates a new module by deserializing the program from the given `bytes`.
Expand Down Expand Up @@ -407,24 +417,26 @@ impl Module {
}
};

let exports = {
log::trace!("Parsing exports...");
let mut exports = Vec::with_capacity(1);
for export in blob.exports() {
log::trace!(" Export at {}: {}", export.program_counter(), export.symbol());
if config.is_strict && cast(export.program_counter().0).to_usize() >= blob.code().len() {
bail!(
"out of range export found; export {} points to code offset {}, while the code blob is only {} bytes",
export.symbol(),
export.program_counter(),
blob.code().len(),
);
}
if_compiler_is_supported! {
let exports = {
log::trace!("Parsing exports...");
let mut exports = Vec::with_capacity(1);
for export in blob.exports() {
log::trace!(" Export at {}: {}", export.program_counter(), export.symbol());
if config.is_strict && cast(export.program_counter().0).to_usize() >= blob.code().len() {
bail!(
"out of range export found; export {} points to code offset {}, while the code blob is only {} bytes",
export.symbol(),
export.program_counter(),
blob.code().len(),
);
}

exports.push(export);
}
exports
};
exports.push(export);
}
exports
};
}

let init = GuestInit {
page_size: config.page_size,
Expand Down
Loading
Loading