After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774876 - meson: add libm to has_function checks
meson: add libm to has_function checks
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-22 21:08 UTC by Scott D Phillips
Modified: 2017-02-23 17:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH gst-plugins-good] meson: add libm to has_function checks (1.22 KB, patch)
2016-11-22 21:09 UTC, Scott D Phillips
committed Details | Review
[PATCH gst-plugins-base] meson: Add headers and libm to has_function checks (1.53 KB, patch)
2016-11-28 18:32 UTC, Scott D Phillips
committed Details | Review

Description Scott D Phillips 2016-11-22 21:08:37 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.
Comment 1 Scott D Phillips 2016-11-22 21:09:33 UTC
Created attachment 340553 [details] [review]
[PATCH gst-plugins-good] meson: add libm to has_function checks
Comment 2 Sebastian Dröge (slomo) 2016-11-23 08:19:14 UTC
The same will also be required in other modules then, right?
Comment 3 Nirbheek Chauhan 2016-11-23 08:22:32 UTC
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.
Comment 4 Scott D Phillips 2016-11-23 23:02:16 UTC
(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.
Comment 5 Nirbheek Chauhan 2016-11-23 23:31:11 UTC
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. :)
Comment 6 Sebastian Dröge (slomo) 2016-11-24 05:54:47 UTC
Do all toolchains have --as-needed (MSVC?)?
Comment 7 Nirbheek Chauhan 2016-11-24 11:10:34 UTC
There's no libm on MSVC.
Comment 8 Scott D Phillips 2016-11-28 18:32:18 UTC
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.
Comment 9 Nirbheek Chauhan 2016-11-28 18:56:39 UTC
Review of attachment 340933 [details] [review]:

LGTM.
Comment 10 Tim-Philipp Müller 2017-02-23 17:36:49 UTC
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.