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

error[E0133]: Errors with libc Dependency When Compiling WASM #4153

Closed
Revyn112 opened this issue Nov 27, 2024 · 1 comment
Closed

error[E0133]: Errors with libc Dependency When Compiling WASM #4153

Revyn112 opened this issue Nov 27, 2024 · 1 comment
Labels
C-bug Category: bug

Comments

@Revyn112
Copy link

We encounter the following error when trying to compile and run our WebAssembly (WASM) project. The issue originates from the libc crate (version 0.2.166), which appears to use extern static variables unsafely, causing multiple E0133 errors.

Our GitHub Action run: https://github.com/headwindsim/aircraft/actions/runs/12041087308/job/33572254499

error[E0133]: use of extern static is unsafe and requires unsafe function or block
             --> /external/target/cargo_home/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.166/src/wasi/mod.rs:388:59
              |
          388 |         pub static CLOCK_MONOTONIC: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC));
              |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of extern static
              |
              = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
              = note: this error originates in the macro `core::ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
          
          error[E0133]: use of extern static is unsafe and requires unsafe function or block
             --> /external/target/cargo_home/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.166/src/wasi/mod.rs:391:23
              |
          391 |             clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID));
              |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of extern static
              |
              = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
              = note: this error originates in the macro `core::ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
          
          error[E0133]: use of extern static is unsafe and requires unsafe function or block
             --> /external/target/cargo_home/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.166/src/wasi/mod.rs:393:58
              |
          393 |         pub static CLOCK_REALTIME: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME));
              |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of extern static
              |
              = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
              = note: this error originates in the macro `core::ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
          
          error[E0133]: use of extern static is unsafe and requires unsafe function or block
             --> /external/target/cargo_home/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.166/src/wasi/mod.rs:396:23
              |
          396 |             clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID));
              |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of extern static
              |
              = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
              = note: this error originates in the macro `core::ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
          
          For more information about this error, try `rustc --explain E0133`.
          error: could not compile `libc` (lib) due to 4 previous errors
@Revyn112 Revyn112 added the C-bug Category: bug label Nov 27, 2024
@tgross35
Copy link
Contributor

This was fixed by #4157, the issue shows up when using a version of Rust older than the current stable which is the first version to make these operations safe.

The fix should make it into a release tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants