Skip to contentSkip to conversation

openntpd: fix linking problem when building statically

PATCH New Vicente Olivert Riera 2 participants 2 messages Sep 7, 2015 – Nov 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 openntpd: fix linking problem when building statically

The problem looks like this:

CCLD ntpd
../compat/.libs/libcompat.a(libcompat_la-arc4random.o): In function `arc4random':
/br/output/build/openntpd-5.7p4/compat/arc4random.c:183: undefined reference to pthread_mutex_lock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:185: undefined reference to pthread_mutex_unlock' ../compat/.libs/libcompat.a(libcompat_la-arc4random.o): In function `arc4random_buf':
/br/output/build/openntpd-5.7p4/compat/arc4random.c:192: undefined reference to pthread_mutex_lock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:194: undefined reference to pthread_mutex_unlock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:194: undefined reference to `pthread_mutex_unlock'
collect2: error: ld returned 1 exit status

Adding -pthread to LDFLAGS fixes the problem.

Fixes:

http://autobuild.buildroot.net/results/b12/b120b6da87ae4eb355d06f2fd8f4fc8050410897/

---
 package/openntpd/openntpd.mk |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
package/openntpd/openntpd.mk +5 -0
index d51f902..816001a 100644
@@ -9,6 +9,11 @@ OPENNTPD_SITE = http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD
 OPENNTPD_LICENSE = MIT-like, BSD-2c, BSD-3c
 OPENNTPD_LICENSE_FILES = COPYING
 
+# openntpd needs -pthread if linking statically
+ifeq ($(BR2_STATIC_LIBS),y)
+OPENNTPD_CONF_ENV += LDFLAGS="$(TARGET_LDFLAGS) -pthread"
+endif
+
 define OPENNTPD_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 0644 package/openntpd/ntpd.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/ntpd.service
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 openntpd: fix linking problem when building statically

Quoted 36 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vicente" == Vicente Olivert Riera <[email protected]> writes:

The problem looks like this:
CCLD ntpd
../compat/.libs/libcompat.a(libcompat_la-arc4random.o): In function `arc4random':
/br/output/build/openntpd-5.7p4/compat/arc4random.c:183: undefined reference to pthread_mutex_lock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:185: undefined reference to pthread_mutex_unlock' ../compat/.libs/libcompat.a(libcompat_la-arc4random.o): In function `arc4random_buf':
/br/output/build/openntpd-5.7p4/compat/arc4random.c:192: undefined reference to pthread_mutex_lock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:194: undefined reference to pthread_mutex_unlock' /br/output/build/openntpd-5.7p4/compat/arc4random.c:194: undefined reference to `pthread_mutex_unlock'
collect2: error: ld returned 1 exit status

Adding -pthread to LDFLAGS fixes the problem.

Fixes:

http://autobuild.buildroot.net/results/b12/b120b6da87ae4eb355d06f2fd8f4fc8050410897/

---
 package/openntpd/openntpd.mk |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
package/openntpd/openntpd.mk +0 -0
index d51f902..816001a 100644

package/openntpd/openntpd.mk OPENNTPD_SITE = http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD · line 16

Quoted 8 lines
package/openntpd/openntpd.mk +5 -0
@@ -9,6 +9,11 @@ OPENNTPD_SITE = http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD
 OPENNTPD_LICENSE = MIT-like, BSD-2c, BSD-3c
 OPENNTPD_LICENSE_FILES = COPYING
 
+# openntpd needs -pthread if linking statically
+ifeq ($(BR2_STATIC_LIBS),y)
+OPENNTPD_CONF_ENV += LDFLAGS="$(TARGET_LDFLAGS) -pthread"
+endif
+

-pthread both affects compilation (it normally adds -D_REENTRANT) and linking, so we should afaik pass it in CFLAGS instead. It isn't really a problem with static linking (but something else probably pulls in libpthread when linking dynamically) so I've changed it to pass -pthread unconditionally and added a note about why.

Committed with that fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard