Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp428012lqa; Sat, 27 Apr 2024 07:55:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSm81kvfNEKK8HM9blW899p3o7VKRfsbC0/dl0VVZ0jqy6E6gr+k/KVBT9I+d0fDEqb+Cn7BInHtlUQDhLUyWhfU7Db7Er4mU2JvKxsg== X-Google-Smtp-Source: AGHT+IFy3F0jht1ngaFR4EKsRX4oNcl5NDyMew3KIj+3xDeIaSW6u0ZLHupoURSbx1LfVlfzX/at X-Received: by 2002:ac2:4a70:0:b0:51b:250a:a8fb with SMTP id q16-20020ac24a70000000b0051b250aa8fbmr4772707lfp.48.1714229749879; Sat, 27 Apr 2024 07:55:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714229749; cv=pass; d=google.com; s=arc-20160816; b=BKmG88iC0t+YcSukPjfIzNZPNrkSSr49u/p4Db5KoLS9X7kw7XZuSLnACsKRFKuodo wjdTRBTTi4kdXKJU34Xau5i3SufQztyBCzcQ4i4rDaPOlYm+gyPAjuD9RYAg/8BmSf+N tEJd+eJ6ieDSKLTX+dFwMaEaRXq7oK0mHC5ZVUZlGvX5G+SKGE3n9QTvvPPqbm9m7ity +b/5ybNHr0rP+hv7IGdD5OIndPZLP5MMBcjjZjdylSD9yjC+8kWaw5Cv82wXofdYwnUJ L9WTKA3325Db/pP6vkXF/aXSQodsO8Hla2VqYcgyHuKyTl4u3ASZj3PmuyUa8xZ4Si2g 4w4w== 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=aHNIH/8DzQ0Uf2hF5cGjWTrAMSs/E6t32LwBSoJ78Gk=; fh=/PhI1yHyFxYs5o3lizcVDuHUNfskx2eM9AUZHILGzH0=; b=wRDFzXwA/GQBjlbT81FczK38R6ApdvUwfOHW6qD8CTJ7Ge3jXLbrXZz9am/EsQJ7MC +H+DtbaWZrbVgkpGP1n3fvFGiYdy2GYDdH0lLZ3xlQf0O1LHZLx7MKlNukiycxcyTXYg flyshvgiQNq5keQFoN23wEDFWo/1PlZu1V6uiDuX/bMXsetRjBeq35Vi3ecTe+gQuh+q Ck/9/YFOKl6ulOF9TIMNmEYJwovEgcFdDykP9b28tX6zuSFyQPr+FFWFADTWmdH7PFGN hGAfbhJUZi0j3Wv25jTTYwKOKGrQxjJ8k4WZk5GIZqOoK+U9uAUyw/dTrk59efqgDrOr kblQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FF0gp7fx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z8-20020a170906240800b00a51e5aa5b2esi12240880eja.575.2024.04.27.07.55.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 07:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FF0gp7fx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161070-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3B6231F227E6 for ; Sat, 27 Apr 2024 14:55:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 234A41DDEA; Sat, 27 Apr 2024 14:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FF0gp7fx" 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 2126611721; Sat, 27 Apr 2024 14:55:12 +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=1714229713; cv=none; b=DV1O2iZgHm5FokZqiWhzFhsWJ4mItKT/Xg4wKqaM28DjmCevibD3E/gLspyChLBuiNABJ8KCrnmFS+c6eOR0eW4JXDWqoFzKGkiNo1U7Sn2Ya1RwyYv7sueN+7U31F3dgOhxc9u0+GvCdr4koPA/pYg/+fEuQ7PEaObpsehOyt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714229713; c=relaxed/simple; bh=sxkO/VNGuHCpY+xaA593lVgtx7OEmQ5zj1XiiuDfS9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O6e9+pfHz7dVkyVuR/FgihEZF24GCdna/UKsP6Vr89MWh1VKR3a0ryiSo3kvC342rNAc/82MyExx0Y6fyuyaracp95cSEQp6O/44ogNaQ5JsTSWbfnF+uGpxJLLy+WB3CZ9upm2S1kr/XhwayFXxiVcBwcm7fXdkK4qQPpb1f6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FF0gp7fx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A76CEC2BD10; Sat, 27 Apr 2024 14:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714229712; bh=sxkO/VNGuHCpY+xaA593lVgtx7OEmQ5zj1XiiuDfS9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FF0gp7fx6+7X5owHaXgnY2c+n0niE6MF2CwPjVBtN+2Ui676eB3E5o4265uR+MGtL GRA4sI7BEuRiUIM6bLTRGgqP8ldhtt2wTTcbBcO2T7teYMu+Qum/Zwa3hJVVDJKlUQ omj0hKaaiqwU/VqNXg5kO0OKKwfkGP+13E4vgWXgo6SLvdQp2G/lw25z3bwTMnzp6z V0OaiWRY85gORgGxP3qkn5qHpXH7yJslCYjkiTow7pCY3oscQQJTQZAMqwTLozXork j49sgdB7pA1vcxs6T+8EnevN9zbZL8wUkmN638AAJPZ/kxRmBVdXCUqrZ7Q+rZoMyW 7hisVHcklQwfg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nicolas Schier Subject: [PATCH v2 3/4] kbuild: use $(obj)/ instead of $(src)/ for common pattern rules Date: Sat, 27 Apr 2024 23:55:01 +0900 Message-Id: <20240427145502.2804311-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240427145502.2804311-1-masahiroy@kernel.org> References: <20240427145502.2804311-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for checked-in source files. It is merely a convention without any functional difference. In fact, $(obj) and $(src) are exactly the same, as defined in scripts/Makefile.build: src := $(obj) Before changing the semantics of $(src) in the next commit, this commit replaces $(obj)/ with $(src)/ in pattern rules where the prerequisite might be a generated file. C, assembly, and Rust files are sometimes generated by tools, so they could be either generated files or real sources. The $(obj)/ prefix works for both cases with the help of VPATH. As mentioned above, $(obj) and $(src) are the same at this point, hence this commit has no functional change. I did not modify scripts/Makefile.userprogs because there is no use case where userspace C files are generated. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - replace $(src)/%.rs with $(obj)/%.rs because Rust files are also generated scripts/Makefile.build | 26 +++++++++++++------------- scripts/Makefile.host | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index baf86c0880b6..41138346afb0 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -113,13 +113,13 @@ endif quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS) $(CC_FLAGS_LTO), $(c_flags)) -fverbose-asm -S -o $@ $< -$(obj)/%.s: $(src)/%.c FORCE +$(obj)/%.s: $(obj)/%.c FORCE $(call if_changed_dep,cc_s_c) quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< -$(obj)/%.i: $(src)/%.c FORCE +$(obj)/%.i: $(obj)/%.c FORCE $(call if_changed_dep,cpp_i_c) genksyms = scripts/genksyms/genksyms \ @@ -133,7 +133,7 @@ cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@) >/dev/null -$(obj)/%.symtypes : $(src)/%.c FORCE +$(obj)/%.symtypes : $(obj)/%.c FORCE $(call cmd,cc_symtypes_c) # LLVM assembly @@ -141,7 +141,7 @@ $(obj)/%.symtypes : $(src)/%.c FORCE quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -fno-discard-value-names -o $@ $< -$(obj)/%.ll: $(src)/%.c FORCE +$(obj)/%.ll: $(obj)/%.c FORCE $(call if_changed_dep,cc_ll_c) # C (.c) files @@ -240,7 +240,7 @@ define rule_as_o_S endef # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE +$(obj)/%.o: $(obj)/%.c $(recordmcount_source) FORCE $(call if_changed_rule,cc_o_c) $(call cmd,force_checksrc) @@ -257,7 +257,7 @@ quiet_cmd_cc_lst_c = MKLST $@ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ System.map $(OBJDUMP) > $@ -$(obj)/%.lst: $(src)/%.c FORCE +$(obj)/%.lst: $(obj)/%.c FORCE $(call if_changed_dep,cc_lst_c) # Compile Rust sources (.rs) @@ -290,7 +290,7 @@ rust_common_cmd = \ quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< -$(obj)/%.o: $(src)/%.rs FORCE +$(obj)/%.o: $(obj)/%.rs FORCE +$(call if_changed_dep,rustc_o_rs) quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ @@ -298,19 +298,19 @@ quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ $(rust_common_cmd) -Zunpretty=expanded $< >$@; \ command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@ -$(obj)/%.rsi: $(src)/%.rs FORCE +$(obj)/%.rsi: $(obj)/%.rs FORCE +$(call if_changed_dep,rustc_rsi_rs) quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $< -$(obj)/%.s: $(src)/%.rs FORCE +$(obj)/%.s: $(obj)/%.rs FORCE +$(call if_changed_dep,rustc_s_rs) quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $< -$(obj)/%.ll: $(src)/%.rs FORCE +$(obj)/%.ll: $(obj)/%.rs FORCE +$(call if_changed_dep,rustc_ll_rs) # Compile assembler sources (.S) @@ -336,14 +336,14 @@ cmd_gensymtypes_S = \ quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null -$(obj)/%.symtypes : $(src)/%.S FORCE +$(obj)/%.symtypes : $(obj)/%.S FORCE $(call cmd,cc_symtypes_S) quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< -$(obj)/%.s: $(src)/%.S FORCE +$(obj)/%.s: $(obj)/%.S FORCE $(call if_changed_dep,cpp_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ @@ -358,7 +358,7 @@ cmd_gen_symversions_S = $(call gen_symversions,S) endif -$(obj)/%.o: $(src)/%.S FORCE +$(obj)/%.o: $(obj)/%.S FORCE $(call if_changed_rule,as_o_S) targets += $(filter-out $(subdir-builtin), $(real-obj-y)) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 3c17e6ba421c..d35f55e0d141 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -112,7 +112,7 @@ endif quiet_cmd_host-csingle = HOSTCC $@ cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem)) -$(host-csingle): $(obj)/%: $(src)/%.c FORCE +$(host-csingle): $(obj)/%: $(obj)/%.c FORCE $(call if_changed_dep,host-csingle) # Link an executable based on list of .o files, all plain c @@ -129,7 +129,7 @@ $(call multi_depend, $(host-cmulti), , -objs) # host-cobjs -> .o quiet_cmd_host-cobjs = HOSTCC $@ cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< -$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE +$(host-cobjs): $(obj)/%.o: $(obj)/%.c FORCE $(call if_changed_dep,host-cobjs) # Link an executable based on list of .o files, a mixture of .c and .cc -- 2.40.1