From patchwork Mon Jun 10 06:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13691568 Received: from wfhigh4-smtp.messagingengine.com (wfhigh4-smtp.messagingengine.com [64.147.123.155]) (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 39A411BF2A for ; Mon, 10 Jun 2024 06:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718001506; cv=none; b=FpGOj09T0py5HFeUGpUoQKS24PiBc0pSfl03IwohohdB2c4FDiuVyl6MP8KWzjG6QlVf5XPlHFy9MnowjkNAL0OlhBu8sj9H2jjKuFURR/nMKPRMTIWNtFiL3SkbYGYn+qJNpisQHe/Ojlb89HKyrpsJUs6nLYTk7x4Bjz3aabo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718001506; c=relaxed/simple; bh=6cabXsBiCkss4J8sFa1tzpTNkbqUMiUcS9pQRnHGG4Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mWjPoFhesVyT4B90C2nMtxI7BvMk1EsEbN7cv3j6SunSYh8J7QzD/lfmY57U2X5nN8y3mC+L3+gc4NGCKvSXcjnsWlq6LhnR09Ef9bM/XrU2k6Q4ik93RjygMy8n+Evrzpi35hKwg31exCAHzCg6faci9NEIhZDho841RNO0tqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=n5MHIoTc; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=S+3203Ud; arc=none smtp.client-ip=64.147.123.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="n5MHIoTc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="S+3203Ud" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 625481800199; Mon, 10 Jun 2024 02:38:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 10 Jun 2024 02:38:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1718001504; x=1718087904; bh=6cabXsBiCk ss4J8sFa1tzpTNkbqUMiUcS9pQRnHGG4Q=; b=n5MHIoTcg779oZ/DBZGsvh2Jkf C5MO3JYJmyLpGFUIEaC4Y2A/scq8m8xsJn5uUwLFnbz7FPKmYX5MKg25fSt55J7M iSl+EODuS/50I1L97sY1GS4nrMKrNqYzfINI3NeIN3FRWv9ayGxJVYohFMgeNo1V i0axx159VDP0txqbdYSSdfojVwJNr7atscVnRpcQEUED4ksCvrz/8NwTLVCGmahY Q3jivOxFOIe47WgcbEefqG/NICNofmP09KCwQ+sJqRBYa10Y9QlLqoUT0gGgyEhR 2N0oaEoOzDjpyHMOY7/K0ephNOWVbe99hVztwkljoKEuh+h0joxlSAZmU7Pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718001504; x=1718087904; bh=6cabXsBiCkss4J8sFa1tzpTNkbqU MiUcS9pQRnHGG4Q=; b=S+3203UdDlSXbOiKZUcBYfv24FY+WbRx0aOk+ayNGiS5 Ny7k63IoOhb8+GfSjDL1MG4tbX0orZC+3aXKtUNYn5egn9Y2F9Fz9aVMUPE174+3 8BHNiPutYB0IJPkHd1QsUeikKzN8ywo1yTqKx/iluBKpL7M0TVULNol9+ipfb9jh /iXd921XEX+XRt8UZL6x6kqFk8++uxfqwD6QJzX29uKcjE23ve3DGR/VYU/0znim fdDDoth/dt73aWjraJz+qjhPUC4qNRi7yvJeHTK0NlxZnsqcc3ENVikUVa1x59Kn GjdRsF+h1Dz2mepV8EQsOOQ2+G7V6Jvlb/1yJyM6Rw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedtledgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Jun 2024 02:38:23 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id a2c494c9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 10 Jun 2024 06:38:15 +0000 (UTC) Date: Mon, 10 Jun 2024 08:38:20 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v4 1/2] Makefile: add ability to append to CFLAGS and LDFLAGS Message-ID: <8120ddaf0bdfd50e0fc4cf9a04f833102630b639.1718001244.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are some usecases where we may want to append CFLAGS to the default CFLAGS set by Git. This could for example be to enable or disable specific compiler warnings or to change the optimization level that code is compiled with. This cannot be done without overriding the complete CFLAGS value though and thus requires the user to redeclare the complete defaults used by Git. Introduce a new variable `CFLAGS_APPEND` that gets appended to the default value of `CFLAGS`. As compiler options are last-one-wins, this fulfills both of the usecases mentioned above. It's also common practice across many other projects to have such a variable. While at it, also introduce a matching `LDFLAGS_APPEND` variable. While there isn't really any need for this variable as there are no default `LDFLAGS`, users may expect this variable to exist, as well. Signed-off-by: Patrick Steinhardt --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2f5f16847a..9cd3b252ff 100644 --- a/Makefile +++ b/Makefile @@ -1446,8 +1446,8 @@ ALL_COMMANDS_TO_INSTALL += git-upload-archive$(X) ALL_COMMANDS_TO_INSTALL += git-upload-pack$(X) endif -ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -ALL_LDFLAGS = $(LDFLAGS) +ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND) +ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND) ifdef SANITIZE SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag)) From patchwork Mon Jun 10 06:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13691569 Received: from wfout2-smtp.messagingengine.com (wfout2-smtp.messagingengine.com [64.147.123.145]) (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 DD0201BF2A for ; Mon, 10 Jun 2024 06:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718001511; cv=none; b=jgJU1NPIlzDuxy+PRdKCGAqdHTUyNHuJPFh4RuQoE8FSya9eZPLj5RbHC4YlNTe+oA8GjBPtCDbW4bOG9xPqRGTc8s4QBTcaFHrFWEGyuLO2Lqla68n3O/f7eMBjBQhVSJrHOt9jzjGHCMReP7Z6oUS3Fj0vIsW055WGZbF9ENM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718001511; c=relaxed/simple; bh=23MU8QhdrWYAA0snxcJBjtAr2tozhvI4VMJyAs2875k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q3lNlnvcHbdl5u4dxeogtC+der71nzyyf4i6RZuSOZ8bvl0YbFDd3I57xinc0oN1Op85R+Bwm+9C6aPXwyO4IvGnFCEiPuXHKYvR/Ww4maDaxB10vOXSHl69slBaDxcXbxa+OuTbRVAEOkJLX7dPCw2xz5oVMplIkdV+NPSUBTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=Em4p1ob0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Xz50JU+h; arc=none smtp.client-ip=64.147.123.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="Em4p1ob0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Xz50JU+h" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id 396E11C00122; Mon, 10 Jun 2024 02:38:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 10 Jun 2024 02:38:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1718001508; x=1718087908; bh=5V/ZB05/+a YEt7I2fCifiE1/9/fuTyFb1sL4Y9gLi4Q=; b=Em4p1ob039lS0Nvc7fD+ksQ3jj YDERCrbB+rpFyCD8MurMUNyB3t1Qyl5CeOPSp/94gQ624jFoca9ue7xpWCqJqlVM QTOt55UnYQbzfvsbfGSZkqQ9SKZo/2jONiUsqQL2XwtzDWk9QTqtJsNQNkVTVann kSo2Ki33ja/vQ7Fxb/7gg2V24ba7cK7aLaTxqBFeFOJfe6iI+1TMuj8QFKb/I6cN 0sbgk1Ah1sSyJ4ib00hnEeMNK+/i90UoLSF35WEtNmMRBK3LqS9c0hZezU1U+Qpd GT6ltBP0303CrZj51KmcVZgaHzI3c96ICi+L5VLaM/2smD879gp0M0dRqGEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718001508; x=1718087908; bh=5V/ZB05/+aYEt7I2fCifiE1/9/fu TyFb1sL4Y9gLi4Q=; b=Xz50JU+h3zBSMANUBIcogjPtele4zN2aXGjw4dEz+9DU aA5TWx7B3jIeOnkqk3bKItxoWnwgrIQnIVfYECPFwU9JPiTQ0Wme/zGE48y1UzwK cdoZ7oi0kGKEpIuZAuyjCbqIHjDJ/ubL551WLJOPch3MdoeA8iYbB6lUTl0QC3nl X6Zmcx+un9xJ6bJxeiyhiZ20kpYoDL8xx5DA53Vs5IneQrHCXbjHLoonizdCm+sQ dQDm+8iSaahq8HB0O5vMpMM4dBo7ujEUWAUjlA/IBvd781+bP1iElYtDzMqrLCKY YijuDDQLYIfVxIfB7PXEZCVGeMDpxin0e8OsI2hFVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedtledgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Jun 2024 02:38:27 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id eaf38979 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 10 Jun 2024 06:38:20 +0000 (UTC) Date: Mon, 10 Jun 2024 08:38:25 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v4 2/2] ci: compile "linux-gcc-default" job with -Og Message-ID: <03270d3414117ae7229d87127cff81e349557039.1718001244.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We have recently noticed that our CI does not always notice variables that may be used uninitialized. While it is expected that compiler warnings aren't perfect, this one was a bit puzzling because it was rather obvious that the variable can be uninitialized. Many compiler warnings unfortunately depend on the optimization level used by the compiler. While `-O0` for example will disable a lot of warnings altogether because optimization passes go away, `-O2`, which is our default optimization level used in CI, may optimize specific code away or even double down on undefined behaviour. Interestingly, this specific instance that triggered the investigation does get noted by GCC when using `-Og`. While we could adapt all jobs to compile with `-Og` now, that would potentially mask other warnings that only get diagnosed with `-O2`. Instead, adapt the "linux-gcc-default" job to compile with `-Og`. This job is chosen because it uses the "ubuntu:latest" image and should thus have a comparatively recent compiler toolchain, and because we have other jobs that use "ubuntu:latest" so that we do not lose coverage for warnings diagnosed only on `-O2` level. To make it easier to set up the optimization level in our CI, add support in our Makefile to specify the level via an environment variable. Signed-off-by: Patrick Steinhardt --- ci/run-build-and-tests.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 98dda42045..40106c6c36 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -13,6 +13,15 @@ esac run_tests=t case "$jobname" in +linux-gcc-default) + # Warnings generated by compilers are unfortunately specific to the + # optimization level. With `-O0`, many warnings won't be shown at all, + # whereas the optimizations performed by our default optimization level + # `-O2` will mask others. We thus use `-Og` here just so that we have + # at least one job with a different optimization level so that we can + # overall surface more warnings. + export CFLAGS_APPEND=-Og + ;; linux-gcc) export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main ;;