package/quagga: fix static linking with getopt
PATCH 1/1 package/quagga: fix static linking with getopt
quagga has its own copy of getopt_long() instead of using the system's, and this copy also defines the opterr and optind variables. Obviously, this is only apparent when linking statically.
This problem can easily be avoided by making sure that getopt() itself is defined too. This way, there is no reason any more to pull in libc's getopt() and the corresponding definitions of opterr and optind. Note that getopt() itself is pulled in by netsnmp, not by quagga itself.
Fortunately, there's a REALLY_NEED_PLAIN_GETOPT flag that we can define to make sure getopt() does get built by quagga. We can safely do this unconditionally (instead of only when BR2_PACKAGE_QUAGGA_SNMP and BR2_STATIC_LIBS are enabled): without netsnmp, getopt() will simply not be used, and with dynamic libs there's no risk of conflicts anyway.
Fixes:
http://autobuild.buildroot.net/results/0ac598c2259a8d7e8b72d4e8ed95079675b31b84
--- package/quagga/quagga.mk | 5 +++++ 1 file changed, 5 insertions(+)
package/quagga/quagga.mk +5 -0
@@ -18,6 +18,11 @@ QUAGGA_CONF_OPTS = \ --sysconfdir=/etc/quagga \ --localstatedir=/var/run/quagga +# quagga has its own internal copy of getopt_long. To avoid conflicts with libc's +# getopt, we need to make sure that the getopt function itself is also built. +QUAGGA_CONF_ENV = \ + CFLAGS="$(TARGET_CFLAGS) -DREALLY_NEED_PLAIN_GETOPT" + ifeq ($(BR2_PACKAGE_LIBCAP),y) QUAGGA_CONF_OPTS += --enable-capabilities QUAGGA_DEPENDENCIES += libcap
Signature · 1 line
2.21.0
Thomas Petazzoni
AppliedPATCH 1/1 package/quagga: fix static linking with getopt
Quoted 15 lines · On Thu, 1 Aug 2019 18:24:08 +0200 "Arnout Vandecappelle (Essensium/Mind)"…
quagga has its own copy of
getopt_long()instead of using the system's, and this copy also defines the opterr and optind variables. Obviously, this is only apparent when linking statically.This problem can easily be avoided by making sure that
getopt()itself is defined too. This way, there is no reason any more to pull in libc'sgetopt()and the corresponding definitions of opterr and optind. Note thatgetopt()itself is pulled in by netsnmp, not by quagga itself.Fortunately, there's a
REALLY_NEED_PLAIN_GETOPTflag that we can define to make suregetopt()does get built by quagga. We can safely do this unconditionally (instead of only whenBR2_PACKAGE_QUAGGA_SNMPandBR2_STATIC_LIBSare enabled): without netsnmp,getopt()will simply not be used, and with dynamic libs there's no risk of conflicts anyway.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/0ac598c2259a8d7e8b72d4e8ed95079675b31b84Cc Fabrice Fontaine <[email protected]>--- package/quagga/quagga.mk | 5 +++++ 1 file changed, 5 insertions(+)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/quagga: fix static linking with getopt
In reply to Arnout Vandecappelle (Essensium/Mind)Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:
quagga has its own copy of
getopt_long()instead of using the system's, and this copy also defines the opterr and optind variables. Obviously, this is only apparent when linking statically.This problem can easily be avoided by making sure that
getopt()itself is defined too. This way, there is no reason any more to pull in libc'sgetopt()and the corresponding definitions of opterr and optind. Note thatgetopt()itself is pulled in by netsnmp, not by quagga itself.Fortunately, there's a
REALLY_NEED_PLAIN_GETOPTflag that we can define to make suregetopt()does get built by quagga. We can safely do this unconditionally (instead of only whenBR2_PACKAGE_QUAGGA_SNMPandBR2_STATIC_LIBSare enabled): without netsnmp,getopt()will simply not be used, and with dynamic libs there's no risk of conflicts anyway.
Quoted 5 lines
Fixes:
http://autobuild.buildroot.net/results/0ac598c2259a8d7e8b72d4e8ed95079675b31b84Cc Fabrice Fontaine <[email protected]>
Committed to 2019.02.x and 2019.05.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard