Preliminary LLVM 19/20 support
Description
Adds preliminary LLVM 19/20 support so that https://github.com/jamesmth/llvm-plugin-rs can build plugin with it. No new features have been added so far.
I've also added nextest and replaced some CI with caching, so now the CI pipeline for testing is faster now.
No new LLVM 19 features have been tested, hence "preliminary" in the sense that it is not a very complete port, but it should be at least backward compatible with existing LLVM API
Related Issue
https://github.com/TheDan64/inkwell/issues/530
How This Has Been Tested
Not yet
Option<Breaking Changes>
Checklist
- [x] I have read the Contributing Guide
I used a simple JIT example from README and it works. Looking good already but still need unit tests
@TheDan64 Should the feature base name be renamed as llvm19-1? Looks like LLVM skipped 19.0 entirely and released 19.1 as the first one
Nah, it's fine and consistent as is 🤔
That is such a weird choice...
Yeah, I guess 19-1 makes more sense
@TheDan64 okay, I also tested LLVM 19 integration with https://github.com/jamesmth/llvm-plugin-rs, so the basic examples provided in their repo do compile pretty well, so I will rename the feature from llvm19-0 to llvm19-1 tonight after running the tests and adding LLVM ~~18 and~~ 19 back to Actions pipeline...
Keep in mind the new features in LLVM 19 aren't added yet, and so a follow up contribution for completing that puzzle would be a huge welcome.
Yeah, I guess 19-1 makes more sense
I believe LLVM skipped 18.0 as well, and inkwell uses 18-0 for the major feature number, so it would be more consistent to use 19-0 now as well.
Yeah, I guess 19-1 makes more sense
I believe LLVM skipped 18.0 as well, and inkwell uses 18-0 for the major feature number, so it would be more consistent to use 19-0 now as well.
No the problem is LLVM directly skipped 19.0 and even llvm-sys have to use 191 as the prefix number, so it is the matter of consistency in the library or in the actual LLVM naming scheme
I have been able to integrate https://github.com/stevefan1999-personal/inkwell/commit/0c1e5dd52cf3e012cb238ecfbdb3b1731b987c03 into my project that relies on Inkwell, but https://github.com/stevefan1999-personal/inkwell/commit/87b70498c4ebfdf4f443c178e35af7f9e5f1d8d1 creates a number of compilation errors about undefined feature version llvm19-0.
For the version with the successful integration everything seems to be working swimmingly so far, with no regressions found by the test suite.
I have been able to integrate stevefan1999-personal@0c1e5dd into my project that relies on Inkwell, but stevefan1999-personal@87b7049 creates a number of compilation errors about undefined feature version
llvm19-0.For the version with the successful integration everything seems to be working swimmingly so far, with no regressions found by the test suite.
That is strange, let me revert the actions changes tonight
I was also able to get 0c1e5dd52cf3e012cb238ecfbdb3b1731b987c03 to work (test suite for my project fully passes), but not the current head. Here's the errors I get on the current head, which seem related to the 19-0 / 19-1 issue.
Compiling inkwell v0.5.0 (https://github.com/stevefan1999-personal/inkwell.git#b144c761)
error: undefined feature version: "llvm19-0"
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:130:19
|
130 | #[llvm_versions(..19)]
| ^^
error: undefined feature version: "llvm19-0"
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:135:17
|
135 | #[llvm_versions(19..)]
| ^^
error: undefined feature version: "llvm19-0"
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:1650:25
|
1650 | #[llvm_versions(19..)]
| ^^
error: undefined feature version: "llvm19-0"
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/lib.rs:383:21
|
383 | #[llvm_versions(19..)]
| ^^
error[E0432]: unresolved import `crate::AtomicRMWBinOp`
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/builder.rs:57:29
|
57 | use crate::{AtomicOrdering, AtomicRMWBinOp, FloatPredicate, IntPredicate};
| ^^^^^^^^^^^^^^
| |
| no `AtomicRMWBinOp` in the root
| help: a similar name exists in the module: `LLVMAtomicRMWBinOp`
error[E0432]: unresolved import `crate::debug_info::DWARFSourceLanguage`
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/module.rs:45:59
|
45 | ...nd, DWARFSourceLanguage, DebugInfoBuilder};
| ^^^^^^^^^^^^^^^^^^^ no `DWARFSourceLanguage` in `debug_info`
error[E0412]: cannot find type `DWARFSourceLanguage` in this scope
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:190:19
|
190 | language: DWARFSourceLanguage,
| ^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0412]: cannot find type `DWARFSourceLanguage` in this scope
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:303:19
|
303 | language: DWARFSourceLanguage,
| ^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDeclareBefore` in this scope
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:952:13
|
952 | LLVMDIBuilderInsertDeclareBefore(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDeclareAtEnd` in this scope
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:983:13
|
983 | LLVMDIBuilderInsertDeclareAtEnd(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDbgValueBefore` in this scope
--> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:1029:13
|
1029 | LLVMDIBuilderInsertDbgValueBefore(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0425, E0432.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `inkwell` (lib) due to 11 previous errors
Simply changing the macro occurrences of "19" to "19.1" seems to solve this issue. Here's the patch (unified diff):
diff --git a/src/debug_info.rs b/src/debug_info.rs
index e393fe9..3411e52 100644
--- a/src/debug_info.rs
+++ b/src/debug_info.rs
@@ -127,12 +127,12 @@ use llvm_sys::debuginfo::{
LLVMDITypeGetAlignInBits, LLVMDITypeGetOffsetInBits, LLVMDITypeGetSizeInBits,
};
-#[llvm_versions(..19)]
+#[llvm_versions(..19.1)]
use llvm_sys::debuginfo::{
LLVMDIBuilderInsertDbgValueBefore, LLVMDIBuilderInsertDeclareAtEnd, LLVMDIBuilderInsertDeclareBefore,
};
-#[llvm_versions(19..)]
+#[llvm_versions(19.1..)]
use llvm_sys::debuginfo::{
LLVMDIBuilderInsertDbgValueRecordBefore as LLVMDIBuilderInsertDbgValueBefore,
LLVMDIBuilderInsertDeclareRecordAtEnd as LLVMDIBuilderInsertDeclareAtEnd,
@@ -1647,51 +1647,51 @@ mod flags {
#[llvm_variant(LLVMDWARFSourceLanguageMojo)]
Mojo,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageHIP)]
Hip,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageAssembly)]
Assembly,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageC_sharp)]
Csharp,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageGLSL)]
Glsl,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageGLSL_ES)]
GlslEs,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageHLSL)]
Hlsl,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageOpenCL_CPP)]
OpenClCpp,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageCPP_for_OpenCL)]
CppForOpenCl,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageSYCL)]
Sycl,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageRuby)]
Ruby,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageMove)]
Move,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMDWARFSourceLanguageHylo)]
Hylo,
}
diff --git a/src/lib.rs b/src/lib.rs
index 582c178..cef20cc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -380,11 +380,11 @@ pub enum AtomicRMWBinOp {
#[llvm_variant(LLVMAtomicRMWBinOpFMin)]
FMin,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMAtomicRMWBinOpUIncWrap)]
UIncWrap,
- #[llvm_versions(19..)]
+ #[llvm_versions(19.1..)]
#[llvm_variant(LLVMAtomicRMWBinOpUDecWrap)]
UDecWrap,
}
Hi @stevefan1999-personal, are you able to address the above issues?
Hi @stevefan1999-personal, are you able to address the above issues?
Ah I was busy with company stuff, let me handle that tonight
I was also able to get
0c1e5dd52cf3e012cb238ecfbdb3b1731b987c03to work (test suite for my project fully passes), but not the current head. Here's the errors I get on the current head, which seem related to the19-0/19-1issue.Compiling inkwell v0.5.0 (https://github.com/stevefan1999-personal/inkwell.git#b144c761) error: undefined feature version: "llvm19-0" --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:130:19 | 130 | #[llvm_versions(..19)] | ^^ error: undefined feature version: "llvm19-0" --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:135:17 | 135 | #[llvm_versions(19..)] | ^^ error: undefined feature version: "llvm19-0" --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:1650:25 | 1650 | #[llvm_versions(19..)] | ^^ error: undefined feature version: "llvm19-0" --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/lib.rs:383:21 | 383 | #[llvm_versions(19..)] | ^^ error[E0432]: unresolved import `crate::AtomicRMWBinOp` --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/builder.rs:57:29 | 57 | use crate::{AtomicOrdering, AtomicRMWBinOp, FloatPredicate, IntPredicate}; | ^^^^^^^^^^^^^^ | | | no `AtomicRMWBinOp` in the root | help: a similar name exists in the module: `LLVMAtomicRMWBinOp` error[E0432]: unresolved import `crate::debug_info::DWARFSourceLanguage` --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/module.rs:45:59 | 45 | ...nd, DWARFSourceLanguage, DebugInfoBuilder}; | ^^^^^^^^^^^^^^^^^^^ no `DWARFSourceLanguage` in `debug_info` error[E0412]: cannot find type `DWARFSourceLanguage` in this scope --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:190:19 | 190 | language: DWARFSourceLanguage, | ^^^^^^^^^^^^^^^^^^^ not found in this scope error[E0412]: cannot find type `DWARFSourceLanguage` in this scope --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:303:19 | 303 | language: DWARFSourceLanguage, | ^^^^^^^^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDeclareBefore` in this scope --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:952:13 | 952 | LLVMDIBuilderInsertDeclareBefore( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDeclareAtEnd` in this scope --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:983:13 | 983 | LLVMDIBuilderInsertDeclareAtEnd( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope error[E0425]: cannot find function, tuple struct or tuple variant `LLVMDIBuilderInsertDbgValueBefore` in this scope --> /home/ryan/.cargo/git/checkouts/inkwell-23378709d3c29eb9/b144c76/src/debug_info.rs:1029:13 | 1029 | LLVMDIBuilderInsertDbgValueBefore( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope Some errors have detailed explanations: E0412, E0425, E0432. For more information about an error, try `rustc --explain E0412`. error: could not compile `inkwell` (lib) due to 11 previous errorsSimply changing the macro occurrences of "19" to "19.1" seems to solve this issue. Here's the patch (unified diff):
diff --git a/src/debug_info.rs b/src/debug_info.rs index e393fe9..3411e52 100644 --- a/src/debug_info.rs +++ b/src/debug_info.rs @@ -127,12 +127,12 @@ use llvm_sys::debuginfo::{ LLVMDITypeGetAlignInBits, LLVMDITypeGetOffsetInBits, LLVMDITypeGetSizeInBits, }; -#[llvm_versions(..19)] +#[llvm_versions(..19.1)] use llvm_sys::debuginfo::{ LLVMDIBuilderInsertDbgValueBefore, LLVMDIBuilderInsertDeclareAtEnd, LLVMDIBuilderInsertDeclareBefore, }; -#[llvm_versions(19..)] +#[llvm_versions(19.1..)] use llvm_sys::debuginfo::{ LLVMDIBuilderInsertDbgValueRecordBefore as LLVMDIBuilderInsertDbgValueBefore, LLVMDIBuilderInsertDeclareRecordAtEnd as LLVMDIBuilderInsertDeclareAtEnd, @@ -1647,51 +1647,51 @@ mod flags { #[llvm_variant(LLVMDWARFSourceLanguageMojo)] Mojo, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageHIP)] Hip, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageAssembly)] Assembly, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageC_sharp)] Csharp, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageGLSL)] Glsl, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageGLSL_ES)] GlslEs, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageHLSL)] Hlsl, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageOpenCL_CPP)] OpenClCpp, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageCPP_for_OpenCL)] CppForOpenCl, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageSYCL)] Sycl, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageRuby)] Ruby, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageMove)] Move, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMDWARFSourceLanguageHylo)] Hylo, } diff --git a/src/lib.rs b/src/lib.rs index 582c178..cef20cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -380,11 +380,11 @@ pub enum AtomicRMWBinOp { #[llvm_variant(LLVMAtomicRMWBinOpFMin)] FMin, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMAtomicRMWBinOpUIncWrap)] UIncWrap, - #[llvm_versions(19..)] + #[llvm_versions(19.1..)] #[llvm_variant(LLVMAtomicRMWBinOpUDecWrap)] UDecWrap, }
I guess the biggest problem is that we don't know why LLVM skipped the whole 19.0 release and go straight to 19.1, which the 19.. range should technically be covered. I think as a workaround, let me merge it to be using 19.1 then, but keep in mind this is pretty abnormal in a common sense
https://github.com/stevefan1999-personal/inkwell/actions/runs/13450580072/job/37584222806
Looks like 19.1 amd64 is missing from KyleMayes and one of the PR that attempts to fix it is still missing it as well...Can't really test 19.1 at the moment with CI for now
See https://github.com/KyleMayes/install-llvm-action/pull/84
@stevefan1999-personal do you suggest waiting to merge until 19.1 is added?
@stevefan1999-personal do you suggest waiting to merge until 19.1 is added?
Yeah the issue is that the upstream LLVM repo doesn't seem to release the LLVM+Clang 19.1 suite in GH release, but the actions intended to fetch the suite in GH release, and clearly this is an impasse that either we wait for it to release or we switch the suite source. Doing the latter takes some effort and I'm preoccupied rn so maybe we could wait for a while and see if things get any better
Hi guys, sorry for the intrusion! I was wondering at what stage is the support for LLVM-19.1? Is milestone 0.6.0 close or will it take some more time?
0.6.0 is basically just blocked on this. See above comments
I saw that Inkweek is currently using the GH KyleMayes/install-llvm-action, which is based on the LLVM GH releases.
As mentioned by @stevefan1999-personal, the problem is that the LLVM repo does not release the LLVM+Clang 19.1.x suite in the GH release.
Thanks for the feedback, if I notice any additions I will ping you!
It looks like the other repo has added newer LLVM versions, including 19: https://github.com/KyleMayes/install-llvm-action/pull/89
@RyanMarcus @TheDan64 I decided to get rid of running that action for LLVM 19/20 and opted to use the official LLVM APT source.
Also FYI: I noticed that the APT source supports up to LLVM 14 but I was thinking, "if existing stuff works until LLVM 19, so why bother"?
@TheDan64 all tests passed on my actions, so if it is LGTY let's merge it ASAP so I can work on the llvm-plugin-rs
I wont be able to review this until next week
@stevefan1999-personal are you able to resolve the remaining issues and comments so we can merge this PR?
@TheDan64 let me take a look this weekend
Related: https://github.com/llvm/llvm-project/blob/3e2fadf3beff93433f125eb1ea1abe470db5aa12/llvm/docs/RemoveDIsDebugInfo.md
@TheDan64 do you think it is good to go
@stevefan1999-personal there are some clippy failures... if you do cargo clippy --fix you should be able to fix them and get the full suite to run
@TheDan64 would you be willing to make a new release with this PR included?