diff --git a/build/native/cargo_driver.rs b/build/native/cargo_driver.rs index f2d0e0f290b..2bf70078775 100644 --- a/build/native/cargo_driver.rs +++ b/build/native/cargo_driver.rs @@ -93,7 +93,7 @@ pub fn build() -> Result { ); let mut tools = vec![]; - let mut subtools = vec![chip.gcc_toolchain(version.as_ref().ok())]; + let mut subtools = vec![chip.gcc_toolchain_install(version.as_ref().ok())]; // Use custom cmake for esp-idf<4.4, because we need at least cmake-3.20 match version.as_ref().map(|v| (v.major, v.minor, v.patch)) { @@ -109,7 +109,7 @@ pub fn build() -> Result { subtools.push("ninja") } if !cfg!(target_os = "linux") || !cfg!(target_arch = "aarch64") { - subtools.extend(chip.ulp_gcc_toolchain(version.as_ref().ok())); + subtools.extend(chip.ulp_gcc_toolchain_install(version.as_ref().ok())); } tools.push(espidf::Tools::new(subtools)); @@ -251,13 +251,13 @@ pub fn build() -> Result { .install_dir(linker_install_dir.path().map(Into::into)) .with_tools(move |_, _| { Ok(vec![espidf::Tools::new(vec![ - chip.gcc_toolchain(version_for_installer.as_ref()) + chip.gcc_toolchain_install(version_for_installer.as_ref()) ])]) }) .install() .context("Could not install GCC linker")?; - let linker_name = format!("{}-gcc", chip.gcc_toolchain(version.as_ref())); + let linker_name = format!("{}-gcc", chip.gcc_toolchain_link(version.as_ref())); let linker = which::which_in_global(linker_name.clone(), Some(installer.exported_path.clone()))? diff --git a/build/native/cargo_driver/chip.rs b/build/native/cargo_driver/chip.rs index bf865af3810..989313d9ae2 100644 --- a/build/native/cargo_driver/chip.rs +++ b/build/native/cargo_driver/chip.rs @@ -57,8 +57,11 @@ impl Chip { matches!(self, Self::ESP32 | Self::ESP32S2 | Self::ESP32S3) } - /// The name of the gcc toolchain (to compile the `esp-idf`) for `idf_tools.py`. - pub fn gcc_toolchain(&self, version: Option<&EspIdfVersion>) -> &'static str { + /// The name of the gcc toolchain (to compile the `esp-idf`) that `idf_tools.py` + /// should find and install. idf_tools.py might install additional components based + /// on what is specified here, for example an xtensa-esp-elf can also end up installing + /// xtensa-espXX-elf also + pub fn gcc_toolchain_install(&self, version: Option<&EspIdfVersion>) -> &'static str { let new = version .map(|version| version.major > 5 || version.major == 5 && version.minor > 1) .unwrap_or(true); @@ -94,9 +97,28 @@ impl Chip { } } - /// The name of the gcc toolchain for the ultra low-power co-processor for - /// `idf_tools.py`. - pub fn ulp_gcc_toolchain(&self, version: Option<&EspIdfVersion>) -> Option<&'static str> { + /// The name of the gcc toolchain that should be actually used to compile/link + /// for the specific idf target + pub fn gcc_toolchain_link(&self, _version: Option<&EspIdfVersion>) -> &'static str { + match self { + Self::ESP32 => "xtensa-esp32-elf", + Self::ESP32S2 => "xtensa-esp32s2-elf", + Self::ESP32S3 => "xtensa-esp32s3-elf", + Self::ESP32C2 + | Self::ESP32C3 + | Self::ESP32H2 + | Self::ESP32C5 + | Self::ESP32C6 + | Self::ESP32P4 => "riscv32-esp-elf", + } + } + + /// The name of the gcc toolchain for the ultra low-power co-processor that + /// `idf_tools.py` should install + pub fn ulp_gcc_toolchain_install( + &self, + version: Option<&EspIdfVersion>, + ) -> Option<&'static str> { match self { Self::ESP32 => Some("esp32ulp-elf"), Self::ESP32S2 | Self::ESP32S3 | Self::ESP32C6 | Self::ESP32P4 => Some( @@ -117,6 +139,13 @@ impl Chip { } } + /// The name of the gcc toolchain for the ultra low-power co-processor + /// that is actually used to compile/link for the specific idf target + #[allow(dead_code)] + pub fn ulp_gcc_toolchain_link(&self, version: Option<&EspIdfVersion>) -> Option<&'static str> { + self.ulp_gcc_toolchain_install(version) + } + pub fn cmake_toolchain_file(self) -> String { format!("toolchain-{self}.cmake") }