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] linking fails on cargo test -p iroha_executor --features debug #4721

Closed
nxsaken opened this issue Jun 12, 2024 · 1 comment · Fixed by #4725
Closed

[BUG] linking fails on cargo test -p iroha_executor --features debug #4721

nxsaken opened this issue Jun 12, 2024 · 1 comment · Fixed by #4725
Assignees
Labels
Bug Something isn't working

Comments

@nxsaken
Copy link
Contributor

nxsaken commented Jun 12, 2024

OS and Environment

macOS M1, happens in CI also (Ubuntu)

GIT commit hash

started in 7a41ae8, still going as of 86d3cbc

Minimum working example / Steps to reproduce

cargo test -p iroha_executor --features debug

Actual result

error: linking with `cc` failed: exit status: 1
  = note: Undefined symbols for architecture arm64:
            "_dbg", referenced from:
                iroha_smart_contract_utils::debug::dbg::h090653f2ad4ed03b in libiroha_smart_contract-dd8fcf4b8ebee85c.rlib[15](iroha_smart_contract-dd8fcf4b8ebee85c.2kke7rkpsclar55l.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected result

Builds and runs tests normally

Logs

Output from one of the failed jobs: https://github.com/hyperledger/iroha/actions/runs/9481834871/job/26125652260#step:5:1050

Who can help to reproduce?

@mversic

Notes

No response

@nxsaken nxsaken added the Bug Something isn't working label Jun 12, 2024
@DCNick3 DCNick3 self-assigned this Jun 13, 2024
@DCNick3
Copy link
Contributor

DCNick3 commented Jun 13, 2024

The linking error happens because iroha_executor::data_model::permission::Permission::id() (which is called in some derive-generated code in iroha_executor::permission::tests::convert_token test) uses .dbg_expect extension on Result.

dbg_expect is intended to be only used in wasm smart contracts and calls iroha_smart_contract_utils::debug::dbg, which, in turn, when debug feature is enabled, is intended to call a host function to print a debug message. This whole mechanism exists to provide better debuggability of panics, as we build smart contracts with minimal panic infrastructure and they can't really print messages (-Z build-std-features=panic_immediate_abort).

I see two main ways to fix this:

  1. make sure all tests for smart-contract related crates are wasm tests (this requires fixing getrandom-related issues, but is doable)
  2. make dbg (and log) functions work outside of wasm

I lean towards option 2, as wasm tests are harder to debug and I would prefer we leave those only to parts that really require testing the wasm parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants