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

FR: Support bitcode for library mode bindings generation #2251

Open
cerisier opened this issue Oct 2, 2024 · 0 comments
Open

FR: Support bitcode for library mode bindings generation #2251

cerisier opened this issue Oct 2, 2024 · 0 comments

Comments

@cerisier
Copy link

cerisier commented Oct 2, 2024

When using LTO and especially the -Clinker-plugin-lto option, object files are emitted as LLVM bitcode and not machine code.

Currently, uniffi_bindgen only supports proper machine code and fails to extract metadata from object files that contain LLVM bitcode and fails with a Unknown library format.

fn extract_from_bytes(file_data: &[u8]) -> anyhow::Result<Vec<Metadata>> {
match Object::parse(file_data)? {
Object::Elf(elf) => extract_from_elf(elf, file_data),
Object::PE(pe) => extract_from_pe(pe, file_data),
Object::Mach(mach) => extract_from_mach(mach, file_data),
Object::Archive(archive) => extract_from_archive(archive, file_data),
_ => bail!("Unknown library format"),
}
}

Since the binary metadata extraction is currently solely based on goblin capabilities, I was wondering:

  1. Does it makes sense for uniffi to support bitcode ?
    a. Given that it contains all required metadata as in normal machine code.
  2. What would be the way to implement it as I am not sure that the goblin crate would accept bitcode support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant