Rollup merge of #123467 - dpaoliello:archcoff, r=wesleywiser

MSVC targets should use COFF as their archive format

While adding support for Arm64EC I ran into an issue where the standard library's rlib was missing the "EC Symbol Table" which is required for the MSVC linker to find import library symbols (generated by Rust's `raw-dylib` feature) when building for EC.

The root cause of the issue is that LLVM only generated symbol tables (including the EC Symbol Table) if the `ArchiveKind` is `COFF`, but the MSVC targets didn't set their archive format, so it was defaulting to GNU.
This commit is contained in:
Matthias Krüger 2024-04-06 08:56:34 +02:00 committed by GitHub
commit 84569f9086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -231,7 +231,11 @@ impl<'a> ArArchiveBuilder<'a> {
"gnu" => ArchiveKind::Gnu,
"bsd" => ArchiveKind::Bsd,
"darwin" => ArchiveKind::Darwin,
"coff" => ArchiveKind::Coff,
"coff" => {
// FIXME: ar_archive_writer doesn't support COFF archives yet.
// https://github.com/rust-lang/ar_archive_writer/issues/9
ArchiveKind::Gnu
}
"aix_big" => ArchiveKind::AixBig,
kind => {
self.sess.dcx().emit_fatal(UnknownArchiveKind { kind });

View file

@ -14,6 +14,7 @@ pub fn opts() -> TargetOptions {
pre_link_args,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
archive_format: "coff".into(),
// Currently this is the only supported method of debuginfo on MSVC
// where `*.pdb` files show up next to the final artifact.