-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tools for dumping information about .rlibs #25820
Comments
cc me For inspecting metadata this tool might be a good starting point. I have a version of that for post-reform metadata, I'll update the script soon. |
👍 |
All rlibs are actually just static archives (e.g. |
Would you expect ldd to work? Otool on os x does not |
I think that |
(sorry about the 20 questions, but I can't find any resources on this stuff) How do .rlibs link against 'normal' dynamic libraries provided to rustc via -l ? Is there an ELF image inside the ar somewhere that's dynamically linked against them? Or does rust embed dynamic loader code e.g dlopen? |
That... may be because none exist :(. I'm more than willing to answer questions though!
No actual linkage occurs, the compiler emits information into the rlib metadata saying what dynamic native libraries should be linked in later, but they're not actually linked until the rlib is linked into a dylib or executable. If the rlib is later used to assemble a staticlib the compiler just prints out what native libraries are needed to link everything.
Nah the only ELF file inside rlibs is the object file that the compiler generates (and possibly the object files of native static libraries linked against).
No the compiler doesn't embed any code like this in this respect. |
Thanks, Alex :) |
What is the status of this? I wouldn't mind working on something like this, I think I could do it fairly easy, as long as someone pointed me at the format of metadata. Also, while I'm here, what precisely is |
@alexcrichton sorry I always forget to ping and not sure if notified since this is very old thread |
AFAIK no changes. You'd basically need to read the compiler source to learn what these are, rlibs are full of internal implementation details. |
I see. Is this something that's still actively desired, or not really? And what did you mean above about tightly integrated with rustdoc? The tool would use it as a lib to pretty print the metadata, or something else? |
With not really much activity for >2 years I wouldn't necessarily classify this as "actively desired". The effort required to stabilize something like this seems quite high, but adding debugging utilities on nightly perhaps may not be so hard. |
Ok. While you're here, do you know offhand what the contents of |
Yes it's just compressed LLVM bytecode. The actual format is a bit wonky with some headers and maybe a footer, you'd have to look around in trans for the exact format. |
Cool, thanks so much for your time and answers :) Let me know if there's something similar to this w.r.t. binary formats, etc., that might need some help/tooling, would be interested in helping. |
I am trying to obtain the stdlib bitcode, so I can use |
Triage; not aware of anyone having implemented this, which, given the fact that all of this is unstable, isn't that surprising. It would be nice to have, but it's unclear that it's a good idea to keep this issue open. |
This os really needed feature, as currently IDEs (Idea and rls/rust-analyzer) have to expand all macros and analyze source code of dependecies. It would be nice if they would be able to extract info about types and signarures from rlib in sone json format. AFAIK Currently there are no way to provide autocompletion for proc-macro generated code. Only for regular macros, as IDEs are expanding them by themselves, but it looks like overkill for already compiled libraries. |
Current rustc has
I also wrote https://github.com/bjorn3/rust_read_rlib at some point, but it would need to be updated to latest rustc. |
It seriously vexes me that things like this can't be allowed on stable because somebody would inevitably come to rely on the exact format of the output. :-( Specifically, the part where we can't inspect the rust-specific metadata. The fact that such functionality would be nightly-only probably isn't helping to motivate anyone to implement it. |
It would be great if there was a set of tools for dumping information about a given .rlib. This could be used to debug linkage and export issues.
Something like
nm
andldd
.I note that
nm
does appear to partly work on a .rlib, but the output is a bit raw.Where is the best place to start for understanding the .rlib format as it stands? Is it a good idea to build this on
rustc::metadata
?See also http://stackoverflow.com/questions/24603672/rust-library-for-inspecting-rlib-binaries
The text was updated successfully, but these errors were encountered: