llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Nicolas Schier <nicolas.schier@linux.dev>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] kbuild: userprogs: use correct linker when mixing clang and GNU ld
Date: Tue, 29 Jul 2025 17:47:17 -0700	[thread overview]
Message-ID: <20250730004717.GA2984390@ax162> (raw)
In-Reply-To: <20250725122604-44874f95-859c-4c0a-b3b0-14b30e00b796@linutronix.de>

On Fri, Jul 25, 2025 at 12:36:34PM +0200, Thomas Weißschuh wrote:
> FWIW some architectures use GNU ld implicitly with clang because they also link
> through $(CC) but do not use --ld-path. One example is UML, where the vDSO and
> vmlinux are linked this way. But linking vmlinux of UML with ld.lld will
> require changes to at least the linker script. Something for the ClangBuiltLinux
> TODO? There were more examples, but I don't remember them right now.

Yes, I believe this is the issue we had for tracking using ld.lld with
UML: https://github.com/ClangBuiltLinux/linux/issues/1715

I had not considered that it could be a linker script handling
difference. I will have to look into that soon.

> Longterm --ld-path should probably be added to the global KBUILD_CFLAGS, too.

'--ld-path' is only relevant when the linking phase is run by the
compiler, which is not really normal for the primary kernel build, as
calling the linker directly with $(LD) is preferred. Doing that would
break the build because of -Werror=unused-command-line-argument, which
is needed to make cc-option work correctly.

  $ echo 'int main(void) { return 0; }' | /usr/bin/clang --ld-path=/usr/bin/ld.lld -c -o /dev/null -x c -
  clang: warning: argument unused during compilation: '--ld-path=/usr/bin/ld.lld' [-Wunused-command-line-argument]

  $ echo 'int main(void) { return 0; }' | /usr/bin/clang --ld-path=/usr/bin/ld.lld -o /dev/null -x c -

> No, it isn't respected. On the other hand I didn't yet run into any issues.
> Do we want to fix it proactively?

No, I think it is fine to just leave it as is and fix it if it comes up
in the future, as I believe getting LLVM_IAS=1 working for sparc64 is
the next major focus of the whole LLVM sparc endeavour.

Cheers,
Nathan

      parent reply	other threads:[~2025-07-30  0:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  8:32 [PATCH] kbuild: userprogs: use correct linker when mixing clang and GNU ld Thomas Weißschuh
2025-07-24 23:10 ` Nathan Chancellor
2025-07-25 10:36   ` Thomas Weißschuh
2025-07-26 10:34     ` Masahiro Yamada
2025-07-30  0:47     ` Nathan Chancellor [this message]

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=20250730004717.GA2984390@ax162 \
    --to=nathan@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=morbo@google.com \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=nicolas.schier@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).