Skip to contentSkip to conversation

package/ntp: fix aarch64/mips build, -fPIC required

PATCH New Romain Naour 3 participants 4 messages May 13, 2017 – May 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ntp: fix aarch64/mips build, -fPIC required

Add -fPIC to CFLAGS to avoid ntpsnmpd link issues with libntpq.a

Fixes:
[aarch64] http://autobuild.buildroot.net/results/866/866b1d28595efd8b6becf83d0a64b596538d58b0
[mips] http://autobuild.buildroot.net/results/c2a/c2a945855172970736a8ffea9c564f029a023344

---
 package/ntp/ntp.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/ntp/ntp.mk +6 -0
index cd6cb16..9b65c5e 100644
@@ -20,6 +20,12 @@ NTP_CONF_OPTS = \
 	--disable-local-libevent \
 	--with-crypto
 
+# ntp build unconditionnaly some static libraries (libntpq.a, libntp.a etc...)
+# The build system fail to create ntpsnmpd while linking these libraries when
+# built without -fPIC.
+NTP_CONF_ENV += \
+	CFLAGS="-fPIC $(TARGET_CFLAGS)"
+
 # 0002-ntp-syscalls-fallback.patch
 NTP_AUTORECONF = YES
 
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 package/ntp: fix aarch64/mips build, -fPIC required

Hello,

package/ntp/ntp.mk NTP_CONF_OPTS = \ · line 27

Quoted 5 lines · Romain Naour
package/ntp/ntp.mk +5 -0
+# ntp build unconditionnaly some static libraries (libntpq.a, libntp.a etc...)
+# The build system fail to create ntpsnmpd while linking these libraries when
+# built without -fPIC.
+NTP_CONF_ENV += \
+	CFLAGS="-fPIC $(TARGET_CFLAGS)"

Thanks for this analysis. However, I was a bit surprised by your patch, because I saw many -fPIC all over the place in the ntp build log, even without your patch.

So I dug a little bit deeper, and found this Gentoo patch
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=494143c3b4921a5c8b8596d58f2c8b98296bf688,
which simply re-adds the proper flags to just the ntpq module. And this does indeed solve the issue.

So I've instead committed a patch that adds the Gentoo patch. Thanks anyway for your initial analysis, it was very useful to understand what was going on.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/ntp: fix aarch64/mips build, -fPIC required

Hi Romain and Thomas,

thank you very much for fixing this! It's sad that we have to use such kind of hacks or patches to fix something that shouldn't happen at all, since the ntp configure script can accept --with-pic=yes.

Anyway, glad to see this fixed :-) Thanks again!

Vincent

Quoted 27 lines · Thomas Petazzoni

Hello,

package/ntp/ntp.mk NTP_CONF_OPTS = \ · line 27

Quoted 5 lines · Romain Naour
package/ntp/ntp.mk +5 -0
+# ntp build unconditionnaly some static libraries (libntpq.a, libntp.a etc...)
+# The build system fail to create ntpsnmpd while linking these libraries when
+# built without -fPIC.
+NTP_CONF_ENV += \
+	CFLAGS="-fPIC $(TARGET_CFLAGS)"

Thanks for this analysis. However, I was a bit surprised by your patch, because I saw many -fPIC all over the place in the ntp build log, even without your patch.

So I dug a little bit deeper, and found this Gentoo patch
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=494143c3b4921a5c8b8596d58f2c8b98296bf688,
which simply re-adds the proper flags to just the ntpq module. And this does indeed solve the issue.

So I've instead committed a patch that adds the Gentoo patch. Thanks anyway for your initial analysis, it was very useful to understand what was going on.

Best regards,

Thomas

#3 lore raw

PATCH 1/1 package/ntp: fix aarch64/mips build, -fPIC required

Hello,

Quoted 3 lines · Vicente Olivert Riera

thank you very much for fixing this! It's sad that we have to use such kind of hacks or patches to fix something that shouldn't happen at all, since the ntp configure script can accept --with-pic=yes.

Not sure what you mean here. The ntp configure script detects if fPIC is needed or not. The only thing that was missing is that this flag was not propagated to ntpq/Makefile.am.

See my final commit,
https://git.buildroot.org/buildroot/commit/?id=7fde83cdf0da338937dae13144eea2923e5c2730.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com