linker stderr: ld: ignoring duplicate libraries: '-lc', '-lm' on macOS when using `getrandom` dependency
Open
Nobody has claimed this yet.
A-linkage
C-bug
O-apple
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
use getrandom as _;
fn main() {}
➜ example git:(main) ✗ cat Cargo.toml
[package]
name = "example"
version = "0.1.0"
edition = "2024"
[lints.rust]
linker-messages = "deny"
[dependencies]
getrandom = { version = "0.3.4", default-features = false }
I expected to see this happen: cargo build to run fine.
Instead, this happened: cargo build erred with:
error: linker stderr: ld: ignoring duplicate libraries: '-lc', '-lm'
|
= note: requested on the command line with `-D linker-messages`
error: could not compile `example` (bin "example") due to 1 previous error
Meta
rustc --version --verbose:
rustc 1.93.0 (254b59607 2026-01-19)
binary: rustc
commit-hash: 254b59607d4417e9dffbc307138ae5c86280fe4c
commit-date: 2026-01-19
host: aarch64-apple-darwin
release: 1.93.0
LLVM version: 21.1.8
➜ ~ uname -a
Darwin ZC0XYQV3R3Q 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041 arm64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the shown Cargo.toml, Rust example, and cargo build on macOS using linker-messages = "deny". Start by tracing how rustc handles linker stderr and the duplicate -lc and -lm messages from the getrandom dependency. Done means the example builds without treating these expected linker messages as a fatal error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100