Download both the release artifacts in extended mode for LLVM >= 17

The Espressif-provided LLVM toolchain no longer has the libs-only
tarball as a strict subset of the full tarball.  Instead the "full"
tarball now contains a clang with libclang built in.  To work around
this we now need to get _both_ tarballs if we're in extended LLVM mode.

Cf. https://github.com/espressif/llvm-project/issues/99

Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
This commit is contained in:
Johannes Löthberg 2024-06-27 15:05:44 +02:00 committed by Sergio Gasquez Arcos
parent 84081c2695
commit 9c0234d118
2 changed files with 43 additions and 19 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Fixed
- Make both `libclang.so` available again when installing the extended LLVM for LLVM versions >= 17 (#432)
### Changed

View File

@ -32,8 +32,10 @@ pub const CLANG_NAME: &str = "xtensa-esp32-elf-clang";
pub struct Llvm {
// /// If `true`, full LLVM, instead of only libraries, are installed.
extended: bool,
/// LLVM Toolchain file name.
pub file_name: String,
/// LLVM libs-only toolchain file name.
pub file_name_libs: String,
/// LLVM "full" toolchain file name.
pub file_name_full: Option<String>,
/// Host triple.
pub host_triple: HostTriple,
/// LLVM Toolchain path.
@ -124,21 +126,31 @@ impl Llvm {
"llvm-"
};
let mut file_name = format!(
let (file_name_libs, file_name_full) = {
let file_name_full = format!(
"{}{}-{}.tar.xz",
name,
version,
Self::get_arch(host_triple, &version)
);
if !extended {
if version != DEFAULT_LLVM_17_VERSION {
file_name = format!("libs_{file_name}");
} else {
file_name = format!("libs-{}", file_name);
}
}
let repository_url = format!("{DEFAULT_LLVM_REPOSITORY}/{version}/{file_name}");
let file_name_libs = if version != DEFAULT_LLVM_17_VERSION {
format!("libs_{file_name_full}")
} else {
format!("libs-{file_name_full}")
};
(
file_name_libs,
if version == DEFAULT_LLVM_15_VERSION || version == DEFAULT_LLVM_16_VERSION {
None
} else {
extended.then_some(file_name_full)
},
)
};
let repository_url = format!("{DEFAULT_LLVM_REPOSITORY}/{version}");
#[cfg(unix)]
let path = toolchain_path.join(CLANG_NAME).join(&version);
#[cfg(windows)]
@ -146,7 +158,8 @@ impl Llvm {
Ok(Self {
extended,
file_name,
file_name_libs,
file_name_full,
host_triple: host_triple.clone(),
path,
repository_url,
@ -248,13 +261,23 @@ impl Installable for Llvm {
} else {
info!("Installing Xtensa LLVM");
download_file(
self.repository_url.clone(),
"idf_tool_xtensa_elf_clang.tar.xz",
format!("{}/{}", self.repository_url, self.file_name_libs),
"idf_tool_xtensa_elf_clang.libs.tar.xz",
self.path.to_str().unwrap(),
true,
false,
)
.await?;
if let Some(file_name_full) = &self.file_name_full {
download_file(
format!("{}/{}", self.repository_url, file_name_full),
"idf_tool_xtensa_elf_clang.full.tar.xz",
self.path.to_str().unwrap(),
true,
false,
)
.await?;
}
}
// Set environment variables.
#[cfg(windows)]