Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extended LLVM mode for LLVM < 17 #437

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/),
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

### Fixed
Expand Down
43 changes: 27 additions & 16 deletions src/toolchain/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Llvm {
// /// If `true`, full LLVM, instead of only libraries, are installed.
extended: bool,
/// LLVM libs-only toolchain file name.
pub file_name_libs: String,
pub file_name_libs: Option<String>,
/// LLVM "full" toolchain file name.
pub file_name_full: Option<String>,
/// Host triple.
Expand Down Expand Up @@ -140,14 +140,23 @@ impl Llvm {
format!("libs-{file_name_full}")
};

(
file_name_libs,
if version == DEFAULT_LLVM_15_VERSION || version == DEFAULT_LLVM_16_VERSION {
None
// For LLVM 15 and 16 the "full" tarball was a superset of the "libs" tarball, so if
// we're in extended LLVM mode we only need the "full" tarballs for those versions.
//
// 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 {
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}");
Expand Down Expand Up @@ -260,14 +269,16 @@ impl Installable for Llvm {
);
} else {
info!("Installing Xtensa LLVM");
download_file(
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_libs) = &self.file_name_libs {
download_file(
format!("{}/{}", self.repository_url, 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),
Expand Down