archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <>
To: Masahiro Yamada <>,
	Michal Marek <>,
	Nick Desaulniers <>
	Sedat Dilek <>,
	Fangrui Song <>,
	Nathan Chancellor <>
Subject: [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as
Date: Tue,  9 Mar 2021 13:59:15 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

When building with LLVM_IAS=1, there is no point to specifying
'--prefix=' because that flag is only used to find GNU cross tools,
which will not be used indirectly when using the integrated assembler.
All of the tools are invoked directly from PATH or a full path specified
via the command line, which does not depend on the value of '--prefix='.

Sharing commands to reproduce issues becomes a little bit easier without
a '--prefix=' value because that '--prefix=' value is specific to a
user's machine due to it being an absolute path.

Some further notes from Fangrui Song:

  clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU
  objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]).
  objcopy is only used for GNU as assembled object files.
  With integrated assembler, the object file streamer creates .o and
  .dwo simultaneously.
  With GNU as, two objcopy commands are needed to extract .debug*.dwo to
  .dwo files && another command to remove .debug*.dwo sections.

A small consequence of this change (to keep things simple) is that
'--prefix=' will always be specified now, even with a native build, when
it was not before. This should not be an issue due to the way that the
Makefile searches for the prefix (based on elfedit's location). This
ends up improving the experience for host builds because PATH is better
respected and matches GCC's behavior more closely. See the below thread
for more details:

Signed-off-by: Nathan Chancellor <>

v1 -> v2:

* Fix position of -no-integrated-as flag to fix native build (thanks to
  Masahiro for catching it and sorry for the breakage).

* Add Fangrui's comments about what GNU binaries clang can spawn at
  Masahiro's request.

* Reword commit message.

I did not carry tags forward so that people could re-review and test.

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 182e93d91198..15292a6d63f5 100644
--- a/Makefile
+++ b/Makefile
@@ -566,11 +566,11 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g
 ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
 ifneq ($(CROSS_COMPILE),)
 CLANG_FLAGS	+= --target=$(notdir $(CROSS_COMPILE:%-=%))
-GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
 ifneq ($(LLVM_IAS),1)
 CLANG_FLAGS	+= -no-integrated-as
+GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
 CLANG_FLAGS	+= -Werror=unknown-warning-option

  reply	other threads:[~2021-03-09 21:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor
2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor
2021-03-02 22:02   ` Fangrui Song
2021-03-02 22:09     ` Nick Desaulniers
2021-03-02 22:40       ` Nick Desaulniers
2021-03-09 19:55   ` Masahiro Yamada
2021-03-09 19:58     ` Masahiro Yamada
2021-09-29 17:26   ` kernel test robot
2021-09-29 19:32   ` kernel test robot
2021-03-02 21:43 ` [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song
2021-03-03  8:33   ` Masahiro Yamada
2021-03-02 22:33 ` Nick Desaulniers
2021-03-03  3:25 ` Sedat Dilek
2021-03-03 14:22   ` Sedat Dilek
2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor
2021-03-09 20:59   ` Nathan Chancellor [this message]
2021-03-09 21:15   ` Fangrui Song
2021-03-15 16:21   ` Masahiro Yamada
2021-03-15 16:41     ` Sedat Dilek
2021-03-16 15:36       ` Masahiro Yamada

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \

* 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).