From patchwork Fri Feb 2 15:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp524568dyc; Fri, 2 Feb 2024 08:02:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4oVljR8IU0cR84OgHOa1x5BYQ2Yb8m4PGsB4J9gZiMvfFIKSVFPSNsgrn+LIvuCCpmrCf X-Received: by 2002:a05:6a00:6a05:b0:6df:f362:f961 with SMTP id hy5-20020a056a006a0500b006dff362f961mr2559172pfb.12.1706889761058; Fri, 02 Feb 2024 08:02:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889761; cv=pass; d=google.com; s=arc-20160816; b=Nx08ktfkrV7gCSOD5CTnFlB3CI0Or+GmNLuoJkIzFCl0ek/2nuuCGvs8lSrGQgyG4r gLCeFX22DiS8uaf54x0aXtm6c2Pa1OtZiFVIEgT+ihT+/XB6sAVrTTWgcvPO4pjNpo81 yfqKKDTL5nt6z1mGTxoq8WMW4gfEKm1t+BmkKU0tOgKnQUFfk1AsDGwTiMT50krGTiFw VpVbK0drLgUy/EBSWRiEtOR4SIRDb9O8oPHVT52kRxs8UkrQ8onlWBKJMpqGCtpsAA4K KftkgclkpQsGagtv+oHdYW/WNrk8iXVPhTZoKCCFiKO4U5me1YGqw9V/T6JhkkEn9s/z cFQA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xFdfeiSlO2bbOFkNP4exziW+LkA5yJj/gKQazAE8sK0=; fh=NC5Iyl4+HpFBsLoRsf6m9AIPalNFo5alz0ogpLDSB/U=; b=0mZiE8tW/PUy5EJyD4kTkBnZxsRxD6S88Y9wIb+k/saB9Ul//P8QfL/32Gz8a7GiOv UA7/cAh5q2ty4hgv3w7YnDfPZJCzYNUKZIflc2Oryx3awZj7SoWrPQ5CRoanzuZdYErT VdSYvntEv5RX2WAeorMnyUa6Qoe8EyxS6qkhvQT7FDaaj2Qotj90hTx7vaAr2HsH24g3 ce72U9CFJk7cBMwff5+4f/pmN3GGON2yrlWPwT57Iy6xLY2dwTrqaksExgsrPLcMHM+r Mi3AeUdtfd15jV7pZIzSfN9msqcT05VaFL3zV0nZ5k3CAyZJgbZ3eODSb5tl8oRX3+qv 9YVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNYxlaze; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW4AYOQL08E+aYAIXnl0IWWIE2ZqAZKAEo4WDiCIn9Zd/g6uqeAxQzSIti7HdcpphC2kWJ82c6Ch+0fC7rLjKg/t5gCBw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e18-20020aa798d2000000b006dde31b3c82si1680668pfm.350.2024.02.02.08.02.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:02:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNYxlaze; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3784028E231 for ; Fri, 2 Feb 2024 16:01:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A44514A0A0; Fri, 2 Feb 2024 15:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iNYxlaze" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DC6651487D3; Fri, 2 Feb 2024 15:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; cv=none; b=liqUIMJlxlNi6InJ/rxUdHgFhyA7stYJBzad3NDohcBepiArlJprw1YDwXgz1my3ytbm9KPUOjy/tnT/VNanWC9eG1wBlkbj8/5/uFJx+7ZjmoTvEZyu8mtaSbea/4afdAhuNNzfc0MczMBUdwSH9vg/fJNs97fzuVwRH26+Y/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; c=relaxed/simple; bh=R/ud+/692kalgVHV0nqCoalOnQuqYPYP1Bs8zxfM520=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Knxhn2bUoDQZDT3rO/CGKv0vmYR/403atT9R6OvbPsOf8nNRg47zJD7+jVLgIKyV91fylm210Lb/84KwZYkqOne5sPKWnijfsj0sTuWjBg9+Q/oEZFqwTFG4QanXRJsog5CwfX5wRAubKe0ajkGcFnO9obg92c5NQolEyiqOh4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iNYxlaze; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE71C433F1; Fri, 2 Feb 2024 15:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889518; bh=R/ud+/692kalgVHV0nqCoalOnQuqYPYP1Bs8zxfM520=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNYxlazejOtTkfIDYgKVtb0w3qXSn/htZNacZR08Yz1ZnsDAGDrl5dXkTmKgew4+b 7B93InMSKi1t4t0iLFaJ+uxVy9U5i2I0za3d3Npy24JTbWAfzrfqPCDhIe9FCZ5jXJ xGYJ9mtlROeoV8AorAayvblqUmYHca3/iYwRqzFKXnTlfDSWyvTWhyZyYfvT6ot97w JemRdBbueOE0dyP/pCulU4fiN8qJ8/OvaeGlMkNFMkdEBGmhKVayu/MksxLyrvFjis HTPwIcxrzvhVgCOzYBp89Bn0+7ctPJNCrDn9ntOhDzKS/iXVlc3cgOWRl5V6kWpHA+ tbIAJNf1RGBfw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 07/27] kconfig: call env_write_dep() right after yyparse() Date: Sat, 3 Feb 2024 00:58:05 +0900 Message-Id: <20240202155825.314567-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> 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: 1789803638090656735 X-GMAIL-MSGID: 1789803638090656735 This allows preprocess.c to free up all of its resources when the parse stage is finished. It also ensures conf_write_autoconf_cmd() produces consistent results even if called multiple times for any reason. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 8 ++------ scripts/kconfig/lkc_proto.h | 2 +- scripts/kconfig/parser.y | 9 ++++++++- scripts/kconfig/preprocess.c | 11 +++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f6a96fdddb7e..dafc572e7b7e 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -994,14 +994,10 @@ static int conf_write_autoconf_cmd(const char *autoconf_name) return -1; } + fprintf(out, "autoconfig := %s\n", autoconf_name); + fputs(str_get(&autoconf_cmd), out); - fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name); - - env_write_dep(out, autoconf_name); - - fprintf(out, "\n$(deps_config): ;\n"); - fflush(out); ret = ferror(out); /* error check for all fprintf() calls */ fclose(out); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index a4ae5e9eadad..85491d74a094 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -46,7 +46,7 @@ enum variable_flavor { VAR_RECURSIVE, VAR_APPEND, }; -void env_write_dep(FILE *f, const char *auto_conf_name); +void env_write_dep(struct gstr *gs); void variable_add(const char *name, const char *value, enum variable_flavor flavor); void variable_all_del(void); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 611038c502fc..cfb82ba09037 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -482,7 +482,7 @@ void conf_parse(const char *name) autoconf_cmd = str_new(); - str_printf(&autoconf_cmd, "deps_config := \\\n"); + str_printf(&autoconf_cmd, "\ndeps_config := \\\n"); zconf_initscan(name); @@ -492,6 +492,13 @@ void conf_parse(const char *name) yydebug = 1; yyparse(); + str_printf(&autoconf_cmd, + "\n" + "$(autoconfig): $(deps_config)\n" + "$(deps_config): ;\n"); + + env_write_dep(&autoconf_cmd); + /* Variables are expanded in the parse phase. We can free them here. */ variable_all_del(); diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index d1f5bcff4b62..b9853d4a891c 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -87,14 +87,17 @@ static char *env_expand(const char *name) return xstrdup(value); } -void env_write_dep(FILE *f, const char *autoconfig_name) +void env_write_dep(struct gstr *s) { struct env *e, *tmp; list_for_each_entry_safe(e, tmp, &env_list, node) { - fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value); - fprintf(f, "%s: FORCE\n", autoconfig_name); - fprintf(f, "endif\n"); + str_printf(s, + "\n" + "ifneq \"$(%s)\" \"%s\"\n" + "$(autoconfig): FORCE\n" + "endif\n", + e->name, e->value); env_del(e); } }