diff --git a/Cargo.toml b/Cargo.toml index dde0ec9bf15fada573624049fda78435bd7eb034..3a6f59e002c9c67885f51af30041c6cc7fb46a24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,10 @@ keywords = ["bindings", "llvm"] categories = ["external-ffi-bindings"] links = "llvm-19" name = "llvm-sys" -version = "191.0.0-rc1" +version = "191.0.0" authors = ["Peter Marheine "] build = "build.rs" +edition = "2021" [badges] gitlab = { repository = "taricorp/llvm-sys.rs" } @@ -43,15 +44,15 @@ force-static = [] [dependencies] libc = "0.2" -clang-sys = { version = "1.2.2", optional = true } -tempfile = { version = "3.2.0", optional = true } +clang-sys = { version = "1.8.1", optional = true } +tempfile = { version = "3.12.0", optional = true } [build-dependencies] anyhow = "1.0" cc = "1.0" lazy_static = "1.0" -regex-lite = "0.1.5" -semver = "1.0.7" +regex-lite = "0.1.6" +semver = "1.0.23" [lints.rust] # LLVM_SYS_NOT_FOUND is set by build.rs if no LLVM library is located, which diff --git a/build.rs b/build.rs index bee7a27c8a8e0b1d4fae1ae35a0e9b1dc7d5253d..8cfb7c5b0a65abc36f94e68821cf3116aaf2f533 100644 --- a/build.rs +++ b/build.rs @@ -83,7 +83,7 @@ fn target_os_is(name: &str) -> bool { fn locate_llvm_config() -> Option { let prefix = env::var_os(&*ENV_LLVM_PREFIX) .map(|p| PathBuf::from(p).join("bin")) - .unwrap_or_else(PathBuf::new); + .unwrap_or_default(); if let Some(x) = llvm_compatible_binary_name(&prefix) { return Some(x); @@ -166,7 +166,7 @@ fn llvm_config_binary_names() -> impl Iterator { /// Check whether the given version of LLVM is blocklisted, /// returning `Some(reason)` if it is. fn is_blocklisted_llvm(llvm_version: &Version) -> Option<&'static str> { - static BLOCKLIST: &'static [(u64, u64, u64, &'static str)] = &[]; + static BLOCKLIST: &[(u64, u64, u64, &str)] = &[]; if let Some(x) = env::var_os(&*ENV_IGNORE_BLOCKLIST) { if &x == "YES" { @@ -185,9 +185,9 @@ fn is_blocklisted_llvm(llvm_version: &Version) -> Option<&'static str> { for &(major, minor, patch, reason) in BLOCKLIST.iter() { let bad_version = Version { - major: major, - minor: minor, - patch: patch, + major, + minor, + patch, pre: semver::Prerelease::EMPTY, build: semver::BuildMetadata::EMPTY, }; @@ -725,13 +725,13 @@ fn main() { let use_debug_msvcrt = env::var_os(&*ENV_USE_DEBUG_MSVCRT).is_some(); if target_env_is("msvc") && (use_debug_msvcrt || is_llvm_debug(&llvm_config_path)) { - println!("cargo:rustc-link-lib={}", "msvcrtd"); + println!("cargo:rustc-link-lib=msvcrtd"); } // Link libffi if the user requested this workaround. // See https://bitbucket.org/tari/llvm-sys.rs/issues/12/ let force_ffi = env::var_os(&*ENV_FORCE_FFI).is_some(); if force_ffi { - println!("cargo:rustc-link-lib=dylib={}", "ffi"); + println!("cargo:rustc-link-lib=dylib=ffi"); } } diff --git a/examples/disassembler.rs b/examples/disassembler.rs index 923b19511659db07c17b1661537f4556ccc56cda..5b42f9be1e4693763570be4749ce91c3b7d7f029 100644 --- a/examples/disassembler.rs +++ b/examples/disassembler.rs @@ -63,7 +63,7 @@ fn disassemble_bytes( x.as_mut_ptr(), x.len() as u64, pc, - sbuf.as_mut_ptr() as *mut i8, + sbuf.as_mut_ptr(), sbuf.len(), ) }; @@ -72,7 +72,7 @@ fn disassemble_bytes( } let instr_str = unsafe { CStr::from_ptr(sbuf.as_ptr()) }; - write!(out, "{}\n", instr_str.to_string_lossy())?; + writeln!(out, "{}", instr_str.to_string_lossy())?; pc += sz as u64; x = &mut x[sz..]; diff --git a/src/bit_reader.rs b/src/bit_reader.rs index dc59059c9fe0753c46b3f90d4fb4f1e45d8104f2..3477c91e97862302a1a2166d34f19427711a8343 100644 --- a/src/bit_reader.rs +++ b/src/bit_reader.rs @@ -7,7 +7,7 @@ extern "C" { /// /// Returns 0 on success and the generated module in `OutModule`. /// Optionally returns a human-readable error message in `OutMessage`. - #[deprecated(since = "3.8", note = "Use LLVMParseBitcode2")] + #[deprecated(since = "38.0.0", note = "Use LLVMParseBitcode2")] pub fn LLVMParseBitcode( MemBuf: LLVMMemoryBufferRef, OutModule: *mut LLVMModuleRef, @@ -21,7 +21,7 @@ extern "C" { OutModule: *mut LLVMModuleRef, ) -> LLVMBool; - #[deprecated(since = "3.8", note = "Use LLVMParseBitcodeInContext2")] + #[deprecated(since = "38.0.0", note = "Use LLVMParseBitcodeInContext2")] pub fn LLVMParseBitcodeInContext( ContextRef: LLVMContextRef, MemBuf: LLVMMemoryBufferRef, @@ -38,7 +38,7 @@ extern "C" { /// performing lazy deserialization. /// /// Returns 0 on success and an optional error message. - #[deprecated(since = "3.8", note = "Use LLVMGetBitcodeModuleInContext2")] + #[deprecated(since = "38.0.0", note = "Use LLVMGetBitcodeModuleInContext2")] pub fn LLVMGetBitcodeModuleInContext( ContextRef: LLVMContextRef, MemBuf: LLVMMemoryBufferRef, @@ -55,7 +55,7 @@ extern "C" { OutM: *mut LLVMModuleRef, ) -> LLVMBool; - #[deprecated(since = "3.8", note = "Use LLVMGetBitcodeModule2")] + #[deprecated(since = "38.0.0", note = "Use LLVMGetBitcodeModule2")] pub fn LLVMGetBitcodeModule( MemBuf: LLVMMemoryBufferRef, OutM: *mut LLVMModuleRef, diff --git a/src/core.rs b/src/core.rs index 86575faf30699eb56c1878068588fc9e0e8543e2..ddd626f16c01320d43a63884f507f2d1d1606cf4 100644 --- a/src/core.rs +++ b/src/core.rs @@ -171,7 +171,10 @@ extern "C" { Len: ::libc::size_t, ); - #[deprecated(since = "3.9", note = "Confusingly named. Use LLVMGetDataLayoutStr.")] + #[deprecated( + since = "39.0.0", + note = "Confusingly named. Use LLVMGetDataLayoutStr." + )] pub fn LLVMGetDataLayout(M: LLVMModuleRef) -> *const ::libc::c_char; /// Obtain the data layout for a module. pub fn LLVMGetDataLayoutStr(M: LLVMModuleRef) -> *const ::libc::c_char; @@ -229,7 +232,7 @@ extern "C" { M: LLVMModuleRef, Len: *mut ::libc::size_t, ) -> *const ::libc::c_char; - #[deprecated(since = "7.0", note = "Use LLVMSetModuleInlineAsm2 instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMSetModuleInlineAsm2 instead")] pub fn LLVMSetModuleInlineAsm(M: LLVMModuleRef, Asm: *const ::libc::c_char); pub fn LLVMSetModuleInlineAsm2( M: LLVMModuleRef, @@ -430,7 +433,7 @@ extern "C" { /// Return the number of types in the derived type. pub fn LLVMGetNumContainedTypes(Tp: LLVMTypeRef) -> ::libc::c_uint; #[deprecated( - since = "17.0", + since = "170.0.0", note = "LLVMArrayType is deprecated in favor of the API accurate LLVMArrayType2" )] pub fn LLVMArrayType(ElementType: LLVMTypeRef, ElementCount: ::libc::c_uint) -> LLVMTypeRef; @@ -440,7 +443,7 @@ extern "C" { /// exists in. pub fn LLVMArrayType2(ElementType: LLVMTypeRef, ElementCount: u64) -> LLVMTypeRef; #[deprecated( - since = "17.0", + since = "170.0.0", note = "LLVMGetArrayLength is deprecated in favor of the API accurate LLVMGetArrayLength2" )] pub fn LLVMGetArrayLength(ArrayTy: LLVMTypeRef) -> ::libc::c_uint; @@ -532,13 +535,13 @@ extern "C" { pub fn LLVMGetValueKind(Val: LLVMValueRef) -> LLVMValueKind; pub fn LLVMTypeOf(Val: LLVMValueRef) -> LLVMTypeRef; - #[deprecated(since = "7.0", note = "Use LLVMGetValueName2 instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMGetValueName2 instead")] pub fn LLVMGetValueName(Val: LLVMValueRef) -> *const ::libc::c_char; pub fn LLVMGetValueName2( Val: LLVMValueRef, Length: *mut ::libc::size_t, ) -> *const ::libc::c_char; - #[deprecated(since = "7.0", note = "Use LLVMSetValueName2 instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMSetValueName2 instead")] pub fn LLVMSetValueName(Val: LLVMValueRef, Name: *const ::libc::c_char); pub fn LLVMSetValueName2( Val: LLVMValueRef, @@ -620,7 +623,7 @@ extern "C" { ) -> ::libc::c_double; // Core->Values->Constants->Composite - #[deprecated(since = "19.1", note = "Use LLVMConstStringInContext2 instead.")] + #[deprecated(since = "191.0.0", note = "Use LLVMConstStringInContext2 instead.")] pub fn LLVMConstStringInContext( C: LLVMContextRef, Str: *const ::libc::c_char, @@ -652,7 +655,7 @@ extern "C" { Packed: LLVMBool, ) -> LLVMValueRef; #[deprecated( - since = "17.0", + since = "170.0.0", note = "LLVMConstArray is deprecated in favor of the API accurate LLVMConstArray2" )] pub fn LLVMConstArray( @@ -672,7 +675,7 @@ extern "C" { Count: ::libc::c_uint, ) -> LLVMValueRef; pub fn LLVMGetAggregateElement(C: LLVMValueRef, idx: ::libc::c_uint) -> LLVMValueRef; - #[deprecated(since = "15.0", note = "Use LLVMGetAggregateElement instead")] + #[deprecated(since = "150.0.0", note = "Use LLVMGetAggregateElement instead")] pub fn LLVMGetElementAsConstant(C: LLVMValueRef, idx: ::libc::c_uint) -> LLVMValueRef; pub fn LLVMConstVector( ScalarConstantVals: *mut LLVMValueRef, @@ -692,7 +695,7 @@ extern "C" { pub fn LLVMSizeOf(Ty: LLVMTypeRef) -> LLVMValueRef; pub fn LLVMConstNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef; pub fn LLVMConstNSWNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef; - #[deprecated(since = "19.1", note = "Use LLVMConstNull instead.")] + #[deprecated(since = "191.0.0", note = "Use LLVMConstNull instead.")] pub fn LLVMConstNUWNeg(ConstantVal: LLVMValueRef) -> LLVMValueRef; pub fn LLVMConstNot(ConstantVal: LLVMValueRef) -> LLVMValueRef; pub fn LLVMConstAdd(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef) -> LLVMValueRef; @@ -748,7 +751,7 @@ extern "C" { VectorBConstant: LLVMValueRef, MaskConstant: LLVMValueRef, ) -> LLVMValueRef; - #[deprecated(since = "7.0", note = "Use LLVMGetInlineAsm instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMGetInlineAsm instead")] pub fn LLVMConstInlineAsm( Ty: LLVMTypeRef, AsmString: *const ::libc::c_char, @@ -777,9 +780,9 @@ extern "C" { pub fn LLVMGetUnnamedAddress(Global: LLVMValueRef) -> LLVMUnnamedAddr; pub fn LLVMSetUnnamedAddress(Global: LLVMValueRef, UnnamedAddr: LLVMUnnamedAddr); pub fn LLVMGlobalGetValueType(Global: LLVMValueRef) -> LLVMTypeRef; - #[deprecated(since = "7.0", note = "Use LLVMGetUnnamedAddress instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMGetUnnamedAddress instead")] pub fn LLVMHasUnnamedAddr(Global: LLVMValueRef) -> LLVMBool; - #[deprecated(since = "7.0", note = "Use LLVMSetUnnamedAddress instead")] + #[deprecated(since = "70.0.0", note = "Use LLVMSetUnnamedAddress instead")] pub fn LLVMSetUnnamedAddr(Global: LLVMValueRef, HasUnnamedAddr: LLVMBool); pub fn LLVMGetAlignment(V: LLVMValueRef) -> ::libc::c_uint; @@ -992,21 +995,21 @@ extern "C" { // Core->Metadata extern "C" { - #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDStringInContext2 instead.")] + #[deprecated(since = "90.0.0", note = "Use LLVMMDStringInContext2 instead.")] pub fn LLVMMDStringInContext( C: LLVMContextRef, Str: *const ::libc::c_char, SLen: ::libc::c_uint, ) -> LLVMValueRef; - #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDStringInContext2 instead.")] + #[deprecated(since = "90.0.0", note = "Use LLVMMDStringInContext2 instead.")] pub fn LLVMMDString(Str: *const ::libc::c_char, SLen: ::libc::c_uint) -> LLVMValueRef; - #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDNodeInContext2 instead.")] + #[deprecated(since = "90.0.0", note = "Use LLVMMDNodeInContext2 instead.")] pub fn LLVMMDNodeInContext( C: LLVMContextRef, Vals: *mut LLVMValueRef, Count: ::libc::c_uint, ) -> LLVMValueRef; - #[deprecated(since = "LLVM 9.0", note = "Use LLVMMDNodeInContext2 instead.")] + #[deprecated(since = "90.0.0", note = "Use LLVMMDNodeInContext2 instead.")] pub fn LLVMMDNode(Vals: *mut LLVMValueRef, Count: ::libc::c_uint) -> LLVMValueRef; /// Create a new operand bundle. @@ -1466,7 +1469,7 @@ extern "C" { /// current debug location for the given builder. If the builder has no current /// debug location, this function is a no-op. #[deprecated( - since = "14.0", + since = "140.0.0", note = "Deprecated in favor of the more general LLVMAddMetadataToInst." )] pub fn LLVMSetInstDebugLocation(Builder: LLVMBuilderRef, Inst: LLVMValueRef); @@ -1476,7 +1479,7 @@ extern "C" { pub fn LLVMBuilderGetDefaultFPMathTag(Builder: LLVMBuilderRef) -> LLVMMetadataRef; /// Set the default floating-point math metadata for the given builder. pub fn LLVMBuilderSetDefaultFPMathTag(Builder: LLVMBuilderRef, FPMathTag: LLVMMetadataRef); - #[deprecated(since = "LLVM 9.0", note = "Use LLVMGetCurrentDebugLocation2 instead.")] + #[deprecated(since = "90.0.0", note = "Use LLVMGetCurrentDebugLocation2 instead.")] pub fn LLVMSetCurrentDebugLocation(Builder: LLVMBuilderRef, L: LLVMValueRef); pub fn LLVMGetCurrentDebugLocation(Builder: LLVMBuilderRef) -> LLVMValueRef; @@ -1805,7 +1808,7 @@ extern "C" { V: LLVMValueRef, Name: *const ::libc::c_char, ) -> LLVMValueRef; - #[deprecated(since = "19.1", note = "Use LLVMBuildNeg + LLVMSetNUW instead.")] + #[deprecated(since = "191.0.0", note = "Use LLVMBuildNeg + LLVMSetNUW instead.")] pub fn LLVMBuildNUWNeg( B: LLVMBuilderRef, V: LLVMValueRef, diff --git a/src/object.rs b/src/object.rs index d8c7c786a7e8605c8a2b3f1baffa2d693bd3caee..a06f910126556dab194f30aa01b1e55e16b6bb1d 100644 --- a/src/object.rs +++ b/src/object.rs @@ -59,11 +59,11 @@ pub enum LLVMBinaryType { LLVMBinaryTypeOffload, } -#[deprecated(since = "LLVM 9.0")] +#[deprecated(since = "90.0.0")] pub enum LLVMOpaqueObjectFile {} #[allow(deprecated)] -#[deprecated(since = "LLVM 9.0")] +#[deprecated(since = "90.0.0")] pub type LLVMObjectFileRef = *mut LLVMOpaqueObjectFile; extern "C" { @@ -126,20 +126,20 @@ extern "C" { pub fn LLVMGetRelocationValueString(RI: LLVMRelocationIteratorRef) -> *const ::libc::c_char; #[allow(deprecated)] - #[deprecated(since = "LLVM 9.0", note = "Use LLVMCreateBinary instead")] + #[deprecated(since = "90.0.0", note = "Use LLVMCreateBinary instead")] pub fn LLVMCreateObjectFile(MemBuf: LLVMMemoryBufferRef) -> LLVMObjectFileRef; #[allow(deprecated)] - #[deprecated(since = "LLVM 9.0", note = "Use LLVMDisposeBinary instead")] + #[deprecated(since = "90.0.0", note = "Use LLVMDisposeBinary instead")] pub fn LLVMDisposeObjectFile(ObjectFile: LLVMObjectFileRef); #[allow(deprecated)] #[deprecated( - since = "LLVM 9.0", + since = "90.0.0", note = "Use LLVMObjectFileCopySectionIterator instead" )] pub fn LLVMGetSections(ObjectFile: LLVMObjectFileRef) -> LLVMSectionIteratorRef; #[allow(deprecated)] #[deprecated( - since = "LLVM 9.0", + since = "90.0.0", note = "Use LLVMObjectFileIsSectionIteratorAtEnd instead" )] pub fn LLVMIsSectionIteratorAtEnd( @@ -148,13 +148,13 @@ extern "C" { ) -> LLVMBool; #[allow(deprecated)] #[deprecated( - since = "LLVM 9.0", + since = "90.0.0", note = "Use LLVMObjectFileCopySymbolIterator instead" )] pub fn LLVMGetSymbols(ObjectFile: LLVMObjectFileRef) -> LLVMSymbolIteratorRef; #[allow(deprecated)] #[deprecated( - since = "LLVM 9.0", + since = "90.0.0", note = "Use LLVMObjectFileIsSymbolIteratorAtEnd instead" )] pub fn LLVMIsSymbolIteratorAtEnd( diff --git a/src/orc2/lljit.rs b/src/orc2/lljit.rs index e8cf0367132f693c9369c1c53c990e738fb6a1b4..6bab694afeb8adb3c22cb2be78d0fbe1c0aaf062 100644 --- a/src/orc2/lljit.rs +++ b/src/orc2/lljit.rs @@ -1,4 +1,4 @@ -use error::LLVMErrorRef; +use crate::error::LLVMErrorRef; use super::*; diff --git a/src/orc2/mod.rs b/src/orc2/mod.rs index 9de2536bfc84f540254700bdfacc1c1cc11b2796..91fe2fc773b903bf3ea8fba9aea0b1d305239da3 100644 --- a/src/orc2/mod.rs +++ b/src/orc2/mod.rs @@ -1,9 +1,9 @@ #![allow(non_snake_case)] //! OrcV2 -use error::LLVMErrorRef; -use prelude::*; -use target_machine::LLVMTargetMachineRef; +use crate::error::LLVMErrorRef; +use crate::prelude::*; +use crate::target_machine::LLVMTargetMachineRef; pub mod ee; pub mod lljit; diff --git a/src/remarks.rs b/src/remarks.rs index b8b022cd2c511e4ba400ab5fa3f7ce0898d0ec18..cc0123f44407076ea0371bdd7a7509aac9be4da7 100644 --- a/src/remarks.rs +++ b/src/remarks.rs @@ -1,5 +1,5 @@ //! Remark diagnostics library. -use prelude::LLVMBool; +use crate::prelude::LLVMBool; #[repr(C)] pub enum LLVMRemarkType { diff --git a/src/transforms/pass_builder.rs b/src/transforms/pass_builder.rs index 3367936505a06e791837adedde02b37df0124b2d..bff2072b90144661d6ac1c52e2d4915d4083434b 100644 --- a/src/transforms/pass_builder.rs +++ b/src/transforms/pass_builder.rs @@ -1,8 +1,8 @@ #![allow(non_snake_case)] use super::super::prelude::*; -use error::LLVMErrorRef; -use target_machine::LLVMTargetMachineRef; +use crate::error::LLVMErrorRef; +use crate::target_machine::LLVMTargetMachineRef; #[derive(Debug)] pub enum LLVMOpaquePassBuilderOptions {}