cross
cross copied to clipboard
armv5te-unknown-linux-musleabi with OpenSSL fails with undefined reference to `__sync_sub_and_fetch_4'
I wonder if this has been fixed? I cannot seem to be able to make an ARMv5TE build OpenSSL without tripping on this error...
Apparently __sync_sub_and_fetch_4
is already supplied by the build target lib, because defining my own version also causes multiple-definition errors. For some reason, the linker just doesn't like to use the library's version.
Is this related to your issue? https://github.com/rust-embedded/cross/issues/229
Nope. I can build a vendored version of OpenSSL just fine with static linking and all. I just cannot resolve the symbol conflicts when I link that OpenSSL lib.
There is a set of atomic intrinics defined in the Rust core lib. But OpenSSL doesn't want to use it and says the functions are not defined. But if I define them myself, it shuts OpenSSL up fine, but then Rust complains that there are conflicting definitions.
I have the same problem. It compiles but it fails to link. Is there a solution to the problem?
I used this to solve the issue as the functions are not defined in the Rust core lib.
#[cfg(target_arch="arm")]
unsafe fn __kernel_cmpxchg_t(old_value: u32, new_value: u32, ptr: *mut u32) -> u32 {
let __kernel_cmpxchg: extern "C" fn(u32, u32, *mut u32) -> u32 = mem::transmute(0xffff0fc0u32);
__kernel_cmpxchg(old_value, new_value, ptr)
}
#[cfg(target_arch="arm")]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
pub unsafe extern "C" fn __sync_add_and_fetch_4(ptr: *mut u32, value: u32) -> u32 {
loop {
let old_value = *ptr;
let new_value = old_value + value;
if __kernel_cmpxchg_t(old_value, new_value, ptr) == 0 {
return new_value;
}
};
}
#[cfg(target_arch="arm")]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
pub unsafe extern "C" fn __sync_sub_and_fetch_4(ptr: *mut u32, value: u32) -> u32 {
loop {
let old_value = *ptr;
let new_value = old_value - value;
if __kernel_cmpxchg_t(old_value, new_value, ptr) == 0 {
return new_value;
}
};
}
Confirmed this is still failing, and due to #485, there's more undefined references to symbols (specifically, the 64-bit time symbols).
This is still failing after the downgrade to musl 1.1.24, however, all the 64-bit time definitions have been fixed, but __sync_add_and_fetch_4
still is not defined, even though the target is supposed to support atomics. Looking through OpenSSL and rust-openssl, there's no internal use of these intrinsics, so this is still a bug, here or upstream.