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

llvm-objcopy does not work on Rust .rlib archive files #53395

Open
jeffy1009 opened this issue Jan 25, 2022 · 3 comments
Open

llvm-objcopy does not work on Rust .rlib archive files #53395

jeffy1009 opened this issue Jan 25, 2022 · 3 comments
Labels
enhancement Improving things as opposed to bug fixing, e.g. new or missing feature rust Rust language tools:llvm-objcopy/strip

Comments

@jeffy1009
Copy link

Rust .rlib archive files contains object files and .rmeta files. Tools for working with .rlib file has been requested for several years but there's still no work on it yet. (rust-lang/rust#25820)

Most of the commands like nm, objdump, etc. work on .rlib file, although there is an error message about unrecognized format of .rmeta files. objcopy is one of them, and commands like objcopy -W foo libxxx.rlib still work, even though it complains about unrecognized .rmeta file.

But it seems that llvm-objcopy does not commit the changes to .rlib files if an error occurs.

I don't know if the policy is to mimic GNU tools' behavior, but it would be a lot more convenient if llvm-objcopy would behave similarly to objcopy in cases like this, provided that the side-effects caused by this change is expected to be small.
Otherwise, I have to extract the archive, apply the change to individual object files, and recreate the archive.

@EugeneZelenko EugeneZelenko added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature rust Rust language tools:llvm-objcopy/strip and removed new issue labels Jan 25, 2022
@llvmbot
Copy link
Member

llvmbot commented Jan 25, 2022

@llvm/issue-subscribers-tools-llvm-objcopy-strip

@jh7370
Copy link
Collaborator

jh7370 commented Jan 31, 2022

I've not given this much thought, but we could probably demote this error to a warning, in the case of archives. I'm not sure we want to remove the error entirely, as that could hide genuine issues people run into with their build-system (e.g. they try to use llvm-objcopy on an archive consisting entirely of unsupported outputs).

An alternative option would be to add specific "support" for .rmeta files, whereby llvm-objcopy ignores them specifically. I'm unfamiliar with Rust though, so I don't know if this would be safe to do. Someone with more Rust familiarity would have to sort that out.

@bjorn3
Copy link

bjorn3 commented May 15, 2022

Since rust-lang/rust#91604 the crate metadata is wrapped in a regular object file on most platforms. Wasm being the notable exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving things as opposed to bug fixing, e.g. new or missing feature rust Rust language tools:llvm-objcopy/strip
Projects
None yet
Development

No branches or pull requests

5 participants