package/axel: fix link order
PATCH 1/1 package/axel: fix link order
libintl may use thread-related functions, so -lpthread must come after -lintl.
Fixes:
http://autobuild.buildroot.org/results/e9d/e9d89fd5b24a76a3c5ab9dc8f01f4643f7c13396/
--- package/axel/axel.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
package/axel/axel.mk +3 -2
@@ -9,13 +9,14 @@ AXEL_SITE = http://sources.buildroot.net AXEL_LICENSE = GPLv2+ AXEL_LICENSE_FILES = COPYING -AXEL_LDFLAGS = -lpthread - ifeq ($(BR2_NEEDS_GETTEXT_IF_LOCALE),y) AXEL_DEPENDENCIES += gettext AXEL_LDFLAGS += -lintl endif +# -lintl may use symbols from -pthread +AXEL_LDFLAGS += -lpthread + ifneq ($(BR2_ENABLE_LOCALE),y) AXEL_DISABLE_I18N = --i18n=0 endif
Signature · 1 line
2.7.4
PATCH 1/1 package/axel: fix link order
Quoted 17 lines · Yann E. MORIN
libintl may use thread-related functions, so -lpthread must come after -lintl.
Fixes:
http://autobuild.buildroot.org/results/e9d/e9d89fd5b24a76a3c5ab9dc8f01f4643f7c13396/Signed-off-by "Yann E. MORIN" <[email protected]>--- package/axel/axel.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)package/axel/axel.mk +0
-0@@ -9,13 +9,14 @@ AXEL_SITE = http://sources.buildroot.net AXEL_LICENSE = GPLv2+
package/axel/axel.mk AXEL_SITE = http://sources.buildroot.net · line 17
Quoted 10 lines
package/axel/axel.mk +1
-2AXEL_LICENSE_FILES = COPYING -AXEL_LDFLAGS = -lpthread - ifeq ($(BR2_NEEDS_GETTEXT_IF_LOCALE),y) AXEL_DEPENDENCIES += gettext AXEL_LDFLAGS += -lintl endif +# -lintl may use symbols from -pthread
Either pthread or -lpthread or libpthread, but not -pthread. I think if you use
-pthread that gcc (or collect2?) _will_ put it in the right order.
Even so:
Regards,
Arnout
Quoted 6 lines
package/axel/axel.mk +2
-0+AXEL_LDFLAGS += -lpthread + ifneq ($(BR2_ENABLE_LOCALE),y) AXEL_DISABLE_I18N = --i18n=0 endif
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/axel: fix link order
In reply to Yann E. MORINQuoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
libintl may use thread-related functions, so -lpthread must come after -lintl.
Fixes:
http://autobuild.buildroot.org/results/e9d/e9d89fd5b24a76a3c5ab9dc8f01f4643f7c13396/Signed-off-by "Yann E. MORIN" <[email protected]>--- package/axel/axel.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)package/axel/axel.mk +0
-0@@ -9,13 +9,14 @@ AXEL_SITE = http://sources.buildroot.net AXEL_LICENSE = GPLv2+ AXEL_LICENSE_FILES = COPYING
package/axel/axel.mk AXEL_SITE = http://sources.buildroot.net · line 18
Quoted 10 lines
package/axel/axel.mk +2
-2-AXEL_LDFLAGS = -lpthread - ifeq ($(BR2_NEEDS_GETTEXT_IF_LOCALE),y) AXEL_DEPENDENCIES += gettext AXEL_LDFLAGS += -lintl endif +# -lintl may use symbols from -pthread +AXEL_LDFLAGS += -lpthread
Committed after s/pthread/lpthread/ as suggested by Arnout, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/axel: fix link order
In reply to Yann E. MORINHello,
Quoted 7 lines · Yann E. MORIN
libintl may use thread-related functions, so -lpthread must come after -lintl.
Fixes:
http://autobuild.buildroot.org/results/e9d/e9d89fd5b24a76a3c5ab9dc8f01f4643f7c13396/Signed-off-by "Yann E. MORIN" <[email protected]>
I am not really happy with this patch. Indeed, when we're doing dynamic linking, libintl.so is *not* linked with libpthread, so I don't see why it should be when statically linking. See:
$ readelf -aW output/target/usr/lib/libintl.so.8.1.5 |grep NEEDED 0x00000001 (NEEDED) Shared library: [libc.so.0]
I am wondering if this is not simply yet another case where the libc is supposed to provide those symbols, so that linking with libpthread is not necessary if the application doesn't use threads.
Indeed, build the following configuration:
BR2_microblazeel=y
BR2_STATIC_LIBS=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-microblaze-full-2016.08-rc1-4-g07e8d1c.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_18=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_NPTL 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_AXEL=y
# BR2_TARGET_ROOTFS_TAR is not set
(which will reproduce the build issue, provided that Yann's patch is not applied).
Then, build the following program:
#include <libintl.h>
int main(void) { dgettext(NULL, NULL); return 0; }
This program does not use threads, so there is no reason to link it with libpthread. But it anyway fails to link with:
$ ./output/host/usr/bin/microblazeel-linux-gcc -o toto toto.c -lintl /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `_nl_find_msg': (.text+0xaa4): undefined reference to `pthread_rwlock_rdlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `_nl_find_msg': (.text+0xb20): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `_nl_find_msg': (.text+0xb34): undefined reference to `pthread_rwlock_wrlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `_nl_find_msg': (.text+0xbd4): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `_nl_find_msg': (.text+0xce0): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x1020): undefined reference to `pthread_rwlock_rdlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x10b0): undefined reference to `pthread_rwlock_rdlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x10e4): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x1140): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x15a4): undefined reference to `pthread_rwlock_wrlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x15d8): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x1664): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(dcigettext.o): In function `libintl_dcigettext': (.text+0x1688): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(finddomain.o): In function `_nl_find_domain': (.text+0x38): undefined reference to `pthread_rwlock_rdlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(finddomain.o): In function `_nl_find_domain': (.text+0xa4): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(finddomain.o): In function `_nl_find_domain': (.text+0x180): undefined reference to `pthread_rwlock_wrlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(finddomain.o): In function `_nl_find_domain': (.text+0x1ec): undefined reference to `pthread_rwlock_unlock' /home/thomas/projets/buildroot2/output/host/usr/microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/libintl.a(loadmsgcat.o): In function `_nl_load_domain': (.text+0x1a54): undefined reference to `pthread_rwlock_init' collect2: error: ld returned 1 exit status
Note however how only the pthread_rwlock_*() symbols are missing: the pthread_mutex_*() symbols are not causing any problem, because they are apparently provided by libc.a.
I still believe there's something wrong going on here, and blindly linking everything with libpthread is not the right thing to do. In the case of axel, it is OK because axel itself uses threads, but it is not a generally correct solution.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com