rust-lang / rust-lang/rust

`--emit obj` with `--crate-type staticlib` doesn't work when `-C lto=thin` is set

Open
#134,998 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I tried this code:

// answer.rs
pub fn answer() -> u64 {
    42
}

And compiled it with:

rustc answer.rs --crate-type staticlib --emit obj -C lto=thin

I expected to see an object file created. Instead it appears to succeed but no object file is produced.

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1

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 issue with answer.rs and the reported rustc command using --crate-type staticlib, --emit obj, and -C lto=thin. Trace rustc's handling of these options and compare the output behavior with the expectation that an object file is created. Done means the command produces the expected object file and has coverage for this combination.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.