-
Notifications
You must be signed in to change notification settings - Fork 417
Description
The example build fails on Cygwin due to an undefined reference to blake3_xof_many_avx512
$ cmake --fresh -S c -B c/build -DBLAKE3_EXAMPLES=ON
(snip)
$ cmake --build c/build
[ 10%] Building C object CMakeFiles/blake3.dir/blake3.c.o
[ 20%] Building C object CMakeFiles/blake3.dir/blake3_dispatch.c.o
[ 30%] Building C object CMakeFiles/blake3.dir/blake3_portable.c.o
[ 40%] Building ASM object CMakeFiles/blake3.dir/blake3_avx2_x86-64_windows_gnu.S.o
[ 50%] Building ASM object CMakeFiles/blake3.dir/blake3_avx512_x86-64_windows_gnu.S.o
[ 60%] Building ASM object CMakeFiles/blake3.dir/blake3_sse2_x86-64_windows_gnu.S.o
[ 70%] Building ASM object CMakeFiles/blake3.dir/blake3_sse41_x86-64_windows_gnu.S.o
[ 80%] Linking C static library libblake3.a
[ 80%] Built target blake3
[ 90%] Building C object CMakeFiles/blake3-example.dir/example.c.o
[100%] Linking C executable blake3-example.exe
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: libblake3.a(blake3_dispatch.c.o):blake3_dispatc:(.text+0x4bd): undefined reference to `blake3_xof_many_avx512'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/blake3-example.dir/build.make:98: blake3-example.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:884: CMakeFiles/blake3-example.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
This happens because, on Cygwin, the build selects blake3_avx512_x86-64_windows_gnu.S (it's correct), which does not define blake3_xof_many_avx512.
However, the dispatch function blake3_xof_many still tries to call blake3_xof_many_avx512 because Cygwin does not define _WIN32, and the fallback logic doesn't apply.
As a result, the function is declared but never defined, leading to a linker error when building the example.
Lines 238 to 243 in 34d293e
| #if !defined(_WIN32) && !defined(BLAKE3_NO_AVX512) | |
| if (features & AVX512VL) { | |
| blake3_xof_many_avx512(cv, block, block_len, counter, flags, out, outblocks); | |
| return; | |
| } | |
| #endif |
I suggest changing this condition to !defined(_WIN32) && !defined(__CYGWIN__) && ... (and the same change in blake3_impl.h) as a quick fix.
If this approach is acceptable, I'm happy to submit a PR for it.