From a48785128c4d6491c35ab36d50d84e24f5fbb64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 7 Jan 2025 20:51:30 +0100 Subject: [PATCH] Fix macos compilation warnings. --- crates/polkavm/src/api.rs | 5 +++++ crates/polkavm/src/compiler.rs | 1 + crates/polkavm/src/error.rs | 1 + crates/polkavm/src/lib.rs | 1 + crates/polkavm/src/mutex_std.rs | 1 + crates/polkavm/src/page_set.rs | 1 + crates/polkavm/src/utils.rs | 3 +++ 7 files changed, 13 insertions(+) diff --git a/crates/polkavm/src/api.rs b/crates/polkavm/src/api.rs index cc67d46a..6d7220f4 100644 --- a/crates/polkavm/src/api.rs +++ b/crates/polkavm/src/api.rs @@ -5,6 +5,7 @@ use alloc::vec::Vec; use polkavm_common::abi::{MemoryMap, MemoryMapBuilder, VM_ADDR_RETURN_TO_HOST}; use polkavm_common::cast::cast; +#[cfg_attr(not(target_os = "linux"), allow(unused_imports))] 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, @@ -226,6 +227,7 @@ impl CompiledModuleKind { } pub(crate) struct ModulePrivate { + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] engine_state: Option>, crosscheck: bool, @@ -282,6 +284,7 @@ impl Module { self.state().dynamic_paging } + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub(crate) fn compiled_module(&self) -> &CompiledModuleKind { &self.state().compiled_module } @@ -340,6 +343,7 @@ impl Module { self.round_to_page_size_down(value) + (u32::from((value & self.state().page_size_mask) != 0) << self.state().page_shift) } + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub(crate) fn address_to_page(&self, address: u32) -> u32 { address >> self.state().page_shift } @@ -407,6 +411,7 @@ impl Module { } }; + #[cfg_attr(not(target_os = "linux"), allow(unused_variables))] let exports = { log::trace!("Parsing exports..."); let mut exports = Vec::with_capacity(1); diff --git a/crates/polkavm/src/compiler.rs b/crates/polkavm/src/compiler.rs index 806fc000..83718af8 100644 --- a/crates/polkavm/src/compiler.rs +++ b/crates/polkavm/src/compiler.rs @@ -151,6 +151,7 @@ where B: CompilerBitness, { #[allow(clippy::too_many_arguments)] + #[cfg(target_os = "linux")] pub(crate) fn new( cache: &CompilerCache, config: &'a ModuleConfig, diff --git a/crates/polkavm/src/error.rs b/crates/polkavm/src/error.rs index 9a80fde9..7fba3898 100644 --- a/crates/polkavm/src/error.rs +++ b/crates/polkavm/src/error.rs @@ -71,6 +71,7 @@ impl Error { } #[cold] + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub(crate) fn context(self, message: impl core::fmt::Display) -> Self { let string = match self.0 { ErrorKind::Owned(buffer) => format!("{}: {}", message, buffer), diff --git a/crates/polkavm/src/lib.rs b/crates/polkavm/src/lib.rs index 9404842f..f14248ae 100644 --- a/crates/polkavm/src/lib.rs +++ b/crates/polkavm/src/lib.rs @@ -59,6 +59,7 @@ mod config; mod gas; mod interpreter; mod linker; +#[cfg(any(test, target_os = "linux"))] mod page_set; #[cfg(feature = "std")] mod source_cache; diff --git a/crates/polkavm/src/mutex_std.rs b/crates/polkavm/src/mutex_std.rs index 4c155c62..96ed7b87 100644 --- a/crates/polkavm/src/mutex_std.rs +++ b/crates/polkavm/src/mutex_std.rs @@ -9,6 +9,7 @@ impl Mutex { } #[inline] + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub fn lock(&self) -> std::sync::MutexGuard { match self.0.lock() { Ok(mutable) => mutable, diff --git a/crates/polkavm/src/page_set.rs b/crates/polkavm/src/page_set.rs index cec2b33f..a3e3c6b7 100644 --- a/crates/polkavm/src/page_set.rs +++ b/crates/polkavm/src/page_set.rs @@ -269,6 +269,7 @@ impl PageSet { } } + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub fn clear(&mut self) { self.intervals.clear(); } diff --git a/crates/polkavm/src/utils.rs b/crates/polkavm/src/utils.rs index 90488bb9..1402474d 100644 --- a/crates/polkavm/src/utils.rs +++ b/crates/polkavm/src/utils.rs @@ -60,6 +60,7 @@ where } #[inline] + #[cfg(target_os = "linux")] pub fn new_reusing_memory(mut memory: Self, capacity: u32) -> Self { memory.inner.clear(); memory.inner.resize_with(capacity as usize, || None); @@ -72,6 +73,7 @@ where } #[inline] + #[cfg(target_os = "linux")] pub fn len(&self) -> u32 { self.inner.len() as u32 } @@ -82,6 +84,7 @@ where } #[inline] + #[cfg(target_os = "linux")] pub fn clear(&mut self) { self.inner.clear(); }