All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Andi Kleen <ak@linux.intel.com>
Cc: Nicolas Pitre <nico@linaro.org>,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 7/7] Kbuild: lto: pass -m32/-m64 to to LDFINAL
Date: Fri,  2 Feb 2018 17:21:04 +0100	[thread overview]
Message-ID: <20180202162104.2300532-7-arnd@arndb.de> (raw)
In-Reply-To: <20180202161550.2106846-1-arnd@arndb.de>

Building randconfig kernels with a biarch compiler fails with LTO
when the final link uses a different target architecture compared
to the earlier compilation stages.

Setting -m32 or -m64 in ${LDFINAL} solves this problem, though my
feeling is that there is a better way to do this. There might also
be other from KBUILD_CFLAGS that we may need in LDFINAL.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile             | 2 +-
 arch/x86/Makefile    | 2 ++
 scripts/Makefile.lto | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 3b214c5a51a5..1a82fa39f82b 100644
--- a/Makefile
+++ b/Makefile
@@ -440,7 +440,7 @@ export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN
 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
-export KBUILD_ARFLAGS
+export KBUILD_ARFLAGS KBUILD_BIARCHFLAGS
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index e79f0fda9aea..12425aafc7fc 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -69,6 +69,7 @@ ifeq ($(CONFIG_X86_32),y)
         biarch := $(call cc-option,-m32)
         KBUILD_AFLAGS += $(biarch)
         KBUILD_CFLAGS += $(biarch)
+	KBUILD_BIARCHFLAGS += $(biarch)
 
         KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
 
@@ -97,6 +98,7 @@ else
         biarch := -m64
         KBUILD_AFLAGS += -m64
         KBUILD_CFLAGS += -m64
+	KBUILD_BIARCHFLAGS += $(biarch)
 
         # Align jump targets to 1 byte, not the default 16 bytes:
         KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
diff --git a/scripts/Makefile.lto b/scripts/Makefile.lto
index 2d6995ba7d0b..e57d025b7728 100644
--- a/scripts/Makefile.lto
+++ b/scripts/Makefile.lto
@@ -72,7 +72,7 @@ endif
 	KBUILD_CFLAGS += ${LTO_CFLAGS}
 
 	LDFINAL := ${CONFIG_SHELL} ${srctree}/scripts/gcc-ld \
-                  ${LTO_FINAL_CFLAGS}
+                  ${LTO_FINAL_CFLAGS} ${KBUILD_BIARCHFLAGS}
 
 	# LTO gcc creates a lot of files in TMPDIR, and with /tmp as tmpfs
 	# it's easy to drive the machine OOM. Use the object directory
-- 
2.9.0

  parent reply	other threads:[~2018-02-02 16:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 16:15 [PATCH 0/7] LTO: hacks to build LTO-enabled randconfig kernels Arnd Bergmann
2018-02-02 16:15 ` Arnd Bergmann
2018-02-02 16:15 ` [PATCH 1/7] [HACK] lto: make config.gz symbol visible Arnd Bergmann
2018-02-02 16:15   ` Arnd Bergmann
2018-02-02 16:20 ` [PATCH 2/7] [HACK] x86: lto: always link in library files Arnd Bergmann
2018-02-02 16:21 ` [PATCH 3/7] [HACK] x86: crypto: fix link error with LTO Arnd Bergmann
2018-02-02 19:49   ` Nicolas Pitre
2018-02-02 22:18     ` Arnd Bergmann
2018-02-02 16:21 ` [PATCH 4/7] [HACK] lto: shut up some warnings Arnd Bergmann
2018-02-02 16:21 ` [PATCH 5/7] [HACK] avoid gcc-8 ICE on LTO Arnd Bergmann
2018-02-02 17:04   ` Joe Perches
2018-02-02 16:21 ` [PATCH 6/7] Kbuild: lto: clean build artifacts Arnd Bergmann
2018-02-02 16:21 ` Arnd Bergmann [this message]
2018-02-02 18:41   ` [PATCH 7/7] Kbuild: lto: pass -m32/-m64 to to LDFINAL Nicolas Pitre
2018-02-02 20:18     ` Arnd Bergmann
2018-02-02 20:38       ` Nicolas Pitre
2018-02-02 20:55         ` Arnd Bergmann
2018-02-02 21:17           ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180202162104.2300532-7-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=ak@linux.intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.