Linux Perf Users
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: sashiko-reviews@lists.linux.dev
Cc: dmitry.torokhov@gmail.com, bpf@vger.kernel.org,
	linux-input@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 5/6] tools/build: selftests: Allow versioning LLVM lld
Date: Fri, 15 May 2026 09:25:13 +0100	[thread overview]
Message-ID: <69034d26-e886-48f2-a20b-524854a5c00f@linaro.org> (raw)
In-Reply-To: <20260514184543.C6400C2BCB3@smtp.kernel.org>



On 14/05/2026 7:45 pm, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Using `-fuse-ld=ld.lld` breaks compilation of BPF selftests with GCC.
> --
> 
> commit 18e1876d18fad631b521da817483ba47293a9020
> Author: James Clark <james.clark@linaro.org>
> 
> tools/build: selftests: Allow versioning LLVM lld
> 
> This commit updates Makefile.include to add an LLD variable, matching the
> rest of the LLVM toolchain. It modifies the BPF selftests Makefile to use
> this new LLD variable instead of hardcoding lld.
> 
>> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
>> index 380ad84ac51e6..5c2d505cba62b 100644
>> --- a/tools/scripts/Makefile.include
>> +++ b/tools/scripts/Makefile.include
> [ ... ]
>> @@ -91,6 +92,7 @@ else
>>     # Some tools still require Clang, LLC and/or LLVM utils
>>     $(call allow-override,CLANG,clang)
>>     $(call allow-override,LLC,llc)
>> +  $(call allow-override,LLD,ld.lld)
> 
> Could setting LLD to ld.lld when not using LLVM cause issues for BPF
> selftests compilation with GCC?
> 

$(LLD) is only used in one place, and it's used with $(CLANG) so this is 
impossible.

>>     $(call allow-override,LLVM_CONFIG,llvm-config)
>>     $(call allow-override,LLVM_OBJCOPY,llvm-objcopy)
>>     $(call allow-override,LLVM_STRIP,llvm-strip)
>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>> index 6ef6872adbc3e..44ba829e5d4dd 100644
>> --- a/tools/testing/selftests/bpf/Makefile
>> +++ b/tools/testing/selftests/bpf/Makefile
>> @@ -245,9 +245,9 @@ $(OUTPUT)/%:%.c
>>   
>>   # LLVM's ld.lld doesn't support all the architectures, so use it only on x86
>>   ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 riscv))
>> -LLD := lld
>> +USE_LD := $(LLD)
>>   else
>> -LLD := $(shell command -v $(LD))
>> +USE_LD := $(shell command -v $(LD))
>>   endif
>>   
>>   # Filter out -static for liburandom_read.so and its dependent targets so that static builds
>> @@ -258,7 +258,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom
>>   		     $(filter-out -static,$(CFLAGS) $(LDFLAGS)) \
>>   		     $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \
>>   		     -Wno-unused-command-line-argument \
>> -		     -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
>> +		     -fuse-ld=$(USE_LD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
> 
> When LLVM=1 is not set, CC defaults to gcc. The Makefile uses
> $(CC) ... -fuse-ld=$(USE_LD) to link liburandom_read.so.
> 
> Because USE_LD evaluates to ld.lld, gcc receives -fuse-ld=ld.lld.
> 
> However, GCC's command-line option parser is strictly hardcoded to accept
> only specific linker names (lld, bfd, gold, mold). It does not recognize
> -fuse-ld=ld.lld or absolute paths, and fails with an error like:
> 
> gcc: error: unrecognized command-line option '-fuse-ld=ld.lld'; did you mean '-fuse-ld=lld'?
> 
> Does this regression break the default GCC build of BPF selftests on x86
> and riscv architectures?
> 

Same as above. $(CC) is not used with $(LLD). You'd probably want to use 
$(LD) in a $(CC) build command anyway.



  reply	other threads:[~2026-05-15  8:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14  9:32 [PATCH 0/6] tools/build: Allow versioning of all LLVM tools James Clark
2026-05-14  9:32 ` [PATCH 1/6] tools/build: Allow versioning of all LLVM tools defined in Makefile.include James Clark
2026-05-14 10:02   ` bot+bpf-ci
2026-05-14 10:13     ` James Clark
2026-05-14  9:32 ` [PATCH 2/6] tools/build: Indent if else blocks James Clark
2026-05-14  9:32 ` [PATCH 3/6] selftests: Remove unused LLD variable James Clark
2026-05-14  9:32 ` [PATCH 4/6] tools/build: Allow versioning LLVM readelf James Clark
2026-05-14  9:32 ` [PATCH 5/6] tools/build: selftests: Allow versioning LLVM lld James Clark
2026-05-14 18:45   ` sashiko-bot
2026-05-15  8:25     ` James Clark [this message]
2026-05-14  9:32 ` [PATCH 6/6] tools/build: selftests: Remove some duplicate toolchain definitions James Clark

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=69034d26-e886-48f2-a20b-524854a5c00f@linaro.org \
    --to=james.clark@linaro.org \
    --cc=bpf@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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