Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

'sp-version' breaks no_std builds that are not wasm #8891

Closed
clangenb opened this issue May 24, 2021 · 4 comments
Closed

'sp-version' breaks no_std builds that are not wasm #8891

clangenb opened this issue May 24, 2021 · 4 comments
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@clangenb
Copy link
Contributor

The re-export of the sp_version_proc_macro::runtime_version in sp-version that was introduced here #8688. Breaks no_std builds that are not wasm.

This is inconvenient for us, as in SubstraTEE, we want to include arbitrary substrate-pallets in an sgx-enclave, which is a no-std but not wasm environment. As sp-version is a dependant of frame-system, it is virtually impossible to use any pallets without patching sp-version.

Is it an option to remove this re-export?

@bkchr
Copy link
Member

bkchr commented May 27, 2021

What kind of error you get?

@clangenb
Copy link
Contributor Author

I get some duplicate lang items error. I could identify the problematic crate to be sp-version. In this crate I found the following section, where I concluded without much more investigation that this is the issue:

/// # 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;

@bkchr
Copy link
Member

bkchr commented May 28, 2021

Do you use the macro? If not, it should not be responsible for what you are seeing.

@clangenb
Copy link
Contributor Author

Ok, I could track it down. It was related to rust-lang/cargo#7915.

Adding resolver = 2 in our no_std crate prevented leakage of std from the proc_macro.

Thanks for your time! 👍

brenzi pushed a commit to scs/substrate-api-client that referenced this issue Jun 26, 2021
Currently, this changes nothing, but this is an improvement of the cargo dependency resolution that might prevent `std` leakage into `no_std` builds for dev-dependencies of procedural macros. See: paritytech/substrate#8891
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants