error[E0308]: mismatched types
Affected Version
alpm.rs 144ced6 on aarch64 cargo 1.74.0
Description
Building from source fails, resulting in the error provided below.
Output
error[E0308]: mismatched types
--> alpm/src/cb.rs:244:60
|
244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) };
| ---- ^^ expected fn pointer, found fn item
| |
| arguments to this enum variant are incorrect
|
= note: expected fn pointer `unsafe extern "C" fn(_, _, _, *mut __va_list_tag)`
found fn item `extern "C" fn(_, _, _, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}`
help: the type constructed contains `extern "C" fn(*mut c_void, u32, *const u8, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` due to the type of the argument passed
--> alpm/src/cb.rs:244:55
|
244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) };
| ^^^^^--^
| |
| this argument influences the type of `Some`
note: tuple variant defined here
--> /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/option.rs:571:5
For more information about this error, try `rustc --explain E0308`.
error: could not compile `alpm` (lib) due to previous error
Closing. See https://github.com/Morganamilo/paru/issues/1085
This error occurs on the current 3.0.x on aarch64
@7Ji FYI
@kwankiu
Strangely, pacman from vanilla Arch Linux on x86_64 and pacman from Arch Linux ARM on aarch64 pack the exactly same alpm.h and alpm_list.h, 1:1. Yet they would produce different bindgen for alpm-sys even on the same rust-bindgen, rust, clang and llvm-libs version.
The following is how ffi.rs would be generated differently on ALARM aarch64:
diff --git a/alpm-sys/src/ffi.rs b/alpm-sys/src/ffi.rs
index f735def..80f7401 100644
--- a/alpm-sys/src/ffi.rs
+++ b/alpm-sys/src/ffi.rs
@@ -1,10 +1,10 @@
-/* automatically generated by rust-bindgen 0.68.1 */
+/* automatically generated by rust-bindgen 0.69.4 */
pub type __mode_t = ::std::os::raw::c_uint;
pub type __off_t = ::std::os::raw::c_long;
pub type mode_t = __mode_t;
pub type off_t = __off_t;
-pub type va_list = __builtin_va_list;
+pub type va_list = [u64; 4usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct archive {
@@ -3324,7 +3324,7 @@ pub type alpm_cb_log = ::std::option::Option<
ctx: *mut ::std::os::raw::c_void,
level: alpm_loglevel_t,
fmt: *const ::std::os::raw::c_char,
- args: *mut __va_list_tag,
+ args: va_list,
),
>;
extern "C" {
@@ -4221,67 +4221,3 @@ extern "C" {
#[doc = " Get the capabilities of the library.\n @return a bitmask of the capabilities"]
pub fn alpm_capabilities() -> ::std::os::raw::c_int;
}
-pub type __builtin_va_list = [__va_list_tag; 1usize];
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct __va_list_tag {
- pub gp_offset: ::std::os::raw::c_uint,
- pub fp_offset: ::std::os::raw::c_uint,
- pub overflow_arg_area: *mut ::std::os::raw::c_void,
- pub reg_save_area: *mut ::std::os::raw::c_void,
-}
-#[test]
-fn bindgen_test_layout___va_list_tag() {
- const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit();
- let ptr = UNINIT.as_ptr();
- assert_eq!(
- ::std::mem::size_of::<__va_list_tag>(),
- 24usize,
- concat!("Size of: ", stringify!(__va_list_tag))
- );
- assert_eq!(
- ::std::mem::align_of::<__va_list_tag>(),
- 8usize,
- concat!("Alignment of ", stringify!(__va_list_tag))
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(__va_list_tag),
- "::",
- stringify!(gp_offset)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(__va_list_tag),
- "::",
- stringify!(fp_offset)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(__va_list_tag),
- "::",
- stringify!(overflow_arg_area)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(__va_list_tag),
- "::",
- stringify!(reg_save_area)
- )
- );
-}
@Morganamilo
As a temporary workaround, projects using alpm.rs could enable its generate feature to generate the bindings on the fly, e.g. on one of my projects:
diff --git a/Cargo.toml b/Cargo.toml
index 32cacb3..71a9ac0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-alpm = "3.0"
+alpm = { version = "3.0", features = [ "generate" ] }
blake2 = "0.10"
crc = "3"
env_logger = "0.10"
This would introduce a few deps both into the project and into system (pacman -S rust-bindgen would satisfy that)
@7Ji Builds successfully with proposed fix.
alpm = { version = "3.0.4", features = [ "generate" ] }
could we please have a release that contains this fix? it's still an issue in the wild today.
@7Ji Builds successfully with proposed fix.
alpm = { version = "3.0.4", features = [ "generate" ] }
i am having this issue now... i see it's closed as fixed / completed.
what is the fix? i'm still having this issue on arch linux arm
i have tried uninstalling paru, and clean building it using yay, and i've also tried rebuilding it like so:
sudo pacman -S --needed git base-devel && git clone https://aur.archlinux.org/paru.git && cd paru && makepkg -si
some system info:
$ uname -a
Linux comp 6.13.7-1-aarch64-ARCH #1 SMP PREEMPT_DYNAMIC Fri Mar 21 14:08:47 MDT 2025 aarch64 GNU/Linux
$
$ pacman -Q paru
paru 2.0.1-1
$
$ cargo --version
cargo 1.85.0 (d73d2caf9 2024-12-31)
$
i noticed during the build... i'm getting this warning, is it related?
==> Sources are ready.
==> Making package: paru 2.0.4-1 (Sun 23 Mar 2025 06:16:18 PM CDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting build()...
warning: Patch `alpm v3.0.4 (https://github.com/archlinux/alpm.rs?rev=306342#306342ef)` was not used in the crate graph.
Patch `aur-depends v3.0.0 (https://github.com/Morganamilo/aur-depends?rev=30c2c1#30c2c150)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
i also tried running cargo update. It updated a bunch of stuff. let me know if you need this info, what else i should supply
here is the main error output from the paru build. it looks like it gets stopped at crossbeam-deque every time:
Compiling crossbeam-deque v0.8.5
error[E0308]: mismatched types
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:60
|
244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) };
| ---- ^^ expected fn pointer, found fn item
| |
| arguments to this enum variant are incorrect
|
= note: expected fn pointer `unsafe extern "C" fn(_, _, _, *mut __va_list_tag)`
found fn item `extern "C" fn(_, _, _, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}`
help: the type constructed contains `extern "C" fn(*mut c_void, u32, *const u8, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` due to the type of the argument passed
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:55
|
244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) };
| ^^^^^--^
| |
| this argument influences the type of `Some`
note: tuple variant defined here
--> /build/rust/src/rustc-1.85.1-src/library/core/src/option.rs:580:5
Compiling locale_config v0.3.0
Compiling phf v0.10.1
Compiling crossbeam-channel v0.5.13
For more information about this error, try `rustc --explain E0308`.
error: could not compile `alpm` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
==> ERROR: A failure occurred in build().
Aborting...
-> error making: paru-exit status 4
-> Failed to install the following packages. Manual intervention is required:
paru - exit status 4
Thanks!
@7Ji Builds successfully with proposed fix.
alpm = { version = "3.0.4", features = [ "generate" ] }i am having this issue now... i see it's closed as fixed / completed.
Yes, i believe that this issue still exists.
what is the fix? i'm still having this issue on arch linux arm
You can patch like this: https://github.com/1usOS/PKGBUILDs/blob/misc/arb/0001-fix-alpm-aarch64-issue.patch
Latest successful build log using this workaround: https://github.com/1usOS/test-repo/actions/runs/14024875895/job/39261822970
here is the main error output from the paru build. it looks like it gets stopped at crossbeam-deque every time:
Compiling crossbeam-deque v0.8.5 error[E0308]: mismatched types --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:60 | 244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) }; | ---- ^^ expected fn pointer, found fn item | | | arguments to this enum variant are incorrect | = note: expected fn pointer `unsafe extern "C" fn(_, _, _, *mut __va_list_tag)` found fn item `extern "C" fn(_, _, _, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` help: the type constructed contains `extern "C" fn(*mut c_void, u32, *const u8, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` due to the type of the argument passed --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:55 | 244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) }; | ^^^^^--^ | | | this argument influences the type of `Some` note: tuple variant defined here --> /build/rust/src/rustc-1.85.1-src/library/core/src/option.rs:580:5 Compiling locale_config v0.3.0 Compiling phf v0.10.1 Compiling crossbeam-channel v0.5.13 For more information about this error, try `rustc --explain E0308`. error: could not compile `alpm` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... ==> ERROR: A failure occurred in build(). Aborting... -> error making: paru-exit status 4 -> Failed to install the following packages. Manual intervention is required: paru - exit status 4Thanks!
@dimyself the specific issue you mentioned building paru from AUR seems to be an issue with how the PKGBUILD of paru handled the deps, try building paru-git instead, I can confirm that it builds successfully.
here is the main error output from the paru build. it looks like it gets stopped at crossbeam-deque every time:
Compiling crossbeam-deque v0.8.5 error[E0308]: mismatched types --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:60 | 244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) }; | ---- ^^ expected fn pointer, found fn item | | | arguments to this enum variant are incorrect | = note: expected fn pointer `unsafe extern "C" fn(_, _, _, *mut __va_list_tag)` found fn item `extern "C" fn(_, _, _, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` help: the type constructed contains `extern "C" fn(*mut c_void, u32, *const u8, [__va_list_tag; 1]) {logcb::<LogCbImpl<T, F>>}` due to the type of the argument passed --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alpm-4.0.1/src/cb.rs:244:55 | 244 | unsafe { alpm_option_set_logcb(self.as_ptr(), Some(cb), &*ctx as *const _ as *mut _) }; | ^^^^^--^ | | | this argument influences the type of `Some` note: tuple variant defined here --> /build/rust/src/rustc-1.85.1-src/library/core/src/option.rs:580:5 Compiling locale_config v0.3.0 Compiling phf v0.10.1 Compiling crossbeam-channel v0.5.13 For more information about this error, try `rustc --explain E0308`. error: could not compile `alpm` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... ==> ERROR: A failure occurred in build(). Aborting... -> error making: paru-exit status 4 -> Failed to install the following packages. Manual intervention is required: paru - exit status 4Thanks!
@dimyself the specific issue you mentioned building paru from AUR seems to be an issue with how the PKGBUILD of
paruhandled the deps, try buildingparu-gitinstead, I can confirm that it builds successfully.
thank you!
yes, i uninstalled paru and tried paru-git, and it worked without any issue!