From 8c4127d044a78179f24f92b80133694b5c3a2a47 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Sat, 3 Apr 2021 18:57:16 +0100 Subject: [PATCH] Add `#[linkage = "weak"]` attribute to all `mem` instrinics. --- library/compiler-builtins/src/mem/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/compiler-builtins/src/mem/mod.rs b/library/compiler-builtins/src/mem/mod.rs index 03dc965ca4ac..3d7372c8273c 100644 --- a/library/compiler-builtins/src/mem/mod.rs +++ b/library/compiler-builtins/src/mem/mod.rs @@ -20,12 +20,14 @@ use core::ops::{BitOr, Shl}; mod impls; #[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)] +#[cfg_attr(not(all(target_os = "windows", target_env = "gnu")), linkage = "weak")] pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { impls::copy_forward(dest, src, n); dest } #[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)] +#[cfg_attr(not(all(target_os = "windows", target_env = "gnu")), linkage = "weak")] pub unsafe extern "C" fn memmove(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { let delta = (dest as usize).wrapping_sub(src as usize); if delta >= n { @@ -39,12 +41,14 @@ pub unsafe extern "C" fn memmove(dest: *mut u8, src: *const u8, n: usize) -> *mu } #[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)] +#[cfg_attr(not(all(target_os = "windows", target_env = "gnu")), linkage = "weak")] pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 { impls::set_bytes(s, c as u8, n); s } #[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)] +#[cfg_attr(not(all(target_os = "windows", target_env = "gnu")), linkage = "weak")] pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { let mut i = 0; while i < n { @@ -59,6 +63,7 @@ pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { } #[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)] +#[cfg_attr(not(all(target_os = "windows", target_env = "gnu")), linkage = "weak")] pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { memcmp(s1, s2, n) }