mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 13:15:41 +00:00
Emit wasm sections only when compiling to wasm (#8845)
This commit is contained in:
@@ -675,6 +675,7 @@ fn generate_runtime_api_versions(impls: &[ItemImpl]) -> Result<TokenStream> {
|
|||||||
#( #attrs )*
|
#( #attrs )*
|
||||||
const _: () = {
|
const _: () = {
|
||||||
// All sections with the same name are going to be merged by concatenation.
|
// All sections with the same name are going to be merged by concatenation.
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
#[link_section = "runtime_apis"]
|
#[link_section = "runtime_apis"]
|
||||||
static SECTION_CONTENTS: [u8; 12] = #c::serialize_runtime_api_info(#id, #version);
|
static SECTION_CONTENTS: [u8; 12] = #c::serialize_runtime_api_info(#id, #version);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ fn generate_emit_link_section_decl(contents: &[u8], section_name: &str) -> Token
|
|||||||
let len = contents.len();
|
let len = contents.len();
|
||||||
quote! {
|
quote! {
|
||||||
const _: () = {
|
const _: () = {
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
#[link_section = #section_name]
|
#[link_section = #section_name]
|
||||||
static SECTION_CONTENTS: [u8; #len] = [#(#contents),*];
|
static SECTION_CONTENTS: [u8; #len] = [#(#contents),*];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ use sp_runtime::{traits::Block as BlockT, generic::BlockId};
|
|||||||
/// A shortcoming of this macro is that it is unable to embed information regarding supported APIs.
|
/// A shortcoming of this macro is that it is unable to embed information regarding supported APIs.
|
||||||
/// This is supported by the `construct_runtime!` macro.
|
/// This is supported by the `construct_runtime!` macro.
|
||||||
///
|
///
|
||||||
|
/// # Usage
|
||||||
|
///
|
||||||
/// This macro accepts a const item like the following:
|
/// This macro accepts a const item like the following:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
@@ -78,6 +80,18 @@ use sp_runtime::{traits::Block as BlockT, generic::BlockId};
|
|||||||
/// - `apis` doesn't have any specific constraints. This is because this information doesn't get into
|
/// - `apis` doesn't have any specific constraints. This is because this information doesn't get into
|
||||||
/// the custom section and is not parsed.
|
/// the custom section and is not parsed.
|
||||||
///
|
///
|
||||||
|
/// # Compilation Target & "std" feature
|
||||||
|
///
|
||||||
|
/// This macro assumes it will be used within a runtime. By convention, a runtime crate defines a
|
||||||
|
/// feature named "std". This feature is enabled when the runtime is compiled to native code and
|
||||||
|
/// disabled when it is compiled to the wasm code.
|
||||||
|
///
|
||||||
|
/// The custom section can only be emitted while compiling to wasm. In order to detect the compilation
|
||||||
|
/// target we use the "std" feature. This macro will emit the custom section only if the "std" feature
|
||||||
|
/// is **not** enabled.
|
||||||
|
///
|
||||||
|
/// Including this macro in the context where there is no "std" feature and the code is not compiled
|
||||||
|
/// to wasm can lead to cryptic linking errors.
|
||||||
pub use sp_version_proc_macro::runtime_version;
|
pub use sp_version_proc_macro::runtime_version;
|
||||||
|
|
||||||
/// The identity of a particular API interface that the runtime might provide.
|
/// The identity of a particular API interface that the runtime might provide.
|
||||||
|
|||||||
Reference in New Issue
Block a user