Blob Blame Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <>
Date: Fri, 12 Jul 2019 17:45:51 +0200
Subject: [PATCH] Try to set -fPIE and friends on libgnu.a

In order to make sure UTIL_CFLAGS and UTIL_LDFLAGS can correctly get
-Wl,-z,relro,-z,now , we need everything going in them to be built with at
least -fPIC (and preferably -fPIE) wherever we can, or else we get relocations
in some component object that can't be used with the link type that's being
used for the final ELF object.

So this makes sure libgnu.a gets built with HOST_CFLAGS and HOST_LDFLAGS,
which are what is later used to define UTIL_CFLAGS and UTIL_LDFLAGS, and
includes -fPIE.

Fixes an rpmdiff check.

Related: rhbz#1658500

Signed-off-by: Peter Jones <>
[javierm: replace from bootstrap instead patching generated]
Signed-off-by: Javier Martinez Canillas <>
 bootstrap.conf | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bootstrap.conf b/bootstrap.conf
index 8804d5beb89..29a6a3e90e2 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -82,6 +82,9 @@ bootstrap_post_import_hook () {
     patch -d grub-core/lib/gnulib -p2 \
       < "grub-core/lib/gnulib-patches/$patchname.patch"
+  for flagvar in CPPFLAGS CFLAGS; do
+    sed -i -e "s/^AM_$flagvar =/AM_$flagvar = \$(HOST_$flagvar)/" grub-core/lib/gnulib/
+  done
   set +e  # bootstrap expects this