-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Add rustc --emit=link-info for staticlib link-line output #31471
Copy link
Copy link
Open
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
When linking rust into C++ projects, I use
rustc --crate-type=staticlibto generate a static library which I can link into the overall project. Since there's no standard for transitive dependency declaration in the C ABI for static libraries, rustc prints out a list of libraries which need to be linked along with the staticlib. (#25820 (comment))This is very helpful in development, but not ideal for automation. I propose adding an
--emit=link-infooption (--emit=libs?--emit=ldflags?) to write the required link line out to a file for use later, similar to--emit=dep-infofor makefile dependency generation.Order of evaluation is a little trickier than with dep-info since it has to work the first time, but this should simplify funky stderr hacks like
into