Skip to content

Commit 1c0a097

Browse files
committed
Auto merge of #148270 - matthiaskrgr:rollup-nkuixr8, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - #148137 (Couple of changes for Redox OS) - #148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - #148253 (Handle default features and -Ctarget-features in the dummy backend) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 292be5c + 29e1283 commit 1c0a097

File tree

23 files changed

+96
-24
lines changed

23 files changed

+96
-24
lines changed

compiler/rustc_interface/src/util.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use rustc_ast as ast;
99
use rustc_attr_parsing::{ShouldEmit, validate_attr};
1010
use rustc_codegen_ssa::back::archive::ArArchiveBuilderBuilder;
1111
use rustc_codegen_ssa::back::link::link_binary;
12+
use rustc_codegen_ssa::target_features::{self, cfg_target_feature};
1213
use rustc_codegen_ssa::traits::CodegenBackend;
13-
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
14+
use rustc_codegen_ssa::{CodegenResults, CrateInfo, TargetConfig};
1415
use rustc_data_structures::fx::FxIndexMap;
1516
use rustc_data_structures::jobserver::Proxy;
1617
use rustc_data_structures::sync;
@@ -354,6 +355,33 @@ impl CodegenBackend for DummyCodegenBackend {
354355
"dummy"
355356
}
356357

