package/iputils: patch ping to link against libm
PATCH 1/1 package/iputils: patch ping to link against libm
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function finite().
Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/
A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42
--- package/iputils/0001-ping-link-against-libm.patch | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package/iputils/0001-ping-link-against-libm.patch
package/iputils/0001-ping-link-against-libm.patch new file +29 -0
@@ -0,0 +1,29 @@ +From 8d189e73e660a637ae3f5a604448103ea42e397d Mon Sep 17 00:00:00 2001 +From: Martin Bark <[email protected]> +Date: Fri, 12 Feb 2016 16:52:19 +0000 +Subject: [PATCH] ping: link against libm + +This commit links ping against libm because ping.c calls the math library +function finite(). + +Signed-off-by: Martin Bark <[email protected]> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 8b37c42..fb80f6f 100644 +--- a/Makefile ++++ b/Makefile +@@ -156,7 +156,7 @@ LIB_clockdiff = $(LIB_CAP) + DEF_ping_common = $(DEF_CAP) $(DEF_IDN) + DEF_ping6_common = $(DEF_CAP) $(DEF_IDN) + DEF_ping = $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS) +-LIB_ping = $(LIB_CAP) $(LIB_IDN) $(LIB_RESOLV) ++LIB_ping = $(LIB_CAP) $(LIB_IDN) $(LIB_RESOLV) -lm + + ping: ping_common.o ping6_common.o + ping.o ping_common.o ping6_common.o: ping.h in6_flowlabel.h +-- +2.7.0 +
Signature · 1 line
2.7.0
PATCH 1/1 package/iputils: patch ping to link against libm
Martin,
Quoted 10 lines · Martin Bark
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function
finite().Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42Signed-off-by Martin Bark <[email protected]>
Thanks for working on this issue. However, I am not entirely happy with the explanation.
Indeed, if you try to build iputils against uClibc, it builds just fine. It is apparently only when the entire build is done with BR2_ENABLE_DEBUG=y that the build failure occurs. And your commit log doesn't explain at all why the problem only occurs when the build is done with debugging symbols enabled.
I've tried building iputils against uClibc, it works fine. I've tried building iputils against uClibc with BR2_ENABLE_DEBUG=y (using a pre-built uClibc toolchain, which isn't built with debugging symbols), and it works fine. So it seems that it only happens when the entire build is done with debugging symbols, including uClibc itself.
While linking with -lm might be the correct fix, I am not convinced yet due the lack of explanation for the root of the problem.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 package/iputils: patch ping to link against libm
Thomas,
Quoted 37 lines · Thomas Petazzoni
Martin,
Quoted 10 lines · Martin Bark
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function
finite().Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42Signed-off-by Martin Bark <[email protected]>Thanks for working on this issue. However, I am not entirely happy with the explanation.
Indeed, if you try to build iputils against uClibc, it builds just fine. It is apparently only when the entire build is done with BR2_ENABLE_DEBUG=y that the build failure occurs. And your commit log doesn't explain at all why the problem only occurs when the build is done with debugging symbols enabled.
I've tried building iputils against uClibc, it works fine. I've tried building iputils against uClibc with BR2_ENABLE_DEBUG=y (using a pre-built uClibc toolchain, which isn't built with debugging symbols), and it works fine. So it seems that it only happens when the entire build is done with debugging symbols, including uClibc itself.
Quoted 6 lines
While linking with -lm might be the correct fix, I am not convinced yet due the lack of explanation for the root of the problem.
Thanks!
Thomas
I missed that BR2_ENABLE_DEBUG=y was part of this. I still think you need libm if you use finite but i agree it would be good to understand further. I'll do some more investigation.
Thanks
Martin
Quoted 4 lines
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH 1/1 package/iputils: patch ping to link against libm
In reply to Thomas PetazzoniHi,
Thomas Petazzoni wrote,
Quoted 31 lines
Martin,
Quoted 10 lines · Martin Bark
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function
finite().Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42Signed-off-by Martin Bark <[email protected]>Thanks for working on this issue. However, I am not entirely happy with the explanation.
Indeed, if you try to build iputils against uClibc, it builds just fine. It is apparently only when the entire build is done with BR2_ENABLE_DEBUG=y that the build failure occurs. And your commit log doesn't explain at all why the problem only occurs when the build is done with debugging symbols enabled.
Quoted 8 lines
I've tried building iputils against uClibc, it works fine. I've tried building iputils against uClibc with BR2_ENABLE_DEBUG=y (using a pre-built uClibc toolchain, which isn't built with debugging symbols), and it works fine. So it seems that it only happens when the entire build is done with debugging symbols, including uClibc itself.
While linking with -lm might be the correct fix, I am not convinced yet due the lack of explanation for the root of the problem.
The root of the problem is rather simple. When you use math library functions you are required to link libm explicitely. I think for historical reasons. For musl this is no issue as everything is included in libc.so. In uClibc world you have the choice and could simply build a system without any math library.
GNU libc seems to have weak aliases for finitef even in libc.so:
nm output/build/glibc-2.22/build/libc.so|grep finitef 0002ba9c W finitef0002ba9c T __finitef0002ba9c t __GI___finitef
So linking with GNU libc does not fail for iputils even without -lm.
Not sure, I cannot find every libm function, but some. tgamma or exp10 is not referenced in libc.so.
May be Mike can explain the Glibc behaviour?
The finite macros where added here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/include/math.h?id=21902b578e96fd6b85b9bcda8a0e929fc844ec51
So 1.0.10 is the first release containing this BSD specific functions in a usable way.
I think BR2_*DEBUG* option is not related to this error.
best regards
Waldemar
PATCH 1/1 package/iputils: patch ping to link against libm
Waldemar,
Yes that is exactly what i found, the gnu libc includes some, but not all, libm function.
Thomas,
I can't reproduce the issues you see. I just ran some more tests and for me iputils fails with undefined reference to `__finite' when built against uClibc regardless of BR2_ENABLE_DEBUG=y. I had a defconfig with only BR2_PACKAGE_IPUTILS=y.
I looked at the autobuild fails for iputils from here
http://autobuild.buildroot.org/?reason=iputils-c8ff6feaf0442f8efd96ccb415770c54f9e84d47
and there are lots of fails without BR2_ENABLE_DEBUG=y
Thanks
Martin
Quoted 70 lines · Waldemar Brodkorb
Hi,
Thomas Petazzoni wrote,Quoted 31 lines
Martin,
Quoted 10 lines · Martin Bark
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function
finite().Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42Signed-off-by Martin Bark <[email protected]>Thanks for working on this issue. However, I am not entirely happy with the explanation.
Indeed, if you try to build iputils against uClibc, it builds just fine. It is apparently only when the entire build is done with BR2_ENABLE_DEBUG=y that the build failure occurs. And your commit log doesn't explain at all why the problem only occurs when the build is done with debugging symbols enabled.
Quoted 8 lines
I've tried building iputils against uClibc, it works fine. I've tried building iputils against uClibc with BR2_ENABLE_DEBUG=y (using a pre-built uClibc toolchain, which isn't built with debugging symbols), and it works fine. So it seems that it only happens when the entire build is done with debugging symbols, including uClibc itself.
While linking with -lm might be the correct fix, I am not convinced yet due the lack of explanation for the root of the problem.
The root of the problem is rather simple. When you use math library functions you are required to link libm explicitely. I think for historical reasons. For musl this is no issue as everything is included in libc.so. In uClibc world you have the choice and could simply build a system without any math library.
GNU libc seems to have weak aliases for finitef even in libc.so:
nm output/build/glibc-2.22/build/libc.so|grep finitef0002ba9cW finitef0002ba9cT__finitef0002ba9ct__GI___finitefSo linking with GNU libc does not fail for iputils even without -lm.
Not sure, I cannot find every libm function, but some. tgamma or exp10 is not referenced in libc.so.
May be Mike can explain the Glibc behaviour?
The finite macros where added here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/include/math.h?id=21902b578e96fd6b85b9bcda8a0e929fc844ec51
So 1.0.10 is the first release containing this BSD specific functions in a usable way.I think BR2_*DEBUG* option is not related to this error.
best regards
Waldemar
PATCH 1/1 package/iputils: patch ping to link against libm
Hello,
Quoted 8 lines · Martin Bark
I can't reproduce the issues you see. I just ran some more tests and for me iputils fails with undefined reference to `__finite' when built against uClibc regardless of BR2_ENABLE_DEBUG=y. I had a defconfig with only BR2_PACKAGE_IPUTILS=y.
I looked at the autobuild fails for iputils from here
http://autobuild.buildroot.org/?reason=iputils-c8ff6feaf0442f8efd96ccb415770c54f9e84d47
and there are lots of fails without BR2_ENABLE_DEBUG=y
All failures occur with the internal toolchain backend, i.e when using the latest uClibc-ng version. So it seems to me that the failure started to exist in a recent uClibc-ng version: the pre-built uClibc toolchains that are based on uClibc-ng 1.0.9 do not exhibit the problem.
Quoted 4 lines
Quoted 4 lines
The finite macros where added here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/include/math.h?id=21902b578e96fd6b85b9bcda8a0e929fc844ec51
So 1.0.10 is the first release containing this BSD specific functions in a usable way.
Which would probably match with Waldemar's change in 1.0.10.
Waldemar, can you conrfirm? If those functions are only available starting in 1.0.10, how can iputils build with 1.0.9 ?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 package/iputils: patch ping to link against libm
In reply to Waldemar BrodkorbHello,
Quoted 16 lines · Waldemar Brodkorb
The root of the problem is rather simple. When you use math library functions you are required to link libm explicitely. I think for historical reasons. For musl this is no issue as everything is included in libc.so. In uClibc world you have the choice and could simply build a system without any math library.
GNU libc seems to have weak aliases for finitef even in libc.so:
nm output/build/glibc-2.22/build/libc.so|grep finitef0002ba9cW finitef0002ba9cT__finitef0002ba9ct__GI___finitefSo linking with GNU libc does not fail for iputils even without -lm.
Not sure, I cannot find every libm function, but some. tgamma or exp10 is not referenced in libc.so.
Quoted 8 lines
May be Mike can explain the Glibc behaviour?
The finite macros where added here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/include/math.h?id=21902b578e96fd6b85b9bcda8a0e929fc844ec51
So 1.0.10 is the first release containing this BSD specific functions in a usable way.I think BR2_*DEBUG* option is not related to this error.
OK, but how do you explain that:
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.11-rc1-71-g90d1299.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_IPUTILS=y
# BR2_TARGET_ROOTFS_TAR is not set
Builds just fine (and uses uClibc 1.0.9) ?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 package/iputils: patch ping to link against libm
Quoted 48 lines · Thomas Petazzoni
Hello,
Quoted 16 lines · Waldemar Brodkorb
The root of the problem is rather simple. When you use math library functions you are required to link libm explicitely. I think for historical reasons. For musl this is no issue as everything is included in libc.so. In uClibc world you have the choice and could simply build a system without any math library.
GNU libc seems to have weak aliases for finitef even in libc.so:
nm output/build/glibc-2.22/build/libc.so|grep finitef0002ba9cW finitef0002ba9cT__finitef0002ba9ct__GI___finitefSo linking with GNU libc does not fail for iputils even without -lm.
Not sure, I cannot find every libm function, but some. tgamma or exp10 is not referenced in libc.so.
Quoted 8 lines
May be Mike can explain the Glibc behaviour?
The finite macros where added here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/include/math.h?id=21902b578e96fd6b85b9bcda8a0e929fc844ec51
So 1.0.10 is the first release containing this BSD specific functions in a usable way.I think BR2_*DEBUG* option is not related to this error.
OK, but how do you explain that:
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.11-rc1-71-g90d1299.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
#BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUGis not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
#BR2_PACKAGE_BUSYBOXis not set
BR2_PACKAGE_IPUTILS=y
#BR2_TARGET_ROOTFS_TARis not set
Quoted 1 line
Builds just fine (and uses uClibc 1.0.9) ?
I think the difference is in gcc versions. It looks like gcc 4.7 in that
external toolchain uses a built-in inline version of __finite(), while gcc 4.9 just calls the external function. I don't think it has anything to do with the uClibc version (though I didn't try all combinations). But for sure, it fails with gcc 4.9 and uClibc 1.0.10 while it succeeds with the same config and gcc 4.7.
I don't think BR2_ENABLE_DEBUG has anything to do with it, but I didn't test that.
Anyway, it seems obvious to me that if you use finite(), then you should link
with -lm. There's bound to be some combination of libc and compiler that requires -lm.
So, maybe add 'and gcc 4.9' to the commit message, but even without it:
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 package/iputils: patch ping to link against libm
Hello,
Quoted 5 lines · Arnout Vandecappelle
I think the difference is in gcc versions. It looks like gcc 4.7 in that
external toolchain uses a built-in inline version of__finite(), while gcc 4.9 just calls the external function. I don't think it has anything to do with the uClibc version (though I didn't try all combinations). But for sure, it fails with gcc 4.9 and uClibc 1.0.10 while it succeeds with the same config and gcc 4.7.
Aaah, okay. Makes sense.
Quoted 5 lines
I don't think
BR2_ENABLE_DEBUGhas anything to do with it, but I didn't test that.Anyway, it seems obvious to me that if you use
finite(), then you should link
with -lm. There's bound to be some combination of libc and compiler that requires -lm.
I fully agree that from the beginning -lm is needed. However, I didn't like the fact that the build failures were not fully understood.
Quoted 1 line
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Thomas Petazzoni
AppliedPATCH 1/1 package/iputils: patch ping to link against libm
In reply to Martin BarkDear Martin Bark,
Quoted 14 lines · Martin Bark
ping fails to compile with uClibc based toolchains with the error
undefined reference to `__finite'
Add a patch to link ping against libm to resolve the math library function
finite().Note, this error is not seen with glibc based toolchains because finite seems to be resolved in both libm and libc.
Fixes:
http://autobuild.buildroot.net/results/08f7386f75c881bc582b338824f8ccd509b2921e/
http://autobuild.buildroot.net/results/5aeef61fbd399dd78dc72b9e7cce978e6f1f58b4/
Quoted 8 lines
A pull request has been sent to fix this issue upstream, see
https://github.com/iputils/iputils/pull/42Signed-off-by Martin Bark <[email protected]>--- package/iputils/0001-ping-link-against-libm.patch | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package/iputils/0001-ping-link-against-libm.patch
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com