[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <611d1e93-6f64-4eb5-a054-4d92f076de41@intel.com>
Date: Tue, 3 Sep 2024 11:22:47 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>, "Muhammad
Usama Anjum" <usama.anjum@...labora.com>, Shuah Khan <shuah@...nel.org>,
<linux-kselftest@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Shaopeng Tan <tan.shaopeng@...fujitsu.com>, Fenghua Yu
<fenghua.yu@...el.com>, Maciej Wieczór-Retman
<maciej.wieczor-retman@...el.com>
Subject: Re: [PATCH v4 3/4] selftests/x86: don't clobber CFLAGS
Hi Ilpo,
On 9/3/24 7:45 AM, Ilpo Järvinen wrote:
> The x86 selftests makefile clobbers CFLAGS preventing lib.mk from
> making the necessary adjustments into CFLAGS. This would lead to a
> build failure after upcoming change which wants to add -DHAVE_CPUID=
> into CFLAGS.
>
> Reorder CFLAGS initialization in x86 selftest. Place the constant part
> of CFLAGS initialization before inclusion of lib.mk but leave adding
> KHDR_INCLUDES into CFLAGS into the existing position because
> KHDR_INCLUDES might be generated inside lib.mk.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> ---
> v4:
> - New patch
>
> tools/testing/selftests/x86/Makefile | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
> index 5c8757a25998..88a6576de92f 100644
> --- a/tools/testing/selftests/x86/Makefile
> +++ b/tools/testing/selftests/x86/Makefile
> @@ -1,4 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0
> +CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
> +
> all:
>
> include ../lib.mk
> @@ -35,7 +37,7 @@ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
> BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
> BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
>
> -CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
> +CFLAGS += $(KHDR_INCLUDES)
>
> # call32_from_64 in thunks.S uses absolute addresses.
> ifeq ($(CAN_BUILD_WITH_NOPIE),1)
These changes are becoming less obvious to me. The first two
red flags are:
- Most other top level Makefiles assign KHDR_INCLUDES to CFLAGS
*before* including lib.mk
- What current Makefiles do matches the guidance from
Documentation/dev-tools/kselftest.rst as per example (verbatim copy):
CFLAGS = $(KHDR_INCLUDES)
TEST_GEN_PROGS := close_range_test
include ../lib.mk
Looking closer it is not clear to me why lib.mk sets KHDR_INCLUDES.
As I understand the usage is intended to be:
make TARGETS="target" -C tools/testing/selftests
This means that it is tools/testing/selftests/Makefile that will
run first and it ensures that KHDR_INCLUDES is set and supports
the usage documented in Documentation/dev-tools/kselftest.rst
One usage that a change like in this patch could support is
for users to be able to run "make" from within the test
directory self ... but considering the current KHDR_INCLUDES
custom this does not seem to be supported? (but we cannot
know which tests/users rely on this behavior)
Looking further I also noticed that
tools/testing/selftests/Makefile even sets ARCH (but does
not export it). When considering the next patch it almost looks
like what is missing is for tools/testing/selftests/Makefile to
"export ARCH" ... but that potentially impacts the Makefiles that
do manipulation of ARCH.
I initially started to look at this because of the
resctrl impact, but I clearly am not familiar enough
with the kselftest build files to understand the
impacts nor provide guidance. I do hope the kselftest
folks can help here.
Reinette
Powered by blists - more mailing lists