Skip to content

Commit 1398103

Browse files
committed
Auto merge of rust-lang#136930 - GuillaumeGomez:rollup-hjsijmf, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang#135025 (Cast allocas to default address space) - rust-lang#136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly) - rust-lang#136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - rust-lang#136758 (tests: `-Copt-level=3` instead of `-O` in assembly tests) - rust-lang#136761 (tests: `-Copt-level=3` instead of `-O` in codegen tests) - rust-lang#136807 (compiler: internally merge `PtxKernel` into `GpuKernel`) - rust-lang#136818 (Implement `read*_exact` for `std:io::repeat`) - rust-lang#136831 (Update stdarch) - rust-lang#136916 (use cc archiver as default in `cc2ar`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ced8e65 + 9fe4c6a commit 1398103

File tree

291 files changed

+581
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+581
-739
lines changed

Diff for: compiler/rustc_codegen_cranelift/src/abi/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
6565
sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented");
6666
}
6767

68-
Conv::Msp430Intr
69-
| Conv::PtxKernel
70-
| Conv::GpuKernel
71-
| Conv::AvrInterrupt
72-
| Conv::AvrNonBlockingInterrupt => {
68+
Conv::Msp430Intr | Conv::GpuKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
7369
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
7470
}
7571
}

Diff for: compiler/rustc_codegen_llvm/src/abi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ impl llvm::CallConv {
687687
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
688688
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
689689
Conv::Msp430Intr => llvm::Msp430Intr,
690-
Conv::PtxKernel => llvm::PtxKernel,
691690
Conv::X86Fastcall => llvm::X86FastcallCallConv,
692691
Conv::X86Intr => llvm::X86_Intr,
693692
Conv::X86Stdcall => llvm::X86StdcallCallConv,

Diff for: compiler/rustc_codegen_llvm/src/asm.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
286286
InlineAsmArch::M68k => {
287287
constraints.push("~{ccr}".to_string());
288288
}
289-
InlineAsmArch::CSKY => {}
289+
InlineAsmArch::CSKY => {
290+
constraints.push("~{psr}".to_string());
291+
}
290292
}
291293
}
292294
if !options.contains(InlineAsmOptions::NOMEM) {

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
543543
unsafe {
544544
let alloca = llvm::LLVMBuildAlloca(bx.llbuilder, ty, UNNAMED);
545545
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
546-
alloca
546+
// Cast to default addrspace if necessary
547+
llvm::LLVMBuildPointerCast(bx.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
547548
}
548549
}
549550

@@ -552,7 +553,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
552553
let alloca =
553554
llvm::LLVMBuildArrayAlloca(self.llbuilder, self.cx().type_i8(), size, UNNAMED);
554555
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
555-
alloca
556+
// Cast to default addrspace if necessary
557+
llvm::LLVMBuildPointerCast(self.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
556558
}
557559
}
558560

