From nobody Tue Apr 7 05:44:52 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 B0F653CF67E; Mon, 16 Mar 2026 16:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773679931; cv=none; b=jeIn+npXVoR1/r8RsgWGe91fnOl64oM4ne8o/PVhWt/KbkmDw3cwHDXVFwUVnKvwhJe823PNVWHuIcQw4FsHA9WvG9+1Fan5lPOrdJAivzvLReTY5djnu4A/Adr3BGSKfQH+b7gJ39QfamR4ioV5WHtVVN5PsqGapn3fvpo65A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773679931; c=relaxed/simple; bh=/d9uTb8lpguhHEi+JxjNFpFcFYqtR3gJDfleYqFkWsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DrIYzQZ0IqnysMjipUVEErZwFgup/eeU2cmAh1wKEnuNwbeDxFlSTR7DgHBSKpB3b8gHfNRB4/W4+sawpUOoLO3MclfCI+qtzJsyV1lQsH7OrKBzPe4Nv7lVF7rCckGMKKBLX5f2RYwkWaBiz/l6db0KdH5RkM48Q0fHsHkYTe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=aOdBU55F; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="aOdBU55F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1773679919; bh=/d9uTb8lpguhHEi+JxjNFpFcFYqtR3gJDfleYqFkWsA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aOdBU55FO8krvC33X6aufc7I2rcIK5hwdi7HBpKyCibg6OLQ0eOtte2nULErYwmwg HhYYLxM+cNXgaoz8zstPn/8w06x79gILZWK7HXL24CiLL820uGjK0WBntZ2LmPuLcE dBjo/fIDvK7bZbgyQJ6B+WTHuuQzjZNWueNPtW0k= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:52:02 +0100 Subject: [PATCH v2 5/5] kbuild: uapi: also test UAPI headers against C++ compilers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260316-kbuild-uapi-c-v2-5-35d6d0ed863f@weissschuh.net> References: <20260316-kbuild-uapi-c-v2-0-35d6d0ed863f@weissschuh.net> In-Reply-To: <20260316-kbuild-uapi-c-v2-0-35d6d0ed863f@weissschuh.net> To: Arnd Bergmann , Nathan Chancellor , Nicolas Schier Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773679918; l=2907; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=/d9uTb8lpguhHEi+JxjNFpFcFYqtR3gJDfleYqFkWsA=; b=Rf867dfg8pc2Ei9wBq/ZCIroWe5YVBnjK5uI2gGJozOIKdMiLs/9BFhbMEFVZK2WQYpDSgB4+ 55L9z8rkRogBzlGKzczyFpVYF6Rpq7lzsC8AB6JVJ7N7c6R7JJSxOAs X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= C++ language requirements differ from those of C. Also test the headers against C++ compilers to make sure no errors creep in accidentally. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Nathan Chancellor --- usr/include/Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/usr/include/Makefile b/usr/include/Makefile index edeaf9d778c4..ee69dd9d970e 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -10,6 +10,7 @@ UAPI_CFLAGS :=3D -std=3Dc90 -Werror=3Dimplicit-function-d= eclaration UAPI_ARCH :=3D $(or $(HEADER_ARCH),$(SRCARCH)) =20 override c_flags =3D $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfil= e) +cxx_flags =3D $(filter-out -Wmissing-prototypes -Wstrict-prototypes -std= =3D%, $(KBUILD_USERCFLAGS)) -std=3Dc++98 =20 # The following are excluded for now because they fail to build. # @@ -61,6 +62,27 @@ endif # asm-generic/*.h is used by asm/*.h, and should not be included directly no-header-test +=3D asm-generic/% =20 +# The following are not compatible with C++. +# +# Do not add a new header to the list without legitimate reason. +# Please consider to fix the header first. +# +# Sorted alphabetically. +no-header-test-cxx +=3D linux/auto_dev-ioctl.h +no-header-test-cxx +=3D linux/map_to_14segment.h +no-header-test-cxx +=3D linux/map_to_7segment.h +no-header-test-cxx +=3D linux/netfilter/xt_sctp.h +no-header-test-cxx +=3D linux/target_core_user.h +no-header-test-cxx +=3D linux/vhost.h +no-header-test-cxx +=3D linux/vhost_types.h +no-header-test-cxx +=3D linux/virtio_net.h +no-header-test-cxx +=3D linux/virtio_ring.h +no-header-test-cxx +=3D scsi/fc/fc_els.h + +ifeq ($(UAPI_ARCH),x86) +no-header-test-cxx +=3D asm/elf.h +endif + # The following are using libc header and types. # # Do not add a new header to the list without legitimate reason. @@ -138,8 +160,12 @@ endif =20 always-y :=3D $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '= *.h' 2>/dev/null)) =20 +# $(cc-option) forces '-x c' which breaks '-x c++' detection. +cc-can-compile-cxx :=3D $(call try-run,$(CC) $(CLANG_FLAGS) -c -x c++ /dev= /null -o "$$TMP", 1) + target-libc =3D $(filter $(uses-libc), $*.h) target-can-compile =3D $(filter-out $(no-header-test), $*.h) +target-can-compile-cxx =3D $(and $(cc-can-compile-cxx), $(target-can-compi= le), $(filter-out $(no-header-test-cxx), $*.h)) =20 hdrtest-flags =3D -fsyntax-only -Werror \ -nostdinc -I $(obj) $(if $(target-libc), -I $(srctree)/usr/dummy-include) @@ -149,6 +175,8 @@ quiet_cmd_hdrtest =3D HDRTEST $< cmd_hdrtest =3D \ $(CC) $(c_flags) $(hdrtest-flags) -x c /dev/null \ $(if $(target-can-compile), -include $< -include $<); \ + $(if $(target-can-compile-cxx), \ + $(CC) $(cxx_flags) $(hdrtest-flags) -x c++ /dev/null -include $<;) \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ =20 --=20 2.53.0