about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-22 15:22:49 +0000
committerbors <bors@rust-lang.org>2024-03-22 15:22:49 +0000
commit2fae357cb87d6ec184a34892394d4e737ecd6030 (patch)
tree2e95d58c16c36d9159307f386ce1912c94bc4fff /compiler/rustc_codegen_ssa/src
parentf61f45f2336ad473ca152252f81e447ae19e0553 (diff)
parentee57d2b318fc17080740172896269cd9865a17f4 (diff)
downloadrust-2fae357cb87d6ec184a34892394d4e737ecd6030.tar.gz
rust-2fae357cb87d6ec184a34892394d4e737ecd6030.zip
Auto merge of #3394 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/command.rs6
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs17
-rw-r--r--compiler/rustc_codegen_ssa/src/back/symbol_export.rs4
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/intrinsic.rs7
-rw-r--r--compiler/rustc_codegen_ssa/src/mono_item.rs46
-rw-r--r--compiler/rustc_codegen_ssa/src/traits/backend.rs7
6 files changed, 40 insertions, 47 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/command.rs b/compiler/rustc_codegen_ssa/src/back/command.rs
index 9b0ba34135c..3a89be89951 100644
--- a/compiler/rustc_codegen_ssa/src/back/command.rs
+++ b/compiler/rustc_codegen_ssa/src/back/command.rs
@@ -100,12 +100,6 @@ impl Command {
             Program::Lld(ref p, flavor) => {
                 let mut c = process::Command::new(p);
                 c.arg("-flavor").arg(flavor.as_str());
-                if let LldFlavor::Wasm = flavor {
-                    // LLVM expects host-specific formatting for @file
-                    // arguments, but we always generate posix formatted files
-                    // at this time. Indicate as such.
-                    c.arg("--rsp-quoting=posix");
-                }
                 c
             }
         };
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index f5e8d5fc92a..c8b8594c0dd 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -785,7 +785,7 @@ fn link_natively<'a>(
     let mut i = 0;
     loop {
         i += 1;
-        prog = sess.time("run_linker", || exec_linker(sess, &cmd, out_filename, tmpdir));
+        prog = sess.time("run_linker", || exec_linker(sess, &cmd, out_filename, flavor, tmpdir));
         let Ok(ref output) = prog else {
             break;
         };
@@ -1576,6 +1576,7 @@ fn exec_linker(
     sess: &Session,
     cmd: &Command,
     out_filename: &Path,
+    flavor: LinkerFlavor,
     tmpdir: &Path,
 ) -> io::Result<Output> {
     // When attempting to spawn the linker we run a risk of blowing out the
@@ -1584,9 +1585,9 @@ fn exec_linker(
     //
     // Here we attempt to handle errors from the OS saying "your list of
     // arguments is too big" by reinvoking the linker again with an `@`-file
-    // that contains all the arguments. The theory is that this is then
-    // accepted on all linkers and the linker will read all its options out of
-    // there instead of looking at the command line.
+    // that contains all the arguments (aka 'response' files).
+    // The theory is that this is then accepted on all linkers and the linker
+    // will read all its options out of there instead of looking at the command line.
     if !cmd.very_likely_to_exceed_some_spawn_limit() {
         match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() {
             Ok(child) => {
@@ -1606,8 +1607,12 @@ fn exec_linker(
     let mut args = String::new();
     for arg in cmd2.take_args() {
         args.push_str(
-            &Escape { arg: arg.to_str().unwrap(), is_like_msvc: sess.target.is_like_msvc }
-                .to_string(),
+            &Escape {
+                arg: arg.to_str().unwrap(),
+                // LLD also uses MSVC-like parsing for @-files by default when running on windows hosts
+                is_like_msvc: sess.target.is_like_msvc || (cfg!(windows) && flavor.uses_lld()),
+            }
+            .to_string(),
         );
         args.push('\n');
     }
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index 87b6f0e914c..b19f52182b6 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -81,10 +81,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
                 return library.kind.is_statically_included().then_some(def_id);
             }
 
-            if tcx.intrinsic(def_id).is_some_and(|i| i.must_be_overridden) {
-                return None;
-            }
-
             // Only consider nodes that actually have exported symbols.
             match tcx.def_kind(def_id) {
                 DefKind::Fn | DefKind::Static { .. } => {}
diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
index ba023f96107..5532ff6e6a5 100644
--- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
@@ -1,7 +1,6 @@
 use super::operand::{OperandRef, OperandValue};
 use super::place::PlaceRef;
 use super::FunctionCx;
-use crate::common::IntPredicate;
 use crate::errors;
 use crate::errors::InvalidMonomorphization;
 use crate::meth;
@@ -456,12 +455,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                 return Ok(());
             }
 
-            sym::ptr_guaranteed_cmp => {
-                let a = args[0].immediate();
-                let b = args[1].immediate();
-                bx.icmp(IntPredicate::IntEQ, a, b)
-            }
-
             sym::ptr_offset_from | sym::ptr_offset_from_unsigned => {
                 let ty = fn_args.type_at(0);
                 let pointee_size = bx.layout_of(ty).size;
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index 7b7cdae0ed6..df564f705bc 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -2,6 +2,7 @@ use crate::base;
 use crate::common;
 use crate::traits::*;
 use rustc_hir as hir;
+use rustc_middle::mir::interpret::ErrorHandled;
 use rustc_middle::mir::mono::MonoItem;
 use rustc_middle::mir::mono::{Linkage, Visibility};
 use rustc_middle::ty;
@@ -40,23 +41,34 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
                         .iter()
                         .map(|(op, op_sp)| match *op {
                             hir::InlineAsmOperand::Const { ref anon_const } => {
-                                let const_value = cx
-                                    .tcx()
-                                    .const_eval_poly(anon_const.def_id.to_def_id())
-                                    .unwrap_or_else(|_| {
-                                        span_bug!(*op_sp, "asm const cannot be resolved")
-                                    });
-                                let ty = cx
-                                    .tcx()
-                                    .typeck_body(anon_const.body)
-                                    .node_type(anon_const.hir_id);
-                                let string = common::asm_const_to_str(
-                                    cx.tcx(),
-                                    *op_sp,
-                                    const_value,
-                                    cx.layout_of(ty),
-                                );
-                                GlobalAsmOperandRef::Const { string }
+                                match cx.tcx().const_eval_poly(anon_const.def_id.to_def_id()) {
+                                    Ok(const_value) => {
+                                        let ty = cx
+                                            .tcx()
+                                            .typeck_body(anon_const.body)
+                                            .node_type(anon_const.hir_id);
+                                        let string = common::asm_const_to_str(
+                                            cx.tcx(),
+                                            *op_sp,
+                                            const_value,
+                                            cx.layout_of(ty),
+                                        );
+                                        GlobalAsmOperandRef::Const { string }
+                                    }
+                                    Err(ErrorHandled::Reported { .. }) => {
+                                        // An error has already been reported and
+                                        // compilation is guaranteed to fail if execution
+                                        // hits this path. So an empty string instead of
+                                        // a stringified constant value will suffice.
+                                        GlobalAsmOperandRef::Const { string: String::new() }
+                                    }
+                                    Err(ErrorHandled::TooGeneric(_)) => {
+                                        span_bug!(
+                                            *op_sp,
+                                            "asm const cannot be resolved; too generic"
+                                        )
+                                    }
+                                }
                             }
                             hir::InlineAsmOperand::SymFn { ref anon_const } => {
                                 let ty = cx
diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs
index e6d42c596d2..e8b9490d401 100644
--- a/compiler/rustc_codegen_ssa/src/traits/backend.rs
+++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs
@@ -21,7 +21,6 @@ use rustc_session::{
 };
 use rustc_span::symbol::Symbol;
 use rustc_target::abi::call::FnAbi;
-use rustc_target::spec::Target;
 
 use std::fmt;
 
@@ -70,12 +69,6 @@ pub trait CodegenBackend {
     fn print_passes(&self) {}
     fn print_version(&self) {}
 
-    /// If this plugin provides additional builtin targets, provide the one enabled by the options here.
-    /// Be careful: this is called *before* init() is called.
-    fn target_override(&self, _opts: &config::Options) -> Option<Target> {
-        None
-    }
-
     /// The metadata loader used to load rlib and dylib metadata.
     ///
     /// Alternative codegen backends may want to use different rlib or dylib formats than the