* [PATCH 1/2] build: work around secondary expansion limitation with some Make versions
@ 2025-09-08 1:06 Nicholas Piggin
2025-09-08 1:06 ` [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives Nicholas Piggin
2025-09-08 18:22 ` [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Andrew Jones
0 siblings, 2 replies; 5+ messages in thread
From: Nicholas Piggin @ 2025-09-08 1:06 UTC (permalink / raw)
To: kvm
Cc: Nicholas Piggin, Andrew Jones, Shaoqin Huang, Alexandru Elisei,
Claudio Imbrenda, Thomas Huth, Sean Christopherson, kvm-riscv,
Joel Stanley
GNU Make 4.2.1 as shipped in Ubuntu 20.04 has a problem with secondary
expansion and variable names containing the '/' character. Make 4.3 and
4.4 don't have the problem.
Instead of using the variable name from riscv/sbi-deps and matching it
from the riscv/sbi.* target name, name the variable sbi-deps and match
it by stripping the riscv/ directory name off the riscv/sbi.* target
name.
Reported-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
riscv/Makefile | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/riscv/Makefile b/riscv/Makefile
index beaeaefa..64720c38 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -18,12 +18,12 @@ tests += $(TEST_DIR)/isa-dbltrp.$(exe)
all: $(tests)
-$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-asm.o
-$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-dbtr.o
-$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-fwft.o
-$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-sse.o
+sbi-deps += $(TEST_DIR)/sbi-asm.o
+sbi-deps += $(TEST_DIR)/sbi-dbtr.o
+sbi-deps += $(TEST_DIR)/sbi-fwft.o
+sbi-deps += $(TEST_DIR)/sbi-sse.o
-all_deps += $($(TEST_DIR)/sbi-deps)
+all_deps += $(sbi-deps)
# When built for EFI sieve needs extra memory, run with e.g. '-m 256' on QEMU
$(TEST_DIR)/sieve.$(exe): AUXFLAGS = 0x1
@@ -113,7 +113,7 @@ cflatobjs += lib/efi.o
.PRECIOUS: %.so
%.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined
-%.so: %.o $(FLATLIBS) $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds $(cstart.o) %.aux.o $$($$*-deps)
+%.so: %.o $(FLATLIBS) $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds $(cstart.o) %.aux.o $$($$(notdir $$*)-deps)
$(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds \
$(filter %.o, $^) $(FLATLIBS) $(EFI_LIBS)
@@ -129,7 +129,7 @@ cflatobjs += lib/efi.o
-O binary $^ $@
else
%.elf: LDFLAGS += -pie -n -z notext
-%.elf: %.o $(FLATLIBS) $(SRCDIR)/riscv/flat.lds $(cstart.o) %.aux.o $$($$*-deps)
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/riscv/flat.lds $(cstart.o) %.aux.o $$($$(notdir $$*)-deps)
$(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/riscv/flat.lds \
$(filter %.o, $^) $(FLATLIBS)
@chmod a-x $@
--
2.51.0
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives
2025-09-08 1:06 [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Nicholas Piggin
@ 2025-09-08 1:06 ` Nicholas Piggin
2025-09-08 18:23 ` Andrew Jones
2025-09-08 18:22 ` [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Andrew Jones
1 sibling, 1 reply; 5+ messages in thread
From: Nicholas Piggin @ 2025-09-08 1:06 UTC (permalink / raw)
To: kvm
Cc: Nicholas Piggin, Andrew Jones, Shaoqin Huang, Alexandru Elisei,
Claudio Imbrenda, Thomas Huth, Sean Christopherson, kvm-riscv,
Joel Stanley
Shellcheck warnings SC2327,SC2328 complain that a command substitution
will be empty if the output is redirected, which is a valid warning but
shellcheck is not smart enough to see when output is redirected into a
command that outputs what the command substitution wanted.
Add comments and shellcheck directives to these cases.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
scripts/arch-run.bash | 9 +++++++++
scripts/runtime.bash | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 58e4f93f..9c089f88 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -9,6 +9,11 @@ run_test ()
# stdout to {stdout}, stderr to $errors and stderr
exec {stdout}>&1
+ # SC complains that redirection without tee takes output way from
+ # command substitution, but that is what we want here (stderr output
+ # does go to command substitution because tee is used, but stdout does
+ # not).
+ # shellcheck disable=SC2327,SC2328
errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout)
ret=$?
exec {stdout}>&-
@@ -23,6 +28,10 @@ run_test_status ()
local stdout ret
exec {stdout}>&1
+ # SC complains that redirection without tee takes output way from
+ # command substitution, but that is what we want here (tee is used
+ # inside the parenthesis).
+ # shellcheck disable=SC2327,SC2328
lines=$(run_test "$@" > >(tee /dev/fd/$stdout))
ret=$?
exec {stdout}>&-
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 289e52bb..12ac0f38 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -190,6 +190,12 @@ function run()
# qemu_params/extra_params in the config file may contain backticks that
# need to be expanded, so use eval to start qemu. Use "> >(foo)" instead of
# a pipe to preserve the exit status.
+ #
+ # SC complains that redirection without tee takes output way from command
+ # substitution, but that is what we want here (tee is used inside the
+ # parenthesis and output piped to extract_summary which is captured by
+ # command substitution).
+ # shellcheck disable=SC2327,SC2328
summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \
> >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary))
ret=$?
--
2.51.0
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] build: work around secondary expansion limitation with some Make versions
2025-09-08 1:06 [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Nicholas Piggin
2025-09-08 1:06 ` [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives Nicholas Piggin
@ 2025-09-08 18:22 ` Andrew Jones
2025-09-08 23:23 ` Nicholas Piggin
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Jones @ 2025-09-08 18:22 UTC (permalink / raw)
To: Nicholas Piggin
Cc: kvm, Shaoqin Huang, Alexandru Elisei, Claudio Imbrenda,
Thomas Huth, Sean Christopherson, kvm-riscv, Joel Stanley
Missing the kvm-unit-tests prefix and, for this patch, the riscv prefix.
On Mon, Sep 08, 2025 at 11:06:17AM +1000, Nicholas Piggin wrote:
> GNU Make 4.2.1 as shipped in Ubuntu 20.04 has a problem with secondary
> expansion and variable names containing the '/' character. Make 4.3 and
> 4.4 don't have the problem.
>
> Instead of using the variable name from riscv/sbi-deps and matching it
> from the riscv/sbi.* target name, name the variable sbi-deps and match
> it by stripping the riscv/ directory name off the riscv/sbi.* target
> name.
>
> Reported-by: Joel Stanley <joel@jms.id.au>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> riscv/Makefile | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
Added the riscv prefix while merging.
Thanks,
drew
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives
2025-09-08 1:06 ` [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives Nicholas Piggin
@ 2025-09-08 18:23 ` Andrew Jones
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Jones @ 2025-09-08 18:23 UTC (permalink / raw)
To: Nicholas Piggin
Cc: kvm, Shaoqin Huang, Alexandru Elisei, Claudio Imbrenda,
Thomas Huth, Sean Christopherson, kvm-riscv, Joel Stanley
On Mon, Sep 08, 2025 at 11:06:18AM +1000, Nicholas Piggin wrote:
> Shellcheck warnings SC2327,SC2328 complain that a command substitution
> will be empty if the output is redirected, which is a valid warning but
> shellcheck is not smart enough to see when output is redirected into a
> command that outputs what the command substitution wanted.
>
> Add comments and shellcheck directives to these cases.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> scripts/arch-run.bash | 9 +++++++++
> scripts/runtime.bash | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 58e4f93f..9c089f88 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -9,6 +9,11 @@ run_test ()
>
> # stdout to {stdout}, stderr to $errors and stderr
> exec {stdout}>&1
> + # SC complains that redirection without tee takes output way from
s/way/away/
Same comment for the other uses below.
> + # command substitution, but that is what we want here (stderr output
> + # does go to command substitution because tee is used, but stdout does
> + # not).
> + # shellcheck disable=SC2327,SC2328
> errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout)
> ret=$?
> exec {stdout}>&-
> @@ -23,6 +28,10 @@ run_test_status ()
> local stdout ret
>
> exec {stdout}>&1
> + # SC complains that redirection without tee takes output way from
> + # command substitution, but that is what we want here (tee is used
> + # inside the parenthesis).
> + # shellcheck disable=SC2327,SC2328
> lines=$(run_test "$@" > >(tee /dev/fd/$stdout))
> ret=$?
> exec {stdout}>&-
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 289e52bb..12ac0f38 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -190,6 +190,12 @@ function run()
> # qemu_params/extra_params in the config file may contain backticks that
> # need to be expanded, so use eval to start qemu. Use "> >(foo)" instead of
> # a pipe to preserve the exit status.
> + #
> + # SC complains that redirection without tee takes output way from command
> + # substitution, but that is what we want here (tee is used inside the
> + # parenthesis and output piped to extract_summary which is captured by
> + # command substitution).
> + # shellcheck disable=SC2327,SC2328
> summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \
> > >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary))
> ret=$?
> --
> 2.51.0
Changed way to away while merging.
Thanks,
drew
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] build: work around secondary expansion limitation with some Make versions
2025-09-08 18:22 ` [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Andrew Jones
@ 2025-09-08 23:23 ` Nicholas Piggin
0 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2025-09-08 23:23 UTC (permalink / raw)
To: Andrew Jones
Cc: kvm, Shaoqin Huang, Alexandru Elisei, Claudio Imbrenda,
Thomas Huth, Sean Christopherson, kvm-riscv, Joel Stanley
On Mon, Sep 08, 2025 at 01:22:01PM -0500, Andrew Jones wrote:
> Missing the kvm-unit-tests prefix and, for this patch, the riscv prefix.
Hey, sorry about that, been a while between kvm-unit-tests patches,
thanks for fixing it all up.
Thanks,
Nick
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-09 6:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-08 1:06 [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Nicholas Piggin
2025-09-08 1:06 ` [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives Nicholas Piggin
2025-09-08 18:23 ` Andrew Jones
2025-09-08 18:22 ` [PATCH 1/2] build: work around secondary expansion limitation with some Make versions Andrew Jones
2025-09-08 23:23 ` Nicholas Piggin
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).