about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-27 22:39:37 +0100
committerGitHub <noreply@github.com>2020-03-27 22:39:37 +0100
commit08e867cc3a30f8fb3339cfcc3dbb4daff6da3dcc (patch)
treefe3aced007575530ecc4798287aac037cd504cbe /src
parent75208942f6144daac669e8e382029fc33bdce841 (diff)
parent02840ca8ab3a1eddda05bc2cbc9df62213fa2b3d (diff)
downloadrust-08e867cc3a30f8fb3339cfcc3dbb4daff6da3dcc.tar.gz
rust-08e867cc3a30f8fb3339cfcc3dbb4daff6da3dcc.zip
Rollup merge of #70345 - nnethercote:rm-no_integrated_as, r=alexcrichton
Remove `no_integrated_as` mode.

Specifically, remove both `-Z no_integrated_as` and
`TargetOptions::no_integrated_as`. The latter was only used for the
`msp430_none_elf` platform, for which it's no longer required.

r? @alexcrichton
Diffstat (limited to 'src')
-rw-r--r--src/librustc_codegen_llvm/back/write.rs63
-rw-r--r--src/librustc_codegen_ssa/back/write.rs66
-rw-r--r--src/librustc_interface/tests.rs4
-rw-r--r--src/librustc_session/options.rs2
-rw-r--r--src/librustc_target/spec/mod.rs8
-rw-r--r--src/librustc_target/spec/msp430_none_elf.rs1
-rw-r--r--src/test/run-make-fulldeps/no-integrated-as/Makefile8
-rw-r--r--src/test/run-make-fulldeps/no-integrated-as/hello.rs3
8 files changed, 26 insertions, 129 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 1557630fc7a..77cae038fe5 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -16,9 +16,7 @@ use crate::ModuleLlvm;
 use log::debug;
 use rustc::bug;
 use rustc::ty::TyCtxt;
-use rustc_codegen_ssa::back::write::{
-    run_assembler, BitcodeSection, CodegenContext, EmitObj, ModuleConfig,
-};
+use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
 use rustc_codegen_ssa::traits::*;
 use rustc_codegen_ssa::{CompiledModule, ModuleCodegen, RLIB_BYTECODE_EXTENSION};
 use rustc_data_structures::small_c_str::SmallCStr;
@@ -734,18 +732,21 @@ pub(crate) unsafe fn codegen(
             })?;
         }
 