358+
fn target_config(&self, sess: &Session) -> TargetConfig {
359+
let (target_features, unstable_target_features) = cfg_target_feature(sess, |feature| {
360+
// This is a standin for the list of features a backend is expected to enable.
361+
// It would be better to parse target.features instead and handle implied features,
362+
// but target.features is a list of LLVM target features, not Rust target features.
363+
// The dummy backend doesn't know the mapping between LLVM and Rust target features.
364+
sess.target.abi_required_features().required.contains(&feature)
365+
});
366+
367+
// To report warnings about unknown features
368+
target_features::flag_to_backend_features::<0>(
369+
sess,
370+
true,
371+
|_| Default::default(),
372+
|_, _| {},
373+
);
374+
375+
TargetConfig {
376+
target_features,
377+
unstable_target_features,
378+
has_reliable_f16: true,
379+
has_reliable_f16_math: true,
380+
has_reliable_f128: true,
381+
has_reliable_f128_math: true,
382+
}
383+
}
384+
357385
fn supported_crate_types(&self, _sess: &Session) -> Vec<CrateType> {
358386
// This includes bin despite failing on the link step to ensure that you
359387
// can still get the frontend handling for binaries. For all library

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) fn opts() -> TargetOptions {
1212
has_thread_local: true,
1313
crt_static_default: true,
1414
crt_static_respected: true,
15-
crt_static_allows_dylibs: true,
15+
crt_static_allows_dylibs: false,
1616
late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-lgcc"]),
1717
..Default::default()
1818
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ supported_targets! {
15531553

15541554
("aarch64-unknown-redox", aarch64_unknown_redox),
15551555
("i586-unknown-redox", i586_unknown_redox),
1556+
("riscv64gc-unknown-redox", riscv64gc_unknown_redox),
15561557
("x86_64-unknown-redox", x86_64_unknown_redox),
15571558

15581559
("x86_64-unknown-managarm-mlibc", x86_64_unknown_managarm_mlibc),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use crate::spec::{CodeModel, Target, TargetMetadata, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::redox::opts();
5+
base.code_model = Some(CodeModel::Medium);
6+
base.cpu = "generic-rv64".into();
7+
base.features = "+m,+a,+f,+d,+c".into();
8+
base.llvm_abiname = "lp64d".into();
9+
base.plt_by_default = false;
10+
base.max_atomic_width = Some(64);
11+
12+
Target {
13+
llvm_target: "riscv64-unknown-redox".into(),
14+
metadata: TargetMetadata {
15+
description: Some("Redox OS".into()),
16+
tier: Some(3),
17+
host_tools: Some(false),
18+
std: Some(true),
19+
},
20+
pointer_width: 64,
21+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
22+
arch: "riscv64".into(),
23+
options: base,
24+
}
25+
}

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
37+
"riscv64gc-unknown-redox",
3738
];
3839

3940
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ target | std | host | notes
393393
[`riscv64gc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | RISC-V NetBSD
394394
[`riscv64gc-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
395395
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
396+
[`riscv64gc-unknown-redox`](platform-support/redox.md) | ✓ | | RISC-V 64bit Redox OS
396397
[`riscv64imac-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
397398
[`riscv64a23-unknown-linux-gnu`](platform-support/riscv64a23-unknown-linux-gnu.md) | ✓ | ✓ | RISC-V Linux (kernel 6.8.0+, glibc 2.39)
398399
[`s390x-unknown-linux-musl`](platform-support/s390x-unknown-linux-musl.md) | ✓ | | S390x Linux (kernel 3.2, musl 1.2.3)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Target triplets available so far:
1010
- `x86_64-unknown-redox` (tier 2)
1111
- `aarch64-unknown-redox` (tier 3)
1212
- `i586-unknown-redox` (tier 3)
13+
- `riscv64gc-unknown-redox` (tier 3)
1314

1415
## Target maintainers
1516

@@ -37,6 +38,7 @@ target = [
3738
"x86_64-unknown-redox",
3839
"aarch64-unknown-redox",
3940
"i586-unknown-redox",
41+
"riscv64gc-unknown-redox",
4042
]
4143
```
4244

src/doc/rustdoc/src/unstable-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Using `index-page` option enables `enable-index-page` option as well.
362362

363363
This feature allows the generation of a default index-page which lists the generated crates.
364364

365-
## `--nocapture`: disable output capture for test
365+
## `--no-capture`: disable output capture for test
366366

367367
When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
368368
captured by rustdoc. Instead, the output will be directed to your terminal,

src/librustdoc/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(crate) struct Options {
155155
/// Whether doctests should emit unused externs
156156
pub(crate) json_unused_externs: JsonUnusedExterns,
157157
/// Whether to skip capturing stdout and stderr of tests.
158-
pub(crate) nocapture: bool,
158+
pub(crate) no_capture: bool,
159159

160160
/// Configuration for scraping examples from the current crate. If this option is Some(..) then
161161
/// the compiler will scrape examples and not generate documentation.
@@ -211,7 +211,7 @@ impl fmt::Debug for Options {
211211
.field("no_run", &self.no_run)
212212
.field("test_builder_wrappers", &self.test_builder_wrappers)
213213
.field("remap-file-prefix", &self.remap_path_prefix)
214-
.field("nocapture", &self.nocapture)
214+
.field("no_capture", &self.no_capture)
215215
.field("scrape_examples_options", &self.scrape_examples_options)
216216
.field("unstable_features", &self.unstable_features)
217217
.finish()
@@ -783,7 +783,7 @@ impl Options {
783783
let run_check = matches.opt_present("check");
784784
let generate_redirect_map = matches.opt_present("generate-redirect-map");
785785
let show_type_layout = matches.opt_present("show-type-layout");
786-
let nocapture = matches.opt_present("nocapture");
786+
let no_capture = matches.opt_present("no-capture");
787787
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
788788
let generate_macro_expansion = matches.opt_present("generate-macro-expansion");
789789
let extern_html_root_takes_precedence =
@@ -854,7 +854,7 @@ impl Options {
854854
no_run,
855855
test_builder_wrappers,
856856
remap_path_prefix,
857-
nocapture,
857+
no_capture,
858858
crate_name,
859859
output_format,
860860
json_unused_externs,

src/librustdoc/doctest.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ pub(crate) fn run_tests(
326326
let mut test_args = Vec::with_capacity(rustdoc_options.test_args.len() + 1);
327327
test_args.insert(0, "rustdoctest".to_string());
328328
test_args.extend_from_slice(&rustdoc_options.test_args);
329-
if rustdoc_options.nocapture {
330-
test_args.push("--nocapture".to_string());
329+
if rustdoc_options.no_capture {
330+
test_args.push("--no-capture".to_string());
331331
}
332332

333333
let mut nb_errors = 0;
@@ -644,8 +644,8 @@ fn run_test(
644644
// tested as standalone tests.
645645
return (Duration::default(), Err(TestFailure::CompileError));
646646
}
647-
if !rustdoc_options.nocapture {
648-
// If `nocapture` is disabled, then we don't display rustc's output when compiling
647+
if !rustdoc_options.no_capture {
648+
// If `no_capture` is disabled, then we don't display rustc's output when compiling
649649
// the merged doctests.
650650
compiler.stderr(Stdio::null());
651651
}
@@ -721,8 +721,8 @@ fn run_test(
721721
// tested as standalone tests.
722722
return (instant.elapsed(), Err(TestFailure::CompileError));
723723
}
724-
if !rustdoc_options.nocapture {
725-
// If `nocapture` is disabled, then we don't display rustc's output when compiling
724+
if !rustdoc_options.no_capture {
725+
// If `no_capture` is disabled, then we don't display rustc's output when compiling
726726
// the merged doctests.
727727
runner_compiler.stderr(Stdio::null());
728728
}
@@ -821,7 +821,7 @@ fn run_test(
821821
cmd.current_dir(run_directory);
822822
}
823823

824-
let result = if doctest.is_multiple_tests() || rustdoc_options.nocapture {
824+
let result = if doctest.is_multiple_tests() || rustdoc_options.no_capture {
825825
cmd.status().map(|status| process::Output {
826826
status,
827827
stdout: Vec::new(),
@@ -1016,7 +1016,7 @@ impl CreateRunnableDocTests {
10161016
.span(scraped_test.span)
10171017
.build(dcx);
10181018
let is_standalone = !doctest.can_be_merged
1019-
|| self.rustdoc_options.nocapture
1019+
|| self.rustdoc_options.no_capture
10201020
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output");
10211021
if is_standalone {
10221022
let test_desc = self.generate_test_desc_and_fn(doctest, scraped_test);

0 commit comments

Comments
 (0)