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

Subxt Metadata: #[no_std] compatibility #1401

Merged
merged 19 commits into from
Feb 15, 2024

Conversation

tadeohepperle
Copy link
Contributor

Related to: #159 and #1394

This PR aims to make subxt-metadata compatible with #[no_std] environments.
It is a first step towards the subxt-core crate that has to rely on subxt-metadata.

The CI pipeline now features a test where we build a small no_std binary, that aborts if any expectations fail.

@tadeohepperle tadeohepperle requested review from a team as code owners January 26, 2024 14:41
subxt/Cargo.toml Outdated
Comment on lines 28 to 31
"jsonrpsee?/async-client",
"jsonrpsee?/client-ws-transport-native-tls",
"subxt-lightclient?/native",
"tokio-util"
]
native = ["jsonrpsee?/async-client", "jsonrpsee?/client-ws-transport-native-tls", "subxt-lightclient?/native", "tokio-util"]

# Enable this for web/wasm builds.
# Exactly 1 of "web" and "native" is expected.
web = [
"jsonrpsee?/async-wasm-client",
"jsonrpsee?/client-web-transport",
"getrandom/js",
"subxt-lightclient?/web",
"subxt-macro/web",
"instant/wasm-bindgen"
]
web = ["jsonrpsee?/async-wasm-client", "jsonrpsee?/client-web-transport", "getrandom/js", "subxt-lightclient?/web", "subxt-macro/web", "instant/wasm-bindgen"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting nit; to me the separate line per item feels cleaner :)

Comment on lines 5 to 6
#[cfg(not(feature = "std"))]
extern crate alloc;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just add extern crate alloc to the top of lib.rs and no need to have it behind a feature flag. Then, you can just always point to the alloc and core versions of things directly as needed and avoid the need for this prelude entirely?

(Side note: polkadot-sdk has a similar prelude and also plans to remove it in favour of just pointing at alloc/core things instead where needed. I think it's generally a bit nicer to just avoid importing from std entirely like this rather than use features etc)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other side note: the annoying time when you cant just slap an extern crate alloc at the root of the library is when you're in a macro generating code. Then, you don't know if the library your macro is spitting code out into has used extern crate alloc or not, and then a nice approach is to pull imports from some known library (eg subxt macro would pull imports from subxt) to avoid needing an std feature flag or whatever)

Comment on lines +34 to +35
#[cfg(feature = "std")]
impl std::error::Error for TryFromError {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly, this is, I think, the only reason that you actually need an "std" feature flag at all for this crate (same is true for some of the scale-* libraries too). Can't wait for Error trait in no-std; then a bunch of crates can just be no-std by default without any feature flag!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yupp, the new error trait looked quite weird in Rust but indeed would be awesome with core::Error :)

"runtime".to_string(),
"generic".to_string(),
"UncheckedExtrinsic".to_string(),
"primitives".to_owned(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an alloc::string::ToString you can import btw :)

Comment on lines 375 to 376
// Note: using the `format!` macro like in `let path = format!("{}Error", pallet.name);`
// leads to linker errors about extern function `_Unwind_Resume` not being defined.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange; this isn't expected! Not a big deal but the alloc::format! macro should work fine here so I'd be keen to understand this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to understand this but just could not. When I use alloc::format!("{}Error", pallet.name) the crate on itself compiles fine with cargo check --no-default-features. But when actually running it in the no-std context of the no-std-tests crate, the linker fails. This is the full error:

[tadeo@tadeo no-std-tests]$ cargo run
warning: /home/tadeo/code/subxt2/metadata/Cargo.toml: unused manifest key: dependencies.codec.package
   Compiling subxt-metadata v0.34.0 (/home/tadeo/code/subxt2/metadata)
   Compiling subxt-core-no-std-tests v0.0.0 (/home/tadeo/code/subxt2/testing/no-std-tests)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/tadeo/binaries/binaryen-version_114/bin/:/home/tadeo/.cargo/bin:/home/tadeo/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/emscripten:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl://home/tadeo/software/clion-2023.1.1/bin://home/tadeo/software/RustRover-232.9921.62/bin://home/tadeo/software://home/tadeo/binaries://home/tadeo/binaries/binaryen-version_114/bin://home/tadeo/tadeo/jai/bin://home/tadeo/software/clion-2023.1.1/bin://home/tadeo/software/RustRover-232.9921.62/bin://home/tadeo/software://home/tadeo/binaries://home/tadeo/binaries/binaryen-version_114/bin://home/tadeo/tadeo/jai/bin://home/tadeo/software/clion-2023.1.1/bin://home/tadeo/software/RustRover-232.9921.62/bin://home/tadeo/software://home/tadeo/binaries://home/tadeo/binaries/binaryen-version_114/bin://home/tadeo/tadeo/jai/bin://home/tadeo/software/clion-2023.1.1/bin://home/tadeo/software/RustRover-232.9921.62/bin://home/tadeo/software://home/tadeo/binaries://home/tadeo/binaries/binaryen-version_114/bin://home/tadeo/tadeo/jai/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcp0Q3ax/symbols.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.103d7shcucyldk1g.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.134jxfsp5r7fpsi4.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.15wugjomekc8u9cd.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.178ff35gl51k9jn6.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.1jqpxfobqlnn8dob.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.1khbisjscn1p6t4n.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.1s6jde34ai0c04oa.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.1sfwv0smmwal94uv.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.1yqju8l0gxt8jp4h.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.22sbasemurmw45jc.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.23vjmkzrwirghvh5.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.29jz3hhor6eyhjgo.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.2e8pm24wjwi8pqnb.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.2eas55mtom89jlpi.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.2g758ypgh7ai9z2d.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.2hlg20o9a8r26tny.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.33oo3s3e7xphmlkm.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.34lm33xs8rpm0f6m.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.39d3e7b2uh6hr0m6.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.39uaa6effdb5z6it.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3dvsizvfqr3wxugi.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3n2r7voz6tr59iem.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3n5vq0xmgqov6qex.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3rb54tsaelnlzp3m.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3rgifcfdkpv1ee4e.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3vd9icfw49rg4xc7.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3vlp1daoj4zytiru.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3wbr0ej039s27x53.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3wsxam7zeczjhu47.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3x65b4y4tgm16nw0.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.3z6qwpbs3u5307w2.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.48lgsnngb8wmhfwn.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4a6gn4zz3e3nsy2p.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4adnto81w9ywcza7.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4b5pmus4hc1u5gx5.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4d795spuxyilox3m.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4exap4y2iot01wrr.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4jc6xztur1jbid8p.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4lcqqww4qtfg47cu.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4svmi0pbwo8m12ww.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4v0rq98kzpd7g0zn.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4vp76ust6qq42pds.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4vz95k3cvgfx132b.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4yaei9hul0k9jvk7.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4zzcigv6wroyicrg.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.50xpqhd15ijd73p6.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.51fi6z0od92rlk20.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.54bpxaa0km7juimd.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.59klo2yrskf6m1f5.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.5abx5mf18w95g7c5.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.5bqzfqvsjx3pno3e.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.5g1m8r2w01p7f6b.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.hmrcr4vtok8xv11.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.iqsert8edir48bn.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.ji0f1ji5xs2c30w.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.jnkpcgsrytzhe0w.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.jwfmp58jpysnbw0.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.pgpbdv4u5zly0z6.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.uyjzkjdkpi41f9x.rcgu.o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44.4euzgjsu130ppiyb.rcgu.o" "-Wl,--as-needed" "-L" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps" "-L" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libsubxt_metadata-51d9f1437669e61a.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libsp_core_hashing-b92301fca1f18fe4.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libsha2-fc2ced99413ea5a3.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libcpufeatures-127b28b7f44f8f73.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libsha3-30102a3273cf6aa8.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libkeccak-b1a57eb5615ae5dd.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libtwox_hash-1b6d84b001e138c9.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libstatic_assertions-76e5be1f276ce5ad.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libblake2b_simd-3a0804c8f03d203f.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libconstant_time_eq-9879df55f4488384.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libarrayref-0a9b0146144627df.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libdigest-824630e7c7967625.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libblock_buffer-25e7908af0286f36.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libcrypto_common-d2724c415a8f25fd.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libgeneric_array-5752b1ffb1411b67.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libtypenum-a84ff3aee3fcd5b8.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libbyteorder-fd4dfae9638f420b.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libhashbrown-587c5fc643045699.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libahash-8f8b55be1f83bb29.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libonce_cell-cc3cb20337a1a354.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libzerocopy-d70ac5a9e7e5bf2b.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/liballocator_api2-f38c7224acdc551b.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libframe_metadata-b6624e76cd6133b1.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libscale_info-ac66d96ac73e377a.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libcfg_if-a6cd404a8612f704.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/liblibc-66190e536753d214.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libparity_scale_codec-5bfe95cae8bb589e.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libarrayvec-b7f808d3db61b112.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/libbyte_slice_cast-3824ae5dc231d397.rlib" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/liblibc_alloc-986027e607c85d37.rlib" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-3bf59988464e229a.rlib" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-9686387289eaa322.rlib" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-632ae0f28c5e55ff.rlib" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-8ebeba8f78436673.rlib" "-Wl,-Bdynamic" "-lc" "-lm" "-lrt" "-lpthread" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/tadeo/code/subxt2/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-d06243bfbe399a44" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/tadeo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-3bf59988464e229a.rlib(alloc-3bf59988464e229a.alloc.9e8bbef5278c9f16-cgu.0.rcgu.o): in function `alloc::fmt::format::format_inner':
          /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/alloc.rs:(.text._ZN5alloc3fmt6format12format_inner17hcb21963db8ce8921E+0x18a): undefined reference to `_Unwind_Resume'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `subxt-core-no-std-tests` (bin "subxt-core-no-std-tests") due to 1 previous error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I tried running this no-std-tests on my M1 mac with cargo +nightly run and it blew up hideously for me (error below) even without the format thing!

A way I've tested no-std before it to try compiling for a certain architecture that doesn't support std. It's a bit less good in that it doesn't then also test any code, but worked pretty well.

I wonder what needs changing to make this example compile on my mac! I'm a little scared by un-understandable errors :D

(my error:)

error: linking with `cc` failed: exit status: 1
  |
  = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/opt/homebrew/opt/llvm/bin:/Users/james/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/james/.cargo/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "arm64" "/var/folders/w9/qpj02kr93657cz711ppx0t000000gn/T/rustc87T3UO/symbols.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.15d5c1azm5qs75er.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.18o25cv5mh1czzjv.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1bgxi20o8beedxh9.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1m7v5cg51x1p7t79.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1mdjt5lke7rk419d.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1v9sz25zdztrk2hg.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.20lu86g86pae7v1.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.269mpyibt1n9z2i8.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.26gmy4iee7clpnjg.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2827u6krwnwjtvmo.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.28terp055wptt9us.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2gjo3dujmmxwsynl.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2hdy6vweutivgntb.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2ij89yj2b9cfmh0k.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2kxijmagjgn5c651.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2l9spa5avf7kavpj.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2mp073awr9qou2fb.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.2xjmwo260sodaqiq.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.31qn6lw1n4lpjdve.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.347ir8fl8lxog3w6.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.34ay7fxhwl65bj7v.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3g07tcecbxwnnq15.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3ggonenpgi5q0rf7.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3hy4l7kks4k4namn.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3mopnmoc36199hoe.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3mwmtcsm84pap21c.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3pxzeifl0mb14zss.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3qm0plxewj6nsfhf.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3qw0ledh0ykcy9u6.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3sx8ru8t9n82j95.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3t69n7kzsmq96tw3.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.3wrm7uvmrqxraehz.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.400crr6k9d61fu17.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.40vv1ehx1u9exf8h.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.419xohj6in5i57zm.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.49kcb06tsafvm0db.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.49o2xnetxigqdpro.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4h4ig9h9alzumjiu.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4l56t28e7lpv17zl.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4l6ylrtnyepjcwz3.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4lvkbyvrpemqogh6.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4w4f3riwmsudy1je.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.4xkclc8ecezl0k83.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.51jptb7x34zdfqf2.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.52x4vlfiymy8pwzd.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.55rg619tv9lf7277.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.5cbdvd0r51grlge5.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.5cfwus2ubakw9ax4.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.7gevje2ejveviaa.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.caeimgud3je6u6x.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.cg62d0ulxjdhpt3.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.er7b56c56du2olw.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.f5h5r5p91v2k9ni.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.fe25tv2z76lodxh.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.gt1xdawrq4l7qvw.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.jv85tnelye4bgri.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.xo8z24wgj0cg9av.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.zq1xrzayduo33qg.rcgu.o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b.1t8ag4zloyspfmmk.rcgu.o" "-L" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps" "-L" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libsubxt_metadata-8e248289f930cb3c.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libsp_core_hashing-f0c25e154b5c4277.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libsha2-cb2ce43e4b8e194a.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libsha3-5838d6073efb5c3e.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libkeccak-d2d65997e5888b81.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libtwox_hash-857443a2d443ea8b.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libstatic_assertions-9023d874dd538a80.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libblake2b_simd-9fb389da054224a0.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libconstant_time_eq-29dc5e34c80a75b2.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libarrayref-9b1fb0b52a86eb41.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libdigest-4c52f81b6eec5fb1.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libblock_buffer-ec353a40d52c9037.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libcrypto_common-57844e855bcb6cd4.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libgeneric_array-b1f0fee6a20334f9.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libtypenum-775d0f072d4f4abd.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libbyteorder-0820adf1e7c48840.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libhashbrown-5244040c47fd6a4a.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libahash-a7a7d37f197f75c4.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libonce_cell-224b04cb628f70ea.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libzerocopy-c44aef1ea18b0c6c.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/liballocator_api2-ca7226a82670e6c8.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libframe_metadata-e1923b9d96c4e0ee.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libscale_info-799db87831817bb0.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libcfg_if-a70192628636786c.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/liblibc-8cc6a15d6487055d.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libparity_scale_codec-39751d065c7b75ba.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libarrayvec-dff866a194c19e5e.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/libbyte_slice_cast-8fd10abbb6202346.rlib" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/liblibc_alloc-8e6c22beab38a9a5.rlib" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-fce2a9bd028a2944.rlib" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-e5afe4e689972eee.rlib" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-113e29613e2cc3c4.rlib" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-0faa98e433ca4c9a.rlib" "-liconv" "-L" "/Users/james/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/james/Work/subxt/testing/no-std-tests/target/debug/deps/subxt_core_no_std_tests-c9e698994923ea6b" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: Undefined symbols for architecture arm64:
            "_memcmp", referenced from:
                _$LT$u8$u20$as$u20$core..slice..cmp..SliceOrd$GT$::compare::h2bc851d9c6b79f93 in libscale_info-799db87831817bb0.rlib(scale_info-799db87831817bb0.scale_info.bfaba07d6ed144ac-cgu.08.rcgu.o)
                _$LT$$u5b$A$u5d$$u20$as$u20$core..slice..cmp..SlicePartialEq$LT$B$GT$$GT$::equal::hb5134437d2fec988 in libscale_info-799db87831817bb0.rlib(scale_info-799db87831817bb0.scale_info.bfaba07d6ed144ac-cgu.08.rcgu.o)
            "_memmove", referenced from:
                core::slice::sort::merge_sort::RunVec$LT$RunAllocF$C$RunDeallocF$GT$::remove::he4ebdd000273eb8e in subxt_core_no_std_tests-c9e698994923ea6b.52x4vlfiymy8pwzd.rcgu.o
                alloc::collections::btree::node::BalancingContext$LT$K$C$V$GT$::bulk_steal_left::h7a76fcbed2e55b36 in libframe_metadata-e1923b9d96c4e0ee.rlib(frame_metadata-e1923b9d96c4e0ee.frame_metadata.41e071e3dfd6810e-cgu.03.rcgu.o)
                hashbrown::raw::RawTableInner::prepare_rehash_in_place::h1c0f596ae44a7f5b in libsubxt_metadata-8e248289f930cb3c.rlib(subxt_metadata-8e248289f930cb3c.2vd0twcydxhja38y.rcgu.o)
            "_memset", referenced from:
                _$LT$i8$u20$as$u20$alloc..vec..spec_from_elem..SpecFromElem$GT$::from_elem::ha4d40836b07f28c1 in subxt_core_no_std_tests-c9e698994923ea6b.5cbdvd0r51grlge5.rcgu.o
                _$LT$u8$u20$as$u20$alloc..vec..spec_from_elem..SpecFromElem$GT$::from_elem::he5fc054bff2de0b8 in subxt_core_no_std_tests-c9e698994923ea6b.5cbdvd0r51grlge5.rcgu.o
                hashbrown::raw::RawTableInner::fallible_with_capacity::had20f01794ceec46 in libsubxt_metadata-8e248289f930cb3c.rlib(subxt_metadata-8e248289f930cb3c.4di09es9j9z0uye5.rcgu.o)
                _$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::h984782dda0343e33 in libframe_metadata-e1923b9d96c4e0ee.rlib(frame_metadata-e1923b9d96c4e0ee.frame_metadata.41e071e3dfd6810e-cgu.01.rcgu.o)
                _$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::h148c0c7b754fe643 in libsubxt_metadata-8e248289f930cb3c.rlib(subxt_metadata-8e248289f930cb3c.4f0vy5igmgli8fsf.rcgu.o)
                _$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::h6b190362ceded8d4 in libsubxt_metadata-8e248289f930cb3c.rlib(subxt_metadata-8e248289f930cb3c.4f0vy5igmgli8fsf.rcgu.o)
                _$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::h6e1c6f16b2e57101 in libsubxt_metadata-8e248289f930cb3c.rlib(subxt_metadata-8e248289f930cb3c.4f0vy5igmgli8fsf.rcgu.o)
                ...
            "_memalign", referenced from:
                _$LT$libc_alloc..LibcAlloc$u20$as$u20$core..alloc..global..GlobalAlloc$GT$::alloc::h6ceccb6ff37b97f1 in subxt_core_no_std_tests-c9e698994923ea6b.269mpyibt1n9z2i8.rcgu.o
            "_memcpy", referenced from:
                core::ops::function::FnMut::call_mut::h50a1ff7c808fa955 in subxt_core_no_std_tests-c9e698994923ea6b.1mdjt5lke7rk419d.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadataPrefixed$GT$::decode::hc2d6160521da3f99 in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadata$GT$::decode::_$u7b$$u7b$closure$u7d$$u7d$::h02992c01d903eeee in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadata$GT$::decode::_$u7b$$u7b$closure$u7d$$u7d$::h0f8ac221182a9398 in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadata$GT$::decode::_$u7b$$u7b$closure$u7d$$u7d$::h36e492884daaee58 in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadata$GT$::decode::_$u7b$$u7b$closure$u7d$$u7d$::h3dc4f7f50ba2c6b4 in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                frame_metadata::_::_$LT$impl$u20$parity_scale_codec..codec..Decode$u20$for$u20$frame_metadata..RuntimeMetadata$GT$::decode::_$u7b$$u7b$closure$u7d$$u7d$::h3fb7d05b52fb5ce6 in subxt_core_no_std_tests-c9e698994923ea6b.1v8ak6ohszt9il8x.rcgu.o
                ...
            "_abort", referenced from:
                _rust_begin_unwind in subxt_core_no_std_tests-c9e698994923ea6b.3g07tcecbxwnnq15.rcgu.o
            "_free", referenced from:
                _$LT$libc_alloc..LibcAlloc$u20$as$u20$core..alloc..global..GlobalAlloc$GT$::dealloc::hf2148cf9f27498b8 in subxt_core_no_std_tests-c9e698994923ea6b.269mpyibt1n9z2i8.rcgu.o
            "_bzero", referenced from:
                _$LT$libc_alloc..LibcAlloc$u20$as$u20$core..alloc..global..GlobalAlloc$GT$::alloc_zeroed::ha8abe505d0f3cbe3 in subxt_core_no_std_tests-c9e698994923ea6b.269mpyibt1n9z2i8.rcgu.o
                alloc::alloc::Global::grow_impl::h89bdf56ff6b1f1a7 in libparity_scale_codec-39751d065c7b75ba.rlib(parity_scale_codec-39751d065c7b75ba.parity_scale_codec.c0eb5f39e1cd9682-cgu.0.rcgu.o)
                alloc::alloc::Global::grow_impl::hc07514a638cb7bc8 in libtwox_hash-857443a2d443ea8b.rlib(twox_hash-857443a2d443ea8b.twox_hash.599fc9e923e5a001-cgu.0.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `subxt-core-no-std-tests` (bin "subxt-core-no-std-tests") due to 1 previous error

subxt/Cargo.toml Outdated
@@ -97,7 +97,7 @@ sp-runtime = { workspace = true, optional = true }

# Other subxt crates we depend on.
subxt-macro = { workspace = true }
subxt-metadata = { workspace = true }
subxt-metadata = { workspace = true, features = ["std"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std is enabled by default anyway so no need here really

@@ -8,8 +8,9 @@ use crate::{
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
StorageEntryType,
};
use alloc::collections::BTreeMap;
use hashbrown::HashSet;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places I've just moved to using BTreeMap/BTreeSet to make it no-std compatible but hashbrown works too :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specifically wanted to use a HashMap in this case because we do a lot of lookups and insertions on a fairly large set of type ids here. :)

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me; just a couple of tiny things :)

# Running the binary and inspecting the output would require an actual machine with matching ISA or some sort of emulator.
- name: Compile `no-std-tests` crate to `thumbv7em-none-eabi` target.
run: |
cargo build --target thumbv7em-none-eabi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, you don't need sudo apt install gcc-arm-none-eabi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to see if it works in the CI without it first, for the subxt-metadata crate alone I remember if worked on my machine before installing gcc-arm-none-eabi, My guess is that it is only required for some things that the core and signer crate are doing. Let's see...

no-std-tests:
name: "Test (no_std)"
runs-on: ubuntu-latest
needs: [machete, docs]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd incline to start this test after the following needs: [clippy, wasm_clippy, check, wasm_check, docs]

Copy link
Member

@niklasad1 niklasad1 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree, this no-std check/test should be cheap and runs faster than for example clippy it's not really a test. It just checks that a binary builds without std enabled.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we'd need to adjust the needs: [clippy, wasm_clippy, check, wasm_check, docs] to include no-std-tests as well :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sounds good :)

Comment on lines 441 to 442
run: |
rustup target add `thumbv7em-none-eabi`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a single line syntax for this run: rustup target add thumbv7em-none-eabi`

Copy link
Member

@niklasad1 niklasad1 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also add it to target in "Install Rust nightly toolchain":

      - name: Install Rust nightly toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
          target: thumbv7em-none-eabi

# We can only make sure that they compile to ARM thumb ISA.
# Running the binary and inspecting the output would require an actual machine with matching ISA or some sort of emulator.
- name: Compile `no-std-tests` crate to `thumbv7em-none-eabi` target.
run: |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we can use a single line syntax

Cargo.toml Outdated
@@ -56,17 +56,20 @@ assert_matches = "1.5.0"
base58 = { version = "0.2.0" }
bitvec = { version = "1", default-features = false }
blake2 = { version = "0.10.6", default-features = false }
cfg-if = "1.0.0"
Copy link
Collaborator

@lexnv lexnv Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using this?

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, LGTM

@tadeohepperle tadeohepperle merged commit 5447035 into master Feb 15, 2024
13 checks passed
@tadeohepperle tadeohepperle deleted the tadeohepperle/subxt-metadata-no-std branch February 15, 2024 09:49
tadeohepperle added a commit that referenced this pull request Feb 15, 2024
* no-std tests and porting of subxt-metadata

* update pipeline

* fix generate custom metadata test

* fix cargo run command

* adjust pipeline

* remove prelude from subxt-metadata

* revert autoformatting of Cargo.toml

* remove alloc::format! again, still causes linker errors

* add no-std-build for thumbv7em-none-eabi target

* remove std feature flag

* remove libc and add small readme with test instructions

* change ci for nightly no std
@jsdw jsdw mentioned this pull request Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants