rust-lang / rust-lang/rust

`--print=native-static-libs` is not emitted to `stdout`, but instead to `stderr`

Open
#125,304 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Running the following:

$ echo "" > empty.rs
$ rustc empty.rs --crate-type=staticlib --print=native-static-libs
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.

note: native-static-libs: -lSystem -lc -lm

I.e. it does produce the expected native-static-libs: ... note, but the note is emitted to the stderr stream, instead of stdout, as is done by the other --print=... flags.

I expected to be able to pipe the output to e.g. grep to extract the note, but no such luck:

$ rustc empty.rs --crate-type=staticlib --print=native-static-libs | grep native-static-libs
Meta

rustc --version --verbose:

rustc 1.80.0-nightly (e82c861d7 2024-05-04)
binary: rustc
commit-hash: e82c861d7e5ecd766cb0dab0bf622445dec999dc
commit-date: 2024-05-04
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.4

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

Start by reproducing the rustc empty.rs --crate-type=staticlib --print=native-static-libs command and trace the --print=native-static-libs handling in rustc. Compare its output stream with other --print flags, then verify that the native-static-libs note can be captured from stdout while the existing content remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.