Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #136084

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9a81dc9
compiler: Set `target_abi = "ilp32e"` on all riscv32e targets
workingjubilee Dec 15, 2024
a9495e0
change lookup from `OsString.inner.inner.0` -> `OsString.inner.inner.…
Walnut356 Jan 21, 2025
0d90d47
TRPL: more backward-compatible Edition changes
chriskrycho Jan 21, 2025
9cfc420
TRPL: integrate edits to Chapter 17
chriskrycho Jan 21, 2025
aaccb71
Fix sparcv8plus test on LLVM 20
nikic Jan 20, 2025
2718710
Fix x86_64-bigint-helpers test on LLVM 20
nikic Jan 20, 2025
84c8015
Add new target for supporting Neutrino QNX 6.1 with `io-socket` netwo…
flba-eb Nov 28, 2024
efe53dd
Add support for QNX 7.1 with io-sock on x64
flba-eb Nov 29, 2024
62661f2
Move common code to mod nto_qnx
flba-eb Nov 30, 2024
3f045c9
add nto80 x86-64 and aarch64 target
AkhilTThomas Dec 6, 2024
46a0333
Update documentation to include QNX 8.0
flba-eb Dec 10, 2024
0462826
Review nto-qnx.md.
jonathanpallant Jan 13, 2025
2d11559
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls
scottmcm Jan 24, 2025
8eebbba
ci.py: check the return code in `run-local`
cuviper Jan 23, 2025
1d97a3e
Remove extra whitespace from rustdoc breadcrumbs for copypasting
kornelski Jan 17, 2025
cb7cad3
Rollup merge of #133631 - flba-eb:add_nto_qnx71_iosock_support, r=wor…
jhpratt Jan 26, 2025
fe2e288
Rollup merge of #134358 - workingjubilee:configure-my-riscv-abi, r=fm…
jhpratt Jan 26, 2025
3476bb2
Rollup merge of #135764 - nikic:llvm-20-test-fixes, r=wesleywiser
jhpratt Jan 26, 2025
c0978e6
Rollup merge of #135812 - Walnut356:gdb_osstring, r=Mark-Simulacrum
jhpratt Jan 26, 2025
da20639
Rollup merge of #135842 - chriskrycho:trpl-2024-edition-more, r=ehuss
jhpratt Jan 26, 2025
5e2a3c8
Rollup merge of #135946 - kornelski:rustdoc-path-space, r=notriddle
jhpratt Jan 26, 2025
530c695
Rollup merge of #135953 - cuviper:ci-run-local-fail, r=Kobzol
jhpratt Jan 26, 2025
24a9bab
Rollup merge of #136019 - scottmcm:alias-unchecked-div, r=Mark-Simula…
jhpratt Jan 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 96 additions & 1 deletion compiler/rustc_target/src/spec/base/nto_qnx.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::spec::{RelroLevel, TargetOptions, cvs};
use crate::spec::{
Cc, LinkArgs, LinkerFlavor, Lld, RelroLevel, Target, TargetMetadata, TargetOptions, cvs,
};

pub(crate) fn opts() -> TargetOptions {
TargetOptions {
Expand All @@ -16,3 +18,96 @@ pub(crate) fn opts() -> TargetOptions {
..Default::default()
}
}

pub(crate) fn meta() -> TargetMetadata {
TargetMetadata { description: None, tier: Some(3), host_tools: Some(false), std: Some(true) }
}

pub(crate) fn aarch64() -> Target {
Target {
llvm_target: "aarch64-unknown-unknown".into(),
metadata: meta(),
pointer_width: 64,
// from: https://llvm.org/docs/LangRef.html#data-layout
// e = little endian
// m:e = ELF mangling: Private symbols get a .L prefix
// i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32
// i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32
// i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64
// i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128
// n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently.
// S128 = 128 bits are the natural alignment of the stack in bits.
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: TargetOptions {
features: "+v8a".into(),
max_atomic_width: Some(128),
..opts()
}
}
}

pub(crate) fn x86_64() -> Target {
Target {
llvm_target: "x86_64-pc-unknown".into(),
metadata: meta(),
pointer_width: 64,
data_layout:
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
arch: "x86_64".into(),
options: TargetOptions {
cpu: "x86-64".into(),
plt_by_default: false,
max_atomic_width: Some(64),
vendor: "pc".into(),
..opts()
},
}
}

pub(crate) fn pre_link_args(api_var: ApiVariant, arch: Arch) -> LinkArgs {
let (qcc_arg, arch_lib_dir) = match arch {
Arch::Aarch64 => ("-Vgcc_ntoaarch64le_cxx", "aarch64le"),
Arch::I586 => {
("-Vgcc_ntox86_cxx", "notSupportedByQnx_compiler/rustc_target/src/spec/base/nto_qnx.rs")
}
Arch::X86_64 => ("-Vgcc_ntox86_64_cxx", "x86_64"),
};
match api_var {
ApiVariant::Default => {
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[qcc_arg])
}
ApiVariant::IoSock => TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
qcc_arg,
get_iosock_param(arch_lib_dir),
]),
}
}

pub(crate) enum ApiVariant {
Default,
IoSock,
}

pub(crate) enum Arch {
Aarch64,
I586,
X86_64,
}

// When using `io-sock` on QNX, we must add a search path for the linker so
// that it prefers the io-sock version.
// The path depends on the host, i.e. we cannot hard-code it here, but have
// to determine it when the compiler runs.
// When using the QNX toolchain, the environment variable QNX_TARGET is always set.
// More information:
// https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html
fn get_iosock_param(arch_lib_dir: &str) -> &'static str {
let target_dir = std::env::var("QNX_TARGET")
.unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp-env.sh".into());
let linker_param = format!("-L{target_dir}/{arch_lib_dir}/io-sock/lib");

// FIXME: leaking this is kind of weird: we're feeding these into something that expects an
// `AsRef<OsStr>`, but often converts to `OsString` anyways, so shouldn't we just demand an `OsString`?
linker_param.leak()
}
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,11 @@ supported_targets! {

("aarch64-unknown-nto-qnx700", aarch64_unknown_nto_qnx700),
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx710),
("aarch64-unknown-nto-qnx710_iosock", aarch64_unknown_nto_qnx710_iosock),
("aarch64-unknown-nto-qnx800", aarch64_unknown_nto_qnx800),
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
("x86_64-pc-nto-qnx710_iosock", x86_64_pc_nto_qnx710_iosock),
("x86_64-pc-nto-qnx800", x86_64_pc_nto_qnx800),
("i586-pc-nto-qnx700", i586_pc_nto_qnx700),

("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions, base};
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
// In QNX, libc does not provide a compatible ABI between versions.
// To distinguish between QNX versions, we needed a stable conditional compilation switch,
// which is why we needed to implement different targets in the compiler.
Target {
llvm_target: "aarch64-unknown-unknown".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 QNX Neutrino 7.0 RTOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
// from: https://llvm.org/docs/LangRef.html#data-layout
// e = little endian
// m:e = ELF mangling: Private symbols get a .L prefix
// i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32
// i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32
// i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64
// i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128
// n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently.
// S128 = 128 bits are the natural alignment of the stack in bits.
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: TargetOptions {
features: "+v8a".into(),
max_atomic_width: Some(128),
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
"-Vgcc_ntoaarch64le_cxx",
]),
env: "nto70".into(),
..base::nto_qnx::opts()
},
}
let mut target = nto_qnx::aarch64();
target.metadata.description = Some("ARM64 QNX Neutrino 7.0 RTOS".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
target.options.env = "nto70".into();
target
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut base = super::aarch64_unknown_nto_qnx700::target();
base.metadata.description = Some("ARM64 QNX Neutrino 7.1 RTOS".into());
base.options.env = "nto71".into();
base
let mut target = nto_qnx::aarch64();
target.metadata.description =
Some("ARM64 QNX Neutrino 7.1 RTOS with io-pkt network stack".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
target.options.env = "nto71".into();
target
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::aarch64();
target.metadata.description =
Some("ARM64 QNX Neutrino 7.1 RTOS with io-sock network stack".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::IoSock, nto_qnx::Arch::Aarch64);
target.options.env = "nto71_iosock".into();
target
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::aarch64();
target.metadata.description = Some("ARM64 QNX Neutrino 8.0 RTOS".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::Aarch64);
target.options.env = "nto80".into();
target
}
20 changes: 10 additions & 10 deletions compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions, base};
use crate::spec::base::nto_qnx;
use crate::spec::{StackProbeType, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut meta = nto_qnx::meta();
meta.description = Some("32-bit x86 QNX Neutrino 7.0 RTOS".into());
meta.std = Some(false);
Target {
llvm_target: "i586-pc-unknown".into(),
metadata: crate::spec::TargetMetadata {
description: Some("32-bit x86 QNX Neutrino 7.0 RTOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
metadata: meta,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
i128:128-f64:32:64-f80:32-n8:16:32-S128"
Expand All @@ -17,9 +16,10 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
cpu: "pentium4".into(),
max_atomic_width: Some(64),
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
"-Vgcc_ntox86_cxx",
]),
pre_link_args: nto_qnx::pre_link_args(
nto_qnx::ApiVariant::Default,
nto_qnx::Arch::I586,
),
env: "nto70".into(),
vendor: "pc".into(),
stack_probes: StackProbeType::Inline,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};

pub(crate) fn target() -> Target {
let abi = "ilp32e";
Target {
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
// `options.llvm_abiname`.
Expand All @@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
arch: "riscv32".into(),

options: TargetOptions {
abi: abi.into(),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
// The ilp32e ABI specifies the `data_layout`
llvm_abiname: "ilp32e".into(),
llvm_abiname: abi.into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+forced-atomics".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};

pub(crate) fn target() -> Target {
let abi = "ilp32e";
Target {
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
// `options.llvm_abiname`.
Expand All @@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
arch: "riscv32".into(),

options: TargetOptions {
abi: abi.into(),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
// The ilp32e ABI specifies the `data_layout`
llvm_abiname: "ilp32e".into(),
llvm_abiname: abi.into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+m,+forced-atomics".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};

pub(crate) fn target() -> Target {
let abi = "ilp32e";
Target {
// The below `data_layout` is explicitly specified by the ilp32e ABI in LLVM. See also
// `options.llvm_abiname`.
Expand All @@ -16,11 +17,12 @@ pub(crate) fn target() -> Target {
arch: "riscv32".into(),

options: TargetOptions {
abi: abi.into(),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
// The ilp32e ABI specifies the `data_layout`
llvm_abiname: "ilp32e".into(),
llvm_abiname: abi.into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+m,+c,+forced-atomics".into(),
Expand Down
34 changes: 9 additions & 25 deletions compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx710.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions, base};
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
Target {
llvm_target: "x86_64-pc-unknown".into(),
metadata: crate::spec::TargetMetadata {
description: Some("x86 64-bit QNX Neutrino 7.1 RTOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout:
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
arch: "x86_64".into(),
options: TargetOptions {
cpu: "x86-64".into(),
plt_by_default: false,
max_atomic_width: Some(64),
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
"-Vgcc_ntox86_64_cxx",
]),
env: "nto71".into(),
vendor: "pc".into(),
..base::nto_qnx::opts()
},
}
let mut target = nto_qnx::x86_64();
target.metadata.description =
Some("x86 64-bit QNX Neutrino 7.1 RTOS with io-pkt network stack".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::X86_64);
target.options.env = "nto71".into();
target
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::x86_64();
target.metadata.description =
Some("x86 64-bit QNX Neutrino 7.1 RTOS with io-sock network stack".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::IoSock, nto_qnx::Arch::X86_64);
target.options.env = "nto71_iosock".into();
target
}
11 changes: 11 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx800.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::spec::Target;
use crate::spec::base::nto_qnx;

pub(crate) fn target() -> Target {
let mut target = nto_qnx::x86_64();
target.metadata.description = Some("x86 64-bit QNX Neutrino 8.0 RTOS".into());
target.options.pre_link_args =
nto_qnx::pre_link_args(nto_qnx::ApiVariant::Default, nto_qnx::Arch::X86_64);
target.options.env = "nto80".into();
target
}
7 changes: 7 additions & 0 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,12 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
impl Div<NonZero<$Int>> for $Int {
type Output = $Int;

/// Same as `self / other.get()`, but because `other` is a `NonZero<_>`,
/// there's never a runtime check for division-by-zero.
///
/// This operation rounds towards zero, truncating any fractional
/// part of the exact result, and cannot panic.
#[doc(alias = "unchecked_div")]
#[inline]
fn div(self, other: NonZero<$Int>) -> $Int {
// SAFETY: Division by zero is checked because `other` is non-zero,
Expand All @@ -1197,6 +1201,9 @@ macro_rules! nonzero_integer_signedness_dependent_impls {

#[stable(feature = "nonzero_div_assign", since = "1.79.0")]
impl DivAssign<NonZero<$Int>> for $Int {
/// Same as `self /= other.get()`, but because `other` is a `NonZero<_>`,
/// there's never a runtime check for division-by-zero.
///
/// This operation rounds towards zero, truncating any fractional
/// part of the exact result, and cannot panic.
#[inline]
Expand Down
Loading
Loading