Skip to content

Commit

Permalink
Add llvm 19 support (#477)
Browse files Browse the repository at this point in the history
* feat: Add llvm 19 support

* docs: Update changelog
  • Loading branch information
SergioGasquez authored Feb 20, 2025
1 parent 236ad27 commit 0a8ac1b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Add support for LLVM esp-19.1.2_20250211 (#477)

### Fixed
- Return an error if GET request fails (#471)
Expand Down
39 changes: 30 additions & 9 deletions src/toolchain/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const OLD_LLVM_16_VERSION: &str = "esp-16.0.0-20230516";
const DEFAULT_LLVM_16_VERSION: &str = "esp-16.0.4-20231113";
const DEFAULT_LLVM_17_VERSION: &str = "esp-17.0.1_20240419";
const DEFAULT_LLVM_18_VERSION: &str = "esp-18.1.2_20240912";
const DEFAULT_LLVM_19_VERSION: &str = "esp-19.1.2_20250211";
pub const CLANG_NAME: &str = "xtensa-esp32-elf-clang";

#[derive(Debug, Clone, Default)]
Expand All @@ -50,7 +51,10 @@ pub struct Llvm {
impl Llvm {
/// Gets the name of the LLVM arch based on the host triple.
fn get_arch(host_triple: &HostTriple, version: &str) -> String {
if version == DEFAULT_LLVM_17_VERSION || version == DEFAULT_LLVM_18_VERSION {
if version == DEFAULT_LLVM_17_VERSION
|| version == DEFAULT_LLVM_18_VERSION
|| version == DEFAULT_LLVM_19_VERSION
{
let arch = match host_triple {
HostTriple::Aarch64AppleDarwin => "aarch64-apple-darwin",
HostTriple::X86_64AppleDarwin => "x86_64-apple-darwin",
Expand Down Expand Up @@ -121,11 +125,18 @@ impl Llvm {
|| (major == 1 && minor < 81)
{
DEFAULT_LLVM_17_VERSION.to_string()
} else {
} else if (major == 1 && minor == 84 && patch == 0 && subpatch == 0)
|| (major == 1 && minor < 84)
{
DEFAULT_LLVM_18_VERSION.to_string()
} else {
DEFAULT_LLVM_19_VERSION.to_string()
};

let name = if version == DEFAULT_LLVM_17_VERSION || version == DEFAULT_LLVM_18_VERSION {
let name = if version == DEFAULT_LLVM_17_VERSION
|| version == DEFAULT_LLVM_18_VERSION
|| version == DEFAULT_LLVM_19_VERSION
{
"clang-"
} else {
"llvm-"
Expand All @@ -139,12 +150,14 @@ impl Llvm {
Self::get_arch(host_triple, &version)
);

let file_name_libs =
if version != DEFAULT_LLVM_17_VERSION && version != DEFAULT_LLVM_18_VERSION {
format!("libs_{file_name_full}")
} else {
format!("libs-{file_name_full}")
};
let file_name_libs = if version != DEFAULT_LLVM_17_VERSION
&& version != DEFAULT_LLVM_18_VERSION
&& version != DEFAULT_LLVM_19_VERSION
{
format!("libs_{file_name_full}")
} else {
format!("libs-{file_name_full}")
};

// 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.
Expand Down Expand Up @@ -229,6 +242,14 @@ impl Llvm {
),
"",
);
updated_path = updated_path.replace(
&format!(
"{}\\{}\\esp-clang\\bin;",
llvm_path.display().to_string().replace('/', "\\"),
DEFAULT_LLVM_19_VERSION,
),
"",
);
updated_path = updated_path.replace(
&format!(
"{}\\esp-clang\\bin;",
Expand Down

0 comments on commit 0a8ac1b

Please sign in to comment.