package/net-tools: fix static linking issue with lintl
PATCH 1/1 package/net-tools: fix static linking issue with lintl
When net-tools are build with uClibc-ng and statically linked, some tools like hostname and route needs to link with -lintl.
Adding -lintl in LDFLAGS place the library before object files:
arm-linux-gcc -O2 -g -Wall -fno-strict-aliasing -static -lintl -Llib -o hostname hostname.o
Move $(LDFLAGS) after object files in the Makefile.
Fixes:
http://autobuild.buildroot.net/results/134/1345b6d366125320b89512e7ce7f142f1a03acf8
--- ...efile-fix-static-linking-issue-with-lintl.patch | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 package/net-tools/0001-Makefile-fix-static-linking-issue-with-lintl.patch
package/net-tools/0001-Makefile-fix-static-linking-issue-with-lintl.patch new file +81 -0
@@ -0,0 +1,81 @@ +From 1df81dbba3c7809ab345133a2409c49befc31e95 Mon Sep 17 00:00:00 2001 +From: Romain Naour <[email protected]> +Date: Sat, 28 May 2016 15:51:31 +0200 +Subject: [PATCH] Makefile: fix static linking issue with lintl + +When net-tools are build with uClibc-ng and statically linked, +some tools like hostname and route needs to link with -lintl. + +Adding -lintl in LDFLAGS place the library before object files: +arm-linux-gcc -O2 -g -Wall -fno-strict-aliasing -static -lintl -Llib -o hostname hostname.o + +Move $(LDFLAGS) after object files in the Makefile. + +Fixes: +http://autobuild.buildroot.net/results/134/1345b6d366125320b89512e7ce7f142f1a03acf8 + +Signed-off-by: Romain Naour <[email protected]> +--- + Makefile | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/Makefile b/Makefile +index 171123d..4d8d5fc 100644 +--- a/Makefile ++++ b/Makefile +@@ -158,40 +158,40 @@ subdirs: libdir + @for i in $(SUBDIRS:$(NET_LIB_PATH)/=); do $(MAKE) -C $$i || exit $$? ; done + + ifconfig: $(NET_LIB) ifconfig.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ ifconfig.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ ifconfig.o $(LDFLAGS) $(NLIB) + + nameif: $(NET_LIB) nameif.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ nameif.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ nameif.o $(LDFLAGS) $(NLIB) + + hostname: hostname.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ hostname.o $(DNLIB) ++ $(CC) $(CFLAGS) -o $@ hostname.o $(LDFLAGS) $(DNLIB) + + route: $(NET_LIB) route.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ route.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ route.o $(LDFLAGS) $(NLIB) + + arp: $(NET_LIB) arp.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ arp.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ arp.o $(LDFLAGS) $(NLIB) + + rarp: $(NET_LIB) rarp.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rarp.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ rarp.o $(LDFLAGS) $(NLIB) + + slattach: $(NET_LIB) slattach.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ slattach.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ slattach.o $(LDFLAGS) $(NLIB) + + plipconfig: $(NET_LIB) plipconfig.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ plipconfig.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ plipconfig.o $(LDFLAGS) $(NLIB) + + netstat: $(NET_LIB) netstat.o statistics.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ netstat.o statistics.o $(NLIB) $(SELIB) ++ $(CC) $(CFLAGS) -o $@ netstat.o statistics.o $(LDFLAGS) $(NLIB) $(SELIB) + + iptunnel: $(NET_LIB) iptunnel.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ iptunnel.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ iptunnel.o $(LDFLAGS) $(NLIB) + + ipmaddr: $(NET_LIB) ipmaddr.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ ipmaddr.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ ipmaddr.o $(LDFLAGS) $(NLIB) + + mii-tool: $(NET_LIB) mii-tool.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ mii-tool.o $(NLIB) ++ $(CC) $(CFLAGS) -o $@ mii-tool.o $(LDFLAGS) $(NLIB) + + installbin: + @echo +-- +2.5.5 +
Signature · 1 line
2.5.5
PATCH 1/1 package/net-tools: fix static linking issue with lintl
Hello,
Quoted 7 lines · Romain Naour
When net-tools are build with uClibc-ng and statically linked, some tools like hostname and route needs to link with -lintl.
Adding -lintl in LDFLAGS place the library before object files:
arm-linux-gcc -O2 -g -Wall -fno-strict-aliasing -static -lintl -Llib -o hostname hostname.oMove $(LDFLAGS) after object files in the
Makefile.
Thanks. However, I believe a slightly better fix is to add a $(LIBS) variable passed after object files, and keep $(LDFLAGS) where it is today. This is what automake Makefiles are doing, so it seems like the most "standard way". See for example
https://lists.gnu.org/archive/html/autoconf/2004-01/msg00182.html.
And this way, maybe the patch can be submitted upstream? I see that upstream has an active Git repository, so such patches could definitely be upstreamed.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 package/net-tools: fix static linking issue with lintl
Le 28/05/2016 ? 19:30, Thomas Petazzoni a ?crit :
Quoted 9 lines
Hello,
Quoted 6 lines · Romain Naour
When net-tools are build with uClibc-ng and statically linked, some tools like hostname and route needs to link with -lintl.
Adding -lintl in LDFLAGS place the library before object files:
arm-linux-gcc -O2 -g -Wall -fno-strict-aliasing -static -lintl -Llib -o hostname hostname.o
Quoted 7 lines
Quoted 1 line
Move $(LDFLAGS) after object files in the
Makefile.Thanks. However, I believe a slightly better fix is to add a $(LIBS) variable passed after object files, and keep $(LDFLAGS) where it is today. This is what automake Makefiles are doing, so it seems like the most "standard way". See for example
https://lists.gnu.org/archive/html/autoconf/2004-01/msg00182.html.
Thanks for the link, fixed in v2.
Quoted 4 lines
And this way, maybe the patch can be submitted upstream? I see that upstream has an active Git repository, so such patches could definitely be upstreamed.
See the recent discussion on their ML [1], the same issue has already been reported and a similar patch has been submitted.
I'll reply and send mine.
Best regards,
Romain
[1]https://sourceforge.net/p/net-tools/mailman/message/34924345/
Quoted 5 lines
Thanks!
Thomas