From patchwork Tue Jan 30 17:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 194253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1378735dyb; Tue, 30 Jan 2024 09:27:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs3Nh7CkWNEkUPsVW2RxTb/ZIHo921rtIslWXLUvp1lef2PLB9dmXxZC2W2fZhbrkudzJF X-Received: by 2002:a17:902:e5cd:b0:1d7:188e:ea62 with SMTP id u13-20020a170902e5cd00b001d7188eea62mr2136165plf.22.1706635650534; Tue, 30 Jan 2024 09:27:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706635650; cv=pass; d=google.com; s=arc-20160816; b=pLfRvxJVo2UOF8U8AeMJByZqOuwQUj/OQbRc+SJDVU1mwaMxoy6SDqitP1PjVExYCo NU6H0/1+eT1a+tOzMYNs1lUHCheU08QuZVNaQ5QpzLUHPPqEAx8nMZEwTJZW3J4Perwr J3IqKpVXPaH3rqB7WCh/iaG6FrXp3KNpm4tbGt/K6Xz32LInAD1MwyUSFA0kBtg0SbO8 ezNiGXTJdYRgepuih0jjNSkPH0lwICpqO8Rls8Vs2CP6P6BYjORBCv6y5hm4YPMFYPSH xaRyCths/CONhJu9aqsp1a+a6n8vAR+tagmFit8yQUQI+nZcTSpHfbeaIOm+bicD8yL4 kerg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=y5wjSHabQXmyjK9UW/hisACzWIzHTQrBleOJJYviNOg=; fh=Ajmc02LBEOafr8OGj3q3+V/GOGw7TCDPsBBVoiI4Bac=; b=EDkIpu6Y8u7lng5l0CaEL2MX4QKdqsjN/liiblKNTbH+d2oHZyc4oYDnrdNyL22H5T 8+yCGah9mvec7y76I+bk0bUxY8tK+qKJVzEa6/14/7IEb1lRcHZbkJI82XFopkrfLJ3P y03yZaTF5XdtvOCZNO8Im/36aqugzhJOt8q38Z+lDCSh7mc5FvvTC6yCqvYINYPT4eM1 czefGn23XgDwdSxx9gFIm2DRZINp0MzE8Jef5FAeebeJukttB88YF0AP+yeNO6nAl8xW TbOlz5QnM0gn8U4RgncP9ppmr8gBUvF6nmSGvARtvuUdb3fxeGjS+r6U+pVCq0pga6Mc UUVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R895J5Nh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45010-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45010-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w12-20020a170902d3cc00b001d8e7ebba53si3366159plb.360.2024.01.30.09.27.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 09:27:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45010-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R895J5Nh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45010-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45010-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5650CB28FAB for ; Tue, 30 Jan 2024 17:06:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98D7C12A141; Tue, 30 Jan 2024 17:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R895J5Nh" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A27E86ADC; Tue, 30 Jan 2024 17:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706634346; cv=none; b=Ru2cwrc9rrb3S1PZwU7C+uzl30H/aW/OF1U+oJJRUP/uxHfrkk1iMxrZJTsSsDXXKolZqoXCN6JprVit00oSw4qs8qHxHbwPcdaDmtvY1FKKKbcSYPRq7bELEaswq+HQumI5mlFpWf0lbWnXtg2y0DISuqrfePvoAHa6SmJy0HA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706634346; c=relaxed/simple; bh=QC4YtFfqL/ZkTH/AF/bNmRRbxvCTQxIQQ8bFBkTG4Qk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jplGLJ67nxHXKTztOmWM7Q+s8WM4IixcrCknMrXAMKA6Zc2yw8xZE8RReI41wDm9SDORzOTA3KvWAnNftXgEE9aJxN1jqZlk/w7HyhPn5grsjE5u45CzjNhzHVS5waMSw+9lPN79ct1D/BsUaeo9dUCIrMzfAGCOUmM5BqHBg0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R895J5Nh; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d50d0c98c3so42255105ad.1; Tue, 30 Jan 2024 09:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706634344; x=1707239144; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y5wjSHabQXmyjK9UW/hisACzWIzHTQrBleOJJYviNOg=; b=R895J5NhqqtkTKCuh5vxuddtlyYNRMnIImOS763RpVW7JltL7a33z0FVZqeXujxjYh +ybUqGoF2srG4xtT+ejfs1oI5g/9RlUc2BBVCQdGg98Bmb1AzoL1hhrwyyDHaD2TwIx5 k8R2FiIKoo7A4YM1LYdIemkOO9kD0JsDaMk6kizQ3Kb6SV89Ee1NSrerBVSt7KW99XAB ibdOatWKeyf6CTA2BvuBNFu4mHWiscGoZpzm2V4+azPEjqNayHi0ClfY6ysuobq12Ktx H68lJVlyg9I7mY0wpmZCmxt1UeHp9m5aebS2JnBQdsbHxiS+0kQUJ56cpFNT+0bb0a39 y7jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706634344; x=1707239144; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y5wjSHabQXmyjK9UW/hisACzWIzHTQrBleOJJYviNOg=; b=MKxP2Se+zyyfJIl2kzji68GQ0OKH4dxrnHrzuD0erTQ8eSLCCrrUT6l8n7c17YnOoK KB8N0PIJRymaw0vQEtzAnsqjkbwaxN2TnZAYSwppGaXYcy74FjyjPCieJUoY0eaHkMJ5 nXfVkGMlMDwISr/FwQDIATsdL3cy9LY5n/xOlfaIAsz2bcjmUJ9D3I8TNrvqXoC60w1L ULDEt0GLyaJIDruLZmEGmTqNsJ2vb8SRk38rdqgwueWYptuUP812IGajE98GIIAdI29O Zxjd0s/QuA2jUYr0M3yB+X9vnJejTznIkduk6YdIJAmytNviTFccQRBTHxQeDgpHtw0r tHaQ== X-Gm-Message-State: AOJu0YwaSpv0ZOW8tsuvMoRllq1zOmIcDzkGFGVdmMLLupSb/v6Fja6T N527Fj6tIE6viBjowd117oaXsN5oL7hPiTyzyzVHxWANFk/1EHT/vC8rwdL8 X-Received: by 2002:a17:90a:d80e:b0:28e:6dfd:ad6c with SMTP id a14-20020a17090ad80e00b0028e6dfdad6cmr2021565pjv.10.1706634343944; Tue, 30 Jan 2024 09:05:43 -0800 (PST) Received: from octofox.hsd1.ca.comcast.net (c-73-63-239-93.hsd1.ca.comcast.net. [73.63.239.93]) by smtp.gmail.com with ESMTPSA id sm5-20020a17090b2e4500b0028ffea988a2sm8856830pjb.37.2024.01.30.09.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 09:05:43 -0800 (PST) From: Max Filippov To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Jiri Olsa , Bartosz Golaszewski , Kent Gibson , Jonathan Cameron , Lars-Peter Clausen , Max Filippov , stable@vger.kernel.org Subject: [PATCH] kbuild: tools: drop overridden CFLAGS from MAKEOVERRIDES Date: Tue, 30 Jan 2024 09:05:14 -0800 Message-Id: <20240130170514.3640723-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789537183635045701 X-GMAIL-MSGID: 1789537183635045701 Some Makefiles under tools/ use the 'override CFLAGS += ...' construct to add a few required options to CFLAGS passed by the user. Unfortunately that only works when user passes CFLAGS as an environment variable, i.e. CFLAGS=... make ... and not in case when CFLAGS are passed as make command line arguments: make ... CFLAGS=... It happens because in the latter case CFLAGS=... is recorded in the make variable MAKEOVERRIDES and this variable is passed in its original form to all $(MAKE) subcommands, taking precedence over modified CFLAGS value passed in the environment variable. E.g. this causes build failure for gpio and iio tools when the build is run with user CFLAGS because of missing _GNU_SOURCE definition needed for the asprintf(). One way to fix it is by removing overridden variables from the MAKEOVERRIDES. Add macro 'drop-var-from-overrides' that removes a definition of a variable passed to it from the MAKEOVERRIDES and use it to fix CFLAGS passing for tools/gpio and tools/iio. Cc: stable@vger.kernel.org Fixes: 4ccc98a48958 ("tools gpio: Allow overriding CFLAGS") Fixes: 572974610273 ("tools iio: Override CFLAGS assignments") Signed-off-by: Max Filippov --- tools/gpio/Makefile | 1 + tools/iio/Makefile | 1 + tools/scripts/Makefile.include | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile index d29c9c49e251..46fc38d51639 100644 --- a/tools/gpio/Makefile +++ b/tools/gpio/Makefile @@ -24,6 +24,7 @@ ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) all: $(ALL_PROGRAMS) export srctree OUTPUT CC LD CFLAGS +$(call drop-var-from-overrides,CFLAGS) include $(srctree)/tools/build/Makefile.include # diff --git a/tools/iio/Makefile b/tools/iio/Makefile index fa720f062229..04307588dd3f 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile @@ -20,6 +20,7 @@ ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) all: $(ALL_PROGRAMS) export srctree OUTPUT CC LD CFLAGS +$(call drop-var-from-overrides,CFLAGS) include $(srctree)/tools/build/Makefile.include # diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 6fba29f3222d..43e1fbb8329f 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -51,6 +51,15 @@ define allow-override $(eval $(1) = $(2))) endef +# When a Makefile overrides a variable and exports it for the nested $(MAKE) +# invocations to use its modified value, it must remove that variable definition +# from the MAKEOVERRIDES variable, otherwise the original definition from the +# MAKEOVERRIDES takes precedence over the exported value. +drop-var-from-overrides = $(eval $(drop-var-from-overrides-code)) +define drop-var-from-overrides-code +MAKEOVERRIDES := $(subst -escaped-space-,\ ,$(filter-out $(1)=%,$(subst \ ,-escaped-space-,$(MAKEOVERRIDES)))) +endef + ifneq ($(LLVM),) ifneq ($(filter %/,$(LLVM)),) LLVM_PREFIX := $(LLVM)