🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1642

Re: [PATCH] Makefile: let ccache cache objects built with the precompiled header

#1642
From: Ben Knoble
Date: Tue, 27 Oct 2026 15:58
73 lines
13739 bytes
> Le 27 oct. 2026 à 08:49, Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com> a écrit :
> 
> From: Harald Nordgren <haraldnordgren@gmail.com>
> 
> Since 8d3a673147 (Makefile: precompile "git-compat-util.h",
> 2026-09-15), rebuilding Git with ccache is almost as slow as building
> it without. ccache refuses to cache a compilation that uses a
> precompiled header unless its "pch_defines" and "time_macros"
> sloppiness is enabled, so it runs the compiler for nearly every object
> file, even after a "make clean" in a tree it has already built.
> 
> Both settings are safe for our build. The precompiled header is only
> pulled in with "-include" ahead of the source file, so no "#define" in
> a source file can come before it, and none of our sources use
> __DATE__, __TIME__ or __TIMESTAMP__.
> 
> Enable them for the precompiled header and the objects built with it.
> On my machine, "make clean && make -j8" with a warm cache goes from
> about 100 seconds to under 30.
> 
> With Clang, switching to a branch that changes one of the headers the
> precompiled header includes and back again still misses the cache,
> because Clang records the modification times of those headers in the
> precompiled header.
> 
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
>    Makefile: let ccache cache objects built with the precompiled header
> 
>    With ccache, building after switching between two feature branches gets
>    about 6 times faster. The first build of each branch gets about 25%
>    slower while ccache fills its cache.
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2464%2FHaraldNordgren%2Fmakefile-ccache-pch-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2464/HaraldNordgren/makefile-ccache-pch-v1
> Pull-Request: https://github.com/git/git/pull/2464

I can’t comment on the above, not being a ccache user myself.

> Makefile | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index a96be506b5..43ea5e0c40 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2946,6 +2946,8 @@ $(PRECOMPILED_HEADER_GCH): %.gch: % GIT-CFLAGS $(missing_dep_dirs) $(missing_com
> $(PRECOMPILED_HEADER_USERS): %.o: %.c $(PRECOMPILED_HEADER_GCH) GIT-CFLAGS $(missing_dep_dirs) $(missing_compdb_dir)
>    $(QUIET_CC)$(CC) -o $*.o -c -include $(PRECOMPILED_HEADER) -Winvalid-pch $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
> 
> +$(PRECOMPILED_HEADER_GCH) $(PRECOMPILED_HEADER_USERS): export CCACHE_SLOPPINESS += pch_defines,time_macros
> +

This is a little curious to me. I’m familiar with the GNU Make-ism 
to set variables for particular targets; how does the export work?
Is it the same but with a propagation to the recipe processes?

Would it be better (for some definition…) to put the export in the 2
pre-compiled header recipes directly?

And, what about Meson?
Technical Details
Message-ID: <579C36BA-1418-4E15-9CA7-70C752A69FCE@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73513-linux-kernel-git=dewy.ru
References: <pull.2464.git.git.1793104847288.gitgitgadget@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73513-linux-kernel-git=dewy.ru
From: ben.knoble@gmail.com (Ben Knoble)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] Makefile: let ccache cache objects built with the precompiled header
Date: Tue, 27 Oct 2026 11:58:50 -0400
Organization: Usenet Network
Message-ID: <579C36BA-1418-4E15-9CA7-70C752A69FCE@gmail.com>
References: <pull.2464.git.git.1793104847288.gitgitgadget@gmail.com>
MIME-Version: 1.0 (1.0)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1578178"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lIthmLFkyXN/DKcCj9sJdf21+xU= sha256:WmLTnRREZn5KitIooy4vk3syBk2KCSUp/Qv/7W4A738=
	sha1:so3Wgae/SGbSMeOrfTIU5bj7d58= sha256:5YoUWMbM1mHHVZUoOazEAAnD7TBU/NGggelD3gL205w=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CA11D125C09; Tue, 27 Oct 2026 19:18:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id KPx84d1Ac5aj;
	Tue, 27 Oct 2026 19:18:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-73513-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id A15D6125C08; Tue, 27 Oct 2026 19:18:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 3458028272; Tue, 27 Oct 2026 15:59:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793116743;
	b=48397MP5+/Rj+zARACDuhPAEfaStzrsmYaMgI4RIyiEBi1Cgzd9CNJqUxoZOWB9cmde2
	 SU/VnLsvBShsMSxwG+K2S5nAKaJ0/SeQvXyhbm+Dxm+afb5nq0S7jiTOFrze6dK6vlDTc
	 UT48Gt8Zv8k7oTW+CNVSRO7xn10J8E+7KqyZ96dh7Rv4WB7/APvhMkQx9e2zyFhJCUteZ
	 G4mABWpwc+4DtiVfhXvqoKZlG13Qb+V7ZTalXHuz7Kq42VD9aPGfFCUmMjimyFWeyWFwV
	 pgGui2eDUjjFxKAe+NN5Bf4HQEOr3ftF/fUUB8b+GfqVvxHuoix9/Xe0YPatzwmVUFQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793116743;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Content-Type:Content-Transfer-Encoding:From:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:Mime-Version:Subject:Date:Message-Id:References:
	 Cc:In-Reply-To:To:X-Mailer;
	bh=SDg2i96V7omk3+T4EfuFmf5cD+SjsdYeANih2WGwVns=;
	b=wksQlQ4z2bbsQRCzD+wcLJGSSMzUv67S8iMV7/88wUMjDU3RNF1CnT1xspkVk6dEOGpT
	 ZI2NM/SxSpIy0usy6/kVQlLM9RJHDBE4ccHmMMSyHHsKKfBc7jOHgv8vJ5kWp57q3aE19
	 dLDSXIfflGoanFe+uSKkIdSNB44zFcQNoDLsnH27FaG7gUDDsvzdxTklNzw68cnT1z7NU
	 bedfj4yU0fuxf0iYC0aVN1+ppd47mPrzTgkpAVPGllM9niNdmMwq2lDtEe9exdLQljUYH
	 ffa/fWLxJ6H6T8Wsj4qBkI07yCUUiMNCjTtJQx3+RvVAPB9ZzguJRjHSZh5G6lI+0kg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QIdtqNrZ;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 74EBC606A339;
	Tue, 27 Oct 2026 15:59:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QIdtqNrZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.174
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793116742;
	b=xy5/sKwO/8Qv3BU1aLSCJGPNBYHrvF+v1bUStFfQDWm7ftZ/tL0GMSQdnkMlMMpvzPwT
	 q8nKITod59sBbPJcBtu5KTSnjhUN2I4GH67JNHXooZN0gTZPmG1ew3DzBPvHsu3VjcfGI
	 +KQReVtP57GG74OFNUxft8Ap7colMSlTbp0wEAi8XimU+3qMJvG6a1De04QnkEPzBRjnJ
	 I652ZS6s+9+oQDC2ctRCt49xoGQojTJb63ombeZh+0ibnU5oTtYPi8QLJNjFrzA84OcaE
	 Fyci6buAkar51oqFJafxN0aE6uAJvMJFjD8EaU9Zp3YYmrwRIpYiaiUt8ymFJylqrag==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793116742;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Content-Type:
	 Content-Transfer-Encoding:From:Mime-Version:Subject:Date:Message-Id:
	 References:Cc:In-Reply-To:To:X-Mailer;
	bh=SDg2i96V7omk3+T4EfuFmf5cD+SjsdYeANih2WGwVns=;
	b=SGnTtFBQlUWMuox2Vrd04sDAxHzKskKPcUZI0LO+7jj+ba6CifeHV7DPumioPPgu4LL+
	 T2FJox0x7oxdKtRJ63NfBW8mTxf2GZ95WIerY4+O/T8evm7A5cgpLh3W18niUUlenbicI
	 h3lQYL8D2/1ffaOeNZkOHKcXMOOFT6zShPT/IQGWeP4iWOh6bZgeIi3MnPVpXgFogafRf
	 NtqTK+Ygqjx4TbaVuYnBjJpuQ4FVNVWUTMcar0ppDSdxanm5SJLGzyBLygFImxrJJdWdu
	 sQdJddKf1vbYUYpxB09WbQHjkh50jSINwLKAVGR8nx79zpkXH+n+zaFFIvmlmvzndSw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QIdtqNrZ;
	arc=none smtp.remote-ip=209.85.128.174
