From nobody Thu Apr 9 20:31:04 2026 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50E9F35975; Fri, 6 Mar 2026 00:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.117.225.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772756483; cv=none; b=gHJKfWLoZKlH2BD0CDfpXL9ZelNEfTFFeu8jPk3Oi8n7QRyFgbzaECYG7yMKgbHiA4WnmZ10RnJ7Bz2GGYA+JcfHbDQWu15vPgbSqh0AgA1l1daSrcWVUZMg5vrUc3pjaCQyYeWDFeeuwtEfqAuN/28u0moEK010kzzAzaDWTZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772756483; c=relaxed/simple; bh=f7KYVhw5pEHwSXD7nd7S6wB4i8qZrmY88A+KR+uCr2c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OHVW9RUHgYMwyUpXQezLyKUbTHhwBguKR5pOO97wpP+uRzRsOlW7gTgti23UNiHO6rxSE2ReM4/BJoeot1x9fgOHzHmFFQpJJR1vkJ2Bb4Wyb/dy2bdnzv5CTAGG8g+HbV8Es9IX+TnopwXOYGXcHXv+ZflwEqWnSVS5bCF2ePE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com; spf=pass smtp.mailfrom=virtuozzo.com; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b=AXjAWSob; arc=none smtp.client-ip=130.117.225.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="AXjAWSob" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=j5sV4+wUvNOc3xS7CkrG8KEGHYOk7JpcEgiSOK3kguU=; b=AXjAWSobMRol 20h18D2GlepRE9enrygSuX0r1WN9naeYhUBjpfWPU5RO5akN8qpT3Y0p3+wKjRVrl1d/LISqtEy/O 7384bWx5AGh0MwexSpiRtM50XRNH8YIPWpT9fkjhgdoQOfN7dsIYhEQZDmve3pGtUZPAdElyr8jd9 VvtKsRvrSnv/BUZpCvygoIP+huEXXUu9p8eipR+SPHHzl9VrW4fhbLMbyZjcS/5sRiWGHLykE6AkH DGPNFpqh2atETX9aFQAW99JVgREHT0nVJWdBM0SN1ABV7ALMqM9+g8yzSEIo5np4qYoDL+bc83ouH ngm/AAd0YhrMFb6LXmRJRA==; Received: from [130.117.225.5] (helo=dev004.aci.vzint.dev) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyIuk-006nPE-06; Fri, 06 Mar 2026 01:21:05 +0100 Received: from dev004.aci.vzint.dev (localhost [127.0.0.1]) by dev004.aci.vzint.dev (8.16.1/8.16.1) with ESMTPS id 6260L6d0519684 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 6 Mar 2026 00:21:06 GMT Received: (from root@localhost) by dev004.aci.vzint.dev (8.16.1/8.16.1/Submit) id 6260L1JW519683; Fri, 6 Mar 2026 00:21:01 GMT From: Aleksei Oladko To: Shuah Khan , Kees Cook , Christian Brauner , Seth Forshee , Tony Luck , Reinette Chatre , Dave Martin , James Morse , Babu Moger , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Abhinav Saxena , Greg Kroah-Hartman Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Aleksei Oladko Subject: [PATCH] selftests: do not override CFLAGS set by the build environment Date: Fri, 6 Mar 2026 00:21:00 +0000 Message-ID: <20260306002100.519673-1-aleksey.oladko@virtuozzo.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some kselftests Makefiles assign CFLAGS using 'CFLAGS=3D...' which overrides any CFLAGS provided by the build environment. If the environment set flags, overriding CFLAGS may result in inconsistent compiler and linker options and cause build failures, for example when building PIE binaries: # export CFLAGS=3D"-fPIE" # export LDFLAGS=3D"-pie" # make -C tools/testing/selftests/ TARGETS=3Dmount_setattr make: Entering directory '/build/kernel/tools/testing/selftests' make[1]: Entering directory '/build/kernel/tools/testing/selftests/mount_= setattr' CC mount_setattr_test /usr/bin/ld: warning: -z pack-relative-relocs ignored /usr/bin/ld: /tmp/ccikConN.o: relocation R_X86_64_32 against `.rodata.str= 1.8' can not be used when making a PIE object; recompile with -fPIE collect2: error: ld returned 1 exit status make[1]: *** [../lib.mk:222: /build/kernel/tools/testing/selftests/mount_= setattr/mount_setattr_test] Error 1 Fix this by appending to CFLAGS using 'CFLAGS+=3D' instead of overriding them. The fix is not applied to the Makefiles in x86, riscv, mm, arm64 and powerpc as they fully define their flags. Signed-off-by: Aleksei Oladko --- tools/testing/selftests/efivarfs/Makefile | 2 +- tools/testing/selftests/exec/Makefile | 2 +- tools/testing/selftests/firmware/Makefile | 4 ++-- tools/testing/selftests/ipc/Makefile | 4 ++-- tools/testing/selftests/mount/Makefile | 4 ++-- tools/testing/selftests/mount_setattr/Makefile | 2 +- tools/testing/selftests/move_mount_set_group/Makefile | 2 +- tools/testing/selftests/resctrl/Makefile | 2 +- tools/testing/selftests/safesetid/Makefile | 2 +- tools/testing/selftests/signal/Makefile | 2 +- tools/testing/selftests/timens/Makefile | 2 +- tools/testing/selftests/tty/Makefile | 2 +- tools/testing/selftests/vDSO/Makefile | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/self= tests/efivarfs/Makefile index e3181338ba5e..f6c412059af3 100644 --- a/tools/testing/selftests/efivarfs/Makefile +++ b/tools/testing/selftests/efivarfs/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS =3D -Wall +CFLAGS +=3D -Wall =20 TEST_GEN_FILES :=3D open-unlink create-read TEST_PROGS :=3D efivarfs.sh diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftest= s/exec/Makefile index 45a3cfc435cf..54cdefb9ccb0 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS =3D -Wall +CFLAGS +=3D -Wall CFLAGS +=3D -Wno-nonnull CFLAGS +=3D $(KHDR_INCLUDES) =20 diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/self= tests/firmware/Makefile index 7992969deaa2..dd9acf972cf5 100644 --- a/tools/testing/selftests/firmware/Makefile +++ b/tools/testing/selftests/firmware/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only # Makefile for firmware loading selftests -CFLAGS =3D -Wall \ - -O2 +CFLAGS +=3D -Wall \ + -O2 =20 TEST_PROGS :=3D fw_run_tests.sh TEST_FILES :=3D fw_fallback.sh fw_filesystem.sh fw_upload.sh fw_lib.sh diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests= /ipc/Makefile index 50e9c299fc4a..5a5577767a35 100644 --- a/tools/testing/selftests/ipc/Makefile +++ b/tools/testing/selftests/ipc/Makefile @@ -3,11 +3,11 @@ uname_M :=3D $(shell uname -m 2>/dev/null || echo not) ARCH ?=3D $(shell echo $(uname_M) | sed -e s/i.86/i386/) ifeq ($(ARCH),i386) ARCH :=3D x86 - CFLAGS :=3D -DCONFIG_X86_32 -D__i386__ + CFLAGS +=3D -DCONFIG_X86_32 -D__i386__ endif ifeq ($(ARCH),x86_64) ARCH :=3D x86 - CFLAGS :=3D -DCONFIG_X86_64 -D__x86_64__ + CFLAGS +=3D -DCONFIG_X86_64 -D__x86_64__ endif =20 CFLAGS +=3D $(KHDR_INCLUDES) diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftes= ts/mount/Makefile index 2d9454841644..38361a896363 100644 --- a/tools/testing/selftests/mount/Makefile +++ b/tools/testing/selftests/mount/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for mount selftests. -CFLAGS =3D -Wall \ - -O2 +CFLAGS +=3D -Wall \ + -O2 =20 TEST_PROGS :=3D run_unprivileged_remount.sh run_nosymfollow.sh TEST_GEN_FILES :=3D unprivileged-remount-test nosymfollow-test diff --git a/tools/testing/selftests/mount_setattr/Makefile b/tools/testing= /selftests/mount_setattr/Makefile index 4d4f810cdf2c..fbdb8f69b548 100644 --- a/tools/testing/selftests/mount_setattr/Makefile +++ b/tools/testing/selftests/mount_setattr/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for mount selftests. -CFLAGS =3D -g $(KHDR_INCLUDES) -Wall -O2 -pthread +CFLAGS +=3D -g $(KHDR_INCLUDES) -Wall -O2 -pthread =20 LOCAL_HDRS +=3D ../filesystems/wrappers.h =20 diff --git a/tools/testing/selftests/move_mount_set_group/Makefile b/tools/= testing/selftests/move_mount_set_group/Makefile index 94235846b6f9..8771a5491ea3 100644 --- a/tools/testing/selftests/move_mount_set_group/Makefile +++ b/tools/testing/selftests/move_mount_set_group/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for mount selftests. -CFLAGS =3D -g $(KHDR_INCLUDES) -Wall -O2 +CFLAGS +=3D -g $(KHDR_INCLUDES) -Wall -O2 =20 TEST_GEN_FILES +=3D move_mount_set_group_test =20 diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selft= ests/resctrl/Makefile index 984534cfbf1b..1d566a91faa7 100644 --- a/tools/testing/selftests/resctrl/Makefile +++ b/tools/testing/selftests/resctrl/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 =20 -CFLAGS =3D -g -Wall -O2 -D_FORTIFY_SOURCE=3D2 +CFLAGS +=3D -g -Wall -O2 -D_FORTIFY_SOURCE=3D2 CFLAGS +=3D $(KHDR_INCLUDES) =20 TEST_GEN_PROGS :=3D resctrl_tests diff --git a/tools/testing/selftests/safesetid/Makefile b/tools/testing/sel= ftests/safesetid/Makefile index e815bbf2d0f4..d3811515d8e3 100644 --- a/tools/testing/selftests/safesetid/Makefile +++ b/tools/testing/selftests/safesetid/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for SafeSetID selftest. -CFLAGS =3D -Wall -O2 +CFLAGS +=3D -Wall -O2 LDLIBS =3D -lcap =20 TEST_PROGS :=3D safesetid-test.sh diff --git a/tools/testing/selftests/signal/Makefile b/tools/testing/selfte= sts/signal/Makefile index e0bf7058d19c..6c437f95132d 100644 --- a/tools/testing/selftests/signal/Makefile +++ b/tools/testing/selftests/signal/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS =3D -Wall +CFLAGS +=3D -Wall TEST_GEN_PROGS =3D mangle_uc_sigmask TEST_GEN_PROGS +=3D sas =20 diff --git a/tools/testing/selftests/timens/Makefile b/tools/testing/selfte= sts/timens/Makefile index f0d51d4d2c87..357077792395 100644 --- a/tools/testing/selftests/timens/Makefile +++ b/tools/testing/selftests/timens/Makefile @@ -1,7 +1,7 @@ TEST_GEN_PROGS :=3D timens timerfd timer clock_nanosleep procfs exec futex= vfork_exec TEST_GEN_PROGS_EXTENDED :=3D gettime_perf =20 -CFLAGS :=3D -Wall -Werror -pthread +CFLAGS +=3D -Wall -Werror -pthread LDLIBS :=3D -lrt -ldl =20 include ../lib.mk diff --git a/tools/testing/selftests/tty/Makefile b/tools/testing/selftests= /tty/Makefile index 7f6fbe5a0cd5..e9c22dafe5e1 100644 --- a/tools/testing/selftests/tty/Makefile +++ b/tools/testing/selftests/tty/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS =3D -O2 -Wall +CFLAGS +=3D -O2 -Wall TEST_GEN_PROGS :=3D tty_tstamp_update tty_tiocsti_test LDLIBS +=3D -lcap =20 diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftest= s/vDSO/Makefile index e361aca22a74..1f4628ceb975 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -11,7 +11,7 @@ TEST_GEN_PROGS +=3D vdso_test_correctness TEST_GEN_PROGS +=3D vdso_test_getrandom TEST_GEN_PROGS +=3D vdso_test_chacha =20 -CFLAGS :=3D -std=3Dgnu99 -O2 -Wall -Wstrict-prototypes +CFLAGS +=3D -std=3Dgnu99 -O2 -Wall -Wstrict-prototypes =20 ifeq ($(CONFIG_X86_32),y) LDLIBS +=3D -lgcc_s --=20 2.43.0