kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.65k stars 253 forks source link

Fix linking with GNU ld/Gold #230

Closed ximion closed 3 weeks ago

ximion commented 3 weeks ago

Hi!

This patch fixes a linking issue when using ld/gold and kfr_dsp from an installed CMake module:

/usr/bin/ld: cannot find LINKER:--push-state,--whole-archive,/usr/local/lib/libkfr_dsp_sse2.a,--pop-state: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

This should work with any linker on Linux/FreeBSD as they are all more or less compatible with ld, but I haven't done extensive testing on that (the testsuite should cover this though, I hope!)

Thank you for creating KFR and for considering this patch!

dancazarin commented 3 weeks ago

Hi, Thank you for the contribution. CMake should have add -Wl automatically according to this: https://cmake.org/cmake/help/latest/command/add_link_options.html#handling-compiler-driver-differences The strange things is that Github Actions' cmake as well as cmake on my test environment perfectly do this. But judging on the error message from your machine cmake just passed the LINKER prefix as is which is weird. What version of CMake do you use?

ximion commented 3 weeks ago

This was on cmake 3.30.2 - but the project uses Meson in its pipeline, so I now wonder whether this might be failing somewhere over there. I did try passing -Wl,LINKER:--push-state,--whole-archive,$<TARGET_FILE:${LIBRARY}>,--pop-state with equally bad results though...

This issue only appears when using an installed version of KFR, I haven't seen it in any other scenarios. Looks like I'll have to investigate this a bit more though, your reply made me a lot less certain that the problem isn't somewhere in our build pipeline.

ximion commented 3 weeks ago

I looked into this more, and the issue is in the Meson part of the build - we are specifically hitting https://github.com/mesonbuild/meson/issues/11404, apparently.

This isn't an issue in KFR, but in Meson, and should be addressed there somehow. Sorry for the noise!

dancazarin commented 2 weeks ago

Thank you anyway for reporting this and discovering the root cause, it may help users who are hitting the same issues with KFR and meson.