build: work around secondary expansion limitation with some Make versions
Subsystems (3)
PATCH 1/2 build: work around secondary expansion limitation with some Make versions
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.
--- riscv/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
riscv/Makefile +7 -7
@@ -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 $@
Signature · 1 line
2.51.0
PATCH 2/2 shellcheck: suppress SC2327,2328 false positives
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.
--- scripts/arch-run.bash | 9 +++++++++ scripts/runtime.bash | 6 ++++++ 2 files changed, 15 insertions(+)
scripts/arch-run.bash +9 -0
@@ -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}>&-
scripts/runtime.bash +6 -0
@@ -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=$?
Signature · 1 line
2.51.0
Re: [PATCH 2/2] shellcheck: suppress SC2327,2328 false positives
Quoted 18 lines · Nicholas Piggin
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 <[email protected]>--- scripts/arch-run.bash | 9 +++++++++ scripts/runtime.bash | 6 ++++++ 2 files changed, 15 insertions(+)scripts/arch-run.bash +0
-0
scripts/arch-run.bash run_test () · line 12
Quoted 4 lines
scripts/arch-run.bash +1
-0@@ -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.
Quoted 37 lines
scripts/arch-run.bash +8
-0+ # 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}>&-scripts/runtime.bash +6
-0@@ -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=$?Signature · 1 line
2.51.0
Changed way to away while merging.
Thanks,
drew
Missing the kvm-unit-tests prefix and, for this patch, the riscv prefix.
Quoted 9 lines · Nicholas Piggin
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.
Quoted 6 lines
Reported-by Joel Stanley <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- riscv/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Added the riscv prefix while merging.
Thanks,
drew
Quoted 1 line · Andrew Jones
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