Skip to content

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

Closed
@Revyn112

Description

@Revyn112

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions