Add GCC to build-manifest

This commit is contained in:
Jakub Beránek 2026-01-15 11:15:26 +01:00
parent 4ceb13807e
commit ea9b062a8a
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 50 additions and 13 deletions

View file

@ -158,7 +158,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);
}
}
@ -227,7 +227,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());
}
}
}
@ -263,7 +263,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 => {
@ -303,6 +303,7 @@ impl Builder {
| PkgType::JsonDocs
| PkgType::RustcCodegenCranelift
| PkgType::RustcCodegenGcc
| PkgType::Gcc { .. }
| PkgType::LlvmBitcodeLinker => {
extensions.push(host_component(pkg));
}

View file

@ -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
}
}
}
@ -60,6 +85,9 @@ pkg_type! {
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 {
@ -68,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()
}
}
@ -84,6 +112,7 @@ impl PkgType {
PkgType::Miri => false,
PkgType::RustcCodegenCranelift => false,
PkgType::RustcCodegenGcc => false,
PkgType::Gcc { suffix: _ } => false,
PkgType::Rust => true,
PkgType::RustStd => true,
@ -114,6 +143,13 @@ impl PkgType {
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,