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

Sync to LLVM 18.1.3 #14

Merged
merged 2 commits into from
Apr 16, 2024
Merged

Sync to LLVM 18.1.3 #14

merged 2 commits into from
Apr 16, 2024

Conversation

dpaoliello
Copy link
Contributor

@dpaoliello dpaoliello commented Apr 11, 2024

Syncs to LLVM 18.1.3:

  • Adds support for COFF.
  • Adds support for Arm64EC.
  • Adds support for AIX symbol tables.

Other changes:

  • Move LLVM C++ files into reference directory, to make it clear that they aren't built.
  • Moved all object parsing into a new object_reader module, and replaced the single get_symbol callback with an ObjectReader struct that has all the callbacks we require for reading object files.
  • Bumped object to latest.
  • Synced round-trip tests with object.
  • Requires beta Rust toolchain (1.78) since this has LLVM 18.
  • Got clippy clean and added clippy to CI.

Fixes #9

src/lib.rs Show resolved Hide resolved
src/archive_writer.rs Outdated Show resolved Hide resolved

struct SymbolicFile<'a> {
data: &'a [u8],
parsed: File<'a>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ar_archive_writer intentionally doesn't parse object files. When used as part of rustc symbols we need to get symbols from LLVM bitcode files, which only LLVM itself can. This is why the get_symbols field is used for getting symbols instead. Rustc overrides it with a function which calls into LLVM to get all symbols.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be able to avoid parsing in most cases, but I'm not sure what to do about AIX symbol tables: we need to know if the obj is 32 or 64 bit to place the symbols in the correct table, and we need to get the alignment. Should I add new callbacks for both of those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've moved everything that was using the object crate into a new object_reader module and replaced the get_symbol function pointer with an ObjectReader struct that has function pointers for each of the functions that need to parse object files.

src/archive_writer.rs Outdated Show resolved Hide resolved
match &obj.parsed {
File::Coff(coff_obj) => {
coff_obj.architecture() != Architecture::Aarch64
|| coff_obj.sub_architecture() == Some(SubArchitecture::Arm64EC)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cover import files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it doesn't handle llvm bitcode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in support for import files, but not for bitcode - we can either try to add this later, or have the LLVM backend provide an implementation that does check for bitcode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support for reading bitcode is currently done by the LLVM backend of rustc by overriding get_symbols (now object_reader).

src/archive_writer.rs Outdated Show resolved Hide resolved
src/archive_writer.rs Outdated Show resolved Hide resolved
@bjorn3
Copy link
Member

bjorn3 commented Apr 12, 2024

I'm done with this review round.

@bjorn3 bjorn3 merged commit a40cba3 into rust-lang:master Apr 16, 2024
2 checks passed
@bjorn3
Copy link
Member

bjorn3 commented Apr 16, 2024

Thanks a lot for this!

@bjorn3
Copy link
Member

bjorn3 commented Apr 16, 2024

Anything else to do before I publish it to crates.io?

@dpaoliello dpaoliello deleted the sync branch April 16, 2024 15:17
@dpaoliello
Copy link
Contributor Author

Anything else to do before I publish it to crates.io?

Nope, I think this is good to go!

@bjorn3
Copy link
Member

bjorn3 commented Apr 16, 2024

Done. The rustc update to 0.2.0 got approved earlier today.

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

Successfully merging this pull request may close these issues.

Add support for creating COFF archives
2 participants