-        let config_emit_object_code = matches!(config.emit_obj, EmitObj::ObjectCode(_));
-
-        if config.emit_asm || (config_emit_object_code && config.no_integrated_as) {
+        if config.emit_asm {
             let _timer = cgcx
                 .prof
                 .generic_activity_with_arg("LLVM_module_codegen_emit_asm", &module.name[..]);
             let path = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
 
-            // We can't use the same module for asm and binary output, because that triggers
-            // various errors like invalid IR or broken binaries, so we might have to clone the
-            // module to produce the asm output
-            let llmod = if config_emit_object_code { llvm::LLVMCloneModule(llmod) } else { llmod };
+            // We can't use the same module for asm and object code output,
+            // because that triggers various errors like invalid IR or broken
+            // binaries. So we must clone the module to produce the asm output
+            // if we are also producing object code.
+            let llmod = if let EmitObj::ObjectCode(_) = config.emit_obj {
+                llvm::LLVMCloneModule(llmod)
+            } else {
+                llmod
+            };
             with_codegen(tm, llmod, config.no_builtins, |cpm| {
                 write_output_file(diag_handler, tm, cpm, llmod, &path, llvm::FileType::AssemblyFile)
             })?;
@@ -753,34 +754,19 @@ pub(crate) unsafe fn codegen(
 
         match config.emit_obj {
             EmitObj::ObjectCode(_) => {
-                if !config.no_integrated_as {
-                    let _timer = cgcx.prof.generic_activity_with_arg(
-                        "LLVM_module_codegen_emit_obj",
-                        &module.name[..],
-                    );
-                    with_codegen(tm, llmod, config.no_builtins, |cpm| {
-                        write_output_file(
-                            diag_handler,
-                            tm,
-                            cpm,
-                            llmod,
-                            &obj_out,
-                            llvm::FileType::ObjectFile,
-                        )
-                    })?;
-                } else {
-                    let _timer = cgcx.prof.generic_activity_with_arg(
-                        "LLVM_module_codegen_asm_to_obj",
-                        &module.name[..],
-                    );
-                    let assembly =
-                        cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
-                    run_assembler(cgcx, diag_handler, &assembly, &obj_out);
-
-                    if !config.emit_asm && !cgcx.save_temps {
-                        drop(fs::remove_file(&assembly));
-                    }
-                }
+                let _timer = cgcx
+                    .prof
+                    .generic_activity_with_arg("LLVM_module_codegen_emit_obj", &module.name[..]);
+                with_codegen(tm, llmod, config.no_builtins, |cpm| {
+                    write_output_file(
+                        diag_handler,
+                        tm,
+                        cpm,
+                        llmod,
+                        &obj_out,
+                        llvm::FileType::ObjectFile,
+                    )
+                })?;
             }
 
             EmitObj::Bitcode => {
@@ -802,6 +788,7 @@ pub(crate) unsafe fn codegen(
 
         drop(handlers);
     }
+
     Ok(module.into_compiled_module(
         config.emit_obj != EmitObj::None,
         config.emit_bc,
diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs
index e9b3bf026b2..7833f22097c 100644
--- a/src/librustc_codegen_ssa/back/write.rs
+++ b/src/librustc_codegen_ssa/back/write.rs
@@ -1,5 +1,4 @@
-use super::command::Command;
-use super::link::{self, get_linker, remove};
+use super::link::{self, remove};
 use super::linker::LinkerInfo;
 use super::lto::{self, SerializedModule};
 use super::symbol_export::symbol_name_for_instance_in_crate;
@@ -116,7 +115,6 @@ pub struct ModuleConfig {
     pub merge_functions: bool,
     pub inline_threshold: Option<usize>,
     pub new_llvm_pass_manager: Option<bool>,
-    pub no_integrated_as: bool,
 }
 
 impl ModuleConfig {
@@ -140,7 +138,6 @@ impl ModuleConfig {
             emit_ir: false,
             emit_asm: false,
             emit_obj: EmitObj::None,
-            no_integrated_as: false,
 
             verify_llvm_ir: false,
             no_prepopulate_passes: false,
@@ -202,12 +199,6 @@ impl ModuleConfig {
     }
 }
 
-/// Assembler name and command used by codegen when no_integrated_as is enabled
-pub struct AssemblerCommand {
-    name: PathBuf,
-    cmd: Command,
-}
-
 // HACK(eddyb) work around `#[derive]` producing wrong bounds for `Clone`.
 pub struct TargetMachineFactory<B: WriteBackendMethods>(
     pub Arc<dyn Fn() -> Result<B::TargetMachine, String> + Send + Sync>,
@@ -260,8 +251,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
     pub cgu_reuse_tracker: CguReuseTracker,
     // Channel back to the main control thread to send messages to
     pub coordinator_send: Sender<Box<dyn Any + Send>>,
-    // The assembler command if no_integrated_as option is enabled, None otherwise
-    pub assembler_cmd: Option<Arc<AssemblerCommand>>,
 }
 
 impl<B: WriteBackendMethods> CodegenContext<B> {
@@ -415,9 +404,6 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
 
     modules_config.emit_pre_lto_bc = need_pre_lto_bitcode_for_incr_comp(sess);
 
-    modules_config.no_integrated_as =
-        tcx.sess.opts.cg.no_integrated_as || tcx.sess.target.target.options.no_integrated_as;
-
     for output_type in sess.opts.output_types.keys() {
         match *output_type {
             OutputType::Bitcode => {
@@ -1030,17 +1016,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
         each_linked_rlib_for_lto.push((cnum, path.to_path_buf()));
     }));
 
-    let assembler_cmd = if modules_config.no_integrated_as {
-        // HACK: currently we use linker (gcc) as our assembler
-        let (linker, flavor) = link::linker_and_flavor(sess);
-
-        let (name, mut cmd) = get_linker(sess, &linker, flavor);
-        cmd.args(&sess.target.target.options.asm_args);
-        Some(Arc::new(AssemblerCommand { name, cmd }))
-    } else {
-        None
-    };
-
     let ol = if tcx.sess.opts.debugging_opts.no_codegen
         || !tcx.sess.opts.output_types.should_codegen()
     {
@@ -1076,7 +1051,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
         target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(),
         target_arch: tcx.sess.target.target.arch.clone(),
         debuginfo: tcx.sess.opts.debuginfo,
-        assembler_cmd,
     };
 
     // This is the "main loop" of parallel work happening for parallel codegen.
@@ -1610,44 +1584,6 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
     });
 }
 
-pub fn run_assembler<B: ExtraBackendMethods>(
-    cgcx: &CodegenContext<B>,
-    handler: &Handler,
-    assembly: &Path,
-    object: &Path,
-) {
-    let assembler = cgcx.assembler_cmd.as_ref().expect("cgcx.assembler_cmd is missing?");
-
-    let pname = &assembler.name;
-    let mut cmd = assembler.cmd.clone();
-    cmd.arg("-c").arg("-o").arg(object).arg(assembly);
-    debug!("{:?}", cmd);
-
-    match cmd.output() {
-        Ok(prog) => {
-            if !prog.status.success() {
-                let mut note = prog.stderr.clone();
-                note.extend_from_slice(&prog.stdout);
-
-                handler
-                    .struct_err(&format!(
-                        "linking with `{}` failed: {}",
-                        pname.display(),
-                        prog.status
-                    ))
-                    .note(&format!("{:?}", &cmd))
-                    .note(str::from_utf8(&note[..]).unwrap())
-                    .emit();
-                handler.abort_if_errors();
-            }
-        }
-        Err(e) => {
-            handler.err(&format!("could not exec the linker `{}`: {}", pname.display(), e));
-            handler.abort_if_errors();
-        }
-    }
-}
-
 enum SharedEmitterMessage {
     Diagnostic(Diagnostic),
     InlineAsmError(u32, String),
diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs
index 6a6d0a8f061..8a8ba8a96f7 100644
--- a/src/librustc_interface/tests.rs
+++ b/src/librustc_interface/tests.rs
@@ -452,10 +452,6 @@ fn test_codegen_options_tracking_hash() {
     assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
 
     opts = reference.clone();
-    opts.cg.no_integrated_as = true;
-    assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
-
-    opts = reference.clone();
     opts.cg.no_redzone = Some(true);
     assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
 
diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs
index 72c720d09b0..9d49075ebbc 100644
--- a/src/librustc_session/options.rs
+++ b/src/librustc_session/options.rs
@@ -665,8 +665,6 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
         "use soft float ABI (*eabihf targets only)"),
     prefer_dynamic: bool = (false, parse_bool, [TRACKED],
         "prefer dynamic linking to static linking"),
-    no_integrated_as: bool = (false, parse_bool, [TRACKED],
-        "use an external assembler rather than LLVM's integrated one"),
     no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "disable the use of the redzone"),
     relocation_model: Option<String> = (None, parse_opt_string, [TRACKED],
diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs
index 6d688c12977..1bc2bf12fad 100644
--- a/src/librustc_target/spec/mod.rs
+++ b/src/librustc_target/spec/mod.rs
@@ -712,11 +712,6 @@ pub struct TargetOptions {
     // will 'just work'.
     pub obj_is_bitcode: bool,
 
-    // LLVM can't produce object files for this target. Instead, we'll make LLVM
-    // emit assembly and then use `gcc` to turn that assembly into an object
-    // file
-    pub no_integrated_as: bool,
-
     /// Don't use this field; instead use the `.min_atomic_width()` method.
     pub min_atomic_width: Option<u64>,
 
@@ -872,7 +867,6 @@ impl Default for TargetOptions {
             allow_asm: true,
             has_elf_tls: false,
             obj_is_bitcode: false,
-            no_integrated_as: false,
             min_atomic_width: None,
             max_atomic_width: None,
             atomic_cas: true,
@@ -1187,7 +1181,6 @@ impl Target {
         key!(main_needs_argc_argv, bool);
         key!(has_elf_tls, bool);
         key!(obj_is_bitcode, bool);
-        key!(no_integrated_as, bool);
         key!(max_atomic_width, Option<u64>);
         key!(min_atomic_width, Option<u64>);
         key!(atomic_cas, bool);
@@ -1415,7 +1408,6 @@ impl ToJson for Target {
         target_option_val!(main_needs_argc_argv);
         target_option_val!(has_elf_tls);
         target_option_val!(obj_is_bitcode);
-        target_option_val!(no_integrated_as);
         target_option_val!(min_atomic_width);
         target_option_val!(max_atomic_width);
         target_option_val!(atomic_cas);
diff --git a/src/librustc_target/spec/msp430_none_elf.rs b/src/librustc_target/spec/msp430_none_elf.rs
index e05a18e76d2..9a90ac7ccec 100644
--- a/src/librustc_target/spec/msp430_none_elf.rs
+++ b/src/librustc_target/spec/msp430_none_elf.rs
@@ -22,7 +22,6 @@ pub fn target() -> TargetResult {
             // dependency on this specific gcc.
             asm_args: vec!["-mcpu=msp430".to_string()],
             linker: Some("msp430-elf-gcc".to_string()),
-            no_integrated_as: true,
 
             // There are no atomic CAS instructions available in the MSP430
             // instruction set, and the LLVM backend doesn't currently support
diff --git a/src/test/run-make-fulldeps/no-integrated-as/Makefile b/src/test/run-make-fulldeps/no-integrated-as/Makefile
deleted file mode 100644
index 1567b325d4f..00000000000
--- a/src/test/run-make-fulldeps/no-integrated-as/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
--include ../tools.mk
-
-# only-linux
-# only-x86_64
-
-all:
-	$(RUSTC) hello.rs -C no_integrated_as
-	$(call RUN,hello)
diff --git a/src/test/run-make-fulldeps/no-integrated-as/hello.rs b/src/test/run-make-fulldeps/no-integrated-as/hello.rs
deleted file mode 100644
index e7a11a969c0..00000000000
--- a/src/test/run-make-fulldeps/no-integrated-as/hello.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
-    println!("Hello, world!");
-}