Re: [PATCH] selftests: fix ARCH normalization to handle command-line argument
From: Andrew Morton
Date: Mon Mar 09 2026 - 17:06:55 EST
On Mon, 9 Mar 2026 20:51:45 +0000 Aleksei Oladko <aleksey.oladko@xxxxxxxxxxxxx> wrote:
> Several selftests Makefiles (e.g. prctl, breakpoints, etc) attempt to
> normalize the ARCH variable by converting x86_64 and i.86 to x86.
> However, it uses the conditional assignment operator '?='.
>
> When ARCH is passed as a command-line argument (e.g., during an rpmbuild
> process), the '?=' operator ignores the shell command and the sed
> transformation. This leads to an incorrect ARCH value being used, which
> causes build failures
>
> # make -C tools/testing/selftests TARGETS=prctl ARCH=x86_64
> make: Entering directory '/build/tools/testing/selftests'
> make[1]: Entering directory '/build/tools/testing/selftests/prctl'
> make[1]: *** No targets. Stop.
> make[1]: Leaving directory '/build/tools/testing/selftests/prctl'
> make: *** [Makefile:197: all] Error 2
>
> Change the assignment to use 'override' and ':=' to ensure the
> normalization logic is applied regardless of how the ARCH variable
> was initially defined.
lgtm, thanks.
> --- a/tools/testing/selftests/ipc/Makefile
> +++ b/tools/testing/selftests/ipc/Makefile
> @@ -1,12 +1,12 @@
> # SPDX-License-Identifier: GPL-2.0
> -uname_M := $(shell uname -m 2>/dev/null || echo not)
> -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
> +ARCH ?= $(shell uname -m 2>/dev/null || echo not)
What does this `echo not' do? ARCH=not if uname failed?