GNOME Bugzilla – Bug 774876
meson: add libm to has_function checks
Last modified: 2017-02-23 17:36:49 UTC
The functions from math.h may be implemented in libm. I'm seeing this build problem with clang-3.9.0 and glibc-2.17(!). Not sure on what other combinations the problem would or would not exist.
Created attachment 340553 [details] [review] [PATCH gst-plugins-good] meson: add libm to has_function checks
The same will also be required in other modules then, right?
Review of attachment 340553 [details] [review]: Makes sense. But are you sure that clang requires `-lm` for math functions? IIRC clang was trying to do away with a separate libm library in favour of putting everything inside libc? If so, please push.
(In reply to Sebastian Dröge (slomo) from comment #2) > The same will also be required in other modules then, right? For whatever reason I only saw the problem in this repo, but yes I guess it make sense to keep everything consistent. (In reply to Nirbheek Chauhan from comment #3) > Review of attachment 340553 [details] [review] [review]: > > Makes sense. But are you sure that clang requires `-lm` for math functions? > IIRC clang was trying to do away with a separate libm library in favour of > putting everything inside libc? If so, please push. It seems that meson's has_function check always checks for '__builtin_'+function if the function itself can't be found normally. The c99 math stuff exists in gcc as __builtin_asinh (for example), but that builtin isn't there in clang. I'm not familiar with an effort to get rid of libm from clang. Absent that, I think that this is the right change.
Adding -lm everywhere is not going to cause overlinking because Meson passes --as-needed by default, so this is ok to go in. I will push it tomorrow if no one else beats me to it. :)
Do all toolchains have --as-needed (MSVC?)?
There's no libm on MSVC.
Created attachment 340933 [details] [review] [PATCH gst-plugins-base] meson: Add headers and libm to has_function checks (In reply to Sebastian Dröge (slomo) from comment #2) > The same will also be required in other modules then, right? Searching various configure.ac for something like: > LIBS_SAVE=$LIBS > LIBS="$LIBS $LIBM" > AC_CHECK_FUNCS(...) > LIBS=$LIBS_SAVE I found occurrences in gst-plugins-base and gst-plugins-good. Here's a patch for -base.
Review of attachment 340933 [details] [review]: LGTM.
Also cherry-picked into 1.10, as it fixes In file included from ../subprojects/gst-plugins-good/gst/audiofx/audiochebband.c:82:0: ../subprojects/gst-plugins-good/gst/audiofx/math_compat.h:33:1: error: static declaration of ‘asinh’ follows non-static declaration asinh (gdouble x) ^~~~~ and similar for sinh and cosh for me.