Diff for: compiler/rustc_smir/src/rustc_smir/convert/abi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl<'tcx> Stable<'tcx> for callconv::Conv {
105105
Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall,
106106
Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry,
107107
Conv::Msp430Intr => CallConvention::Msp430Intr,
108-
Conv::PtxKernel => CallConvention::PtxKernel,
109108
Conv::X86Fastcall => CallConvention::X86Fastcall,
110109
Conv::X86Intr => CallConvention::X86Intr,
111110
Conv::X86Stdcall => CallConvention::X86Stdcall,

Diff for: compiler/rustc_target/src/callconv/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ pub enum Conv {
542542

543543
Msp430Intr,
544544

545-
PtxKernel,
546-
547545
GpuKernel,
548546

549547
X86Fastcall,
@@ -689,7 +687,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
689687
"sparc" => sparc::compute_abi_info(cx, self),
690688
"sparc64" => sparc64::compute_abi_info(cx, self),
691689
"nvptx64" => {
692-
if cx.target_spec().adjust_abi(abi, self.c_variadic) == ExternAbi::PtxKernel {
690+
let abi = cx.target_spec().adjust_abi(abi, self.c_variadic);
691+
if abi == ExternAbi::PtxKernel || abi == ExternAbi::GpuKernel {
693692
nvptx64::compute_ptx_kernel_abi_info(cx, self)
694693
} else {
695694
nvptx64::compute_abi_info(self)
@@ -841,7 +840,6 @@ impl FromStr for Conv {
841840
"CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall),
842841
"CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry),
843842
"Msp430Intr" => Ok(Conv::Msp430Intr),
844-
"PtxKernel" => Ok(Conv::PtxKernel),
845843
"X86Fastcall" => Ok(Conv::X86Fastcall),
846844
"X86Intr" => Ok(Conv::X86Intr),
847845
"X86Stdcall" => Ok(Conv::X86Stdcall),

Diff for: compiler/rustc_target/src/json.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl ToJson for crate::callconv::Conv {
105105
Self::CCmseNonSecureCall => "CCmseNonSecureCall",
106106
Self::CCmseNonSecureEntry => "CCmseNonSecureEntry",
107107
Self::Msp430Intr => "Msp430Intr",
108-
Self::PtxKernel => "PtxKernel",
109108
Self::X86Fastcall => "X86Fastcall",
110109
Self::X86Intr => "X86Intr",
111110
Self::X86Stdcall => "X86Stdcall",

Diff for: compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv
290290
Aapcs { .. } => Conv::ArmAapcs,
291291
CCmseNonSecureCall => Conv::CCmseNonSecureCall,
292292
CCmseNonSecureEntry => Conv::CCmseNonSecureEntry,
293-
PtxKernel => Conv::PtxKernel,
293+
PtxKernel => Conv::GpuKernel,
294294
Msp430Interrupt => Conv::Msp430Intr,
295295
X86Interrupt => Conv::X86Intr,
296296
GpuKernel => Conv::GpuKernel,

Diff for: library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
#![feature(powerpc_target_feature)]
212212
#![feature(riscv_target_feature)]
213213
#![feature(rtm_target_feature)]
214+
#![feature(s390x_target_feature)]
214215
#![feature(sha512_sm_x86)]
215216
#![feature(sse4a_target_feature)]
216217
#![feature(tbm_target_feature)]

Diff for: library/std/src/io/util.rs

+11
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ impl Read for Repeat {
188188
Ok(buf.len())
189189
}
190190

191+
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
192+
for slot in &mut *buf {
193+
*slot = self.byte;
194+
}
195+
Ok(())
196+
}
197+
191198
fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
192199
// SAFETY: No uninit bytes are being written
193200
for slot in unsafe { buf.as_mut() } {
@@ -204,6 +211,10 @@ impl Read for Repeat {
204211
Ok(())
205212
}
206213

214+
fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
215+
self.read_buf(buf)
216+
}
217+
207218
/// This function is not supported by `io::Repeat`, because there's no end of its data
208219
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
209220
Err(io::Error::from(io::ErrorKind::OutOfMemory))

Diff for: library/std/src/net/ip_addr.rs

-29
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,3 @@ pub use core::net::IpAddr;
88
pub use core::net::Ipv6MulticastScope;
99
#[stable(feature = "rust1", since = "1.0.0")]
1010
pub use core::net::{Ipv4Addr, Ipv6Addr};
11-
12-
use crate::sys::net::netc as c;
13-
use crate::sys_common::{FromInner, IntoInner};
14-
15-
impl IntoInner<c::in_addr> for Ipv4Addr {
16-
#[inline]
17-
fn into_inner(self) -> c::in_addr {
18-
// `s_addr` is stored as BE on all machines and the array is in BE order.
19-
// So the native endian conversion method is used so that it's never swapped.
20-
c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) }
21-
}
22-
}
23-
impl FromInner<c::in_addr> for Ipv4Addr {
24-
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
25-
Ipv4Addr::from(addr.s_addr.to_ne_bytes())
26-
}
27-
}
28-
29-
impl IntoInner<c::in6_addr> for Ipv6Addr {
30-
fn into_inner(self) -> c::in6_addr {
31-
c::in6_addr { s6_addr: self.octets() }
32-
}
33-
}
34-
impl FromInner<c::in6_addr> for Ipv6Addr {
35-
#[inline]
36-
fn from_inner(addr: c::in6_addr) -> Ipv6Addr {
37-
Ipv6Addr::from(addr.s6_addr)
38-
}
39-
}

Diff for: library/std/src/net/socket_addr.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,8 @@ mod tests;
66
pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
77

88
use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr};
9-
use crate::sys::net::{LookupHost, netc as c};
10-
use crate::sys_common::{FromInner, IntoInner};
11-
use crate::{io, iter, mem, option, slice, vec};
12-
13-
impl FromInner<c::sockaddr_in> for SocketAddrV4 {
14-
fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 {
15-
SocketAddrV4::new(Ipv4Addr::from_inner(addr.sin_addr), u16::from_be(addr.sin_port))
16-
}
17-
}
18-
19-
impl FromInner<c::sockaddr_in6> for SocketAddrV6 {
20-
fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 {
21-
SocketAddrV6::new(
22-
Ipv6Addr::from_inner(addr.sin6_addr),
23-
u16::from_be(addr.sin6_port),
24-
addr.sin6_flowinfo,
25-
addr.sin6_scope_id,
26-
)
27-
}
28-
}
29-
30-
impl IntoInner<c::sockaddr_in> for SocketAddrV4 {
31-
fn into_inner(self) -> c::sockaddr_in {
32-
c::sockaddr_in {
33-
sin_family: c::AF_INET as c::sa_family_t,
34-
sin_port: self.port().to_be(),
35-
sin_addr: self.ip().into_inner(),
36-
..unsafe { mem::zeroed() }
37-
}
38-
}
39-
}
40-
41-
impl IntoInner<c::sockaddr_in6> for SocketAddrV6 {
42-
fn into_inner(self) -> c::sockaddr_in6 {
43-
c::sockaddr_in6 {
44-
sin6_family: c::AF_INET6 as c::sa_family_t,
45-
sin6_port: self.port().to_be(),
46-
sin6_addr: self.ip().into_inner(),
47-
sin6_flowinfo: self.flowinfo(),
48-
sin6_scope_id: self.scope_id(),
49-
..unsafe { mem::zeroed() }
50-
}
51-
}
52-
}
9+
use crate::sys::net::LookupHost;
10+
use crate::{io, iter, option, slice, vec};
5311

5412
/// A trait for objects which can be converted or resolved to one or more
5513
/// [`SocketAddr`] values.

Diff for: library/std/src/os/solid/io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl BorrowedFd<'_> {
122122
/// Creates a new `OwnedFd` instance that shares the same underlying file
123123
/// description as the existing `BorrowedFd` instance.
124124
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
125-
let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?;
125+
let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?;
126126
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
127127
}
128128
}
@@ -168,7 +168,7 @@ impl FromRawFd for OwnedFd {
168168
impl Drop for OwnedFd {
169169
#[inline]
170170
fn drop(&mut self) {
171-
unsafe { sys::net::netc::close(self.fd.as_inner()) };
171+
unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) };
172172
}
173173
}
174174

