Skip to contentSkip to conversation

package/Makefile.in: add host-cc-option macro

PATCH New Arnout Vandecappelle (Essensium/Mind) 3 participants 5 messages Jul 3, 2017 – Jul 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/Makefile.in: add host-cc-option macro

This macro allows to test if HOSTCC supports a specific option. It is needed to pass '-no-pie' on recent Debian, Ubuntu and Gentoo hosts.

---
 package/Makefile.in | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
package/Makefile.in +21 -0
index 8087bde999..2dabfd69b2 100644
@@ -222,6 +222,27 @@ HOST_CFLAGS   += $(HOST_CPPFLAGS)
 HOST_CXXFLAGS += $(HOST_CFLAGS)
 HOST_LDFLAGS  += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
 
+# The macros below are taken from linux 4.11 and adapted slightly.
+# Copy more when needed.
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;               \
+	TMP="$$(tempfile)";             \
+	if ($(1)) >/dev/null 2>&1;      \
+	then echo "$(2)";               \
+	else echo "$(3)";               \
+	fi;                             \
+	rm -f "$$TMP")
+
+# host-cc-option
+# Usage: HOST_FOO_CFLAGS += $(call host-cc-option,-no-pie,)
+host-cc-option = $(call try-run,\
+        $(HOSTCC) $(HOST_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+
+
 # host-intltool should be executed with the system perl, so we save
 # the path to the system perl, before a host-perl built by Buildroot
 # might get installed into $(HOST_DIR)/usr/bin and therefore appears
Signature · 1 line
2.13.2
#1 lore raw

PATCH 2/2 package/aespipe: fix host compile

From: Bernd Kuhls <[email protected]>

Building host-aespipe fails on Debian stretch at linking stage:

/usr/bin/gcc -L/home/buildroot/br6/output/host/lib -L/home/buildroot/br6/output/host/usr/lib -Wl,-rpath,/home/buildroot/br6/output/host/usr/lib -o aespipe aespipe.o aes-amd64.o md5-amd64.o md5-2x-amd64.o aes-intel64.o sha512.o rmd160.o /usr/bin/ld: aes-amd64.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

The same problem apparently exists on recent Ubuntu and Gentoo.

Fix is also used in Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837393

[Peter: add comment explaining why]
[Arnout: use host-cc-option to discover if -no-pie is available;
cfr. 57b628a932b9b4a3c4bf80f4c82a81da5adcb173]

---
 package/aespipe/aespipe.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/aespipe/aespipe.mk +10 -0
index 6a38556ef1..5ef95d5206 100644
@@ -9,5 +9,15 @@ AESPIPE_SOURCE = aespipe-v$(AESPIPE_VERSION).tar.bz2
 AESPIPE_SITE = http://loop-aes.sourceforge.net/aespipe
 AESPIPE_LICENSE = GPL
 
+# Recent Debian, Gentoo and Ubuntu enable -fPIE by default, breaking the build:
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837393
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835148
+# Older gcc versions however don't support the -no-pie flag, so we have to
+# check its availability.
+HOST_AESPIPE_NO_PIE_FLAG = $(call host-cc-option,-no-pie)
+HOST_AESPIPE_CONF_ENV = \
+	CFLAGS="$(HOST_CFLAGS) $(HOST_AESPIPE_NO_PIE_FLAG)" \
+	LDFLAGS="$(HOST_LDFLAGS) $(HOST_AESPIPE_NO_PIE_FLAG)"
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 1 line
2.13.2
#2 lore raw

PATCH 2/2 package/aespipe: fix host compile

Quoted 18 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:

From: Bernd Kuhls <[email protected]>
Building host-aespipe fails on Debian stretch at linking stage:

/usr/bin/gcc -L/home/buildroot/br6/output/host/lib

(quoted diff) +0 -2
-L/home/buildroot/br6/output/host/usr/lib
-Wl,-rpath,/home/buildroot/br6/output/host/usr/lib -o aespipe

aespipe.o aes-amd64.o md5-amd64.o md5-2x-amd64.o aes-intel64.o sha512.o rmd160.o
/usr/bin/ld: aes-amd64.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

The same problem apparently exists on recent Ubuntu and Gentoo.

Fix is also used in Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837393

Quoted 6 lines

[Peter: add comment explaining why]
[Arnout: use host-cc-option to discover if -no-pie is available;
cfr. 57b628a932b9b4a3c4bf80f4c82a81da5adcb173]

Committed to 2017.02.x and 2017.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/2 package/Makefile.in: add host-cc-option macro

In reply to Arnout Vandecappelle (Essensium/Mind)

Hello,

Quoted 7 lines · Arnout Vandecappelle (Essensium/Mind)

This macro allows to test if HOSTCC supports a specific option. It is needed to pass '-no-pie' on recent Debian, Ubuntu and Gentoo hosts.

---
 package/Makefile.in | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Both applied. Thanks!

Thomas

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

PATCH 1/2 package/Makefile.in: add host-cc-option macro

In reply to Arnout Vandecappelle (Essensium/Mind)
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:

This macro allows to test if HOSTCC supports a specific option. It is needed to pass '-no-pie' on recent Debian, Ubuntu and Gentoo hosts.

Committed to 2017.02.x and 2017.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard