From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 832282EDD58 for ; Tue, 5 May 2026 18:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778005023; cv=none; b=Nlj4zBlAsqg3K+uojE/+E5yCnB84k/LUito3OoU2zwx4DZNGZBg1gE3rIrpvrsHD4b7iGED9gSsEPycWqeATAD6qbd9jJraXauTzRlxx2Tif114Vtz2tb7mXqU2O2FHh8sk6SGSg3PwQnFZTgPEtzlcrZPCle/fHMMon9bkGTtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778005023; c=relaxed/simple; bh=J3Q+YkMrNteHusAAel5oPhBkOkq6Bw543OiTUS9fDs4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Nw4ijkV/Qx7+2yzXf1ZY23NsWB737PgY+tLw6fp4k1QngdIzmZ7nQjPNd88m4Q4/dvN8Y7QTTNAxkFUtsAs4rdVcTwTlIYfcMX9P+vR1EYYPDnqe2a2LILRkVXuddp7kTqca9LYGxToKl+Zp7SLBJwqfL4xR13tiRveFaCLhiOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=emdWt0mX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="emdWt0mX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778005020; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9sCJE7nk0s6pfhio4EtmHGvwzgqGoc5RnV2km1CoRVo=; b=emdWt0mXCyZ40/y++aRGFWPeNglb/M85iZKHNKWrErA2uoo0wP5WfHm8MSVZKUVjeCKQv5 w47Gry5zKQxXr+0Wmo8dTypXqpUmwF06xveQ8c5McpeBNousG/HathHUfbrY7lztRWSN/E eXSzl+eUTob2sjrnjGLIAI72mhhfK+g= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360-SSBSa_AHMWyHVrHh48V5iw-1; Tue, 05 May 2026 14:16:59 -0400 X-MC-Unique: SSBSa_AHMWyHVrHh48V5iw-1 X-Mimecast-MFC-AGG-ID: SSBSa_AHMWyHVrHh48V5iw_1778005018 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 320D918002D1 for ; Tue, 5 May 2026 18:16:58 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.44.32.15]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B05041944CED for ; Tue, 5 May 2026 18:16:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 645IGslv1345662 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Tue, 5 May 2026 20:16:55 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 645IGsO61345661 for linux-kernel@vger.kernel.org; Tue, 5 May 2026 20:16:54 +0200 Date: Tue, 5 May 2026 20:16:54 +0200 From: Jakub Jelinek To: linux-kernel@vger.kernel.org Subject: [PATCH] gcc-plugins: Fix build with GCC 16.1 Message-ID: Reply-To: Jakub Jelinek 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-Disposition: inline Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 GCC is written in C++ for 13 years already, and from the time it was implemented in C and times when it could be built by both C and C++ there were various CONST_CAST* macros. In GCC 16 these macros were removed because one can use C++ const_cast directly. The kernel gcc-plugins use 2 of those macros though, so when GCC plugins are enabled, kernel fails to build with In file included from scripts/gcc-plugins/latent_entropy_plugin.c:78: scripts/gcc-plugins/gcc-common.h: In function ‘void debug_tree(const_tree)’: scripts/gcc-plugins/gcc-common.h:417:20: error: ‘CONST_CAST_TREE’ was not declared in this scope; did you mean ‘CONST_CAST_EXPR’? 417 | debug_tree(CONST_CAST_TREE(t)); | ^~~~~~~~~~~~~~~ | CONST_CAST_EXPR scripts/gcc-plugins/gcc-common.h: In function ‘void debug_gimple_stmt(const_gimple_ptr)’: scripts/gcc-plugins/gcc-common.h:312:47: error: expected primary-expression before ‘,’ token 312 | #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X)) | ^ scripts/gcc-plugins/gcc-common.h:422:27: note: in expansion of macro ‘CONST_CAST_GIMPLE’ 422 | debug_gimple_stmt(CONST_CAST_GIMPLE(s)); | ^~~~~~~~~~~~~~~~~ scripts/gcc-plugins/gcc-common.h:312:30: error: ‘CONST_CAST’ was not declared in this scope; did you mean ‘CONST_INT’? 312 | #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X)) | ^~~~~~~~~~ scripts/gcc-plugins/gcc-common.h:422:27: note: in expansion of macro ‘CONST_CAST_GIMPLE’ 422 | debug_gimple_stmt(CONST_CAST_GIMPLE(s)); | ^~~~~~~~~~~~~~~~~ The following patch fixes it by defining the macros the way they were defined in GCC 15 and earlier for the plugin compatibility layer. Tested with both GCC 15.2.1 (where it works before/after this patch) and GCC 16.1.1 (where it is fixed with it). Signed-off-by: Jakub Jelinek diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h index 8f1b3500f8e2..0e46215793ba 100644 --- a/scripts/gcc-plugins/gcc-common.h +++ b/scripts/gcc-plugins/gcc-common.h @@ -304,6 +304,12 @@ static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_e symtab->call_edge_duplication_hooks(cs1, cs2); } + +#if BUILDING_GCC_VERSION >= 16000 +#define CONST_CAST(TYPE, X) (const_cast(X)) +#define CONST_CAST_TREE(X) CONST_CAST(union tree_node *, (X)) +#endif + typedef gimple *gimple_ptr; typedef const gimple *const_gimple_ptr; #define gimple gimple_ptr