X-Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 414B3606A32D
	for <git@vger.kernel.org>; Tue, 27 Oct 2026 15:59:02 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 414B3606A32D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-8b0dba37a7fso37029977b3.0
        for <git@vger.kernel.org>; Tue, 27 Oct 2026 08:59:02 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793116741; x=1793721541; darn=vger.kernel.org;
        h=to:in-reply-to:cc:references:message-id:date:subject:mime-version
         :from:content-transfer-encoding:content-type:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=SDg2i96V7omk3+T4EfuFmf5cD+SjsdYeANih2WGwVns=;
        b=QIdtqNrZ1EHdLw/lqYII10ZlLKNeAQtZhtrmqH9+3yzfYyDtLkhH0YzhtoNXYieWzm
         NKm88UsITTfbSsnRo34DO3SZsArGU1i6CBwsHD+XOSi3qLZD7iXhQvaZvH333lIvXFQD
         AF4kRwOvoNkm82KsCjZscXgApBCAJqjDvx+e6KkTNHx4bW78sD97Ejtuo2FpYwOsBtMn
         XL/osni0mdM4ogWwCdd9rCoBHtO/N0EODDlJQpDpvaYb7JCChCmOtBg2S0Wc5k/MWz4h
         xeDJymPPml426pNppbVwge9+N6426nkYBwaNJyofdcimhzrjpHTOYHU5FhWYycvry8zD
         7xqw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793116741; x=1793721541;
        h=to:in-reply-to:cc:references:message-id:date:subject:mime-version
         :from:content-transfer-encoding:content-type:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=SDg2i96V7omk3+T4EfuFmf5cD+SjsdYeANih2WGwVns=;
        b=s6fTR06upwrzcOodbh3g7LioTMiNWZnn6o/hKt6CzU/ZexjJ+3lxnzCzAeniANuF2z
         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9gqBmphAd5mcNZqChTjIFeTe2nxOrOF
	R88HGO7V3Hi/BmxMfEoYGUaMTg3ATaQ==
X-Received: by 2002:a05:690c:7108:b0:873:5bd1:98cf with SMTP id 00721157ae682-8b166c956f2mr62552017b3.65.1793116741077;
        Tue, 27 Oct 2026 08:59:01 -0700 (PDT)
X-Received: from smtpclient.apple ([2605:a601:9d17:3000:4455:c602:9aaa:33ee])
        by smtp.gmail.com with ESMTPSA id 00721157ae682-8b19e5adfd2sm14851947b3.25.2026.10.27.08.59.00
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 27 Oct 2026 08:59:00 -0700 (PDT)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
X-In-Reply-To: <pull.2464.git.git.1793104847288.gitgitgadget@gmail.com>
X-Mailer: iPhone Mail (23D8133)