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

Emulator build with poetry shell fails on Mac OS X with Clang 15 and buildgen v0.61 #3774

Closed
martin-tomes opened this issue May 5, 2024 · 3 comments · Fixed by #3782
Closed
Labels
bug Something isn't working as expected

Comments

@martin-tomes
Copy link

Describe the bug
When trying to follow the documentation after fresh install, the make build_unix within poetry shell environment, fails with an error.

Firmware version and revision
Current (latest commit is f8be07b) main branch.

Desktop/smartphone setup (please complete the following information):

  • OS: macOS Sonoma 14.4.1 (23E224)
  • clang --version:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

To Reproduce
Steps to reproduce the behavior:

  1. git clone --recurse-submodules https://github.com/trezor/trezor-firmware.git
  2. cd trezor-firmware
  3. poetry install
  4. brew install scons sdl2 sdl2_image pkg-config llvm
  5. rustup default nightly && rustup update
  6. cd core
  7. poetry shell
  8. make build_unix

Expected behavior
Build is successful.

Screenshots

--- stderr
  thread 'main' panicked at /Users/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.29/src/fallback.rs:702:9:
  "_mp_obj_fun_builtin_fixed_t_union_(unnamed_at___/__/vendor/micropython/py/obj_h_981_5)" is not a valid Ident
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
scons: *** [build/unix/build/unix/rust/aarch64-apple-darwin/release/libtrezor_lib.a] Error 101
make: *** [build_unix] Error 2

Additional context
The problem is described here, however it suggests problem is in Clang version 16 and above. But I am encountering this error with clang 15.

However, there is a workaround in updating the bindgen crate to version 0.62.0 and above (current version os 0.69.4):

  1. Updating the bindgen to version 0.62.0 in core/embed/rust/Cargo.toml
  2. As 0.62.0 and above changes the API of bindgen::EnumVariation it is needed to add is_global variable when creating default enum style in core/embed/rust/build.rs line 37:
        .default_enum_style(bindgen::EnumVariation::NewType { is_bitfield: false, is_global: false })

With the workaround applied, build is done and I am able to run the emu.py. Also all tests passed locally.

After investigating this problem I suggest to update the version of bindgen to at least v0.62.0 and do the necessary changes in the code.

If someone gives me a green light, I can prepare the PR for this.

@martin-tomes martin-tomes added the bug Something isn't working as expected label May 5, 2024
@martin-tomes
Copy link
Author

Solved by #3773

@martin-tomes
Copy link
Author

Reopening because the #3773 solves the problem under nix-shell. Without using the nix-shell with poetry only, the build errors as described above.

@prusnak
Copy link
Member

prusnak commented May 6, 2024

I confirmed the issue on macOS - I applied the suggested changes in #3782

@prusnak prusnak linked a pull request May 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants