summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-08-16 19:32:22 +0000
committerChris Denton <chris@chrisdenton.dev>2024-08-17 19:10:46 +0000
commit0156eb57a152003c0c82552229747b3d04e1fddc (patch)
tree249846c9486615f1e2434cfbf0ac0995260389f5 /compiler/rustc_codegen_cranelift
parent27b93da8de2477b3a41811b0ee486cffa99fa00e (diff)
downloadrust-0156eb57a152003c0c82552229747b3d04e1fddc.tar.gz
rust-0156eb57a152003c0c82552229747b3d04e1fddc.zip
Always use ar_archive_writer for import libs
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r--compiler/rustc_codegen_cranelift/src/archive.rs83
-rw-r--r--compiler/rustc_codegen_cranelift/src/lib.rs1
2 files changed, 1 insertions, 83 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/archive.rs b/compiler/rustc_codegen_cranelift/src/archive.rs
index 5eedab4f2cb..c7725e49c94 100644
--- a/compiler/rustc_codegen_cranelift/src/archive.rs
+++ b/compiler/rustc_codegen_cranelift/src/archive.rs
@@ -1,13 +1,6 @@
-use std::borrow::Borrow;
-use std::fs;
-use std::path::Path;
-
-use ar_archive_writer::{COFFShortExport, MachineTypes};
 use rustc_codegen_ssa::back::archive::{
-    create_mingw_dll_import_lib, ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder,
-    DEFAULT_OBJECT_READER,
+    ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
 };
-use rustc_codegen_ssa::common::is_mingw_gnu_toolchain;
 use rustc_session::Session;
 
 pub(crate) struct ArArchiveBuilderBuilder;
@@ -16,78 +9,4 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
     fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
         Box::new(ArArchiveBuilder::new(sess, &DEFAULT_OBJECT_READER))
     }
-
-    fn create_dll_import_lib(
-        &self,
-        sess: &Session,
-        lib_name: &str,
-        import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
-        output_path: &Path,
-    ) {
-        if is_mingw_gnu_toolchain(&sess.target) {
-            // The binutils linker used on -windows-gnu targets cannot read the import
-            // libraries generated by LLVM: in our attempts, the linker produced an .EXE
-            // that loaded but crashed with an AV upon calling one of the imported
-            // functions. Therefore, use binutils to create the import library instead,
-            // by writing a .DEF file to the temp dir and calling binutils's dlltool.
-            create_mingw_dll_import_lib(
-                sess,
-                lib_name,
-                import_name_and_ordinal_vector,
-                output_path,
-            );
-        } else {
-            let mut file =
-                match fs::OpenOptions::new().write(true).create_new(true).open(&output_path) {
-                    Ok(file) => file,
-                    Err(error) => {
-                        sess.dcx().fatal(format!(
-                            "failed to create import library file `{path}`: {error}",
-                            path = output_path.display(),
-                        ));
-                    }
-                };
-
-            let machine = match sess.target.arch.borrow() {
-                "x86" => MachineTypes::I386,
-                "x86_64" => MachineTypes::AMD64,
-                "arm" => MachineTypes::ARMNT,
-                "aarch64" => MachineTypes::ARM64,
-                _ => {
-                    sess.dcx().fatal(format!(
-                        "unsupported target architecture `{arch}`",
-                        arch = sess.target.arch,
-                    ));
-                }
-            };
-
-            let exports = import_name_and_ordinal_vector
-                .iter()
-                .map(|(name, ordinal)| COFFShortExport {
-                    name: name.to_string(),
-                    ext_name: None,
-                    symbol_name: None,
-                    alias_target: None,
-                    ordinal: ordinal.unwrap_or(0),
-                    noname: ordinal.is_some(),
-                    data: false,
-                    private: false,
-                    constant: false,
-                })
-                .collect::<Vec<_>>();
-
-            if let Err(error) = ar_archive_writer::write_import_library(
-                &mut file,
-                lib_name,
-                &exports,
-                machine,
-                !sess.target.is_like_msvc,
-            ) {
-                sess.dcx().fatal(format!(
-                    "failed to create import library `{path}`: `{error}`",
-                    path = output_path.display(),
-                ));
-            }
-        }
-    }
 }
diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs
index 21930fa2ddb..f737af25b62 100644
--- a/compiler/rustc_codegen_cranelift/src/lib.rs
+++ b/compiler/rustc_codegen_cranelift/src/lib.rs
@@ -12,7 +12,6 @@
 #![warn(unused_lifetimes)]
 // tidy-alphabetical-end
 
-extern crate ar_archive_writer;
 extern crate jobserver;
 #[macro_use]
 extern crate rustc_middle;