Skip to content

Commit f6092f2

Browse files
committed
Auto merge of #146892 - GuillaumeGomez:rollup-fa7lp0n, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #146795 (Enable `limit_rdylib_exports` on wasm targets) - #146828 (fix a crash in rustdoc merge finalize without input file) - #146848 (Add x86_64-unknown-motor (Motor OS) tier 3 target) - #146884 (Fix modification check of `rustdoc-json-types`) - #146887 (Remove unused #![feature(get_mut_unchecked)] in Rc and Arc examples) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ce4beeb + 9814d08 commit f6092f2

File tree

18 files changed

+173
-30
lines changed

18 files changed

+173
-30
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,11 @@ impl<'a> Linker for GccLinker<'a> {
845845
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
846846
}
847847
self.link_arg("--dynamic-list").link_arg(path);
848+
} else if self.sess.target.is_like_wasm {
849+
self.link_arg("--no-export-dynamic");
850+
for (sym, _) in symbols {
851+
self.link_arg("--export").link_arg(sym);
852+
}
848853
} else {
849854
// Write an LD version script
850855
let res: io::Result<()> = try {

compiler/rustc_target/src/spec/base/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(crate) mod linux_uclibc;
2121
pub(crate) mod linux_wasm;
2222
pub(crate) mod lynxos178;
2323
pub(crate) mod managarm_mlibc;
24+
pub(crate) mod motor;
2425
pub(crate) mod msvc;
2526
pub(crate) mod netbsd;
2627
pub(crate) mod nto_qnx;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use crate::spec::{
2+
Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions,
3+
};
4+
5+
pub(crate) fn opts() -> TargetOptions {
6+
let pre_link_args = TargetOptions::link_args(
7+
LinkerFlavor::Gnu(Cc::No, Lld::No),
8+
&[
9+
"-e",
10+
"motor_start",
11+
"--no-undefined",
12+
"--error-unresolved-symbols",
13+
"--no-undefined-version",
14+
"-u",
15+
"__rust_abort",
16+
],
17+
);
18+
TargetOptions {
19+
os: "motor".into(),
20+
executables: true,
21+
// TLS is false below because if true, the compiler assumes
22+
// we handle TLS at the ELF loading level, which we don't.
23+
// We use "OS level" TLS (see thread/local.rs in stdlib).
24+
has_thread_local: false,
25+
frame_pointer: FramePointer::NonLeaf,
26+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
27+
main_needs_argc_argv: true,
28+
panic_strategy: PanicStrategy::Abort,
29+
pre_link_args,
30+
stack_probes: StackProbeType::Inline,
31+
supports_stack_protector: true,
32+
..Default::default()
33+
}
34+
}

compiler/rustc_target/src/spec/base/wasm.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ pub(crate) fn options() -> TargetOptions {
8181
// threaded model which will legalize atomics to normal operations.
8282
singlethread: true,
8383

84-
// Symbol visibility takes care of this for the WebAssembly.
85-
// Additionally the only known linker, LLD, doesn't support the script
86-
// arguments just yet
87-
limit_rdylib_exports: false,
88-
8984
// we use the LLD shipped with the Rust toolchain by default
9085
linker: Some("rust-lld".into()),
9186
linker_flavor: LinkerFlavor::WasmLld(Cc::No),

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,7 @@ supported_targets! {
16421642
("aarch64-unknown-hermit", aarch64_unknown_hermit),
16431643
("riscv64gc-unknown-hermit", riscv64gc_unknown_hermit),
16441644
("x86_64-unknown-hermit", x86_64_unknown_hermit),
1645+
("x86_64-unknown-motor", x86_64_unknown_motor),
16451646

16461647
("x86_64-unikraft-linux-musl", x86_64_unikraft_linux_musl),
16471648

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use crate::spec::{
2+
CodeModel, LinkSelfContainedDefault, LldFlavor, RelocModel, RelroLevel, Target, base,
3+
};
4+
5+
pub(crate) fn target() -> Target {
6+
let mut base = base::motor::opts();
7+
base.cpu = "x86-64".into();
8+
base.max_atomic_width = Some(64);
9+
base.code_model = Some(CodeModel::Small);
10+
11+
// We want fully static relocatable binaries. It was surprisingly
12+
// difficult to make it happen reliably, especially various
13+
// linker-related options below. Mostly trial and error.
14+
base.position_independent_executables = true;
15+
base.relro_level = RelroLevel::Full;
16+
base.static_position_independent_executables = true;
17+
base.relocation_model = RelocModel::Pic;
18+
base.lld_flavor_json = LldFlavor::Ld;
19+
base.link_self_contained = LinkSelfContainedDefault::True;
20+
base.dynamic_linking = false;
21+
base.crt_static_default = true;
22+
base.crt_static_respected = true;
23+
24+
Target {
25+
llvm_target: "x86_64-unknown-none-elf".into(),
26+
metadata: crate::spec::TargetMetadata {
27+
description: Some("Motor OS".into()),
28+
tier: Some(3),
29+
host_tools: None,
30+
std: None,
31+
},
32+
pointer_width: 64,
33+
data_layout:
34+
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
35+
arch: "x86_64".into(),
36+
options: base,
37+
}
38+
}

library/alloc/src/rc.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,6 @@ impl<T> Rc<T> {
480480
/// # Examples
481481
///
482482
/// ```
483-
/// #![feature(get_mut_unchecked)]
484-
///
485483
/// use std::rc::Rc;
486484
///
487485
/// let mut five = Rc::<u32>::new_uninit();
@@ -572,7 +570,6 @@ impl<T> Rc<T> {
572570
///
573571
/// ```
574572
/// #![feature(allocator_api)]
575-
/// #![feature(get_mut_unchecked)]
576573
///
577574
/// use std::rc::Rc;
578575
///
@@ -1014,8 +1011,6 @@ impl<T> Rc<[T]> {
10141011
/// # Examples
10151012
///
10161013
/// ```
1017-
/// #![feature(get_mut_unchecked)]
1018-
///
10191014
/// use std::rc::Rc;
10201015
///
10211016
/// let mut values = Rc::<[u32]>::new_uninit_slice(3);
@@ -1181,8 +1176,6 @@ impl<T, A: Allocator> Rc<mem::MaybeUninit<T>, A> {
11811176
/// # Examples
11821177
///
11831178
/// ```
1184-
/// #![feature(get_mut_unchecked)]
1185-
///
11861179
/// use std::rc::Rc;
11871180
///
11881181
/// let mut five = Rc::<u32>::new_uninit();
@@ -1218,8 +1211,6 @@ impl<T, A: Allocator> Rc<[mem::MaybeUninit<T>], A> {
12181211
/// # Examples
12191212
///
12201213
/// ```
1221-
/// #![feature(get_mut_unchecked)]
1222-
///
12231214
/// use std::rc::Rc;
12241215
///
12251216
/// let mut values = Rc::<[u32]>::new_uninit_slice(3);

library/alloc/src/sync.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,6 @@ impl<T> Arc<T> {
480480
/// # Examples
481481
///
482482
/// ```
483-
/// #![feature(get_mut_unchecked)]
484-
///
485483
/// use std::sync::Arc;
486484
///
487485
/// let mut five = Arc::<u32>::new_uninit();
@@ -586,7 +584,6 @@ impl<T> Arc<T> {
586584
///
587585
/// ```
588586
/// #![feature(allocator_api)]
589-
/// #![feature(get_mut_unchecked)]
590587
///
591588
/// use std::sync::Arc;
592589
///
@@ -1156,8 +1153,6 @@ impl<T> Arc<[T]> {
11561153
/// # Examples
11571154
///
11581155
/// ```
1159-
/// #![feature(get_mut_unchecked)]
1160-
///
11611156
/// use std::sync::Arc;
11621157
///
11631158
/// let mut values = Arc::<[u32]>::new_uninit_slice(3);
@@ -1326,8 +1321,6 @@ impl<T, A: Allocator> Arc<mem::MaybeUninit<T>, A> {
13261321
/// # Examples
13271322
///
13281323
/// ```
1329-
/// #![feature(get_mut_unchecked)]
1330-
///
13311324
/// use std::sync::Arc;
13321325
///
13331326
/// let mut five = Arc::<u32>::new_uninit();
@@ -1364,8 +1357,6 @@ impl<T, A: Allocator> Arc<[mem::MaybeUninit<T>], A> {
13641357
/// # Examples
13651358
///
13661359
/// ```
1367-
/// #![feature(get_mut_unchecked)]
1368-
///
13691360
/// use std::sync::Arc;
13701361
///
13711362
/// let mut values = Arc::<[u32]>::new_uninit_slice(3);

src/bootstrap/src/core/sanity.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
3838
// just a dummy comment so the list doesn't get onelined
3939
"aarch64_be-unknown-hermit",
4040
"aarch64_be-unknown-none-softfloat",
41+
"x86_64-unknown-motor",
4142
];
4243

4344
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
@@ -239,6 +240,10 @@ than building it.
239240
continue;
240241
}
241242

243+
if target.contains("motor") {
244+
continue;
245+
}
246+
242247
// skip check for cross-targets
243248
if skip_target_sanity && target != &build.host_target {
244249
continue;

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ target | std | host | notes
431431
`x86_64-unknown-l4re-uclibc` | ? | |
432432
[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc
433433
[`x86_64-unknown-managarm-mlibc`](platform-support/managarm.md) | ? | | x86_64 Managarm
434+
[`x86_64-unknown-motor`[(platform-support/motor.md) | ? | | x86_64 Motor OS
434435
[`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD
435436
[`x86_64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
436437
`x86_64-uwp-windows-gnu` | ✓ | |

0 commit comments

Comments
 (0)