toku-mac opened a new pull request, #18978:
URL: https://github.com/apache/nuttx/pull/18978

   ## Summary
   
   This PR fixes `clock_gettime()` compatibility for Rust on the macOS 
simulator.
   
   On macOS sim, that Darwin clock ID can reach NuttX `clock_gettime()`, where 
it is outside the NuttX `clockid_t` namespace and fails with `EINVAL`. This 
causes Tokio-based Rust code to panic.
   
   The fix keeps the common clock implementation using NuttX clock IDs, and 
adds a small optional architecture hook for translating clock IDs at the public 
`clock_gettime()` boundary.
   
   ## Impact
   
   Running `hello_rust_cargo` with nsh on macOS should no longer cause a panic.
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host(s): OS (macOS 26.5), CPU(Apple M1), compiler(Apple clang 
version 21.0.0)
   * Target(s): arch(sim)
   * Ensure your PATH environment variable is properly configured to allow 
execution of: menuconfig, olddefconfig, savedefconfig, and setconfig.
   * Use the Rust toolchain version prior to nightly-2026-04-29 to avoid errors 
related to 
lib/rustlib/src/rust/library/std/src/sys/net/connection/socket/unix.rs.
   * This PR is a successor of PR #18962.
   
   Configuration and Build:
   
   ```
   rm -rf build-debug
   make distclean
   cmake -S . -B build-debug -DBOARD_CONFIG=sim:nsh -GNinja
   
   printf "CONFIG_SYSTEM_TIME64=y
   CONFIG_FS_LARGEFILE=y
   CONFIG_TLS_NELEM=16
   CONFIG_DEV_URANDOM=y
   CONFIG_EXAMPLES_HELLO_RUST_CARGO=y
   CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE=8192
   " >> build-debug/.config
   
   cmake --build build-debug -t olddefconfig
   cmake --build build-debug
   ```
   
   Testing logs before change:
   
   ```
   NuttShell (NSH) NuttX-12.13.0
   nsh> hello_rust_cargo
   {"name":"John","age":30}
   {"name":"Jane","age":25}
   Deserialized: Alice is 28 years old
   Pretty JSON:
   {
     "name": "Alice",
     "age": 28
   }
   
   thread '<unnamed>' (1797510) panicked at 
/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/pal/unix/time.rs:107:68:
   called `Result::unwrap()` on an `Err` value: Os { code: 0, kind: 
Uncategorized, message: "Unknown error 0" }
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   ```
   
   Testing logs after change:
   
   ```
   NuttShell (NSH) NuttX-12.13.0
   nsh> hello_rust_cargo
   {"name":"John","age":30}
   {"name":"Jane","age":25}
   Deserialized: Alice is 28 years old
   Pretty JSON:
   {
     "name": "Alice",
     "age": 28
   }
   Hello world from tokio!
   ```
   
   ## PR verification Self-Check
   
   * [x] My PR adheres to Contributing 
[Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md) and 
[Documentation](https://nuttx.apache.org/docs/latest/contributing/index.html) 
(git commit title and message, coding standard, etc).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to