From 3910ea36fd148a27f53c700eb5b39471d71e08ea Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Arcos Date: Tue, 17 Oct 2023 14:05:55 +0200 Subject: [PATCH] Update GCC version (#373) * feat: Update GCC version * docs: Update changelog --- CHANGELOG.md | 1 + src/toolchain/gcc.rs | 53 ++++++++++--------------------------------- src/toolchain/mod.rs | 17 +++++++------- src/toolchain/rust.rs | 6 ++--- 4 files changed, 24 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afad75ea..d1277926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Changed +- Update GCC version to 13.2 (#373) ### Removed diff --git a/src/toolchain/gcc.rs b/src/toolchain/gcc.rs index 4e25cfd3..187fe5c1 100644 --- a/src/toolchain/gcc.rs +++ b/src/toolchain/gcc.rs @@ -4,7 +4,6 @@ use crate::{ emoji, error::Error, host_triple::HostTriple, - targets::Target, toolchain::{download_file, Installable}, }; use async_trait::async_trait; @@ -16,18 +15,16 @@ use std::{ }; const DEFAULT_GCC_REPOSITORY: &str = "https://github.com/espressif/crosstool-NG/releases/download"; -const DEFAULT_GCC_RELEASE: &str = "12.2.0_20230208"; -pub const ESP32_GCC: &str = "xtensa-esp32-elf"; -pub const ESP32S2_GCC: &str = "xtensa-esp32s2-elf"; -pub const ESP32S3_GCC: &str = "xtensa-esp32s3-elf"; +const DEFAULT_GCC_RELEASE: &str = "13.2.0_20230928"; pub const RISCV_GCC: &str = "riscv32-esp-elf"; +pub const XTENSA_GCC: &str = "xtensa-esp-elf"; #[derive(Debug, Clone)] pub struct Gcc { /// Host triple. pub host_triple: HostTriple, - /// GCC Toolchain name. - pub name: String, + /// GCC Toolchain architecture. + pub arch: String, /// GCC Toolchain path. pub path: PathBuf, } @@ -35,33 +32,18 @@ pub struct Gcc { impl Gcc { /// Gets the binary path. pub fn get_bin_path(&self) -> String { - format!("{}/{}/bin", &self.path.to_str().unwrap(), &self.name) + format!("{}/{}/bin", &self.path.to_str().unwrap(), &self.arch) } /// Create a new instance with default values and proper toolchain name. - pub fn new(target: &Target, host_triple: &HostTriple, toolchain_path: &Path) -> Self { - let name = get_gcc_name(target); + pub fn new(arch: &str, host_triple: &HostTriple, toolchain_path: &Path) -> Self { let path = toolchain_path - .join(&name) + .join(arch) .join(format!("esp-{DEFAULT_GCC_RELEASE}")); Self { host_triple: host_triple.clone(), - name, - path, - } - } - - /// Create a new instance of RISC-V GCC with default values and proper toolchain name. - pub fn new_riscv(host_triple: &HostTriple, toolchain_path: &Path) -> Self { - let name = RISCV_GCC.to_string(); - let path = toolchain_path - .join(&name) - .join(format!("esp-{DEFAULT_GCC_RELEASE}")); - - Self { - host_triple: host_triple.clone(), - name, + arch: arch.to_string(), path, } } @@ -81,7 +63,7 @@ impl Installable for Gcc { } else { let gcc_file = format!( "{}-{}-{}.{}", - self.name, + self.arch, DEFAULT_GCC_RELEASE, get_arch(&self.host_triple).unwrap(), extension @@ -92,7 +74,7 @@ impl Installable for Gcc { ); download_file( gcc_dist_url, - &format!("{}.{}", &self.name, extension), + &format!("{}.{}", &self.arch, extension), &self.path.display().to_string(), true, false, @@ -119,7 +101,7 @@ impl Installable for Gcc { } fn name(&self) -> String { - format!("GCC ({})", self.name) + format!("GCC ({})", self.arch) } } @@ -144,22 +126,11 @@ fn get_artifact_extension(host_triple: &HostTriple) -> &str { } } -/// Gets the toolchain name based on the Target -pub fn get_gcc_name(target: &Target) -> String { - let toolchain = match target { - Target::ESP32 => ESP32_GCC, - Target::ESP32S2 => ESP32S2_GCC, - Target::ESP32S3 => ESP32S3_GCC, - Target::ESP32C2 | Target::ESP32C3 | Target::ESP32C6 | Target::ESP32H2 => RISCV_GCC, - }; - toolchain.to_string() -} - /// Checks if the toolchain is pressent, if present uninstalls it. pub fn uninstall_gcc_toolchains(toolchain_path: &Path) -> Result<(), Error> { info!("{} Uninstalling GCC toolchain", emoji::WRENCH); - let gcc_toolchains = vec![ESP32_GCC, ESP32S2_GCC, ESP32S3_GCC, RISCV_GCC]; + let gcc_toolchains = vec![XTENSA_GCC, RISCV_GCC]; for toolchain in gcc_toolchains { let gcc_path = toolchain_path.join(toolchain); diff --git a/src/toolchain/mod.rs b/src/toolchain/mod.rs index dab997d0..fdac3fd4 100644 --- a/src/toolchain/mod.rs +++ b/src/toolchain/mod.rs @@ -8,7 +8,7 @@ use crate::{ host_triple::get_host_triple, targets::Target, toolchain::{ - gcc::Gcc, + gcc::{Gcc, RISCV_GCC, XTENSA_GCC}, llvm::Llvm, rust::{check_rust_installation, get_rustup_home, RiscVTarget, XtensaRust}, }, @@ -217,16 +217,17 @@ pub async fn install(args: InstallOpts) -> Result<()> { } if !args.std { - targets.iter().for_each(|target| { - if target.is_xtensa() { - let gcc = Gcc::new(target, &host_triple, &install_path); - to_install.push(Box::new(gcc)); - } - }); + if targets + .iter() + .any(|t| t == &Target::ESP32 || t == &Target::ESP32S2 || t == &Target::ESP32S3) + { + let xtensa_gcc = Gcc::new(XTENSA_GCC, &host_triple, &install_path); + to_install.push(Box::new(xtensa_gcc)); + } // All RISC-V targets use the same GCC toolchain // ESP32S2 and ESP32S3 also install the RISC-V toolchain for their ULP coprocessor if targets.iter().any(|t| t != &Target::ESP32) { - let riscv_gcc = Gcc::new_riscv(&host_triple, &install_path); + let riscv_gcc = Gcc::new(RISCV_GCC, &host_triple, &install_path); to_install.push(Box::new(riscv_gcc)); } } diff --git a/src/toolchain/rust.rs b/src/toolchain/rust.rs index 64b8496d..eca47bad 100644 --- a/src/toolchain/rust.rs +++ b/src/toolchain/rust.rs @@ -6,7 +6,7 @@ use crate::{ host_triple::HostTriple, toolchain::{ download_file, - gcc::{ESP32S2_GCC, ESP32S3_GCC, ESP32_GCC, RISCV_GCC}, + gcc::{RISCV_GCC, XTENSA_GCC}, github_query, llvm::CLANG_NAME, Installable, @@ -165,9 +165,7 @@ impl XtensaRust { let entry_path = entry.unwrap().path(); let entry_name = entry_path.display().to_string(); if !entry_name.contains(RISCV_GCC) - && !entry_name.contains(ESP32_GCC) - && !entry_name.contains(ESP32S2_GCC) - && !entry_name.contains(ESP32S3_GCC) + && !entry_name.contains(XTENSA_GCC) && !entry_name.contains(CLANG_NAME) { if entry_path.is_dir() {