Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 29 additions & 1 deletion compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use rustc_ast as ast;
use rustc_attr_parsing::{ShouldEmit, validate_attr};
use rustc_codegen_ssa::back::archive::ArArchiveBuilderBuilder;
use rustc_codegen_ssa::back::link::link_binary;
use rustc_codegen_ssa::target_features::{self, cfg_target_feature};
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
use rustc_codegen_ssa::{CodegenResults, CrateInfo, TargetConfig};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::jobserver::Proxy;
use rustc_data_structures::sync;
Expand Down Expand Up @@ -354,6 +355,33 @@ impl CodegenBackend for DummyCodegenBackend {
"dummy"
}

fn target_config(&self, sess: &Session) -> TargetConfig {
let (target_features, unstable_target_features) = cfg_target_feature(sess, |feature| {
// This is a standin for the list of features a backend is expected to enable.
// It would be better to parse target.features instead and handle implied features,
// but target.features is a list of LLVM target features, not Rust target features.
// The dummy backend doesn't know the mapping between LLVM and Rust target features.
sess.target.abi_required_features().required.contains(&feature)
});

// To report warnings about unknown features
target_features::flag_to_backend_features::<0>(
sess,
true,
|_| Default::default(),
|_, _| {},
);

TargetConfig {
target_features,
unstable_target_features,
has_reliable_f16: true,
has_reliable_f16_math: true,
has_reliable_f128: true,
has_reliable_f128_math: true,
}
}

