Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions primitives/api/proc-macro/src/impl_runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ fn generate_runtime_api_versions(impls: &[ItemImpl]) -> Result<TokenStream> {
#( #attrs )*
const _: () = {
// All sections with the same name are going to be merged by concatenation.
#[cfg(not(feature = "std"))]
#[link_section = "runtime_apis"]
static SECTION_CONTENTS: [u8; 12] = #c::serialize_runtime_api_info(#id, #version);
};
Expand Down
1 change: 1 addition & 0 deletions primitives/version/proc-macro/src/decl_runtime_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ fn generate_emit_link_section_decl(contents: &[u8], section_name: &str) -> Token
let len = contents.len();
quote! {
const _: () = {
#[cfg(not(feature = "std"))]
#[link_section = #section_name]
static SECTION_CONTENTS: [u8; #len] = [#(#contents),*];
};
Expand Down
14 changes: 14 additions & 0 deletions primitives/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// This is supported by the `construct_runtime!` macro.
///
/// # Usage
///
/// This macro accepts a const item like the following:
///
/// ```rust
Expand Down Expand Up @@ -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
/// 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;

/// The identity of a particular API interface that the runtime might provide.
Expand Down