Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::core::build_steps::tool::{
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
use crate::core::build_steps::{compile, llvm};
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata};
use crate::core::config::TargetSelection;
use crate::core::config::{GccCiMode, TargetSelection};
use crate::utils::build_stamp::{self, BuildStamp};
use crate::utils::channel::{self, Info};
use crate::utils::exec::{BootstrapCommand, command};
Expand Down Expand Up @@ -3035,6 +3035,14 @@ impl Step for Gcc {
return None;
}

if builder.config.is_running_on_ci {
assert_eq!(
builder.config.gcc_ci_mode,
GccCiMode::BuildLocally,
"Cannot use gcc.download-ci-gcc when distributing GCC on CI"
);
}

// We need the GCC sources to build GCC and also to add its license and README
// files to the tarball
builder.require_submodule(
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl std::str::FromStr for RustcLto {
}

/// Determines how will GCC be provided.
#[derive(Default, Clone)]
#[derive(Default, Debug, Clone, PartialEq)]
pub enum GccCiMode {
/// Build GCC from the local `src/gcc` submodule.
BuildLocally,
Expand Down
22 changes: 16 additions & 6 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ static DOCS_FALLBACK: &[(&str, &str)] = &[

static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin"];

static NIGHTLY_ONLY_COMPONENTS: &[PkgType] =
&[PkgType::Miri, PkgType::JsonDocs, PkgType::RustcCodegenCranelift];
fn is_nightly_only(pkg: &PkgType) -> bool {
match pkg {
PkgType::Miri
| PkgType::JsonDocs
| PkgType::RustcCodegenCranelift
| PkgType::RustcCodegenGcc
| PkgType::Gcc { .. } => true,
_ => false,
}
}

macro_rules! t {
($e:expr) => {
Expand Down Expand Up @@ -158,7 +166,7 @@ impl Builder {
}

fn add_packages_to(&mut self, manifest: &mut Manifest) {
for pkg in PkgType::all() {
for pkg in &PkgType::all() {
self.package(pkg, &mut manifest.pkg);
}
}
Expand Down Expand Up @@ -227,7 +235,7 @@ impl Builder {
};
for pkg in PkgType::all() {
if pkg.is_preview() {
rename(pkg.tarball_component_name(), &pkg.manifest_component_name());
rename(&pkg.tarball_component_name(), &pkg.manifest_component_name());
}
}
}
Expand Down Expand Up @@ -263,7 +271,7 @@ impl Builder {

let host_component = |pkg: &_| Component::from_pkg(pkg, host);

for pkg in PkgType::all() {
for pkg in &PkgType::all() {
match pkg {
// rustc/rust-std/cargo/docs are all required
PkgType::Rustc | PkgType::Cargo | PkgType::HtmlDocs => {
Expand Down Expand Up @@ -302,6 +310,8 @@ impl Builder {
| PkgType::RustAnalysis
| PkgType::JsonDocs
| PkgType::RustcCodegenCranelift
| PkgType::RustcCodegenGcc
| PkgType::Gcc { .. }
| PkgType::LlvmBitcodeLinker => {
extensions.push(host_component(pkg));
}
Expand Down Expand Up @@ -373,7 +383,7 @@ impl Builder {
let mut is_present = version_info.present;

// Never ship nightly-only components for other trains.
if self.versions.channel() != "nightly" && NIGHTLY_ONLY_COMPONENTS.contains(&pkg) {
if self.versions.channel() != "nightly" && is_nightly_only(&pkg) {
is_present = false; // Pretend the component is entirely missing.
}

Expand Down
59 changes: 49 additions & 10 deletions src/tools/build-manifest/src/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,54 @@ use xz2::read::XzDecoder;
const DEFAULT_TARGET: &str = "x86_64-unknown-linux-gnu";

macro_rules! pkg_type {
( $($variant:ident = $component:literal $(; preview = true $(@$is_preview:tt)? )? ),+ $(,)? ) => {
( $($variant:ident = $component:literal $(; preview = true $(@$is_preview:tt)? )? $(; suffixes = [$($suffixes:literal),+] $(@$is_suffixed:tt)? )? ),+ $(,)? ) => {
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
pub(crate) enum PkgType {
$($variant,)+
$($variant $( $($is_suffixed)? { suffix: &'static str })?,)+
}

impl PkgType {
pub(crate) fn is_preview(&self) -> bool {
match self {
$( $( $($is_preview)? PkgType::$variant => true, )? )+
_ => false,
$( PkgType::$variant $($($is_suffixed)? { .. })? => false $( $($is_preview)? || true)?, )+
}
}

/// First part of the tarball name.
pub(crate) fn tarball_component_name(&self) -> &str {
/// First part of the tarball name. May include a suffix, if the package has one.
pub(crate) fn tarball_component_name(&self) -> String {
match self {
$( PkgType::$variant => $component,)+
$( PkgType::$variant $($($is_suffixed)? { suffix })? => {
#[allow(unused_mut)]
let mut name = $component.to_owned();
$($($is_suffixed)?
name.push('-');
name.push_str(suffix);
)?
name
},)+
}
}

pub(crate) fn all() -> &'static [PkgType] {
&[ $(PkgType::$variant),+ ]
pub(crate) fn all() -> Vec<PkgType> {
let mut packages = vec![];
$(
// Push the single variant
packages.push(PkgType::$variant $($($is_suffixed)? { suffix: "" })?);
// Macro hell, we have to remove the fake empty suffix if we actually have
// suffixes
$(
$($is_suffixed)?
packages.pop();
)?
// And now add the suffixes, if any
$(
$($is_suffixed)?
$(
packages.push(PkgType::$variant { suffix: $suffixes });
)+
)?
)+
packages
}
}
}
Expand All @@ -59,6 +84,10 @@ pkg_type! {
JsonDocs = "rust-docs-json"; preview = true,
RustcCodegenCranelift = "rustc-codegen-cranelift"; preview = true,
LlvmBitcodeLinker = "llvm-bitcode-linker"; preview = true,
RustcCodegenGcc = "rustc-codegen-gcc"; preview = true,
Gcc = "gcc"; preview = true; suffixes = [
"x86_64-unknown-linux-gnu"
],
}

impl PkgType {
Expand All @@ -67,7 +96,7 @@ impl PkgType {
if self.is_preview() {
format!("{}-preview", self.tarball_component_name())
} else {
self.tarball_component_name().to_string()
self.tarball_component_name()
}
}

Expand All @@ -82,6 +111,8 @@ impl PkgType {
PkgType::LlvmTools => false,
PkgType::Miri => false,
PkgType::RustcCodegenCranelift => false,
PkgType::RustcCodegenGcc => false,
PkgType::Gcc { suffix: _ } => false,

PkgType::Rust => true,
PkgType::RustStd => true,
Expand Down Expand Up @@ -111,6 +142,14 @@ impl PkgType {
RustcDocs => HOSTS,
Cargo => HOSTS,
RustcCodegenCranelift => HOSTS,
RustcCodegenGcc => HOSTS,
// Gcc is "special", because we need a separate libgccjit.so for each
// (host, target) compilation pair. So it's even more special than stdlib, which has a
// separate component per target. This component thus hardcodes its compilation
// target in its name, and we thus ship it for HOSTS only. So we essentially have
// gcc-T1, gcc-T2, a separate *component/package* per each compilation target.
// So on host T1, if you want to compile for T2, you would install gcc-T2.
Gcc { suffix: _ } => HOSTS,
RustMingw => MINGW,
RustStd => TARGETS,
HtmlDocs => HOSTS,
Expand Down
Loading