breakfastquay / rubberband

Official mirror of Rubber Band Library, an audio time-stretching and pitch-shifting library.
http://breakfastquay.com/rubberband/
GNU General Public License v2.0
561 stars 89 forks source link

link failure with 3.0.0 and Clang 14.0 on Linux #62

Open Be-ing opened 2 years ago

Be-ing commented 2 years ago

With environment variables CC=clang and CXX=clang++ when running Meson, the build fails with:

[27/44] Linking target librubberband.so.2.2.0
FAILED: librubberband.so.2.2.0
clang++  -o librubberband.so.2.2.0 librubberband_objlib.a.p/src_rubberband-c.cpp.o librubberband_objlib.a.p/src_RubberBandStretcher.cpp.o librubberband_objlib.a.p/src_faster_AudioCurveCalculator.cpp.o librubberband_objlib.a.p/src_faster_CompoundAudioCurve.cpp.o librubberband_objlib.a.p/src_faster_HighFrequencyAudioCurve.cpp.o librubberband_objlib.a.p/src_faster_SilentAudioCurve.cpp.o librubberband_objlib.a.p/src_faster_PercussiveAudioCurve.cpp.o librubberband_objlib.a.p/src_faster_R2Stretcher.cpp.o librubberband_objlib.a.p/src_faster_StretcherChannelData.cpp.o librubberband_objlib.a.p/src_faster_StretcherProcess.cpp.o librubberband_objlib.a.p/src_common_Allocators.cpp.o librubberband_objlib.a.p/src_common_FFT.cpp.o librubberband_objlib.a.p/src_common_Log.cpp.o librubberband_objlib.a.p/src_common_Profiler.cpp.o librubberband_objlib.a.p/src_common_Resampler.cpp.o librubberband_objlib.a.p/src_common_StretchCalculator.cpp.o librubberband_objlib.a.p/src_common_sysutils.cpp.o librubberband_objlib.a.p/src_common_Thread.cpp.o librubberband_objlib.a.p/src_finer_R3Stretcher.cpp.o librubberband_objlib.a.p/src_common_BQResampler.cpp.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,librubberband.so.2 -Wl,--end-group -fuse-ld=mold -pthread
mold: error: undefined symbol: __atomic_is_lock_free
>>> referenced by R3Stretcher.cpp
>>>               librubberband_objlib.a.p/src_finer_R3Stretcher.cpp.o:(RubberBand::R3Stretcher::R3Stretcher(RubberBand::R3Stretcher::Parameters, double, double, RubberBand::Log))>>> referenced by R3Stretcher.cpp
>>>               librubberband_objlib.a.p/src_finer_R3Stretcher.cpp.o:(RubberBand::R3Stretcher::R3Stretcher(RubberBand::R3Stretcher::Parameters, double, double, RubberBand::Log))
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

The error is reproducible regardless of linker (mold, lld, GNU ld).

Compiling with GCC 12.1.1 works.

cannam commented 2 years ago

Odd. How can that be a link error? Either the standard library has it or it doesn't surely?

cannam commented 2 years ago

Huh. Looks like there is such a thing as libatomic. I had no idea. Interesting that it isn't necessary when using Clang on macOS.

cannam commented 2 years ago

If the only symbol undefined is the one that we use for diagnostic purposes only (i.e. is_lock_free) and not any of the actual atomic ops, then it might actually be better to (at least conditionally) eliminate the diagnostic check than to add a system-specific library dependency. (Is libatomic system-specific? I'm finding it surprisingly hard to find reliable info)

Be-ing commented 2 years ago

I found this issue: https://github.com/godotengine/godot/issues/46375. Installing the libatomic-static Fedora package as described in this comment resolved the issue. :shrug:

Be-ing commented 2 years ago

I'm unclear whether it should be the build system's responsibility to check for the availability of libatomic.