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
1 change: 0 additions & 1 deletion compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ features = ['override_allocator_on_supported_platforms']
check_only = ['rustc_driver_impl/check_only']
jemalloc = ['dep:tikv-jemalloc-sys']
llvm = ['rustc_driver_impl/llvm']
llvm_enzyme = ['rustc_driver_impl/llvm_enzyme']
llvm_offload = ['rustc_driver_impl/llvm_offload']
max_level_info = ['rustc_driver_impl/max_level_info']
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ tracing = "0.1"

[features]
# tidy-alphabetical-start
llvm_enzyme = []
# tidy-alphabetical-end
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ tracing = "0.1"
[features]
# tidy-alphabetical-start
check_only = ["rustc_llvm/check_only"]
llvm_enzyme = []
llvm_offload = []
# tidy-alphabetical-end

2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ pub(crate) fn run_pass_manager(
);
}

if cfg!(feature = "llvm_enzyme") && enable_ad && !thin {
if enable_ad && !thin {
let opt_stage = llvm::OptStage::FatLTO;
let stage = write::AutodiffStage::PostAD;
if !config.autodiff.contains(&config::AutoDiff::NoPostopt)
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_codegen_llvm/src/typetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,9 @@ enum TTLocation {
Callsite,
}

#[cfg_attr(not(feature = "llvm_enzyme"), allow(unused))]
pub(crate) fn add_tt<'tcx, 'll>(cx: &FullCx<'ll, 'tcx>, fn_def: &'ll Value, tt: FncTree) {
// TypeTree processing uses functions from Enzyme, which we might not have available if we did
// not build this compiler with `llvm_enzyme`. This feature is not strictly necessary, but
// skipping this function increases the chance that Enzyme fails to compile some code.
// FIXME(autodiff): In the future we should conditionally run this function even without the
// `llvm_enzyme` feature, in case that libEnzyme was provided via rustup.
#[cfg(not(feature = "llvm_enzyme"))]
return;
// TypeTree processing uses functions from Enzyme. This feature is not strictly necessary,
// but skipping this function increases the chance that Enzyme fails to compile some code.

let tcx = cx.tcx;
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Unlike all the other GC helpers where we check if an `AllocId` is found in the interpreter or
// is live, here all the IDs in the map are for dead allocations so we don't
// need to check for liveness.
#[allow(rustc::potential_query_instability)] // Only used from Miri, not queries.
self.memory.dead_alloc_map.retain(|id, _| reachable_allocs.contains(id));
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ ctrlc = "3.4.4"
# tidy-alphabetical-start
check_only = ['rustc_interface/check_only']
llvm = ['rustc_interface/llvm']
llvm_enzyme = ['rustc_interface/llvm_enzyme']
llvm_offload = ['rustc_interface/llvm_offload']
max_level_info = ['rustc_log/max_level_info']
rustc_randomized_layouts = [
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ rustc_abi = { path = "../rustc_abi" }
# tidy-alphabetical-start
check_only = ['rustc_codegen_llvm?/check_only']
llvm = ['dep:rustc_codegen_llvm']
llvm_enzyme = ['rustc_builtin_macros/llvm_enzyme', 'rustc_codegen_llvm/llvm_enzyme']
llvm_offload = ['rustc_codegen_llvm/llvm_offload']
# tidy-alphabetical-end
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(function_sections, Some(false));
tracked!(hint_mostly_unused, true);
tracked!(human_readable_cgu_names, true);
tracked!(implicit_sysroot_deps, false);
tracked!(incremental_ignore_spans, true);
tracked!(indirect_branch_cs_prefix, true);
tracked!(inline_mir, Some(true));
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ impl SubdiagnosticDerive {

let diag = &self.diag;

// FIXME(edition_2024): Fix the `keyword_idents_2024` lint to not trigger here?
#[allow(keyword_idents_2024)]
let ret = structure.gen_impl(quote! {
gen impl rustc_errors::Subdiagnostic for @Self {
fn add_to_diag<__G>(
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// tidy-alphabetical-start
#![allow(rustc::default_hash_types)]
#![feature(never_type)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_tracked_env)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_macros/src/print_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ pub(crate) fn print_attribute(input: Structure<'_>) -> TokenStream {
}
};

#[allow(keyword_idents_2024)]
input.gen_impl(quote! {
#[allow(unused)]
gen impl PrintAttribute for @Self {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! [`rustc`] module.
// tidy-alphabetical-start
#![allow(unused_crate_dependencies)]
#![cfg_attr(test, allow(unused_crate_dependencies))] // Used for integration tests, not unit tests
// tidy-alphabetical-end

pub(crate) mod checks;
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_session/src/config/sigpipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@
///
/// Note that `SIG_IGN` has been the Rust default since 2014. See
/// <https://github.com/rust-lang/rust/issues/62569>.
#[allow(dead_code)]
pub const DEFAULT: u8 = 0;

/// Do not touch `SIGPIPE`. Use whatever the parent process uses.
#[allow(dead_code)]
pub const INHERIT: u8 = 1;

/// Change `SIGPIPE` to `SIG_IGN` so that failed writes results in `EPIPE`
/// that are eventually converted to `ErrorKind::BrokenPipe`.
#[allow(dead_code)]
pub const SIG_IGN: u8 = 2;

/// Change `SIGPIPE` to `SIG_DFL` so that the process is killed when trying
/// to write to a closed pipe. This is usually the desired behavior for CLI
/// apps that produce textual output that you want to pipe to other programs
/// such as `head -n 1`.
#[allow(dead_code)]
pub const SIG_DFL: u8 = 3;
16 changes: 14 additions & 2 deletions compiler/rustc_session/src/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::search_paths::{PathKind, SearchPath};
pub struct FileSearch {
cli_search_paths: Vec<SearchPath>,
tlib_path: SearchPath,
use_implicit_sysroot_deps: bool,
}

impl FileSearch {
Expand All @@ -20,16 +21,27 @@ impl FileSearch {
}

pub fn search_paths<'b>(&'b self, kind: PathKind) -> impl Iterator<Item = &'b SearchPath> {
// If the crate is `PathKind::Crate` (a top level dependency)
// and `-Z implicit-sysroot-deps=false`, then don't include the sysroot in the search paths.
let exclude_sysroot = kind.matches(PathKind::Crate) && !self.use_implicit_sysroot_deps;
let maybe_tlib = (!exclude_sysroot).then_some(&self.tlib_path);

self.cli_search_paths
.iter()
.filter(move |sp| sp.kind.matches(kind))
.chain(std::iter::once(&self.tlib_path))
.chain(maybe_tlib.into_iter())
}

pub fn new(cli_search_paths: &[SearchPath], tlib_path: &SearchPath, target: &Target) -> Self {
pub fn new(
cli_search_paths: &[SearchPath],
tlib_path: &SearchPath,
target: &Target,
use_implicit_sysroot_deps: bool,
) -> Self {
let this = FileSearch {
cli_search_paths: cli_search_paths.to_owned(),
tlib_path: tlib_path.clone(),
use_implicit_sysroot_deps,
};
this.refine(&["lib", &target.staticlib_prefix, &target.dll_prefix])
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2531,6 +2531,8 @@ options! {
"display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
ignore_directory_in_diagnostics_source_blocks: Vec<String> = (Vec::new(), parse_string_push, [UNTRACKED],
"do not display the source code block in diagnostics for files in the directory"),
implicit_sysroot_deps: bool = (true, parse_bool, [TRACKED],
"allows rust to search sysroot for a crate's dependencies (default: yes)"),
incremental_ignore_spans: bool = (false, parse_bool, [TRACKED],
"ignore spans during ICH computation -- used for testing (default: no)"),
incremental_info: bool = (false, parse_bool, [UNTRACKED],
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,18 @@ pub fn build_session(
});

let asm_arch = if target.allow_asm { InlineAsmArch::from_arch(&target.arch) } else { None };
let target_filesearch =
filesearch::FileSearch::new(&sopts.search_paths, &target_tlib_path, &target);
let host_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &host_tlib_path, &host);
let target_filesearch = filesearch::FileSearch::new(
&sopts.search_paths,
&target_tlib_path,
&target,
sopts.unstable_opts.implicit_sysroot_deps,
);
let host_filesearch = filesearch::FileSearch::new(
&sopts.search_paths,
&host_tlib_path,
&host,
sopts.unstable_opts.implicit_sysroot_deps,
);

let timings = TimingSectionHandler::new(sopts.json_timings);

Expand Down
2 changes: 0 additions & 2 deletions library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ optimize_for_size = []
# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = []
llvm_enzyme = []

[lints.rust.unexpected_cfgs]
level = "warn"
Expand All @@ -39,7 +38,6 @@ check-cfg = [
'cfg(target_has_reliable_f16_math)',
'cfg(target_has_reliable_f128)',
'cfg(target_has_reliable_f128_math)',
'cfg(llvm_enzyme)',
# Prevents use of a static variable for providing platform specific RawOsError
# functionality
'cfg(no_io_statics)',
Expand Down
2 changes: 0 additions & 2 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]
# a borrow error occurs
debug_refcell = ["core/debug_refcell"]

llvm_enzyme = ["core/llvm_enzyme"]

# Enable using raw-dylib for Windows imports.
# This will eventually be the default.
windows_raw_dylib = ["windows-link/windows_raw_dylib"]
Expand Down
1 change: 0 additions & 1 deletion library/sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ optimize_for_size = ["std/optimize_for_size"]
panic-unwind = ["std/panic-unwind"]
profiler = ["dep:profiler_builtins"]
windows_raw_dylib = ["std/windows_raw_dylib"]
llvm_enzyme = ["std/llvm_enzyme"]
89 changes: 89 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::{env, fs, iter};

use build_helper::git::get_closest_upstream_commit;

use crate::core::build_steps::compile::{ArtifactKeepMode, Std, run_cargo};
use crate::core::build_steps::doc::{DocumentationFormat, prepare_doc_compiler};
use crate::core::build_steps::gcc::{Gcc, GccTargetPair, add_cg_gcc_cargo_flags};
Expand Down Expand Up @@ -4613,3 +4615,90 @@ impl CommandLineStep for RemoteTestClientTests {
);
}
}

fn check_if_cargo_semver_checks_is_installed(builder: &Builder<'_>) -> bool {
command("cargo")
.allow_failure()
.arg("semver-checks")
.arg("--version")
// Cache the output to avoid running this command more than once (per builder).
.cached()
.run_capture_stdout(builder)
.is_success()
}

/// Run cargo-semver-checks on the standard library and compare its API
/// versus a previous baseline, using rustdoc JSON data.
///
/// Fails if a semver-breaking change is detected.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StdSemverCheck {
build_compiler: Compiler,
target: TargetSelection,
/// The baseline commit that we are comparing the local stdlib API against.
commit: String,
}

impl CommandLineStep for StdSemverCheck {
type Output = ();

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias("std-semver-check")
}

fn make_run(run: RunConfig<'_>) {
if !check_if_cargo_semver_checks_is_installed(run.builder) {
panic!("cargo-semver-checks was not found, please install it");
}

let baseline_commit = match get_closest_upstream_commit(
Some(&run.builder.config.src),
&run.builder.config.git_config(),
run.builder.config.ci_env,
) {
Ok(Some(commit)) => commit,
Ok(None) => {
panic!("No baseline parent commit found for std-semver-check");
}
Err(error) => {
panic!("Cannot get baseline parent commit for std-semver-check: {error:?}");
}
};

run.builder.ensure(Self {
build_compiler: run.builder.compiler_for_std(run.builder.top_stage),
target: run.target,
commit: baseline_commit,
});
}

fn run(self, builder: &Builder<'_>) {
let Some(docs_dir) = builder.config.download_std_json_docs(self.target, &self.commit)
else {
return;
};

let directory = builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
self.build_compiler,
self.target,
DocumentationFormat::Json,
));
let baseline_dir = docs_dir.join("share").join("doc").join("rust").join("json");

for library in ["core", "alloc", "std"] {
println!("Checking semver compatibility of {library}");
let mut cmd = command("cargo");
cmd.arg("semver-checks")
.arg("-Z")
.arg("unstable-options")
.arg("--stability-aware")
.arg("--release-type")
.arg("minor")
.arg("--current-rustdoc")
.arg(directory.join(format!("{library}.json")))
.arg("--baseline-rustdoc")
.arg(baseline_dir.join(format!("{library}.json")));
cmd.run(builder);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
expression: test std-semver-check
---
[Test] test::StdSemverCheck
targets: [aarch64-unknown-linux-gnu]
- Set({test::std-semver-check})
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/cli_paths/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ declare_tests!(
(x_test_librustdoc_rustdoc_html, "test librustdoc rustdoc-html"),
(x_test_rustdoc, "test rustdoc"),
(x_test_rustdoc_html, "test rustdoc-html"),
(x_test_semver_check, "test std-semver-check"),
(x_test_skip_coverage, "test --skip=coverage"),
(x_test_skip_coverage_map, "test --skip=coverage-map"),
(x_test_skip_coverage_run, "test --skip=coverage-run"),
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ impl<'a> Builder<'a> {
test::RunMake,
test::RunMakeCargo,
test::BuildStd,
test::StdSemverCheck,
test::IntrinsicTest,
),
Kind::Miri => describe!(test::Crate),
Expand Down
Loading
Loading