Skip to content

Add a feature to print actual static libs linked in, --print=native-static-libs seems not to work #53281

@infinity0

Description

@infinity0
Contributor

For Debian we need to keep track of static libs linked into a final binary, for copyright purposes.

It seems that src/librustc_codegen_llvm/back/link.rs performs the actual linking and search of paths, and it refers to a --print=native-static-libs option but this doesn't seem to work.

For example when I link to the system libbacktrace and then build this with RUSTFLAGS="--print=native-static-libs" cargo build --verbose --verbose --verbose I can see the build.rs output which is

cargo:rustc-link-lib=static=backtrace
cargo:rustc-link-search=native=/usr/lib/gcc/x86_64-linux-gnu/7/

But then I don't see any follow-up output that indicates that rustc actually found the file /usr/lib/gcc/x86_64-linux-gnu/7/libbacktrace.a and this was what was actually linked into the final backtrace-sys.rlib.

Activity

infinity0

infinity0 commented on Aug 12, 2018

@infinity0
ContributorAuthor

@kornelski You were the one that originally implemented --print=native-static-libs in #43067 any comments?

retep998

retep998 commented on Aug 12, 2018

@retep998
Member

This is not what --print=native-static-libs was intended for, but rather it is for when your crate type is staticlib and it tells you what libraries you must link to when linking to that staticlib.

Certainly though there is room for a feature here to confirm which static libraries the static kind actually ended up pulling in. We can't do the same for the dylib or static-nobundle kinds though because in those cases it is the linker itself that is responsible for choosing what to link to.

added
A-linkageArea: linking into static, shared libraries and binaries
A-driverArea: rustc_driver that ties everything together into the `rustc` compiler
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
on Jan 27, 2019
pnkfelix

pnkfelix commented on Mar 6, 2023

@pnkfelix
Member

(deleted comment that had missed the point of what the original issue filer was concerned about, and thus was forking the discussion into the wrong direction. My comment has now been refiled as #108825.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerA-linkageArea: linking into static, shared libraries and binariesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @infinity0@pnkfelix@retep998@jonas-schievink

        Issue actions

          Add a feature to print actual static libs linked in, --print=native-static-libs seems not to work · Issue #53281 · rust-lang/rust