fn supported_crate_types(&self, _sess: &Session) -> Vec<CrateType> {
// This includes bin despite failing on the link step to ensure that you
// can still get the frontend handling for binaries. For all library
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/base/redox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) fn opts() -> TargetOptions {
has_thread_local: true,
crt_static_default: true,
crt_static_respected: true,
crt_static_allows_dylibs: true,
crt_static_allows_dylibs: false,
late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-lgcc"]),
..Default::default()
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ supported_targets! {

("aarch64-unknown-redox", aarch64_unknown_redox),
("i586-unknown-redox", i586_unknown_redox),
("riscv64gc-unknown-redox", riscv64gc_unknown_redox),
("x86_64-unknown-redox", x86_64_unknown_redox),

("x86_64-unknown-managarm-mlibc", x86_64_unknown_managarm_mlibc),
Expand Down
25 changes: 25 additions & 0 deletions compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::spec::{CodeModel, Target, TargetMetadata, base};

pub(crate) fn target() -> Target {
let mut base = base::redox::opts();
base.code_model = Some(CodeModel::Medium);
base.cpu = "generic-rv64".into();
base.features = "+m,+a,+f,+d,+c".into();
base.llvm_abiname = "lp64d".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);

Target {
llvm_target: "riscv64-unknown-redox".into(),
metadata: TargetMetadata {
description: Some("Redox OS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
arch: "riscv64".into(),
options: base,
}
}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct Finder {
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"riscv64gc-unknown-redox",
];

/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ target | std | host | notes
[`riscv64gc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | RISC-V NetBSD
[`riscv64gc-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
[`riscv64gc-unknown-redox`](platform-support/redox.md) | ✓ | | RISC-V 64bit Redox OS
[`riscv64imac-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
[`riscv64a23-unknown-linux-gnu`](platform-support/riscv64a23-unknown-linux-gnu.md) | ✓ | ✓ | RISC-V Linux (kernel 6.8.0+, glibc 2.39)
[`s390x-unknown-linux-musl`](platform-support/s390x-unknown-linux-musl.md) | ✓ | | S390x Linux (kernel 3.2, musl 1.2.3)
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/platform-support/redox.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Target triplets available so far:
- `x86_64-unknown-redox` (tier 2)
- `aarch64-unknown-redox` (tier 3)
- `i586-unknown-redox` (tier 3)
- `riscv64gc-unknown-redox` (tier 3)

## Target maintainers

Expand Down Expand Up @@ -37,6 +38,7 @@ target = [
"x86_64-unknown-redox",
"aarch64-unknown-redox",
"i586-unknown-redox",
"riscv64gc-unknown-redox",
]
```

Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Using `index-page` option enables `enable-index-page` option as well.

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

## `--nocapture`: disable output capture for test
## `--no-capture`: disable output capture for test

When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
captured by rustdoc. Instead, the output will be directed to your terminal,
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub(crate) struct Options {
/// Whether doctests should emit unused externs
pub(crate) json_unused_externs: JsonUnusedExterns,
/// Whether to skip capturing stdout and stderr of tests.
pub(crate) nocapture: bool,
pub(crate) no_capture: bool,

/// Configuration for scraping examples from the current crate. If this option is Some(..) then
/// the compiler will scrape examples and not generate documentation.
Expand Down Expand Up @@ -211,7 +211,7 @@ impl fmt::Debug for Options {
.field("no_run", &self.no_run)
.field("test_builder_wrappers", &self.test_builder_wrappers)
.field("remap-file-prefix", &self.remap_path_prefix)
.field("nocapture", &self.nocapture)
.field("no_capture", &self.no_capture)
.field("scrape_examples_options", &self.scrape_examples_options)
.field("unstable_features", &self.unstable_features)
.finish()
Expand Down Expand Up @@ -783,7 +783,7 @@ impl Options {
let run_check = matches.opt_present("check");
let generate_redirect_map = matches.opt_present("generate-redirect-map");
let show_type_layout = matches.opt_present("show-type-layout");
let nocapture = matches.opt_present("nocapture");
let no_capture = matches.opt_present("no-capture");
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
let generate_macro_expansion = matches.opt_present("generate-macro-expansion");
let extern_html_root_takes_precedence =
Expand Down Expand Up @@ -854,7 +854,7 @@ impl Options {
no_run,
test_builder_wrappers,
remap_path_prefix,
nocapture,
no_capture,
crate_name,
output_format,
json_unused_externs,
Expand Down
16 changes: 8 additions & 8 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ pub(crate) fn run_tests(
let mut test_args = Vec::with_capacity(rustdoc_options.test_args.len() + 1);
test_args.insert(0, "rustdoctest".to_string());
test_args.extend_from_slice(&rustdoc_options.test_args);
if rustdoc_options.nocapture {
test_args.push("--nocapture".to_string());
if rustdoc_options.no_capture {
test_args.push("--no-capture".to_string());
}

let mut nb_errors = 0;
Expand Down Expand Up @@ -644,8 +644,8 @@ fn run_test(
// tested as standalone tests.
return (Duration::default(), Err(TestFailure::CompileError));
}
if !rustdoc_options.nocapture {
// If `nocapture` is disabled, then we don't display rustc's output when compiling
if !rustdoc_options.no_capture {
// If `no_capture` is disabled, then we don't display rustc's output when compiling
// the merged doctests.
compiler.stderr(Stdio::null());
}
Expand Down Expand Up @@ -721,8 +721,8 @@ fn run_test(
// tested as standalone tests.
return (instant.elapsed(), Err(TestFailure::CompileError));
}
if !rustdoc_options.nocapture {
// If `nocapture` is disabled, then we don't display rustc's output when compiling
if !rustdoc_options.no_capture {
// If `no_capture` is disabled, then we don't display rustc's output when compiling
// the merged doctests.
runner_compiler.stderr(Stdio::null());
}
Expand Down Expand Up @@ -821,7 +821,7 @@ fn run_test(
cmd.current_dir(run_directory);
}

let result = if doctest.is_multiple_tests() || rustdoc_options.nocapture {
let result = if doctest.is_multiple_tests() || rustdoc_options.no_capture {
cmd.status().map(|status| process::Output {
status,
stdout: Vec::new(),
Expand Down Expand Up @@ -1016,7 +1016,7 @@ impl CreateRunnableDocTests {
.span(scraped_test.span)
.build(dcx);
let is_standalone = !doctest.can_be_merged
|| self.rustdoc_options.nocapture
|| self.rustdoc_options.no_capture
|| self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output");
if is_standalone {
let test_desc = self.generate_test_desc_and_fn(doctest, scraped_test);
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3904,6 +3904,8 @@ class DocSearch {
return name === "primitive" || name === "associatedtype";
case "trait":
return name === "traitalias";
case "macro":
return name === "attr" || name === "derive";
}

// No match
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ fn opts() -> Vec<RustcOptGroup> {
"Include the memory layout of types in the docs",
"",
),
opt(Unstable, Flag, "", "nocapture", "Don't capture stdout and stderr of tests", ""),
opt(Unstable, Flag, "", "no-capture", "Don't capture stdout and stderr of tests", ""),
opt(
Unstable,
Flag,
Expand Down
3 changes: 3 additions & 0 deletions tests/assembly-llvm/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@
//@ revisions: riscv64gc_unknown_openbsd
//@ [riscv64gc_unknown_openbsd] compile-flags: --target riscv64gc-unknown-openbsd
//@ [riscv64gc_unknown_openbsd] needs-llvm-components: riscv
//@ revisions: riscv64gc_unknown_redox
//@ [riscv64gc_unknown_redox] compile-flags: --target riscv64gc-unknown-redox
//@ [riscv64gc_unknown_redox] needs-llvm-components: riscv
//@ revisions: riscv64imac_unknown_none_elf
//@ [riscv64imac_unknown_none_elf] compile-flags: --target riscv64imac-unknown-none-elf
//@ [riscv64imac_unknown_none_elf] needs-llvm-components: riscv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Options:
Remap source names in compiler messages
--show-type-layout
Include the memory layout of types in the docs
--nocapture Don't capture stdout and stderr of tests
--no-capture Don't capture stdout and stderr of tests
--generate-link-to-definition
Make the identifiers in the HTML source code pages
navigable
Expand Down
9 changes: 9 additions & 0 deletions tests/rustdoc-js-std/filter-macro-attr-derive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This test ensures that filtering on "macro" will also include attribute and derive
// macros.

const EXPECTED = {
'query': 'macro:debug',
'others': [
{ 'path': 'std::fmt', 'name': 'Debug', 'href': '../std/fmt/derive.Debug.html' },
],
};
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/check-cfg-test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options
//@ compile-flags: --test --no-capture --check-cfg=cfg(feature,values("test")) -Z unstable-options
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test -Zunstable-options --nocapture
//@ compile-flags:--test -Zunstable-options --no-capture
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: struct literal body without path
--> $DIR/nocapture-fail.rs:8:10
--> $DIR/no-capture-fail.rs:8:10
|
LL | fn foo() {
| __________^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

running 1 test
test $DIR/nocapture-fail.rs - Foo (line 7) - compile fail ... ok
test $DIR/no-capture-fail.rs - Foo (line 7) - compile fail ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test -Zunstable-options --nocapture
//@ compile-flags:--test -Zunstable-options --no-capture
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

running 1 test
hello!
test $DIR/nocapture.rs - Foo (line 6) ... ok
test $DIR/no-capture.rs - Foo (line 6) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/non_local_defs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass
//@ compile-flags:--test --test-args --test-threads=1 --nocapture -Zunstable-options
//@ compile-flags:--test --test-args --test-threads=1 --no-capture -Zunstable-options
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stderr: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
Loading