Diff for: library/std/src/sys/net/connection/sgx.rs

-35
Original file line numberDiff line numberDiff line change
@@ -499,38 +499,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
499499
LookupHost::new(format!("{host}:{port}"))
500500
}
501501
}
502-
503-
#[allow(bad_style)]
504-
pub mod netc {
505-
pub const AF_INET: u8 = 0;
506-
pub const AF_INET6: u8 = 1;
507-
pub type sa_family_t = u8;
508-
509-
#[derive(Copy, Clone)]
510-
pub struct in_addr {
511-
pub s_addr: u32,
512-
}
513-
514-
#[derive(Copy, Clone)]
515-
pub struct sockaddr_in {
516-
#[allow(dead_code)]
517-
pub sin_family: sa_family_t,
518-
pub sin_port: u16,
519-
pub sin_addr: in_addr,
520-
}
521-
522-
#[derive(Copy, Clone)]
523-
pub struct in6_addr {
524-
pub s6_addr: [u8; 16],
525-
}
526-
527-
#[derive(Copy, Clone)]
528-
pub struct sockaddr_in6 {
529-
#[allow(dead_code)]
530-
pub sin6_family: sa_family_t,
531-
pub sin6_port: u16,
532-
pub sin6_addr: in6_addr,
533-
pub sin6_flowinfo: u32,
534-
pub sin6_scope_id: u32,
535-
}
536-
}

0 commit comments

Comments
 (0)