Skip to content

Commit 54c8dfb

Browse files
committed
Add linkage attributes to extern "C" blocks
1 parent 27cbd6b commit 54c8dfb

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ fn build_avx512_assembly() {
230230
}
231231

232232
fn build_neon_c_intrinsics() {
233+
println!("cargo:rustc-cfg=blake3_neon_ffi");
233234
let mut build = new_build();
234235
// Note that blake3_neon.c normally depends on the blake3_portable.c
235236
// for the single-instance compression function, but we expose
@@ -254,7 +255,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
254255
"blake3_avx2_ffi",
255256
"blake3_avx2_rust",
256257
"blake3_avx512_ffi",
257-
"blake3_neon",
258+
"blake3_neon_ffi",
258259
];
259260
for cfg_name in all_cfgs {
260261
// TODO: Switch this whole file to the new :: syntax when our MSRV reaches 1.77.
@@ -296,7 +297,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
296297
if (is_arm() && is_neon())
297298
|| (!is_no_neon() && !is_pure() && is_aarch64() && is_little_endian())
298299
{
299-
println!("cargo:rustc-cfg=blake3_neon");
300300
build_neon_c_intrinsics();
301301
}
302302

src/ffi_avx2.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ pub unsafe fn hash_many<const N: usize>(
3333
}
3434

3535
pub mod ffi {
36+
#[cfg_attr(
37+
blake3_avx2_ffi,
38+
link(name = "blake3_sse2_sse41_avx2_assembly", kind = "static")
39+
)]
3640
extern "C" {
3741
pub fn blake3_hash_many_avx2(
3842
inputs: *const *const u8,

src/ffi_avx512.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub unsafe fn hash_many<const N: usize>(
6161
}
6262

6363
pub mod ffi {
64+
#[cfg_attr(
65+
blake3_avx512_ffi,
66+
link(name = "blake3_avx512_assembly", kind = "static")
67+
)]
6468
extern "C" {
6569
pub fn blake3_compress_in_place_avx512(
6670
cv: *mut u32,

src/ffi_neon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub extern "C" fn blake3_compress_in_place_portable(
5353
}
5454

5555
pub mod ffi {
56+
#[cfg_attr(blake3_neon_ffi, link(name = "blake3_neon", kind = "static"))]
5657
extern "C" {
5758
pub fn blake3_hash_many_neon(
5859
inputs: *const *const u8,

src/ffi_sse2.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub unsafe fn hash_many<const N: usize>(
6161
}
6262

6363
pub mod ffi {
64+
#[cfg_attr(
65+
blake3_sse2_ffi,
66+
link(name = "blake3_sse2_sse41_avx2_assembly", kind = "static")
67+
)]
6468
extern "C" {
6569
pub fn blake3_compress_in_place_sse2(
6670
cv: *mut u32,

src/ffi_sse41.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub unsafe fn hash_many<const N: usize>(
6161
}
6262

6363
pub mod ffi {
64+
#[cfg_attr(
65+
blake3_sse41_ffi,
66+
link(name = "blake3_sse2_sse41_avx2_assembly", kind = "static")
67+
)]
6468
extern "C" {
6569
pub fn blake3_compress_in_place_sse41(
6670
cv: *mut u32,

0 commit comments

Comments
 (0)