Documentation | Rust Documentation: Rust builds fails due to missing "unsafe" keywords (#87)

Frank Kuehndel (@frank_k) gitlab at rtems.org
Fri Feb 21 10:45:44 UTC 2025



Frank Kuehndel created an issue: https://gitlab.rtems.org/rtems/docs/rtems-docs/-/issues/87



## Summary

Executing the exact instructions from the [rtems user manual](https://docs.rtems.org/branches/master/user/rust/bare-metal.html#bare-metal-rust-with-rtems) results in error messages complaining about missing `unsafe` keywords. The output looks like:

```+ cd hello-rtems
+ cargo build --target=riscv64gc-unknown-none-elf
   Compiling hello-rtems v0.1.0 (/home/ferris/example-rust/hello-rtems)
error: extern blocks must be unsafe
  --> src/lib.rs:7:1
   |
7  | / extern "C" {
8  | |     fn printk(fmt: *const core::ffi::c_char, ...) -> core::ffi::c_int;
9  | |     fn rtems_panic(fmt: *const core::ffi::c_char, ...) -> !;
10 | |     fn rtems_shutdown_executive(fatal_code: u32);
11 | | }
   | |_^

error: unsafe attribute used without unsafe
  --> src/lib.rs:34:3
   |
34 | #[no_mangle]
   |   ^^^^^^^^^ usage of unsafe attribute
   |
help: wrap the attribute in `unsafe(...)`
   |
34 | #[unsafe(no_mangle)]
   |   +++++++         +

error: could not compile `hello-rtems` (lib) due to 2 previous errors
```

The first known buggy build was:

| | Version/Commit |
| ------ | ------ |
|Date: |2025-02-21T02:33:14+01:00 |
|rtems-docs: |4f9f4a538fdaf6805145ac8916ab4cf48de004c4 |
|rtems-source-builder: |d647353d439f59479236b2ec51b9c2e9f5b19f67 |
|rtems: |330d01131890b75743cd2fa2d14b331f3acdefb0 |
|cargo: |1.85.0 (d73d2caf9 2024-12-31) |
|rustc: |1.85.0 (4d91de4e4 2025-02-17) |
|OS: |Ubuntu 24.04.2 LTS |
|CI job: |rtems-rust-doc-check#2778 |

The last known good build was:

| | Version/Commmit |
| ------ | ------ |
|Date: |2024-11-13T02:33:13+01:00 |
|rtems-docs: |4d2c0048e536648c4f6d9346f01868c1e7463ed3 |
|rtems-source-builder: |d82e3f433ba1441dc97e9d3c78eb0eb93212ed16 |
|rtems: |30fc123f8d65310772a07926acb7b0413e28b624 |
|cargo: |1.82.0 (8f40fc59f 2024-08-21) |
|rustc: |1.84.0-nightly (f7273e004 2024-11-12) |

## Steps to reproduce

Follow the instructions in [Bare Metal Rust with RTEMS](https://docs.rtems.org/branches/master/user/rust/bare-metal.html#bare-metal-rust-with-rtems)

### Pre-set options

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/docs/rtems-docs/-/issues/87
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250221/68c18914/attachment-0001.htm>


More information about the bugs mailing list