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

[Bug]: Running cargo test/build fails with 'linking with cc failed' #43

Open
0xNeshi opened this issue Dec 18, 2024 · 0 comments · May be fixed by #44
Open

[Bug]: Running cargo test/build fails with 'linking with cc failed' #43

0xNeshi opened this issue Dec 18, 2024 · 0 comments · May be fixed by #44

Comments

@0xNeshi
Copy link

0xNeshi commented Dec 18, 2024

Repro steps:

  • run the following script:
git clone [email protected]:OffchainLabs/stylus-hello-world.git
cd stylus-hello-world
rustup toolchain install 1.80 # in case it's not already installed
rustup target add wasm32-unknown-unknown
cargo update # resolves some weird "type annotations needed for `Box<_>`" error
  • open src/lib.rs, and at the end of the file add:
#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}
  • run cargo test --lib
Error log:
```bash
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/nenad/.nvm/versions/node/v22.12.0/bin:/home/nenad/.local/share/pnpm:/home/nenad/.asdf/shims:/home/nenad/.asdf/bin:/home/nenad/.starkli/bin:/home/nenad/.cargo/bin:/home/nenad/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/nenad/.foundry/bin:/home/nenad/.local/bin:/home/nenad/.local/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcXrS4KN/symbols.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.0a4738f2g99ere2ypmq4m1nrk.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.22wox5v7e9c8e466e9hejwqa1.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.27hc01cu155zjeh8yklh7psqa.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.29fl6x6kqpp35rd1jlijpas3w.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.2gf1q9kzo0v6wiz6cmkxupb5z.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.2lodtxbktxm0ioke7n87mg8ew.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.347oohxibz9zxmh1v8zz946tt.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.42i3woaw465hyethuu38v0msy.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.4b3zm0079phh6kl7a7g2e9tul.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.4hexoi33mk43iiwh8cpb6j5v9.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.4kpe48f740gzgy5yv901hwq2o.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.55xm9u1zy66lx4ak9mkhaa0bb.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.6cpagd0vubhfpv8e2spkjsujo.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.6z0f21ad2xcb5ils4a10li60g.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.7mt5nam7a30zi2v5jc8hw4gxr.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.88gok1mr605lhc31k9jfvt1ep.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.8bptt28jcd6sm84w96o5os8yd.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.8cxqlslnbqohj1y41wf0gtzeh.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.8kkbjp02vuqfvjm0vmfdu3fl9.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.95shykuyidbgt3gwv9afjq1wd.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.9lr71whscf7j31j0yh48v2v8x.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.ae1b4fq8lb19also3sm3hrkmc.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.ambotqcnwhdd5kku98uz6afxn.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.aspi96y6lpnnnhk59s1dkfwvf.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.b1zj1cyn26aldbc37wf32lr5y.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.bymfo035jefqeryq93ghjo3fh.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.bz0g4rzw0xnqcwsh5p75p615u.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.cv4846bhf4aedxn6mebu3w68f.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.damt1o68vxnxt572m0h2ev7te.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.ewtivwxbm7rwyuag1zehemyrs.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.ex699cetzyoe5yedver7r2tm6.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.f2ben15evq9dztg81khkz5kfo.rcgu.o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a.0iz66e2akqfs7swn9oo9fy4hm.rcgu.o" "-Wl,--as-needed" "-L" "/home/nenad/repos/tempproj/target/debug/deps" "-L" "/home/nenad/repos/tempproj/target/debug/build/ring-46fa3655fc8a512f/out" "-L" "/home/nenad/repos/tempproj/target/debug/build/ring-75dacf1209df8f52/out" "-L" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-54b60a748c677e53.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-9bcac91f96e18782.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-39147797553ffa4c.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-aee75f1e365c6355.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libstylus_sdk-6d34c4f912a40499.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libkeccak_const-952cdfeb183191df.rlib" "/home/nenad/repos/tempproj/target/debug/deps/liballoy_sol_types-05ce77bdab7acb94.rlib" "/home/nenad/repos/tempproj/target/debug/deps/liballoy_primitives-0565d776c7590d35.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libitoa-42af64bdede19cfe.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libhex_literal-83a66bba401d9ee3.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libbytes-78702b9fbbc2f3b1.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libserde-5038efda9de1e01f.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libconst_hex-2fe5baf2ace47b66.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libhex-17de966a983efd22.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libcpufeatures-3176e9805aaaa4fc.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libcfg_if-f93ad0443750a3ea.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libruint-f4263af1b8f65a04.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libtiny_keccak-33225fd9e44ef21d.rlib" "/home/nenad/repos/tempproj/target/debug/deps/libcrunchy-9c51c2066d1ef88c.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0fbbe72b9e0d57dc.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-4cbc28d57c85be7b.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-d583e13b4b2d89a2.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-5d2a1bfb1589ab43.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-dcf90797fbd00d23.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-3b6828d7a1725131.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-f75bdd612dd19f44.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-130d6997e9e34e6a.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c9c9da5b4611a660.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-0f5b4153173c663b.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-877178c8f84ba478.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-3907ca7c36d3c032.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-e8b263070ac20a8a.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-d1969118c6f0c13e.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d48855f89c749535.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-9a1cbc1305da137e.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-d290b706bbcc90ac.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fd707bd9d5d3d672.rlib" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d4ebcca572002f93.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/nenad/.rustup/toolchains/1.80.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/nenad/repos/tempproj/target/debug/deps/stylus_hello_world-67a73fa8d245e82a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
          (.text+0x1b): undefined reference to `main'
          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#rustc-link-lib)

error: could not compile `stylus-hello-world` (lib test) due to 1 previous error
  • run cargo test - a similar issue occurs, but for bin test as well
  • run cargo build - a similar issue occurs

It seems the problem is caused by main function not being generated when tests are run. The logic for when main is generated needs to be fixed.


Another problem, as mentioned above, is that it's necessary to run cargo update before running cargo test, because of an issue with external dependency time:

   Compiling encoding_rs v0.8.33
   Compiling bech32 v0.9.1
   Compiling data-encoding v2.5.0
error[E0282]: type annotations needed for `Box<_>`
  --> /home/nenad/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.34/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
help: consider giving `items` an explicit type, where the placeholders `_` are specified
   |
83 |     let items: Box<_> = format_items
   |              ++++++++

   Compiling sync_wrapper v0.1.2
   Compiling untrusted v0.7.1

Running cargo update solves this issue.

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 a pull request may close this issue.

1 participant