Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
infinity0 opened this issue Aug 12, 2018 · 3 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-linkage Area: linking into static, shared libraries and binaries C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@infinity0
Copy link
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.

@infinity0
Copy link
Contributor Author

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

@retep998
Copy link
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.

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries A-driver Area: rustc_driver that ties everything together into the `rustc` compiler T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jan 27, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Mar 6, 2023

(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
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-linkage Area: linking into static, shared libraries and binaries C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants