Fix extended LLVM mode for LLVM < 17 (#437)

The fix for extended LLVM mode with LLVM 17 accidentally broke it for
toolchain versions using LLVM 15 and 16.

Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
This commit is contained in:
Johannes Löthberg 2024-07-17 13:06:48 +02:00 committed by GitHub
parent e5bf496aaf
commit e108653b63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 16 deletions

View File

@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fix extended LLVM mode regression for LLVM versions < 17 introduced by #432. (#437)
## [0.12.1] - 2024-07-15 ## [0.12.1] - 2024-07-15
### Fixed ### Fixed

View File

@ -33,7 +33,7 @@ pub struct Llvm {
// /// If `true`, full LLVM, instead of only libraries, are installed. // /// If `true`, full LLVM, instead of only libraries, are installed.
extended: bool, extended: bool,
/// LLVM libs-only toolchain file name. /// LLVM libs-only toolchain file name.
pub file_name_libs: String, pub file_name_libs: Option<String>,
/// LLVM "full" toolchain file name. /// LLVM "full" toolchain file name.
pub file_name_full: Option<String>, pub file_name_full: Option<String>,
/// Host triple. /// Host triple.
@ -140,14 +140,23 @@ impl Llvm {
format!("libs-{file_name_full}") format!("libs-{file_name_full}")
}; };
( // For LLVM 15 and 16 the "full" tarball was a superset of the "libs" tarball, so if
file_name_libs, // we're in extended LLVM mode we only need the "full" tarballs for those versions.
if version == DEFAULT_LLVM_15_VERSION || version == DEFAULT_LLVM_16_VERSION { //
None // Later LLVM versions are built such that the "full" tarball has a statically linked
// `clang` binary and therefore doesn't contain libclang, and so then we need to fetch
// both tarballs.
if version == DEFAULT_LLVM_15_VERSION || version == DEFAULT_LLVM_16_VERSION {
if extended {
(None, Some(file_name_full))
} else { } else {
extended.then_some(file_name_full) (Some(file_name_libs), None)
}, }
) } else if extended {
(Some(file_name_libs), Some(file_name_full))
} else {
(Some(file_name_libs), None)
}
}; };
let repository_url = format!("{DEFAULT_LLVM_REPOSITORY}/{version}"); let repository_url = format!("{DEFAULT_LLVM_REPOSITORY}/{version}");
@ -260,14 +269,16 @@ impl Installable for Llvm {
); );
} else { } else {
info!("Installing Xtensa LLVM"); info!("Installing Xtensa LLVM");
download_file( if let Some(file_name_libs) = &self.file_name_libs {
format!("{}/{}", self.repository_url, self.file_name_libs), download_file(
"idf_tool_xtensa_elf_clang.libs.tar.xz", format!("{}/{}", self.repository_url, file_name_libs),
self.path.to_str().unwrap(), "idf_tool_xtensa_elf_clang.libs.tar.xz",
true, self.path.to_str().unwrap(),
false, true,
) false,
.await?; )
.await?;
}
if let Some(file_name_full) = &self.file_name_full { if let Some(file_name_full) = &self.file_name_full {
download_file( download_file(
format!("{}/{}", self.repository_url, file_name_full), format!("{}/{}", self.repository_url, file_name_full),