rust-lang / rust-lang/libc

"cannot find value REG_EIP in crate libc" when targetting i686-unknown-linux-musl

Open
#2,787 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug E-medium O-musl
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

Trying to build wasmtime for the i686-unknown-linux-musl target leads to the following error:

error[E0425]: cannot find value `REG_EIP` in crate `libc`
   --> /Users/victor.paleologue/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-runtime-0.33.1/src/traphandlers/unix.rs:173:40
    |
173 |             cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
    |                                        ^^^^^^^ not found in `libc`

error[E0609]: no field `gregs` on type `mcontext_t`
   --> /Users/victor.paleologue/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-runtime-0.33.1/src/traphandlers/unix.rs:173:28
    |
173 |             cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
    |                            ^^^^^ unknown field

It seems libc is lacking few elements for this target platform specifically.

Specific steps to reproduce the issue on a Mac M1:

brew tap messense/macos-cross-toolchains
brew install i686-unknown-linux-musl
rustup target add i686-unknown-linux-musl
git clone git@github.com:bytecodealliance/wasmtime.git --recurse-submodules
cd wasmtime
CC_i686_unknown_linux_musl=/opt/homebrew/Cellar/i686-unknown-linux-musl/11.2.0/bin/i686-unknown-linux-musl-gcc CXX_i686_unknown_linux_musl=/opt/homebrew/Cellar/i686-unknown-linux-musl/11.2.0/bin/i686-unknown-linux-musl-g++ AR_i686_unknown_linux_musl=/opt/homebrew/Cellar/i686-unknown-linux-musl/11.2.0/bin/i686-unknown-linux-musl-ar CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_LINKER=/opt/homebrew/Cellar/i686-unknown-linux-musl/11.2.0/bin/i686-unknown-linux-musl-gcc cargo build --target i686-unknown-linux-musl

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported cargo build command for i686-unknown-linux-musl, then inspect the libc platform bindings related to the mcontext_t fields and REG_EIP referenced by wasmtime-runtime-0.33.1/src/traphandlers/unix.rs. Done means the target builds without the missing-value and missing-field errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.