rust-lang / rust-lang/rust

The std build failed for thumbv7em-nuttx-eabihf target.

Open
#156,790 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-targets C-bug
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

I tried this code in thumbv7em-nuttx-eabihf target.

#[unsafe(no_mangle)]
pub extern "C" fn main() {
    println!("Hello, world!");
}
cargo build --target thumbv7em-nuttx-eabihf -Zbuild-std=std
error[E0425]: cannot find value `SO_KEEPALIVE` in crate `libc`                                                                                                                                                                                     
   --> C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\net\connection\socket\unix.rs:460:59
    |
460 |         unsafe { setsockopt(self, libc::SOL_SOCKET, libc::SO_KEEPALIVE, keepalive as c_int) }
    |                                                           ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `SO_KEEPALIVE` in crate `libc`                                                                                                                                                                                     
   --> C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\net\connection\socket\unix.rs:464:76
    |
464 |         let raw: c_int = unsafe { getsockopt(self, libc::SOL_SOCKET, libc::SO_KEEPALIVE)? };
    |                                                                            ^^^^^^^^^^^^ not found in `libc`

For more information about this error, try `rustc --explain E0425`.                                                                                                                                                                                
error: could not compile `std` (lib) due to 2 previous errors     

It is unclear whether other *-nuttx-* targets are affected.

Meta

rustc --version --verbose:

PS C:\Users\zqdq_\Documents\code\mcu_os_std> rustc --version --verbose
rustc 1.97.0-nightly (e50aa6fba 2026-05-19)
binary: rustc
commit-hash: e50aa6fba4e63ab34c72bf9acfd2c307c1155d1a
commit-date: 2026-05-19
host: x86_64-pc-windows-msvc
release: 1.97.0-nightly
Backtrace

PS C:\Users\zqdq_\Documents\code\mcu_os_std> cargo build --target thumbv7em-nuttx-eabihf -Zbuild-std=std
   Compiling compiler_builtins v0.1.160 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\compiler-builtins\compiler-builtins)
   Compiling core v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core)
   Compiling libc v0.2.185
   Compiling object v0.37.3
   Compiling std v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std)
   Compiling rustc-std-workspace-core v1.99.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\rustc-std-workspace-core)                                                                             
   Compiling alloc v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc)
   Compiling memchr v2.7.6                                                                                                                                                                                                                         
   Compiling adler2 v2.0.1
   Compiling cfg-if v1.0.4
   Compiling panic_abort v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\panic_abort)
   Compiling rustc-demangle v0.1.27
   Compiling rustc-literal-escaper v0.0.7
   Compiling unwind v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\unwind)                                                                                                                  
   Compiling rustc-std-workspace-alloc v1.99.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\rustc-std-workspace-alloc)                                                                           
   Compiling panic_unwind v0.0.0 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\panic_unwind)
   Compiling gimli v0.32.3                                                                                                                                                                                                                         
   Compiling hashbrown v0.17.1
   Compiling std_detect v0.1.5 (C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std_detect)
   Compiling miniz_oxide v0.8.9
   Compiling addr2line v0.25.1                                                                                                                                                                                                                     
error[E0425]: cannot find value `SO_KEEPALIVE` in crate `libc`                                                                                                                                                                                     
   --> C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\net\connection\socket\unix.rs:460:59
    |
460 |         unsafe { setsockopt(self, libc::SOL_SOCKET, libc::SO_KEEPALIVE, keepalive as c_int) }
    |                                                           ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `SO_KEEPALIVE` in crate `libc`                                                                                                                                                                                     
   --> C:\Users\zqdq_\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\net\connection\socket\unix.rs:464:76
    |
464 |         let raw: c_int = unsafe { getsockopt(self, libc::SOL_SOCKET, libc::SO_KEEPALIVE)? };
    |                                                                            ^^^^^^^^^^^^ not found in `libc`

For more information about this error, try `rustc --explain E0425`.                                                                                                                                                                                
error: could not compile `std` (lib) due to 2 previous errors   

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 failure with cargo build --target thumbv7em-nuttx-eabihf -Zbuild-std=std, then inspect library/std/src/sys/net/connection/socket/unix.rs and the target-specific libc definitions involved in SO_KEEPALIVE. Check whether other *-nuttx-* targets show the same error. Done means the std build succeeds for the reported target and relevant target coverage is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.