mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>, Tom Rix <trix@redhat.com>,
	linux-kbuild@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH 1/5] try generic compiler name "cc" before falling back to "gcc".
Date: Thu, 23 Feb 2023 07:50:14 -0600	[thread overview]
Message-ID: <380c88ef-eb19-e73e-0ec9-805b8b90e957@landley.net> (raw)
In-Reply-To: <CAK7LNASA+Dpe9nv4afnueFeRj4BZDUccOFGJRPr7_rZQ7ZZKaA@mail.gmail.com>

On 2/22/23 23:31, Masahiro Yamada wrote:
> On Wed, Feb 22, 2023 at 5:41 AM Rob Landley <rob@landley.net> wrote:
>>
>> Distros like debian install the generic "cc" name for both gcc and clang,
>> and the plumbing already does CC_VERSION_TEXT to include Makefile.clang.
>>
>> Previously: https://lkml.iu.edu/hypermail/linux/kernel/2202.0/01505.html
>> Signed-off-by: Rob Landley <rob@landley.net>
>> ---
>>  Makefile | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 3f6628780eb2..0ac57ae3b45f 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -456,7 +456,7 @@ endif
>>  HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
>>  HOSTCXX        = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX)
>>  else
>> -HOSTCC = gcc
>> +HOSTCC := $(shell cc --version >/dev/null 2>&1 && echo cc || echo gcc)
> 
> 'cc' only makes sense for the host compiler,

It was the generic posix name for "C compiler" until posix decided to put an
expiration date in the command name, which seems as widely honored as the
tar->pax switch or the removal of cpio.

The name "gcc" was like "gmake" and "gawk". (On macos homebrew there's "gsed".)

> which is configured by 'update-alternative'.

Hexagon only has llvm support, not gcc, so I had to add an llvm cross compiler
to my cross compiler set, prefixed hexagon-unknown-linux-musl-*, but the linux
kernel wants to call it as hexagon-unknown-linux-musl-gcc.

The kernel builds find with a "gcc" symlink to clang, but there _is_ a generic
name, which is widely installed.

> I tried it before, but LLVM folks preferred
> using $(LLVM) to choose clang/gcc.

So if we want generic behavior without having to specify, we should create a
"gcc" symlink to clang?

>>  HOSTCXX        = g++
>>  endif
>>  HOSTRUSTC = rustc
>> @@ -503,7 +503,8 @@ OBJDUMP             = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
>>  READELF                = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
>>  STRIP          = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>>  else
>> -CC             = $(CROSS_COMPILE)gcc
>> +CC             := $(CROSS_COMPILE)$(shell $(CROSS_COMPILE)cc --version \
>> +                       >/dev/null 2>&1 && echo cc || echo gcc)
> 
> This hunk sets up GCC/binutils.

This is the codepath that's taken when you don't explicitly specify "LLVM=1".
The test there is falling back to (appropriately prefixed) gcc when it can't
find a working (appropriately prefixed) cc.

> So, cc does not make sense.  NACK.

Do you explicitly specify the "gold" linker vs the previous gnu one vs
lld.llvm.org on the kernel build command line?

Rob

  reply	other threads:[~2023-02-23 13:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 20:53 [PATCH 0/5] Patches used to build mkroot Rob Landley
2023-02-21 20:55 ` [PATCH 1/5] try generic compiler name "cc" before falling back to "gcc" Rob Landley
2023-02-23  5:31   ` Masahiro Yamada
2023-02-23 13:50     ` Rob Landley [this message]
2023-02-24  0:27       ` Masahiro Yamada
2023-02-21 20:56 ` [PATCH 2/5] X86-64 should not uniquely require a third ELF package to build Rob Landley
2023-02-21 23:12   ` Thomas Gleixner
2023-02-22 18:14     ` Rob Landley
2023-02-22 18:41       ` Thomas Gleixner
2023-02-21 20:57 ` [PATCH 3/5] Wire up CONFIG_DEVTMPFS_MOUNT to initramfs Rob Landley
2023-02-21 21:00 ` [PATCH 4/5] Replace timeconst.bc with mktimeconst.c Rob Landley
2023-02-21 23:53   ` Thomas Gleixner
2023-02-22 22:52     ` Rob Landley
2023-02-21 21:04 ` [PATCH 5/5] fix rootfstype=tmpfs Rob Landley
2023-11-01 13:10   ` Stefan Berger
2023-11-08 22:05     ` Stefan Berger
2023-11-09 16:42       ` Rob Landley
2023-11-09 16:46         ` Rob Landley
2023-11-09 16:55           ` Rob Landley
2023-02-23 20:35 ` [PATCH 0/5] Patches used to build mkroot Andrew Morton

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=380c88ef-eb19-e73e-0ec9-805b8b90e957@landley.net \
    --to=rob@landley.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=trix@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®