From 11b82e134c3fb3fee493230a166a46dfdef9bd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sat, 25 Oct 2025 18:47:30 +0200 Subject: [PATCH 1/6] rustdoc: Rename unstable option `--nocapture` to `--no-capture` --- src/doc/rustdoc/src/unstable-features.md | 2 +- src/librustdoc/config.rs | 8 ++++---- src/librustdoc/doctest.rs | 16 ++++++++-------- src/librustdoc/lib.rs | 2 +- .../rustdoc-default-output/output-default.stdout | 2 +- tests/rustdoc-ui/doctest/check-cfg-test.rs | 2 +- .../{nocapture-fail.rs => no-capture-fail.rs} | 2 +- ...apture-fail.stderr => no-capture-fail.stderr} | 2 +- ...apture-fail.stdout => no-capture-fail.stdout} | 2 +- .../doctest/{nocapture.rs => no-capture.rs} | 2 +- .../{nocapture.stderr => no-capture.stderr} | 0 .../{nocapture.stdout => no-capture.stdout} | 2 +- tests/rustdoc-ui/doctest/non_local_defs.rs | 2 +- 13 files changed, 22 insertions(+), 22 deletions(-) rename tests/rustdoc-ui/doctest/{nocapture-fail.rs => no-capture-fail.rs} (83%) rename tests/rustdoc-ui/doctest/{nocapture-fail.stderr => no-capture-fail.stderr} (89%) rename tests/rustdoc-ui/doctest/{nocapture-fail.stdout => no-capture-fail.stdout} (62%) rename tests/rustdoc-ui/doctest/{nocapture.rs => no-capture.rs} (79%) rename tests/rustdoc-ui/doctest/{nocapture.stderr => no-capture.stderr} (100%) rename tests/rustdoc-ui/doctest/{nocapture.stdout => no-capture.stdout} (72%) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 04d3c0cd630f5..a26ae7d284443 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -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, diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index cf0858810f55f..35d3a68c7e0e8 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -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. @@ -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() @@ -785,7 +785,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 = @@ -856,7 +856,7 @@ impl Options { no_run, test_builder_wrappers, remap_path_prefix, - nocapture, + no_capture, crate_name, output_format, json_unused_externs, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 0d551a969d632..c9cd9f7fd4b11 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -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; @@ -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()); } @@ -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()); } @@ -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(), @@ -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); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 5f72064f0a8ce..f5d94dc010988 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -585,7 +585,7 @@ fn opts() -> Vec { "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, diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index badbc0b6d15b7..f1116d65cabbc 100644 --- a/tests/run-make/rustdoc-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout @@ -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 diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.rs b/tests/rustdoc-ui/doctest/check-cfg-test.rs index 39fdb3a5853fc..201d6d60672d2 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.rs +++ b/tests/rustdoc-ui/doctest/check-cfg-test.rs @@ -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" diff --git a/tests/rustdoc-ui/doctest/nocapture-fail.rs b/tests/rustdoc-ui/doctest/no-capture-fail.rs similarity index 83% rename from tests/rustdoc-ui/doctest/nocapture-fail.rs rename to tests/rustdoc-ui/doctest/no-capture-fail.rs index 8c64a49f65005..c58d2495aee0d 100644 --- a/tests/rustdoc-ui/doctest/nocapture-fail.rs +++ b/tests/rustdoc-ui/doctest/no-capture-fail.rs @@ -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" diff --git a/tests/rustdoc-ui/doctest/nocapture-fail.stderr b/tests/rustdoc-ui/doctest/no-capture-fail.stderr similarity index 89% rename from tests/rustdoc-ui/doctest/nocapture-fail.stderr rename to tests/rustdoc-ui/doctest/no-capture-fail.stderr index c6a5785a24fe4..2817a66b514ce 100644 --- a/tests/rustdoc-ui/doctest/nocapture-fail.stderr +++ b/tests/rustdoc-ui/doctest/no-capture-fail.stderr @@ -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() { | __________^ diff --git a/tests/rustdoc-ui/doctest/nocapture-fail.stdout b/tests/rustdoc-ui/doctest/no-capture-fail.stdout similarity index 62% rename from tests/rustdoc-ui/doctest/nocapture-fail.stdout rename to tests/rustdoc-ui/doctest/no-capture-fail.stdout index 754f77db53ca3..ee94540e37b43 100644 --- a/tests/rustdoc-ui/doctest/nocapture-fail.stdout +++ b/tests/rustdoc-ui/doctest/no-capture-fail.stdout @@ -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 diff --git a/tests/rustdoc-ui/doctest/nocapture.rs b/tests/rustdoc-ui/doctest/no-capture.rs similarity index 79% rename from tests/rustdoc-ui/doctest/nocapture.rs rename to tests/rustdoc-ui/doctest/no-capture.rs index c4360341864fd..b1e3014798f9a 100644 --- a/tests/rustdoc-ui/doctest/nocapture.rs +++ b/tests/rustdoc-ui/doctest/no-capture.rs @@ -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" diff --git a/tests/rustdoc-ui/doctest/nocapture.stderr b/tests/rustdoc-ui/doctest/no-capture.stderr similarity index 100% rename from tests/rustdoc-ui/doctest/nocapture.stderr rename to tests/rustdoc-ui/doctest/no-capture.stderr diff --git a/tests/rustdoc-ui/doctest/nocapture.stdout b/tests/rustdoc-ui/doctest/no-capture.stdout similarity index 72% rename from tests/rustdoc-ui/doctest/nocapture.stdout rename to tests/rustdoc-ui/doctest/no-capture.stdout index 4880e75da7062..9916d3d1f8095 100644 --- a/tests/rustdoc-ui/doctest/nocapture.stdout +++ b/tests/rustdoc-ui/doctest/no-capture.stdout @@ -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 diff --git a/tests/rustdoc-ui/doctest/non_local_defs.rs b/tests/rustdoc-ui/doctest/non_local_defs.rs index ce65ad2cf72c2..1b87b04148a88 100644 --- a/tests/rustdoc-ui/doctest/non_local_defs.rs +++ b/tests/rustdoc-ui/doctest/non_local_defs.rs @@ -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" From 857a18735f99e6e3e520a2e3330643e74df797ba Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Oct 2025 15:58:56 +0100 Subject: [PATCH 2/6] rustdoc search: Include attribute and derive macros when filtering on "macros" --- src/librustdoc/html/static/js/search.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 337c973a2c84f..0a73d32dac2de 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -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 From 52c99e6d0dd40b1331d24fc5b71910e7e0de6e5e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Oct 2025 16:00:32 +0100 Subject: [PATCH 3/6] Add regression test for including derive macros in macro filtering --- tests/rustdoc-js-std/filter-macro-attr-derive.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/rustdoc-js-std/filter-macro-attr-derive.js diff --git a/tests/rustdoc-js-std/filter-macro-attr-derive.js b/tests/rustdoc-js-std/filter-macro-attr-derive.js new file mode 100644 index 0000000000000..4c8ec77030b42 --- /dev/null +++ b/tests/rustdoc-js-std/filter-macro-attr-derive.js @@ -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' }, + ], +}; From bd61985bb63e22551c859c1d157d690ad0dfd285 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 3 Oct 2025 09:11:24 -0600 Subject: [PATCH 4/6] Disable crt_static_allows_dylibs in redox targets --- compiler/rustc_target/src/spec/base/redox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/base/redox.rs b/compiler/rustc_target/src/spec/base/redox.rs index e0a0c20c56d63..e9b47f3fa3fdb 100644 --- a/compiler/rustc_target/src/spec/base/redox.rs +++ b/compiler/rustc_target/src/spec/base/redox.rs @@ -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() } From fa0f1630d67d06c03ceb61b4a7fb970032b161db Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 26 Oct 2025 11:41:23 +0000 Subject: [PATCH 5/6] Add riscv64gc-unknown-redox Co-Authored-By: Jeremy Soller --- compiler/rustc_target/src/spec/mod.rs | 1 + .../spec/targets/riscv64gc_unknown_redox.rs | 25 +++++++++++++++++++ src/bootstrap/src/core/sanity.rs | 1 + src/doc/rustc/src/platform-support.md | 1 + src/doc/rustc/src/platform-support/redox.md | 2 ++ tests/assembly-llvm/targets/targets-elf.rs | 3 +++ 6 files changed, 33 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 1638c87c9ca9a..39a260f9a9b44 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -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), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs new file mode 100644 index 0000000000000..01276a8be465e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs @@ -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, + } +} diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index d0405270f6634..08e5abc0a03b1 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -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 diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 4eb0dabe5952c..99739ee734e4c 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -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) diff --git a/src/doc/rustc/src/platform-support/redox.md b/src/doc/rustc/src/platform-support/redox.md index fc36a551c8617..02ba5254d196c 100644 --- a/src/doc/rustc/src/platform-support/redox.md +++ b/src/doc/rustc/src/platform-support/redox.md @@ -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 @@ -37,6 +38,7 @@ target = [ "x86_64-unknown-redox", "aarch64-unknown-redox", "i586-unknown-redox", + "riscv64gc-unknown-redox", ] ``` diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index e26c213837066..6c85dbcfed1a5 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -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 From 4d7c784caf1964d75cc41f8243560fb3553f2474 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 Oct 2025 13:43:14 +0000 Subject: [PATCH 6/6] Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. --- compiler/rustc_interface/src/util.rs | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 5e9cb42365049..56c3f65d8ae8e 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -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; @@ -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 { // This includes bin despite failing on the link step to ensure that you // can still get the frontend handling for binaries. For all library