Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking errors on Windows with msys2 #1

Open
moneylobster opened this issue Dec 30, 2024 · 2 comments
Open

Linking errors on Windows with msys2 #1

moneylobster opened this issue Dec 30, 2024 · 2 comments

Comments

@moneylobster
Copy link

After doing some replacements to adapt some parts of the repo to Windows (changing the foreign-library name in shared-object.lisp from libbmas.so to libbmas.dll and doing the same for make.sh) I got some errors during the linking stage with Windows 10 with msys2 on UCRT64.

Compilation Output

$ ./make.sh
In file included from simd/x86_64.h:11,
                 from bmas.c:11:
simd/x86_64/avx2.h: In function 'BMAS_vector_i64hindex':
simd/x86_64/avx2.h:1128:21: warning: left shift count >= width of type [-Wshift-count-overflow]
 1128 |   case 'a': m = 1UL << 63;  break;
      |                     ^~
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1ade7): undefined reference to `_ZGVdN8v_sinf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1aff9): undefined reference to `_ZGVdN8v_sinf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b19f): undefined reference to `_ZGVdN8v_sinf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b27b): undefined reference to `_ZGVdN8v_sinf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b397): undefined reference to `_ZGVdN8v_cosf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b5a9): undefined reference to `_ZGVdN8v_cosf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b74f): undefined reference to `_ZGVdN8v_cosf'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccjCZ5xB.o:bmas.c:(.text+0x1b82b): undefined reference to `_ZGVdN8v_cosf'
collect2.exe: error: ld returned 1 exit status

The errors seem to have to do with the sinf and cosf functions, and indeed trying to compile with these lines commented out works:

bmas/bmas.c

Lines 186 to 187 in bf68699

one_arg_fn_body(ssin, SIMD_SINGLE_STRIDE, float, BMAS_svec, float, BMAS_svec);
one_arg_fn_body(scos, SIMD_SINGLE_STRIDE, float, BMAS_svec, float, BMAS_svec);

@digikar99
Copy link
Owner

The undefined reference must be stemming from here:

bmas/simd/x86_64/avx2.h

Lines 1680 to 1685 in bf68699

/* BMAS_svec static inline BMAS_vector_ssin(BMAS_svec x){ return Sleef_sinf8_u10avx2(x);} */
__m256 _ZGVdN8v_sinf(__m256 x);
BMAS_svec static inline BMAS_vector_ssin(BMAS_svec x){ return _ZGVdN8v_sinf(x);}
/* BMAS_svec static inline BMAS_vector_scos(BMAS_svec x){ return Sleef_cosf8_u10avx2(x);} */
__m256 _ZGVdN8v_cosf(__m256 x);
BMAS_svec static inline BMAS_vector_scos(BMAS_svec x){ return _ZGVdN8v_cosf(x);}

These are the SIMD sind and cos provided by gcc. Atleast on x86_64 linux, they are faster than SLEEF's versions. I'm not sure what the equivalent to this are on windows. As a starting point, you can use the the Sleef_{sin|cos}f8_u10avx2 and later look into whether these are slower than alternatives.

@moneylobster
Copy link
Author

The SLEEF version compiled without a problem, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants