build: Unconditionally link with libm if found

New versions of gcc have implemented __has_builtin which causes meson
to detect functions in libm, such as hypot() and sqrt() as built-ins
during configure time, while they are actually part of libm. This has
been causing build failures in Fedora 32 Rawhide and has been reported
in meson for some time now: https://github.com/mesonbuild/meson/issues/3740

Meson always adds --as-needed to linker arguments so, it does not hurt
to link against libm even though no functions from that library will be
used.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Eduardo Lima (Etrunko) 2020-02-07 10:59:01 -03:00 committed by Frediano Ziglio
parent 35f45282d4
commit 03e1fb94e4

View File

@ -83,15 +83,11 @@ foreach func : functions
endif
endforeach
# check for hypot function
#
# Include math.h header to avoid problems with builtins.
# In some systems the function is in libm.
if not compiler.has_function('hypot', prefix : '#include <math.h>')
libm = compiler.find_library('m', required : false)
if compiler.has_function('hypot', prefix : '#include <math.h>', dependencies : libm)
spice_common_deps += libm
endif
# FIXME
# check for libm, as workaround for https://github.com/mesonbuild/meson/issues/3740
libm = compiler.find_library('m', required : false)
if libm.found()
spice_common_deps += libm
endif
#