Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp512037rwi; Thu, 13 Oct 2022 01:01:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4n0cZue7VMe3xAXIkhvMoqZXqeLCNQ4gRO2/GbbI5VH9Q0xNxC0hO3PqVE7J2DITC+4OrL X-Received: by 2002:a17:906:cc5a:b0:78d:c3cf:6ff7 with SMTP id mm26-20020a170906cc5a00b0078dc3cf6ff7mr12999633ejb.383.1665648065542; Thu, 13 Oct 2022 01:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665648065; cv=none; d=google.com; s=arc-20160816; b=EvZrR4823c/mbaGyOp9EMljhUJuwMxmNRu4tZDJ2jJaJrnCfVNMSiY3zYF98kpe0Tk k+JgZe+eYDw5Q1MGS5S/NH/WC09jetDujPiNqF/c/gYkxIjkq7e4xbOt5ZEMvADTloRV NNDnZR6uyTXygsJZctGR/BJXEHiB79n5U8z4CEKFXfIVsrvOhj3my+7T2ZXrCED1ptKe o513FvxnbmC4d9cOCFGHSOxPg1rNLnasB7n76RSMqrjxIDP7k+nV/QsopvI0LF7ByOTO 7Oz1LhwvzlyJgRZ9xQ1wP2wZmIrjBhSL8p69mhPMXrosmOYPt+8PbqmEBWDY+iFzX2ij A7Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:dkim-signature :dkim-signature; bh=HdOPO99xuMfZ/oP6c+KobUVqYqDXR7WD4w84BArgUFo=; b=qQHK6vPylZ5dDycExuWXpR466Rh/fjfGHpHB0WPKH7YXLOEkvM4O6Al54qaDkcO+yt lTOxu41PWJXYEzmI7j+dBBIqAaNLuxxufdfVk/268TCUhrpxqgGiB/jKZ4Rptb7gOA2o s4eJyLdffjYjQHN0sip6py4xNvgmt9lMSAoRqw5RWMlOi0kzvEvsyq2z8C6kMfSskbfZ X2hr6TkcJs9huVerCoCRutXWs1DRqk63YSV+q27/iiIr4J/zT90EcPFHjjSOAA1IWxWE LjwMRMK97/K09plRogCPQO1bXBUrP1jEnv7MgXZFJPWFcgMeMMXQV5hggETVPClBQuUK 3quA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=gKjdz+K4; dkim=neutral (no key) header.i=@suse.cz header.b=eNgQ9WTq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d26-20020a50cd5a000000b00459b0e0e04bsi16329605edj.199.2022.10.13.01.00.29; Thu, 13 Oct 2022 01:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=gKjdz+K4; dkim=neutral (no key) header.i=@suse.cz header.b=eNgQ9WTq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiJMHlH (ORCPT + 99 others); Thu, 13 Oct 2022 03:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiJMHlF (ORCPT ); Thu, 13 Oct 2022 03:41:05 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B8A11E454 for ; Thu, 13 Oct 2022 00:41:01 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C2E9A225C6; Thu, 13 Oct 2022 07:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1665646859; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HdOPO99xuMfZ/oP6c+KobUVqYqDXR7WD4w84BArgUFo=; b=gKjdz+K4izZEevlx/jrNz8axz6mlKJG1xAdpa+XbXHudPafqhh/IxXUdDRd/dho9r2nisW dP07VCzdQFRjrnivPGPAEeLdh47YJVts1wlQcp/zGWRCIG0ar4YDyvd2XDgWDaSaf0CF4r 2jH996/amtKBm+wXzgCu3oEIyVz8ZkY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1665646859; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HdOPO99xuMfZ/oP6c+KobUVqYqDXR7WD4w84BArgUFo=; b=eNgQ9WTq4mzq2l0Z2iRktECS2mErWqIj3SdepyvFFo3ZTTO+3GMgQLZSeAag1YlHOdX62R XIpSo2GrQHAUJ8Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 873C7139F3; Thu, 13 Oct 2022 07:40:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fv5mHgvBR2PCTQAAMHmgww (envelope-from ); Thu, 13 Oct 2022 07:40:59 +0000 Message-ID: <624bda92-f307-30e9-9aaa-8cc678b2dfb2@suse.cz> Date: Thu, 13 Oct 2022 09:40:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] gcov: support GCC 12.1 and newer compilers To: linux-kernel@vger.kernel.org Cc: oberpar@linux.ibm.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Starting with GCC 12.1, there are 2 significant changes to the .gcda file format that needs to be supported: a) [gcov: Use system IO buffering] (23eb66d1d46a34cb28c4acbdf8a1deb80a7c5a05) changed that all sizes in the format are in bytes and not in words (4B) b) [gcov: make profile merging smarter] (72e0c742bd01f8e7e6dcca64042b9ad7e75979de) add a new checksum to the file header. Tested with GCC 7.5, 10.4, 12.2 and the current master. Signed-off-by: Martin Liska --- kernel/gcov/gcc_4_7.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c index 460c12b7dfea..7971e989e425 100644 --- a/kernel/gcov/gcc_4_7.c +++ b/kernel/gcov/gcc_4_7.c @@ -30,6 +30,13 @@ #define GCOV_TAG_FUNCTION_LENGTH 3 +/* Since GCC 12.1 sizes are in BYTES and not in WORDS (4B). */ +#if (__GNUC__ >= 12) +#define GCOV_UNIT_SIZE 4 +#else +#define GCOV_UNIT_SIZE 1 +#endif + static struct gcov_info *gcov_info_head; /** @@ -383,12 +390,18 @@ size_t convert_to_gcda(char *buffer, struct gcov_info *info) pos += store_gcov_u32(buffer, pos, info->version); pos += store_gcov_u32(buffer, pos, info->stamp); +#if (__GNUC__ >= 12) + /* Use zero as checksum of the compilation unit. */ + pos += store_gcov_u32(buffer, pos, 0); +#endif + for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { fi_ptr = info->functions[fi_idx]; /* Function record. */ pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION); - pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH); + pos += store_gcov_u32(buffer, pos, + GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE); pos += store_gcov_u32(buffer, pos, fi_ptr->ident); pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); @@ -402,7 +415,8 @@ size_t convert_to_gcda(char *buffer, struct gcov_info *info) /* Counter record. */ pos += store_gcov_u32(buffer, pos, GCOV_TAG_FOR_COUNTER(ct_idx)); - pos += store_gcov_u32(buffer, pos, ci_ptr->num * 2); + pos += store_gcov_u32(buffer, pos, + ci_ptr->num * 2 * GCOV_UNIT_SIZE); for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { pos += store_gcov_u64(buffer, pos, -- 2.37.3