Update code base to use LLVM 21

This commit is contained in:
kvp
2025-10-27 08:28:12 -07:00
parent 91bd1b0b4e
commit c952471647
24 changed files with 224 additions and 172 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
//! The compiler build utilities library.
/// The revive LLVM host dependency directory prefix environment variable.
pub const REVIVE_LLVM_HOST_PREFIX: &str = "LLVM_SYS_181_PREFIX";
pub const REVIVE_LLVM_HOST_PREFIX: &str = "LLVM_SYS_211_PREFIX";
/// The revive LLVM target dependency directory prefix environment variable.
pub const REVIVE_LLVM_TARGET_PREFIX: &str = "REVIVE_LLVM_TARGET_PREFIX";
+1 -1
View File
@@ -7,4 +7,4 @@
"FibonacciIterative": 1454,
"Flipper": 2083,
"SHA1": 7727
}
}
+28
View File
@@ -14,6 +14,7 @@ fn set_rustc_link_flags() {
"lldELF",
"lldCommon",
"lldMachO",
"lldWasm",
"LLVMSupport",
"LLVMLinker",
"LLVMCore",
@@ -68,6 +69,33 @@ fn set_rustc_link_flags() {
"LLVMBitReader",
"LLVMRemarks",
"LLVMBitstreamReader",
"LLVMTextAPI",
"LLVMDebugInfoDWARFLowLevel",
"LLVMDebugInfoGSYM",
"LLVMDebugInfoMSF",
"LLVMDebugInfoPDB",
"LLVMDebugInfoBTF",
"LLVMInterfaceStub",
"LLVMCGData",
"LLVMMIRParser",
"LLVMDWARFLinker",
"LLVMDWARFLinkerParallel",
"LLVMDWARFLinkerClassic",
"LLVMLibDriver",
"LLVMDlltoolDriver",
"LLVMTextAPIBinaryReader",
"LLVMCoverage",
"LLVMLineEditor",
"LLVMRISCVTargetMCA",
"LLVMRuntimeDyld",
"LLVMDWP",
"LLVMDWARFCFIChecker",
"LLVMDebugInfoLogicalView",
"LLVMMCA",
"LLVMipo",
"LLVMVectorize",
"LLVMSandboxIR",
"LLVMExtensions",
] {
println!("cargo:rustc-link-lib=static={lib}");
}
+2 -2
View File
@@ -82,10 +82,10 @@ Obtain a compatible build for your host platform from the release section of thi
Build artifacts end up in the `./target-llvm/gnu/target-final/` directory by default.
The `gnu` directory depends on the supported archticture and will either be `gnu`, `musl` or `emscripten`.
You now need to export the final target directory `$LLVM_SYS_181_PREFIX`:
You now need to export the final target directory `$LLVM_SYS_211_PREFIX`:
```shell
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
export LLVM_SYS_211_PREFIX=${PWD}/target-llvm/gnu/target-final
```
If built with the `--enable-tests` option, test tools will be in the `./target-llvm/gnu/build-final/` directory, along with copies of the build artifacts. For all supported build options, run `revive-llvm build --help`.
@@ -221,7 +221,6 @@ fn build_host(
"-DCOMPILER_RT_BUILD_MEMPROF='Off'",
"-DCOMPILER_RT_BUILD_ORC='Off'",
"-DCOMPILER_RT_DEFAULT_TARGET_ARCH='aarch64'",
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY='On'",
])
.args(crate::platforms::shared::SHARED_BUILD_OPTS)
.args(crate::platforms::shared::shared_build_opts_ccache(
@@ -219,7 +219,6 @@ fn build_host(
"-DCOMPILER_RT_BUILD_MEMPROF='Off'",
"-DCOMPILER_RT_BUILD_ORC='Off'",
"-DCOMPILER_RT_DEFAULT_TARGET_ARCH='x86_64'",
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY='On'",
"-DLIBCLANG_BUILD_STATIC='On'",
"-DBUILD_SHARED_LIBS='Off'",
])
+1 -1
View File
@@ -38,7 +38,7 @@ pub const MUSL_SNAPSHOTS_URL: &str = "https://git.musl-libc.org/cgit/musl/snapsh
pub const EMSDK_SOURCE_URL: &str = "https://github.com/emscripten-core/emsdk.git";
/// The emscripten SDK version.
pub const EMSDK_VERSION: &str = "4.0.9";
pub const EMSDK_VERSION: &str = "4.0.20";
/// The subprocess runner.
///
@@ -8,7 +8,7 @@ use serde::Serialize;
/// inside of the LLVM build directory. This order is actually generated during the building.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Attribute {
Unused = 0,
// FirstEnumAttr = 1,
AllocAlign = 1,
AllocatedPointer = 2,
AlwaysInline = 3,
@@ -16,92 +16,107 @@ pub enum Attribute {
Cold = 5,
Convergent = 6,
CoroDestroyOnlyWhenComplete = 7,
DeadOnUnwind = 8,
DisableSanitizerInstrumentation = 9,
FnRetThunkExtern = 10,
Hot = 11,
ImmArg = 12,
InReg = 13,
InlineHint = 14,
JumpTable = 15,
MinSize = 16,
MustProgress = 17,
Naked = 18,
Nest = 19,
NoAlias = 20,
NoBuiltin = 21,
NoCallback = 22,
NoCapture = 23,
NoCfCheck = 24,
NoDuplicate = 25,
NoFree = 26,
NoImplicitFloat = 27,
NoInline = 28,
NoMerge = 29,
NoProfile = 30,
NoRecurse = 31,
NoRedZone = 32,
NoReturn = 33,
NoSanitizeBounds = 34,
NoSanitizeCoverage = 35,
NoSync = 36,
NoUndef = 37,
NoUnwind = 38,
NonLazyBind = 39,
NonNull = 40,
NullPointerIsValid = 41,
OptForFuzzing = 42,
OptimizeForDebugging = 43,
OptimizeForSize = 44,
OptimizeNone = 45,
PresplitCoroutine = 46,
ReadNone = 47,
ReadOnly = 48,
Returned = 49,
ReturnsTwice = 50,
SExt = 51,
SafeStack = 52,
SanitizeAddress = 53,
SanitizeHWAddress = 54,
SanitizeMemTag = 55,
SanitizeMemory = 56,
SanitizeThread = 57,
ShadowCallStack = 58,
SkipProfile = 59,
Speculatable = 60,
SpeculativeLoadHardening = 61,
StackProtect = 62,
StackProtectReq = 63,
StackProtectStrong = 64,
StrictFP = 65,
SwiftAsync = 66,
SwiftError = 67,
SwiftSelf = 68,
WillReturn = 69,
Writable = 70,
WriteOnly = 71,
ZExt = 72,
// LastEnumAttr = 72,
// FirstTypeAttr = 73,
ByRef = 73,
ByVal = 74,
ElementType = 75,
InAlloca = 76,
Preallocated = 77,
StructRet = 78,
// LastTypeAttr = 78,
// FirstIntAttr = 79,
Alignment = 79,
AllocKind = 80,
AllocSize = 81,
Dereferenceable = 82,
DereferenceableOrNull = 83,
Memory = 84,
NoFPClass = 85,
StackAlignment = 86,
UWTable = 87,
VScaleRange = 88,
// LastIntAttr = 88,
CoroElideSafe = 8,
DeadOnReturn = 9,
DeadOnUnwind = 10,
DisableSanitizerInstrumentation = 11,
FnRetThunkExtern = 12,
Hot = 13,
HybridPatchable = 14,
ImmArg = 15,
InReg = 16,
InlineHint = 17,
JumpTable = 18,
MinSize = 19,
MustProgress = 20,
Naked = 21,
Nest = 22,
NoAlias = 23,
NoBuiltin = 24,
NoCallback = 25,
NoCfCheck = 26,
NoDivergenceSource = 27,
NoDuplicate = 28,
NoExt = 29,
NoFree = 30,
NoImplicitFloat = 31,
NoInline = 32,
NoMerge = 33,
NoProfile = 34,
NoRecurse = 35,
NoRedZone = 36,
NoReturn = 37,
NoSanitizeBounds = 38,
NoSanitizeCoverage = 39,
NoSync = 40,
NoUndef = 41,
NoUnwind = 42,
NonLazyBind = 43,
NonNull = 44,
NullPointerIsValid = 45,
OptForFuzzing = 46,
OptimizeForDebugging = 47,
OptimizeForSize = 48,
OptimizeNone = 49,
PresplitCoroutine = 50,
ReadNone = 51,
ReadOnly = 52,
Returned = 53,
ReturnsTwice = 54,
SExt = 55,
SafeStack = 56,
SanitizeAddress = 57,
SanitizeHWAddress = 58,
SanitizeMemTag = 59,
SanitizeMemory = 60,
SanitizeNumericalStability = 61,
SanitizeRealtime = 62,
SanitizeRealtimeBlocking = 63,
SanitizeThread = 64,
SanitizeType = 65,
ShadowCallStack = 66,
SkipProfile = 67,
Speculatable = 68,
SpeculativeLoadHardening = 69,
StackProtect = 70,
StackProtectReq = 71,
StackProtectStrong = 72,
StrictFP = 73,
SwiftAsync = 74,
SwiftError = 75,
SwiftSelf = 76,
WillReturn = 77,
Writable = 78,
WriteOnly = 79,
ZExt = 80,
//LastEnumAttr = 80,
//FirstTypeAttr = 81,
ByRef = 81,
ByVal = 82,
ElementType = 83,
InAlloca = 84,
Preallocated = 85,
StructRet = 86,
//LastTypeAttr = 86,
//FirstIntAttr = 87,
Alignment = 87,
AllocKind = 88,
AllocSize = 89,
Captures = 90,
Dereferenceable = 91,
DereferenceableOrNull = 92,
Memory = 93,
NoFPClass = 94,
StackAlignment = 95,
UWTable = 96,
VScaleRange = 97,
//LastIntAttr = 97,
//FirstConstantRangeAttr = 98,
Range = 98,
//LastConstantRangeAttr = 98,
//FirstConstantRangeListAttr = 99,
Initializes = 99,
//LastConstantRangeListAttr = 99,
}
impl TryFrom<&str> for Attribute {
+5 -12
View File
@@ -838,8 +838,7 @@ impl<'ctx> Context<'ctx> {
.builder()
.build_call(intrinsic, &[value.into()], "call_byte_swap")?
.try_as_basic_value()
.left()
.unwrap())
.unwrap_basic())
}
/// Builds a GEP instruction.
@@ -912,7 +911,7 @@ impl<'ctx> Context<'ctx> {
)
.unwrap()
.try_as_basic_value()
.left()
.basic()
}
/// Builds a call to the runtime API `import`, where `import` is a "getter" API.
@@ -950,7 +949,7 @@ impl<'ctx> Context<'ctx> {
)
.unwrap();
self.modify_call_site_value(arguments, call_site_value, function);
call_site_value.try_as_basic_value().left()
call_site_value.try_as_basic_value().basic()
}
/// Sets the alignment to `1`, since all non-stack memory pages have such alignment.
@@ -1082,13 +1081,7 @@ impl<'ctx> Context<'ctx> {
Ok(call_site_value
.try_as_basic_value()
.left()
.unwrap_or_else(|| {
panic!(
"revive runtime function {} should return a value",
<PolkaVMSbrkFunction as RuntimeFunction>::NAME,
)
})
.unwrap_basic()
.into_pointer_value())
}
@@ -1277,7 +1270,7 @@ impl<'ctx> Context<'ctx> {
call_site_value.add_attribute(
inkwell::attributes::AttributeLoc::Param(index as u32),
self.llvm
.create_enum_attribute(Attribute::NoCapture as u32, 0),
.create_enum_attribute(Attribute::Captures as u32, 0), // captures(none)
);
call_site_value.add_attribute(
inkwell::attributes::AttributeLoc::Param(index as u32),
@@ -275,6 +275,6 @@ pub fn count_leading_zeros<'ctx>(
"clz",
)?
.try_as_basic_value()
.left()
.basic()
.expect("the llvm.ctlz should return a value"))
}
+1 -1
View File
@@ -42,7 +42,7 @@ mimalloc = { version = "0.1.46", default-features = false }
[target.'cfg(target_os = "emscripten")'.dependencies]
libc = { workspace = true }
inkwell = { workspace = true, features = ["target-riscv", "llvm18-1-no-llvm-linking"]}
inkwell = { workspace = true, features = ["target-riscv", "llvm21-1-no-llvm-linking"]}
[build-dependencies]
git2 = { workspace = true, default-features = false }
+1 -1
View File
@@ -9,7 +9,7 @@ description = "Implements the low level runtime API bindings with pallet contrac
[dependencies]
anyhow = { workspace = true }
inkwell = { workspace = true, features = ["target-riscv", "no-libffi-linking", "llvm18-1"] }
inkwell = { workspace = true, features = ["target-riscv", "no-libffi-linking", "llvm21-1"] }
revive-common = { workspace = true }
+1 -1
View File
@@ -7,7 +7,7 @@ repository.workspace = true
description = "revive compiler stdlib components"
[dependencies]
inkwell = { workspace = true, features = ["target-riscv", "no-libffi-linking", "llvm18-1"] }
inkwell = { workspace = true, features = ["target-riscv", "no-libffi-linking", "llvm21-1"] }
[build-dependencies]
revive-build-utils = { workspace = true }