Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable parallel rustc front end in nightly builds #117435

Merged
merged 4 commits into from Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock
Expand Up @@ -2982,9 +2982,9 @@ dependencies = [

[[package]]
name = "portable-atomic"
version = "1.4.2"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e"
checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b"

[[package]]
name = "ppv-lite86"
Expand Down Expand Up @@ -3712,6 +3712,7 @@ dependencies = [
"measureme",
"memmap2",
"parking_lot 0.12.1",
"portable-atomic",
"rustc-hash",
"rustc-rayon",
"rustc-rayon-core",
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_data_structures/Cargo.toml
Expand Up @@ -47,6 +47,9 @@ features = [
memmap2 = "0.2.1"
# tidy-alphabetical-end

[target.'cfg(any(target_arch = "powerpc", target_arch = "mips"))'.dependencies]
portable-atomic = "1.5.1"

[features]
# tidy-alphabetical-start
rustc_use_parallel_compiler = ["indexmap/rustc-rayon", "rustc-rayon", "rustc-rayon-core"]
Expand Down
13 changes: 12 additions & 1 deletion compiler/rustc_data_structures/src/marker.rs
Expand Up @@ -138,7 +138,6 @@ cfg_match! {
[std::sync::atomic::AtomicUsize]
[std::sync::atomic::AtomicU8]
[std::sync::atomic::AtomicU32]
[std::sync::atomic::AtomicU64]
[std::backtrace::Backtrace]
[std::io::Error]
[std::fs::File]
Expand All @@ -148,6 +147,18 @@ cfg_match! {
[crate::owned_slice::OwnedSlice]
);

// PowerPC and MIPS platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "powerpc", target_arch = "mips")))]
already_sync!(
[std::sync::atomic::AtomicU64]
);

#[cfg(any(target_arch = "powerpc", target_arch = "mips"))]
already_sync!(
[portable_atomic::AtomicU64]
);

macro_rules! impl_dyn_sync {
($($($attr: meta)* [$ty: ty where $($generics2: tt)*])*) => {
$(unsafe impl<$($generics2)*> DynSync for $ty {})*
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_data_structures/src/sync.rs
Expand Up @@ -265,7 +265,15 @@ cfg_match! {

pub use std::sync::OnceLock;

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32};

// PowerPC and MIPS platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "powerpc", target_arch = "mips")))]
pub use std::sync::atomic::AtomicU64;

#[cfg(any(target_arch = "powerpc", target_arch = "mips"))]
pub use portable_atomic::AtomicU64;

pub use std::sync::Arc as Lrc;
pub use std::sync::Weak as Weak;
Expand Down
11 changes: 6 additions & 5 deletions config.example.toml
Expand Up @@ -30,7 +30,7 @@
#
# If `change-id` does not match the version that is currently running,
# `x.py` will prompt you to update it and check the related PR for more details.
change-id = 116998
change-id = 117435

# =============================================================================
# Tweaking how LLVM is compiled
Expand Down Expand Up @@ -553,10 +553,11 @@ change-id = 116998
# Whether to always use incremental compilation when building rustc
#incremental = false

# Build a multi-threaded rustc
# FIXME(#75760): Some UI tests fail when this option is enabled.
# NOTE: This option is NOT SUPPORTED. See #48685.
#parallel-compiler = false
# Build a multi-threaded rustc. This allows users to use parallel rustc
# via the unstable option `-Z threads=n`.
# Since stable/beta channels only allow using stable features,
# `parallel-compiler = false` should be set for these channels.
#parallel-compiler = true

# The default linker that will be hard-coded into the generated
# compiler for targets that don't specify a default linker explicitly
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Expand Up @@ -1072,6 +1072,7 @@ impl Config {
config.bindir = "bin".into();
config.dist_include_mingw_linker = true;
config.dist_compression_profile = "fast".into();
config.rustc_parallel = true;

config.stdout_is_tty = std::io::stdout().is_terminal();
config.stderr_is_tty = std::io::stderr().is_terminal();
Expand Down Expand Up @@ -1429,7 +1430,9 @@ impl Config {
set(&mut config.use_lld, rust.use_lld);
set(&mut config.lld_enabled, rust.lld);
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
config.rustc_parallel = rust.parallel_compiler.unwrap_or(false);
config.rustc_parallel = rust
.parallel_compiler
.unwrap_or(config.channel == "dev" || config.channel == "nightly");
oli-obk marked this conversation as resolved.
Show resolved Hide resolved
config.rustc_default_linker = rust.default_linker;
config.musl_root = rust.musl_root.map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.map(PathBuf::from);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/lib.rs
Expand Up @@ -77,7 +77,7 @@ const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
///
/// If you make any major changes (such as adding new values or changing default values), please
/// ensure that the associated PR ID is added to the end of this list.
pub const CONFIG_CHANGE_HISTORY: &[usize] = &[115898, 116998];
pub const CONFIG_CHANGE_HISTORY: &[usize] = &[115898, 116998, 117435];
Copy link
Member

@RalfJung RalfJung Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you do this, please explain in the PR description what we have to do to update our configs. I was sent here by bootstrap ("WARNING: there have been changes to x.py since you last updated") and now I have no idea what I'm supposed to do.


/// Extra --check-cfg to add when building
/// (Mode restriction, config name, config values (if any))
Expand Down
4 changes: 2 additions & 2 deletions src/ci/run.sh
Expand Up @@ -98,8 +98,8 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
elif [ "$DEPLOY_ALT" != "" ]; then
if [ "$NO_PARALLEL_COMPILER" = "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
if [ "$ALT_PARALLEL_COMPILER" = "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler=false"
davidtwco marked this conversation as resolved.
Show resolved Hide resolved
fi
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Expand Up @@ -211,6 +211,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"perf-event-open-sys",
"pin-project-lite",
"polonius-engine",
"portable-atomic", // dependency for platforms doesn't support `AtomicU64` in std
"ppv-lite86",
"proc-macro-hack",
"proc-macro2",
Expand Down