From nobody Fri Nov 29 17:47:27 2024 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 F228117A918; Tue, 17 Sep 2024 14:17:33 +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=1726582654; cv=none; b=Z9aTTsWQ3C7uobKJkMPsxAv4f5JwlONR3qjOfMTin4Pfo2jFw00YdWoZSkLObMee5YI/wC7arctfPAir4l5N/BboSDkCk411DWrtd/KWQWLJcLjTOSh5J/MSAqPlaCghQXcPYCvnrGO5Y7VWUo6swM80/3A21axAokt2rdx/jjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582654; c=relaxed/simple; bh=GKorpVSUF9hPEdB9ymdQzxEwHHwAdZIW5qqmtDYc5C4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NQr3qw81eYvGHViuNGdRStT2D6YloeN8q+fKFQx8PLt6lyOal29Ekt4FSlwAHgd2q7lb1U5PL+s2RtFevcJxpRE1s8+EGLI9xNjXDT+qmo0FN6Kejn8JKqHE85FUnQjHd5BEUENvmp0ipM7web5VBq6uR3pK+ZRa/2RpUT+pVf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fV67669S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fV67669S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D504DC4CECD; Tue, 17 Sep 2024 14:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582653; bh=GKorpVSUF9hPEdB9ymdQzxEwHHwAdZIW5qqmtDYc5C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fV67669SoEfCdMzvPe0nT1FhMAqa+yt3j6JOM4c2H4eQDv2fgYSx7MKqcWzUtiMks dt8YKP2m+wCvYY0yqeNLLH8eDBUjon6woZ2fPMf+kDY5BTkQAQSi1mXZEATmhxDs/5 /OAodKIuxy8kM7sA3856Bp6YRDTq5Lh062SBcXTFySlWiq3W1c0jsvajIYXXdwG4u/ 5642QIx9ciVyqgWK2BxKA0U65KgdjP4ru1+3W95Q9nuyOSkVAUO9Jzlc4uMvTXeIrG Sj5GAypokuRbe8BPBf/l1xW6SVkJPOTnvVFVuSnH+sY5JoVCGW8c0SWe3U5on0zAhv oStCLYKEZToyA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 01/23] kbuild: doc: update the description about Kbuild/Makefile split Date: Tue, 17 Sep 2024 23:16:29 +0900 Message-ID: <20240917141725.466514-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" The phrase "In newer versions of the kernel" was added by commit efdf02cf0651 ("Documentation/kbuild: major edit of modules.txt sections 1-4"). This feature is no longer new, so remove it and update the paragraph. Example 3 was written 20 years ago. [1] There is no need to note about backward compatibility with such an old build system. Remove Example 3 entirely. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/co= mmit/?id=3D65e433436b5794ae056d22ddba60fe9194bba007 Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 38 +++----------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 131863142cbb..1014a275a7e1 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -224,10 +224,9 @@ module 8123.ko, which is built from the following file= s:: 3.2 Separate Kbuild File and Makefile ------------------------------------- =20 - In newer versions of the kernel, kbuild will first look for a - file named "Kbuild," and only if that is not found, will it - then look for a makefile. Utilizing a "Kbuild" file allows us - to split up the makefile from example 1 into two files: + Kbuild will first look for a file named "Kbuild", and if it is not + found, it will then look for "Makefile". Utilizing a "Kbuild" file + allows us to split up the "Makefile" from example 1 into two files: =20 Example 2:: =20 @@ -250,37 +249,6 @@ module 8123.ko, which is built from the following file= s:: consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest. =20 - The next example shows a backward compatible version. - - Example 3:: - - --> filename: Kbuild - obj-m :=3D 8123.o - 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o - - --> filename: Makefile - ifneq ($(KERNELRELEASE),) - # kbuild part of makefile - include Kbuild - - else - # normal makefile - KDIR ?=3D /lib/modules/`uname -r`/build - - default: - $(MAKE) -C $(KDIR) M=3D$$PWD - - # Module specific targets - genbin: - echo "X" > 8123_bin.o_shipped - - endif - - Here the "Kbuild" file is included from the makefile. This - allows an older version of kbuild, which only knows of - makefiles, to be used when the "make" and kbuild parts are - split into separate files. - 3.3 Binary Blobs ---------------- =20 --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 EBC4317C9A7; Tue, 17 Sep 2024 14:17:35 +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=1726582656; cv=none; b=M5ozGpkalMn59j+0mPxYabqUNw0xmUJg9wtNlpD+/Zz2X8Kkd4sQp/nE+6wpyXLOXU2M6vhbVgBJ4Ik/gyL/Yo0ZXQiLTlw2QGR8wRfvaupPi3NtPj1rpo5iEgDY8elXuVQNANrQzhQiHzabTAp+4CyheSEqNYdBU0hhBs4exzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582656; c=relaxed/simple; bh=i2X5CGYdAQj7D1JJrAj+pHMkEjk/Y29Sea8SsHGcNkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3XTlbBtNvkqz9omgrvAI0nN5TmmSjBf+2xF9IqgnPysjWlCwBkbXIrPgs+RaPme8oSlmYmEQvoY6F5fCosOKBzKpIlEF1Uq1CyjVedUGTjCuNSkVhl8KorruTcee5UibwI7ezC0kVRjAttSrrPtL+FjV2aPSZvdWZ4LFxn1sow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m6XnzA1K; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m6XnzA1K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05B93C4CED5; Tue, 17 Sep 2024 14:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582655; bh=i2X5CGYdAQj7D1JJrAj+pHMkEjk/Y29Sea8SsHGcNkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6XnzA1Kr+++5Y87VdLgXLoTj/dUyyCb+Zm9bmNchVmR+/82UL82qpdL9dbTc5NRs QNKeS0/aHzdNNeaeq1tzedAlR3TuzR0ipNT4pe7xRUS/Iztm8Kyf9sypjgAkxGWRGL Pc7sUqpk5LEprT9pLAXK7f4K8GMOgYKBShFzX8iYF+eZii1H5ATAryf0iDJffA8o+v cRUMsx9koLMYfll6/9cEhBDmiokM9fzRXMw9BBKsYOofqW11cDct+fEVbvmczKIBe5 3SdCv6CiCu3zGpV0G0G46yxwTa7j0ZRrd//Z5uP/9ZgocUhyV/mQOLfNICinSXuP9G R2wjU/pFdxgSQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 02/23] kbuild: doc: remove description about grepping CONFIG options Date: Tue, 17 Sep 2024 23:16:30 +0900 Message-ID: <20240917141725.466514-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" This description was added 20 years ago [1]. It does not convey any useful information except for a feeling of nostalgia. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/co= mmit/?id=3D65e433436b5794ae056d22ddba60fe9194bba007 Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 1014a275a7e1..268ebbd2ab74 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -521,9 +521,3 @@ build. =20 ext2-y :=3D balloc.o bitmap.o dir.o ext2-$(CONFIG_EXT2_FS_XATTR) +=3D xattr.o - - External modules have traditionally used "grep" to check for - specific `CONFIG_` settings directly in .config. This usage is - broken. As introduced before, external modules should use - kbuild for building and can therefore use the same methods as - in-tree modules when testing for `CONFIG_` definitions. --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 2CAE618594F; Tue, 17 Sep 2024 14:17:37 +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=1726582658; cv=none; b=nKmTvDAn7sSrCBvtV1+BuSqGG6rbTP/SDM7t6RxDxG4i9j+hgbZqlvQWCAF9OZuIU0QknzI7dQsDEIxBjismJVa18mqzzN9YtGHyFCvDh6E8NWZHT2WQTF9chro7REJ34m/NaooTl4KHgzDIPyaQCANqWqlrtiiPIldL49fPCDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582658; c=relaxed/simple; bh=mEQ0ucDdLUQliMtanUxk44g5JWErCiGrOMyYhL1jU8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=amXN8rxx+6+nJVy+M5GTDnPSaFvMP342KQnVZyLkvpTtnWO6Y3/h7hG/JsvKkWB07KOL0UP+vSYonH7rQNtedq2IL7bDkRVo6XcRUO303T0VQar7e9Xy8IuXR7r6FCns9X2vkHvsMMadkWG/ssJm9jk6FVDn6HmF4x3tTmLz0Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ToA62I3D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ToA62I3D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11942C4CECD; Tue, 17 Sep 2024 14:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582657; bh=mEQ0ucDdLUQliMtanUxk44g5JWErCiGrOMyYhL1jU8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToA62I3DlVO5DsXeJCBgIqatkpRCPrEwx6J1aXJONw2xm9MUakM5NkaltIugwb7lc +KakMreO0NvbKPS0KLviMBXvUzL/j+Eh3r6O6ExQPdz5wkyNYotS73jNpm0LsQZz7I Kh2mKbev4qC4PefI7yP3yO1ulWguqONEdA3FruhDY9Ysoo/YZHZT9aixi8y6wHS/s9 ORphFAFmWYbK8P++ahlH2Er9J8GxSUIpaxtpHVZif+lcs08ypQhtl7GrXWbFu701uH rF3XWxTruIdrberKoFTa2Ivl5b9wjEoBA2D3GjobqUOZS3uV90pAAZHgGaUvnxuW3R yJlp/gb80RNAA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 03/23] kbuild: doc: remove outdated description of the limitation on -I usage Date: Tue, 17 Sep 2024 23:16:31 +0900 Message-ID: <20240917141725.466514-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Kbuild used to manipulate header search paths, enforcing the odd limitation of "no space after -I". Commit cdd750bfb1f7 ("kbuild: remove 'addtree' and 'flags' magic for header search paths") stopped doing that. This limitation no longer exists. Instead, you need to accurately specify the header search path. (In this case, $(src)/include) Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 268ebbd2ab74..7eceb9a65e9c 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -328,13 +328,9 @@ according to the following rule: --> filename: Kbuild obj-m :=3D 8123.o =20 - ccflags-y :=3D -Iinclude + ccflags-y :=3D -I $(src)/include 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o =20 - Note that in the assignment there is no space between -I and - the path. This is a limitation of kbuild: there must be no - space present. - 4.3 Several Subdirectories -------------------------- =20 --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 396DA18757D; Tue, 17 Sep 2024 14:17:39 +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=1726582660; cv=none; b=fuyzplkj8YNFMZbxix20w+b47oc8u0h3f9FskL8T4/Bu1ePIRY/rOBPzzZinR+PlBExQXilJ/JADQJY4gG5M0o2A7hVV54eUTaoxlS/G3cBICDkF4s3molCUBLE5tF5zt+q9NaCq/DvwqgXd+S5sZV/00tEgUaBflWlBJmgE3x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582660; c=relaxed/simple; bh=M5hwbxGmb3kFIwBUjhm/vKr9Jp1vcsNIkcx9cZ1dz/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P1FTPIcdYxrhSnK/f9YC8sgAWubMADudVJvLFXxkYFCsz5BhDXaYJW6WXeOL6c9AGBTOEe87Agiwq/2KlcnIjwhbLNci7LrpK+lOLouBYmc7+67YZhMdJFLNPJHENyuVhjnkM8Kxx8A0Zz+b8KhOtduB5RWimuaZl595VdLmU40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MWc/OAQJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MWc/OAQJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F4BEC4CECF; Tue, 17 Sep 2024 14:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582659; bh=M5hwbxGmb3kFIwBUjhm/vKr9Jp1vcsNIkcx9cZ1dz/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWc/OAQJOTgPjXBC/zSjUa4v5+Mr++4m5gzJFVPj/+Z1TxHe9TfkRecHrs3e0f7Le ++eq01SBf39lsPA5zraelQ1Q2NGhtMEm9OZYIL9/JWpMFg22Bv1S5KhF34flw3TIEt eY8YMhAa3+YEl555Fh67Oza/yuOGH1jKbwAEP1/JVSFcK8Pk876xxFxJbr5SCfvncG dS9ib/pTO/wkUQ889CJyYMIl5s4NO090BckwTlHLZE/DMQPDKlm4TBXeRC4UZTi13C Q3wn0S1VZhNh2vGQzoZeLpMjNEYqmIxyQRlKrWaSC3AVhiVs/LV5H8lQlT7j4DYrbZ B4OPqFAnY/QYg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 04/23] kbuild: doc: remove the description about shipped files Date: Tue, 17 Sep 2024 23:16:32 +0900 Message-ID: <20240917141725.466514-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" The use of shipped files is discouraged in the upstream kernel these days. [1] Downstream Makefiles have the freedom to use shipped files or other options to handle binaries, but this is not what should be advertised in the upstream document. [1]: https://lore.kernel.org/all/CAHk-=3DwgSEi_ZrHdqr=3D20xv+d6dr5G895CbOAi= 8ok+7-CQUN=3DfQ@mail.gmail.com/ Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 35 +++----------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 7eceb9a65e9c..1afa6b1b4090 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -180,7 +180,6 @@ module 8123.ko, which is built from the following files= :: 8123_if.c 8123_if.h 8123_pci.c - 8123_bin.o_shipped <=3D Binary blob =20 3.1 Shared Makefile ------------------- @@ -198,7 +197,7 @@ module 8123.ko, which is built from the following files= :: ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m :=3D 8123.o - 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o + 8123-y :=3D 8123_if.o 8123_pci.o =20 else # normal makefile @@ -207,10 +206,6 @@ module 8123.ko, which is built from the following file= s:: default: $(MAKE) -C $(KDIR) M=3D$$PWD =20 - # Module specific targets - genbin: - echo "X" > 8123_bin.o_shipped - endif =20 The check for KERNELRELEASE is used to separate the two parts @@ -232,7 +227,7 @@ module 8123.ko, which is built from the following files= :: =20 --> filename: Kbuild obj-m :=3D 8123.o - 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o + 8123-y :=3D 8123_if.o 8123_pci.o =20 --> filename: Makefile KDIR ?=3D /lib/modules/`uname -r`/build @@ -240,35 +235,11 @@ module 8123.ko, which is built from the following fil= es:: default: $(MAKE) -C $(KDIR) M=3D$$PWD =20 - # Module specific targets - genbin: - echo "X" > 8123_bin.o_shipped - The split in example 2 is questionable due to the simplicity of each file; however, some external modules use makefiles consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest. =20 -3.3 Binary Blobs ----------------- - - Some external modules need to include an object file as a blob. - kbuild has support for this, but requires the blob file to be - named _shipped. When the kbuild rules kick in, a copy - of _shipped is created with _shipped stripped off, - giving us . This shortened filename can be used in - the assignment to the module. - - Throughout this section, 8123_bin.o_shipped has been used to - build the kernel module 8123.ko; it has been included as - 8123_bin.o:: - - 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o - - Although there is no distinction between the ordinary source - files and the binary file, kbuild will pick up different rules - when creating the object file for the module. - 3.4 Building Multiple Modules =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =20 @@ -329,7 +300,7 @@ according to the following rule: obj-m :=3D 8123.o =20 ccflags-y :=3D -I $(src)/include - 8123-y :=3D 8123_if.o 8123_pci.o 8123_bin.o + 8123-y :=3D 8123_if.o 8123_pci.o =20 4.3 Several Subdirectories -------------------------- --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 F0F74178397; Tue, 17 Sep 2024 14:17:41 +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=1726582662; cv=none; b=QviSODDb49UyiLyL52Ta7oNwrnhoqTnWcotWTJ1eu4EvDCF7IBqYfkcRaVNqao7kFXIyeiv0RpD32eqhnRGGlo4oSav7T7OrVRMNzMFdLSj07iOX4yf4QzyDgw8xeevHw1ayMpcwfsFypU89cjIxAdnPXFD1pEywsPm/g58UKi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582662; c=relaxed/simple; bh=zOKWLWOiEYUwJiA94nx2gJuvgncyH0kFTF0myUNTP9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gNRuaQRCq3ivusGiFEBE0RyGN9GXJY8P02EGGmw2HKdQ3tKXliAqa+OzWW9yoDOTO/EwkuFRRDlisTCN4hKkUsXfT+RTXGU0MzCcwBXKfK9xxo1hIWa1EmPvsSXbl6qUscr4qFdZTk9YoT2o7pvR24cpsmB4WXwlg/vm4jxot0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NRkSmNbJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NRkSmNbJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E3BFC4CECE; Tue, 17 Sep 2024 14:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582661; bh=zOKWLWOiEYUwJiA94nx2gJuvgncyH0kFTF0myUNTP9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRkSmNbJuo3Hq9ZTl320PZn/MO+WmCugD2N6q31nRrCb16Ne1BdOLsPzdPaBrjphn +cTQcD48Ad5XjpNwkIQn3PtgNL5CHssJnHoy23ym60aEu1MgoNDhjftZ29YvHQNlIs yKLR6yrLc3Yi53Ls7yQwNkW1FZZGzFxr3/Deb05iUmDd2Bqh9qZHcVjNlEn6otEQNj dxonGv/z9mJyZDSZK/jnCgc6rbTMB0TWZhR8iZOnCImU13KK2ujhWWkGxzHN2cbz+w kzdhqjbvLN0jODN0E6VJreNegwxvPr8tYsUdgCHvwfHwKWQhi0/ceJrVi/4OpZSnvE L4E9DcPKIhayg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 05/23] kbuild: doc: describe the -C option precisely for external module builds Date: Tue, 17 Sep 2024 23:16:33 +0900 Message-ID: <20240917141725.466514-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Building external modules is typically done using this command: $ make -C M=3D Here, refers to the output directory where the kernel was built, not the kernel source directory. When the kernel is built in-tree, there is no ambiguity, as the output directory and the source directory are the same. If the kernel was built in a separate build directory, should be the kernel output directory. Otherwise, Kbuild cannot locate necessary build artifacts such as the .config file, etc. This has been the method for building external modules based on the kernel compiled in a separate directory for over 20 years. [1] If you pass the kernel source directory to the -C option, you must also specify the kernel build directory using the O=3D option. This approach works as well, though it results in a slightly longer command: $ make -C O=3D M=3D Some people mistakenly believe that O=3D should point to a separate output directory for external modules when used together with M=3D. This commit adds more clarification to Documentation/kbuild/kbuild.rst. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/co= mmit/?id=3De321b2ec2eb2993b3d0116e5163c78ad923e3c54 Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/kbuild.rst | 5 +++++ Documentation/kbuild/modules.rst | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.= rst index 9c8d1d046ea5..716f6fb70829 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -129,6 +129,11 @@ KBUILD_OUTPUT ------------- Specify the output directory when building the kernel. =20 +This variable can also be used to point to the kernel output directory when +building external modules using kernel build artifacts in a separate build +directory. Please note that this does NOT specify the output directory for= the +external modules themselves. + The output directory can also be specified using "O=3D...". =20 Setting "O=3D..." takes precedence over KBUILD_OUTPUT. diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 1afa6b1b4090..a80bff699e77 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -74,7 +74,7 @@ executed to make module versioning work. =20 The command to build an external module is:: =20 - $ make -C M=3D$PWD + $ make -C M=3D$PWD =20 The kbuild system knows that an external module is being built due to the "M=3D" option given in the command. @@ -91,12 +91,15 @@ executed to make module versioning work. 2.2 Options =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 - ($KDIR refers to the path of the kernel source directory.) + ($KDIR refers to the path of the kernel source directory, or the path + of the kernel output directory if the kernel was built in a separate + build directory.) =20 make -C $KDIR M=3D$PWD =20 -C $KDIR - The directory where the kernel source is located. + The directory that contains the kernel and relevant build + artifacts used for building an external module. "make" will actually change to the specified directory when executing and will change back when finished. =20 --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 3C70B189503; Tue, 17 Sep 2024 14:17:43 +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=1726582664; cv=none; b=to9qUWRDqqvHFvr5Of66CiZX1asrrNZq4SFbykINtMs3pc4G1jk+YY9bbrUzpQbgm18Lzk6EI6PzfQruBsz3xFgCPICh/4tPMqrKwatfYi4D1h7PwgTKIzvtv4oWu08DwjEIz084Drs1Gw4wYrXFauJccKh7D8eqXDKI5UYWj2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582664; c=relaxed/simple; bh=BrRTM809vvzXSKo1ggTymNEipDQUHfKnrRRZ0fYJjww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U4jYgtNLDzdUDaHioAHIaNJRPgIM+44QvleiPd9ma7u2xLUoeLgsa3etCVsnheskmkp/AB4uQWCTAtXX8wkRQ56YhMfZLw8Qf5ZQ4kWaqPQJQOn9do8pmSc0LM5eAzt0zK4vjbxUL7AN6dYc0S+wyzAKOPm4J8Q4fHN/C+cN7ZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XMPLBvWH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XMPLBvWH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 349B6C4CECE; Tue, 17 Sep 2024 14:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582663; bh=BrRTM809vvzXSKo1ggTymNEipDQUHfKnrRRZ0fYJjww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMPLBvWH6B6t01Pd2ofS+HINpciwcG7dp1EW/GNH5X96HxWtY9mkj8hjjQ71N3t8S f7ABnyosJfuVdxgOEE7JtX1VkO/dF0uBtZfxwzdIvBRnO8sIzNqcNwlws33v8vxIaA QKteJFRnMhmxb9CjGJydlXDDSxB5yCyd+oToaKvVY4gkgCLVOAlOGQaUiEZaw+DGi1 YQikz0kq9Er2JUG8n9JskP6EIia5MOxREqkMHRMm7Oet+uLFZIZIpviooFtqQRawF0 f33y8D9qdC9Q96+SgAl00Q4/k9ylvCDvLCT+8Rpnxyn8DyyDeQqBzpCI5Tr+svSQfT KbOU8ZW/mQVkg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 06/23] kbuild: doc: replace "gcc" in external module description Date: Tue, 17 Sep 2024 23:16:34 +0900 Message-ID: <20240917141725.466514-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Avoid "gcc" since it is not the only compiler supported by Kbuild. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index a80bff699e77..3a6e7bdc0889 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -38,7 +38,7 @@ This document describes how to build an out-of-tree kerne= l module. =20 "kbuild" is the build system used by the Linux kernel. Modules must use kbuild to stay compatible with changes in the build infrastructure and -to pick up the right flags to "gcc." Functionality for building modules +to pick up the right flags to the compiler. Functionality for building mod= ules both in-tree and out-of-tree is provided. The method for building either is similar, and all modules are initially developed and built out-of-tree. @@ -284,7 +284,7 @@ according to the following rule: =20 #include =20 - kbuild will add options to "gcc" so the relevant directories + kbuild will add options to the compiler so the relevant directories are searched. =20 4.2 Single Subdirectory --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 4619F18A6CC; Tue, 17 Sep 2024 14:17:46 +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=1726582666; cv=none; b=k2iUKGj+HUTGLdtsb/Ry4bPithXgoNgMq3xVXWue2XjzNFo8M23FJYd39raqSqQQHV0aGYAwWtpIi2W/yxsZtNKIYFPVI33o0W1O+/IjACkBNz0Y9EgIm8Req6h4llzgFq14t3rFZcS7IyP8ZyO/HPje8XgZfImkYGDpHHKPKVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582666; c=relaxed/simple; bh=+9PNpuHsdm7Ec9+L5pNvm1cAeo6Z5ZSpTWnrQWR6nsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k1sf6F2hXZRI2ioKLgbyykpJG7on1UvyGD1IeDQO7eIMtyOA8nAog++qWz8rFpBchjIAbjxjMt0KLfkgAb3+zCzUGSIZ97vpc/C4VMS0eS1J3ceY4XZ9/XFc9ePYf8Rgv+UoZoK2rleGSpwN7eC/kcBdOz5OE87DEUoQOvy2gNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BTwPRpGA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BTwPRpGA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 599BAC4CEC5; Tue, 17 Sep 2024 14:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582666; bh=+9PNpuHsdm7Ec9+L5pNvm1cAeo6Z5ZSpTWnrQWR6nsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTwPRpGA7aRIKVZP6gJs11R258Rf/4UU5zer3t5jnekFkSwXESj29OVdiDU/GaxO2 MGXEMJ3GY74WkfZvQAoHTmqCPhQ1kjiv8t6ml/Bx5Qi+d6TZZsq3VLTO71dFuP0KuP sdsGbbBQ9KigJp/IYxzNR5ybSkuJwlrD2OXPGuYtxUR9KxZDOxGLKNLGMvdZEPeHNM oVimC+mEmgUx9Qtskna0HwMwrkJU2QbnD9OREkncCoVmoh6FSmWRxs3UyriKXtJPX1 k2NpB6dXd8WoM/0fXiTXMRGdsYaEK7nE5UkFY+3aQJQrhnDHMPBfMIe7FNDu12LiD4 u1BxdQA/VnPiA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 07/23] kbuild: remove unnecessary prune of rust/alloc for rustfmt Date: Tue, 17 Sep 2024 23:16:35 +0900 Message-ID: <20240917141725.466514-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 9d0441bab775 ("rust: alloc: remove our fork of the `alloc` crate") removed the rust/alloc/ directory. Signed-off-by: Masahiro Yamada Acked-by: Miguel Ojeda Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 35b8392d2bef..5b16e0605a77 100644 --- a/Makefile +++ b/Makefile @@ -1741,9 +1741,7 @@ PHONY +=3D rustfmt rustfmtcheck # We `grep` afterwards in order to remove the directory entry itself. rustfmt: $(Q)find $(abs_srctree) -type f -name '*.rs' \ - -o -path $(abs_srctree)/rust/alloc -prune \ -o -path $(abs_objtree)/rust/test -prune \ - | grep -Fv $(abs_srctree)/rust/alloc \ | grep -Fv $(abs_objtree)/rust/test \ | grep -Fv generated \ | xargs $(RUSTFMT) $(rustfmt_flags) --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 AC34917AE11; Tue, 17 Sep 2024 14:17:48 +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=1726582668; cv=none; b=khsyr2voekBkXaHxW0IwbRKEdC8Jzo5UgHG21HaJf1q1Vk1Lg96SCa82LDnMhgnLRO94ymYutFwYLLBuUN8w/KCwSotENSGQBJxHjx35w8dYVZoydeJrUdsP1MySSrnWV1OnGapP/DidCzXj/Lfjlx8059lJ1T+iWS6vW+Myj0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582668; c=relaxed/simple; bh=n8IL6UM3AlOmJPnvqYyhhURelp40V5xK3Ka0wCaa2Q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fUxUkpRhnMRWfoynG+WtYJk/1Hp8pCXfL0wYuGvXRRYFTvTH1IwnpEoSKcm2Vm4u7xmbiBqYCtkN+7ZAdo2z3syg3hhTZn6LGs5mvsftasOLzso6iFzbiWM6cz0MXOgQbF8v5aJDJN90r3tZcDVJhJZdYlFbvYnXZ3y+/3X+wug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tbWqWCsX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tbWqWCsX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B188FC4CECD; Tue, 17 Sep 2024 14:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582668; bh=n8IL6UM3AlOmJPnvqYyhhURelp40V5xK3Ka0wCaa2Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tbWqWCsXC+BMGDSCr1VxGr9145xEILy0CqXIockESg7e+uDliCAdp6aWgKYYtTPXa jRw1khQ8xp3jkiUDjqi01iIBmDhQx8vBChhrcNMuve/BqYQzKwCXQ5yKLGNsOu8zdk mcZx7mqV4e1H4TAHWwfXai+ILxNk4EQJD30nOI/twKx8/gBCiUlfKm6npi/Uffr1Cd SP41JPqy3gjab5DlV24aPr7ogjc6dyJntjG63bDJcZe9fThoJCIu0I5zHRIwBl7PZW leoUd2dHWyvsvsC6iQzDjWNaUwVGCtGiyeATybuSpqIa/cQeTwlli0WGqv/zA1Tb6v 0JyFgAzA+ZUmw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 08/23] kbuild: simplify find command for rustfmt Date: Tue, 17 Sep 2024 23:16:36 +0900 Message-ID: <20240917141725.466514-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" The current 'find' command does not prune the rust/test directory itself, requiring an additional 'grep -Fv' command to exclude it. This is cumbersome. The correct use of the -prune option can be seen in the 'make clean' rule. [Current command] $ find . -type f -name '*.rs' -o -path ./rust/test -prune | wc 70 70 1939 $ find . -type f -name '*.rs' -o -path ./rust/test -prune | grep rust/test ./rust/test [Improved command] $ find . -path ./rust/test -prune -o -type f -name '*.rs' -print | wc 69 69 1927 $ find . -path ./rust/test -prune -o -type f -name '*.rs' -print | grep r= ust/test With the improved 'find' command, the grep command is no longer needed. There is also no need to use the absolute path, so $(abs_srctree) can be replaced with $(srctree). The pruned directory rust/test must be prefixed with $(srctree) instead of $(objtree). Otherwise, 'make O=3D... rustfmt' would visit the stale rust/test directory remaining in the source tree. Signed-off-by: Masahiro Yamada Acked-by: Miguel Ojeda Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5b16e0605a77..4992b2895dd5 100644 --- a/Makefile +++ b/Makefile @@ -1740,9 +1740,8 @@ PHONY +=3D rustfmt rustfmtcheck # when matching, which is a problem when e.g. `srctree` is `..`. # We `grep` afterwards in order to remove the directory entry itself. rustfmt: - $(Q)find $(abs_srctree) -type f -name '*.rs' \ - -o -path $(abs_objtree)/rust/test -prune \ - | grep -Fv $(abs_objtree)/rust/test \ + $(Q)find $(srctree) -path $(srctree)/rust/test -prune \ + -o -type f -name '*.rs' -print \ | grep -Fv generated \ | xargs $(RUSTFMT) $(rustfmt_flags) =20 --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 EA01E18E02B; Tue, 17 Sep 2024 14:17:50 +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=1726582671; cv=none; b=esbi+WBjPqkSi8XZiFVbc5FCsX7v1moCDgoS7IdXDzVTNVk+OF9OXTvM4oTFrQ89mU8VwHNid3kGtlvYV6sX97RNSlEkREMzJ7KQV1Q/p6OykqconY2N4lL3vvqH5nB3S9KhYHwOx63PzUdGv/2tsiS20I/fQFFvcj9LLD7DP5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582671; c=relaxed/simple; bh=v1w8q5fANzCuOIlI91VhLyPWmXzboTXSVo9AD3A2I0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gWL9+SmtmiSR4o4aMNUnH6wMx0p91RvxN5cMX3RIV2jw3lPtw3OubdR3+sssKLAafRlUU2IZeS58NYorTP+o6dF3oipB6tZ/jplNPbOCyLvxjTG0Fwf2+de+AXf8q9PmYBakga0niVJ12ZvjEyiQlp60/a6UhxIyvuLB+zt0jmo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OzXSvH7r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OzXSvH7r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF7B6C4CECF; Tue, 17 Sep 2024 14:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582670; bh=v1w8q5fANzCuOIlI91VhLyPWmXzboTXSVo9AD3A2I0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OzXSvH7r9H0jhAg4LT7kVq5RXbI35nkRhJGKkXRly5yEfNWsBdbvPgUHU7IlyGhAO QVBBVtiHOOx3uHXcDtzFx3XxQG/45Evv+0lyk/+jFkC1+o7JEIl/2XSTqIUMKB/CFc U+RtU0nExBesrp01FEjrF11s8NcAxd0KRj23l+YjQXZz9ZZlIc2f32FMkxBX7uy7fC 4JdlA8K2Yi9DXKdZ/64iXxtenQ8JW8IQgOAS7Ez5v7TQxUk1nnYdlyoWhjqEtHyNN4 JUnlkMxB24d6ZImIqqBdHU0xeFLcwiFYjVpD7go804uAUgGg1r9R+iZMHIiJ7TPT2f 69PyiXzsHlKCg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 09/23] speakup: use SPKDIR=$(src) to specify the source directory Date: Tue, 17 Sep 2024 23:16:37 +0900 Message-ID: <20240917141725.466514-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit b1992c3772e6 ("kbuild: use $(src) instead of $(srctree)/$(src) for source directory"), $(src) consistently points to the source directory whether this is compiled an as external module or not. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- drivers/accessibility/speakup/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/accessibility/speakup/Makefile b/drivers/accessibility= /speakup/Makefile index 6f6a83565c0d..14ba1cca87f4 100644 --- a/drivers/accessibility/speakup/Makefile +++ b/drivers/accessibility/speakup/Makefile @@ -40,9 +40,7 @@ hostprogs +=3D makemapdata makemapdata-objs :=3D makemapdata.o =20 quiet_cmd_mkmap =3D MKMAP $@ - cmd_mkmap =3D TOPDIR=3D$(srctree) \ - SPKDIR=3D$(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD),$(srctree)/drivers/acc= essibility/speakup) \ - $(obj)/makemapdata > $@ + cmd_mkmap =3D TOPDIR=3D$(srctree) SPKDIR=3D$(src) $(obj)/makemapdata= > $@ =20 $(obj)/mapdata.h: $(obj)/makemapdata $(call cmd,mkmap) --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 37D67190486; Tue, 17 Sep 2024 14:17:52 +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=1726582673; cv=none; b=L7yi9M5/3Vft84b6014wYzuKLBrcYvnsSbFdf8yB2Auyfzhv7k//Dx8PYFr9Ydx1SFOiswvfAzdbwcWNXyaKFSlV20ktaMzEGb+NKEcgbvsESm57ARmSZ2xF/pGTJ/r3WMyEVgNJGaWgWk+r/RhK8HWhEM/Yj5lDsGpYlfQkCtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582673; c=relaxed/simple; bh=WhinTnECYKQ6Ay8RYWYnKkOB1a4zHCeW5QL3zgxwZ7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JxLu1QAO60KNnjvuij+iUBXY0DAUh9s9HNKC0TlmsFuQ8+T+HXbJR/nmnB8SH5uxb5Ezr8jmkH0UsuhwGGKRhzAVojZbf5UcSdK6aENU7nG4WShan0Ps2l/f1MbpqteFmqN7dvf78M4OwI3YXB/M0TdoaQECRV/0hxRl1s6nldM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FuehOgjg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FuehOgjg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05521C4CEC5; Tue, 17 Sep 2024 14:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582672; bh=WhinTnECYKQ6Ay8RYWYnKkOB1a4zHCeW5QL3zgxwZ7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuehOgjgaEL1OGaw0GMYGiAp1C257VwJJ3DDlRIAKvje33x2KLQ6aQ9off2YHjPoJ qzc2BMF3u+Jm17lrfCn23ZpHJBCm0ytPSJEZXQUYQaGPjlluJ+ekJ2fU6MiYZ3v6JW ggR+XCMn5RARvkuX/Vf17kTgMK7l+II1yH+WndUAh9V76DzVI9kMLPJjOyx3dBiwhb 658ABNr0U0MbgiTa4LBdA2VHzv6R8siZeHDMPee8EsKTAFvnT8BSw5oOBPn1GVnpqc 57aP0YQcEl5cJx4V3ge9vCzBL/lmEsj86ZTA/ZexgbqpoUugEWfpp/cJmt2rIT7HVg tCXdrWqmACbUQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 10/23] kbuild: refactor the check for missing config files Date: Tue, 17 Sep 2024 23:16:38 +0900 Message-ID: <20240917141725.466514-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" This commit refactors the check for missing configuration files, making it easier to add more files to the list. The format of the error message has been slightly changed, as follows: [Before] ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are mis= sing. Run 'make oldconfig && make prepare' on kernel src to fix it. [After] *** *** ERROR: Kernel configuration is invalid. The following files are miss= ing: *** - include/generated/autoconf.h *** - include/config/auto.conf *** Run "make oldconfig && make prepare" on kernel source to fix it. *** Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 4992b2895dd5..3f5c273c2901 100644 --- a/Makefile +++ b/Makefile @@ -778,17 +778,22 @@ $(KCONFIG_CONFIG): else # !may-sync-config # External modules and some install targets need include/generated/autocon= f.h # and include/config/auto.conf but do not care if they are up-to-date. -# Use auto.conf to trigger the test +# Use auto.conf to show the error message + +checked-configs :=3D include/generated/autoconf.h include/config/auto.conf +missing-configs :=3D $(filter-out $(wildcard $(checked-configs)), $(checke= d-configs)) + +ifdef missing-configs PHONY +=3D include/config/auto.conf =20 include/config/auto.conf: - @test -e include/generated/autoconf.h -a -e $@ || ( \ - echo >&2; \ - echo >&2 " ERROR: Kernel configuration is invalid."; \ - echo >&2 " include/generated/autoconf.h or $@ are missing.";\ - echo >&2 " Run 'make oldconfig && make prepare' on kernel src to = fix it."; \ - echo >&2 ; \ - /bin/false) + @echo >&2 '***' + @echo >&2 '*** ERROR: Kernel configuration is invalid. The following f= iles are missing:' + @printf >&2 '*** - %s\n' $(missing-configs) + @echo >&2 '*** Run "make oldconfig && make prepare" on kernel source t= o fix it.' + @echo >&2 '***' + @/bin/false +endif =20 endif # may-sync-config endif # need-config --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 6B32617BEDB; Tue, 17 Sep 2024 14:17:55 +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=1726582675; cv=none; b=RbI5WCIOxELIDhQZz5PQnJG69s0C8CKFyygMtL0lZvZdrnp2bRjcTToMgBXOpSOWbLbMcidw4VO/riCm2S2j7pzKve/1X+AltkFhNl3eDzAndEIff5UmQP65rWYbpKNV37SPqgp9pfTAzA3lCSdS1JVj1rbaEenjdzGin6SF+jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582675; c=relaxed/simple; bh=4bq9doD09IGzlJ3vv9HsmysgLeLSxT9Eyw84oRf2g1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UchGlwTvHAEEwHtJEvD4+lT1+zyvVf45H+CSaYYzFOc7vTClJUYgC1cY2KmzaPEfO0Lj4amNXppa0AhUgsX+Dfi74uAhlC7ovFs3GkAo+541ZjR2qHsTXU3VwTGtK9cyq1xw//aLG+sghg1r5T+nfzjQWMfnbS5fQo3IhTOYtGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DKX6o4/r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DKX6o4/r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42FBCC4CECE; Tue, 17 Sep 2024 14:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582675; bh=4bq9doD09IGzlJ3vv9HsmysgLeLSxT9Eyw84oRf2g1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKX6o4/rSSj/+99p6SQAuNKThNXjF+BJA2kw2x9aSClEOtv5zysvRDgXIdXtFwwpk 3kvuQWyTw2vFMucNX5MGNztXZIVXlUYMpWlOhHSgDVNfnYedO4l+hdizb+Yeu2xvTz K4YrjvLrtkBD+dwj7YK4SXhWpNQqW+tgknpFMtdN9cywZO/NbabRrS4iyisKh6PUqz vwp1leq9nFURUP2KOXvHGyvmCZmmokq5wfecgHTTzqbWYSJHiQkuUApUp8oBM9pCYo USu9LBQ2asHTDl/ZJSQfRqa9KHCLzIN9KSXYQ4a+ynOpnBTGu3wEZFFdPeGK06U0U5 KmLsxAvhtVygA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 11/23] kbuild: check the presence of include/generated/rustc_cfg Date: Tue, 17 Sep 2024 23:16:39 +0900 Message-ID: <20240917141725.466514-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit 2f7ab1267dc9 ("Kbuild: add Rust support"), Kconfig generates include/generated/rustc_cfg, but its presence is not checked in the top-level Makefile. It should be checked similarly to the C header counterpart, include/generated/autoconf.h. Signed-off-by: Masahiro Yamada Acked-by: Miguel Ojeda Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3f5c273c2901..5700d08c9b57 100644 --- a/Makefile +++ b/Makefile @@ -780,7 +780,7 @@ else # !may-sync-config # and include/config/auto.conf but do not care if they are up-to-date. # Use auto.conf to show the error message =20 -checked-configs :=3D include/generated/autoconf.h include/config/auto.conf +checked-configs :=3D include/generated/autoconf.h include/generated/rustc_= cfg include/config/auto.conf missing-configs :=3D $(filter-out $(wildcard $(checked-configs)), $(checke= d-configs)) =20 ifdef missing-configs @@ -1187,7 +1187,8 @@ PHONY +=3D prepare archprepare =20 archprepare: outputmakefile archheaders archscripts scripts include/config= /kernel.release \ asm-generic $(version_h) include/generated/utsrelease.h \ - include/generated/compile.h include/generated/autoconf.h remove-stale-fil= es + include/generated/compile.h include/generated/autoconf.h \ + include/generated/rustc_cfg remove-stale-files =20 prepare0: archprepare $(Q)$(MAKE) $(build)=3Dscripts/mod --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 AA3A91925B1; Tue, 17 Sep 2024 14:17:57 +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=1726582677; cv=none; b=T205+eUOt70ocOTel9K6FbzcwunRp7RdJUqD6smukABTl8/+0uSNUgtfi87fiKelWXaPoofzdjOjyNv9+t5y4rZCY1g78KiUeEzmnh7z7QrF5pihjP+0GXFqj2jlJSVOlvWo29q8sY3O4YyfHbGdKHBqehkMLJhxDtvWZEVhK/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582677; c=relaxed/simple; bh=CPGuVVmP9nfnoF+wMfgzB9DaNE/+HVqfHgpUsGHpkck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ioY400YZboTnuE5kEdBdh05bIrlAuxQ4WLTQ7r8CEGo6Hhdn1HoIon07+EHiFvcYenydkP8DMihnThofVFoZYBcc/zOZS6GMYXfxYxLyrdGYb5IlLh/Y7G8za1k2JTMtq3AtG2HnmhC+cP2EFwhyWIy3j2hoAJH44Y+KDUvyRZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HxsxDyhz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HxsxDyhz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94298C4CEC5; Tue, 17 Sep 2024 14:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582677; bh=CPGuVVmP9nfnoF+wMfgzB9DaNE/+HVqfHgpUsGHpkck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HxsxDyhz/AwuzXACq66np4u4XrLpfHNQqs5Bm6tWzlHQ+885AdHOzSiSN1ztMyrAD 8ZoaJW7oQZwvS4D3qOdA1SKcRue4DSLjJnZfQP9j3kRDcP9Xac9kxgkbeDYIPE6VeB UJOzimE6zu47d+4fAMPldduXCNxV/+Z/9QEQOL2CVsgV+DiZOX6D4kVmtIpwT+8vHB YQSGUQy15KElY6hGYPmxtM6Qb6ghabXxVDXNS52dXQSCuf79b4HJpSeQsERmOu8YMo jjImF+uCPm8IumSRyvo+Pfmmw1JPYIVEppeKTKGExZiwihShQ0V2fld1xU2UnsOBsJ tF1mdozZZts0w== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix Date: Tue, 17 Sep 2024 23:16:40 +0900 Message-ID: <20240917141725.466514-13-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" This change allows it to work not only for in-tree modules but also for external modules, even if they are built in a separate build directory. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- scripts/nsdeps | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/nsdeps b/scripts/nsdeps index f1718cc0d700..8b4db63838ce 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -19,10 +19,10 @@ if ! { echo "$SPATCH_REQ_VERSION"; echo "$SPATCH_VERSIO= N"; } | sort -CV ; then exit 1 fi =20 -if [ "$KBUILD_EXTMOD" ]; then +if [ "${VPATH+set}" ]; then src_prefix=3D else - src_prefix=3D$srctree/ + src_prefix=3D$VPATH/ fi =20 generate_deps_for_ns() { --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 2275917C99B; Tue, 17 Sep 2024 14:17:59 +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=1726582680; cv=none; b=jrdMsy947iGx17PtAK3yg2qzI/Xk5lnOiGezxICS1aNrjwnsCobzSoKtoL0V0PiDnA2fGvakarQHBwIe/zMH/+gg4QS6ZNly6WEaq0cpYU0e1nlIGCaLZFG6f4SP+5D44+yH7T4gIa5exLMKmCInJY/WGuJ2oLhCC4S1GbDlQTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582680; c=relaxed/simple; bh=dwKSfpuXEb7k3eYZ4e5Rn0Sa6XU7qYIELYeSbbtc8lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WkTHrq4HtNc4IpYpuHhsFOtLH2QNWMqRibwt2ua79fKPUHS1aDFdNIZ5ydr/0Uw6tW99kwOY76HsBoubLiIf+I/y8l/7S45Rj/q0f4R04cBSE9elFvqWs9V+AJ2vWKbUufwTV8q61kFmJhSOBH2cRqNkbmStyd+vUwLAwhjtTr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AIVlRwM2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AIVlRwM2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBE01C4CEC5; Tue, 17 Sep 2024 14:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582679; bh=dwKSfpuXEb7k3eYZ4e5Rn0Sa6XU7qYIELYeSbbtc8lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AIVlRwM2FUewwZKUrJJdl5EsCeHBQBPtX6OhxpHOFEIK9AraokHsrtNY/xSxE5tgl AaAdfZlGy2I7l63r2Kp/Z0qOIujYa/cqQESKw6LrxicB64QqxhRSZRUkpjSgPLFsys g7tWOtUzFpp0KNu0UqbxJzCcH3ySNuiSAbYa7TfkxEA+Y17UlrboAtE74i/DlrM6lt OUhVqIu2xJHr6LZp/X0OKIpEiHK7P0VDI6O+bSI6tg9aVJ8jSWzvu0i+If0JxmKz5g frqA1qk29/VpKAja8loJv7t4rqDDuLlMny6TFTIpUyYLgyvbIMIw3AO+EmiFQF178d Gr1AUE1Pkcr3g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 13/23] kbuild: replace two $(abs_objtree) with $(CURDIR) in top Makefile Date: Tue, 17 Sep 2024 23:16:41 +0900 Message-ID: <20240917141725.466514-14-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Kbuild changes the working directory until it matches $(abs_objtree). When $(need-sub-make) is empty, $(abs_objtree) is the same as $(CURDIR). Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5700d08c9b57..ee9ad0f0960f 100644 --- a/Makefile +++ b/Makefile @@ -228,12 +228,12 @@ else # need-sub-make =20 # We process the rest of the Makefile if this is the final invocation of m= ake =20 -ifeq ($(abs_srctree),$(abs_objtree)) +ifeq ($(abs_srctree),$(CURDIR)) # building in the source tree srctree :=3D . building_out_of_srctree :=3D else - ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) + ifeq ($(abs_srctree)/,$(dir $(CURDIR))) # building in a subdirectory of the source tree srctree :=3D .. else --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 40DFB192D8F; Tue, 17 Sep 2024 14:18:02 +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=1726582682; cv=none; b=UTSiHAysM4I4lO2CpcC4lhd3Da6SUs5z/wbXOGkcoTmXWfz2SlEtdX1Bwje2XHVmT7/MwPQES0Cwe4ltZwS8VA6fHEYjXjX2nN7I+qzrGfMPiXFd5VF+SJBkh/ZFstjF9gl4r+wr/qUbu2epo2j9rZc/wmAlET78gBwX6JvBwus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582682; c=relaxed/simple; bh=sHAeApIqfGlTqapdYcO1A9RoNWPGiHzfamf04FN3TXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BfhadMkElLGCM7fl0p0tVroUR1xN6TeQjQHtIOQLVWkwSOBnQ5Nt2B+gpKICFKnF/JJta9RBmdaEPLMrwmM4swN4Z25/f7nJrhgcqFkI1FnhKr7v1+R/g3mrHJlqJSYdNjPw2Z7TLKKkr42fhoqVrqG2l1nt2zD/PbYPKTS79AY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vAWXa3CM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vAWXa3CM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56AF5C4CECF; Tue, 17 Sep 2024 14:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582682; bh=sHAeApIqfGlTqapdYcO1A9RoNWPGiHzfamf04FN3TXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAWXa3CM6bRnk2tcv0VM8xus1m2aTcJ4Ezr1niZCoBOikv643tfUQo++zFf3nyeRD Clj166vJaIk/hzTqNqD1X4dwK0Zu5S4KycUa47I+rRhW9OYtFCNxTYNCAIcW6v6FXS RZGFoerGLHHvz5r+DylcvjYvHcwZQy+M/vISpIYlycFIvgnmOFdcbzif7dVAmVMZla srCtee5Wx9c6j2X8U7/GKmHbG3yaafF8olPSB801Q67Bm06o1iK9ECDmGOAkyRsIWg nEuoEDLTn7Xi0ZqTybXbkHpVoiSuOwfYa4/v5g0nVgnYRKnb/iJhXZMynO2f6fxlHu DNBOunYiKEgdA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 14/23] kbuild: add $(objtree)/ prefix to some in-kernel build artifacts Date: Tue, 17 Sep 2024 23:16:42 +0900 Message-ID: <20240917141725.466514-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" $(objtree) refers to the top of the output directory of kernel builds. This commit adds the explicit (objtree)/ prefix to build artifacts needed for building external modules. This change has no immediate impact, as the top-level Makefile currently defines: objtree :=3D . However, it prepares for supporting the building of external modules in a different directory. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 10 +++++----- scripts/Kbuild.include | 2 +- scripts/Makefile.build | 4 ++-- scripts/Makefile.modfinal | 14 +++++++------- scripts/Makefile.modinst | 2 +- scripts/Makefile.modpost | 12 ++++++------ scripts/depmod.sh | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index ee9ad0f0960f..c923bea7043b 100644 --- a/Makefile +++ b/Makefile @@ -354,7 +354,7 @@ else # !mixed-build include $(srctree)/scripts/Kbuild.include =20 # Read KERNELRELEASE from include/config/kernel.release (if it exists) -KERNELRELEASE =3D $(call read-file, include/config/kernel.release) +KERNELRELEASE =3D $(call read-file, $(objtree)/include/config/kernel.relea= se) KERNELVERSION =3D $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEV= EL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION =20 @@ -717,7 +717,7 @@ endif export KBUILD_MODULES KBUILD_BUILTIN =20 ifdef need-config -include include/config/auto.conf +include $(objtree)/include/config/auto.conf endif =20 ifeq ($(KBUILD_EXTMOD),) @@ -780,13 +780,13 @@ else # !may-sync-config # and include/config/auto.conf but do not care if they are up-to-date. # Use auto.conf to show the error message =20 -checked-configs :=3D include/generated/autoconf.h include/generated/rustc_= cfg include/config/auto.conf +checked-configs :=3D $(addprefix $(objtree)/, include/generated/autoconf.h= include/generated/rustc_cfg include/config/auto.conf) missing-configs :=3D $(filter-out $(wildcard $(checked-configs)), $(checke= d-configs)) =20 ifdef missing-configs -PHONY +=3D include/config/auto.conf +PHONY +=3D $(objtree)/include/config/auto.conf =20 -include/config/auto.conf: +$(objtree)/include/config/auto.conf: @echo >&2 '***' @echo >&2 '*** ERROR: Kernel configuration is invalid. The following f= iles are missing:' @printf >&2 '*** - %s\n' $(missing-configs) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index ed8a7493524b..8c311b997e24 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -205,7 +205,7 @@ if_changed_dep =3D $(if $(if-changed-cond),$(cmd_and_fi= xdep),@:) =20 cmd_and_fixdep =3D = \ $(cmd); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ + $(objtree)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-targe= t).cmd;\ rm -f $(depfile) =20 # Usage: $(call if_changed_rule,foo) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 8403eba15457..6e8954cbf53a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -34,7 +34,7 @@ subdir-asflags-y :=3D subdir-ccflags-y :=3D =20 # Read auto.conf if it exists, otherwise ignore --include include/config/auto.conf +-include $(objtree)/include/config/auto.conf =20 include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Makefile.compiler @@ -107,7 +107,7 @@ cmd_cpp_i_c =3D $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(obj)/%.c FORCE $(call if_changed_dep,cpp_i_c) =20 -genksyms =3D scripts/genksyms/genksyms \ +genksyms =3D $(objtree)/scripts/genksyms/genksyms \ $(if $(1), -T $(2)) \ $(if $(KBUILD_PRESERVE), -p) \ -r $(or $(wildcard $(2:.symtypes=3D.symref)), /dev/null) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 1482884ec3ca..6d8aa3059ee2 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -6,7 +6,7 @@ PHONY :=3D __modfinal __modfinal: =20 -include include/config/auto.conf +include $(objtree)/include/config/auto.conf include $(srctree)/scripts/Kbuild.include =20 # for c_flags @@ -37,15 +37,15 @@ quiet_cmd_ld_ko_o =3D LD [M] $@ cmd_ld_ko_o =3D \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -T scripts/module.lds -o $@ $(filter %.o, $^) + -T $(objtree)/scripts/module.lds -o $@ $(filter %.o, $^) =20 quiet_cmd_btf_ko =3D BTF [M] $@ cmd_btf_ko =3D \ - if [ ! -f vmlinux ]; then \ + if [ ! -f $(objtree)/vmlinux ]; then \ printf "Skipping BTF generation for %s due to unavailability of vmlinux\= n" $@ 1>&2; \ else \ - LLVM_OBJCOPY=3D"$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE= _FLAGS) --btf_base vmlinux $@; \ - $(RESOLVE_BTFIDS) -b vmlinux $@; \ + LLVM_OBJCOPY=3D"$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE= _FLAGS) --btf_base $(objtree)/vmlinux $@; \ + $(RESOLVE_BTFIDS) -b $(objtree)/vmlinux $@; \ fi; =20 # Same as newer-prereqs, but allows to exclude specified extra dependencies @@ -57,8 +57,8 @@ if_changed_except =3D $(if $(call newer_prereqs_except,$(= 2))$(cmd-check), \ printf '%s\n' 'savedcmd_$@ :=3D $(make-cmd)' > $(dot-target).cmd, @:) =20 # Re-generate module BTFs if either module's .ko or vmlinux changed -%.ko: %.o %.mod.o $(extmod_prefix).module-common.o scripts/module.lds $(an= d $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE - +$(call if_changed_except,ld_ko_o,vmlinux) +%.ko: %.o %.mod.o $(extmod_prefix).module-common.o $(objtree)/scripts/modu= le.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/= vmlinux) FORCE + +$(call if_changed_except,ld_ko_o,$(objtree)/vmlinux) ifdef CONFIG_DEBUG_INFO_BTF_MODULES +$(if $(newer-prereqs),$(call cmd,btf_ko)) endif diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 4d81ed9af294..2d39d452c49e 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -6,7 +6,7 @@ PHONY :=3D __modinst __modinst: =20 -include include/config/auto.conf +include $(objtree)/include/config/auto.conf include $(srctree)/scripts/Kbuild.include =20 install-y :=3D diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 44936ebad161..12e7c15d099c 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -35,10 +35,10 @@ PHONY :=3D __modpost __modpost: =20 -include include/config/auto.conf +include $(objtree)/include/config/auto.conf include $(srctree)/scripts/Kbuild.include =20 -MODPOST =3D scripts/mod/modpost +MODPOST =3D $(objtree)/scripts/mod/modpost =20 modpost-args =3D \ $(if $(CONFIG_MODULES),-M) \ @@ -119,11 +119,11 @@ include $(kbuild-file) =20 output-symdump :=3D $(KBUILD_EXTMOD)/Module.symvers =20 -ifeq ($(wildcard Module.symvers),) -missing-input :=3D Module.symvers +ifeq ($(wildcard $(objtree)/Module.symvers),) +missing-input :=3D $(objtree)/Module.symvers else -modpost-args +=3D -i Module.symvers -modpost-deps +=3D Module.symvers +modpost-args +=3D -i $(objtree)/Module.symvers +modpost-deps +=3D $(objtree)/Module.symvers endif =20 modpost-args +=3D -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) diff --git a/scripts/depmod.sh b/scripts/depmod.sh index e22da27fe13e..3c34fecacbc8 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh @@ -12,7 +12,7 @@ KERNELRELEASE=3D$1 =20 : ${DEPMOD:=3Ddepmod} =20 -if ! test -r System.map ; then +if ! test -r "${objtree}/System.map" ; then echo "Warning: modules_install: missing 'System.map' file. Skipping depmo= d." >&2 exit 0 fi @@ -25,7 +25,7 @@ if [ -z $(command -v $DEPMOD) ]; then exit 0 fi =20 -set -- -ae -F System.map +set -- -ae -F "${objtree}/System.map" if test -n "$INSTALL_MOD_PATH"; then set -- "$@" -b "$INSTALL_MOD_PATH" fi --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 E8BE1181339; Tue, 17 Sep 2024 14:18:04 +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=1726582685; cv=none; b=sXJ5dSX/feEphSRkVbsZs5n6s5j2sb3UJMyVq6osbaw92R2MAKundCYaW23afTL/8EP6SRjOI82D2e3rqQH2TxMtFqYp68IX2kN4kmTkpHqk0kuUuXeXuvAY3O/zZKxWcbZIQMSDR+7VlEUXu7iAj9yGfbSPli+tbpxa/ZCZAcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582685; c=relaxed/simple; bh=lf/ZusSJTTcvWWbKf+tPGBQ2Lsaj7xnEDyV2byZ55dg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XK1ApRgFMb8lulHGpvXxqSyeaZGQ3ebC2dEAj+5vKmLYAP2Gcv5TOS5iYGQoob6dpGPtIywxw0GvuwAryb+8KQhkBKwMVKkK0QxAbBBDnx14NCH33j2BdNqmtF02U6JxKfzW+0j16/ppOVMPhSOKddlyAxwlfQfU/dWTYX/ZROs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YSht7sGd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YSht7sGd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F9CC4CEC5; Tue, 17 Sep 2024 14:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582684; bh=lf/ZusSJTTcvWWbKf+tPGBQ2Lsaj7xnEDyV2byZ55dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSht7sGdptXhO3YCVWjSFjEnvDgmPbBRhnvjHUlHEoa1d8cjTb3mXka24xbS5ZG3V wPAtAQf9mDwYJN5DWv1MUaJb1W99lk/o97D3FjYHIGaHwJmywl+HPtxyydIrH6JMjr 50AABl4Oje1D3AP9DmCQDDe4R+aXYKly2kRc1SIQ6kiMiiLF4pKJbFqNBUPO+SvdGU gm96Nul5sJDu20O8lbxU/25vMh9t+Gg7wwvu3BKg089flfx8slIuD52ekmmBfSvkV/ /ODBNo8Y7aE2qcWl78WDi4JL7wAD1m/udiIF6uA6Ej5Gm2tbLQWati1RNpuXFEXMa8 /ebgLQIirKBcA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 15/23] kbuild: rename abs_objtree to abs_output Date: Tue, 17 Sep 2024 23:16:43 +0900 Message-ID: <20240917141725.466514-16-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" 'objtree' refers to the top of the output directory of kernel builds. Rename abs_objtree to a more generic name, to better reflect its use in the context of external module builds. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c923bea7043b..254f05a1cc0f 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ __all: =20 this-makefile :=3D $(lastword $(MAKEFILE_LIST)) abs_srctree :=3D $(realpath $(dir $(this-makefile))) -abs_objtree :=3D $(CURDIR) +abs_output :=3D $(CURDIR) =20 ifneq ($(sub_make_done),1) =20 @@ -185,8 +185,8 @@ ifneq ($(KBUILD_OUTPUT),) # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' fi= rst. $(shell mkdir -p "$(KBUILD_OUTPUT)") # $(realpath ...) resolves symlinks -abs_objtree :=3D $(realpath $(KBUILD_OUTPUT)) -$(if $(abs_objtree),,$(error failed to create output directory "$(KBUILD_O= UTPUT)")) +abs_output :=3D $(realpath $(KBUILD_OUTPUT)) +$(if $(abs_output),,$(error failed to create output directory "$(KBUILD_OU= TPUT)")) endif # ifneq ($(KBUILD_OUTPUT),) =20 ifneq ($(words $(subst :, ,$(abs_srctree))), 1) @@ -197,7 +197,7 @@ export sub_make_done :=3D 1 =20 endif # sub_make_done =20 -ifeq ($(abs_objtree),$(CURDIR)) +ifeq ($(abs_output),$(CURDIR)) # Suppress "Entering directory ..." if we are at the final work directory. no-print-directory :=3D --no-print-directory else @@ -221,7 +221,7 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: = __sub-make =20 # Invoke a second make in the output directory, passing relevant variables __sub-make: - $(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \ + $(Q)$(MAKE) $(no-print-directory) -C $(abs_output) \ -f $(abs_srctree)/Makefile $(MAKECMDGOALS) =20 else # need-sub-make --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 22E71193422; Tue, 17 Sep 2024 14:18:06 +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=1726582687; cv=none; b=QPL85Bq8KhYJICp1vbwDR82aopxlwS1FFFkW819W72HDYRLKFVMc2bz8atQN5wCwNPlBpLB5Hz7FBL6U5mxns30DPznLkawKryrGbZcKyFcTmhqmTpfBADzJCGeIPGxE5azh6RDcQ/PvQJvEiHYiet/lUG0OUS5cpTez2whnP0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582687; c=relaxed/simple; bh=Ujo2ggpWsK2c23dBQVr2WlNq1lt94SVOQJZd+ZZqT5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mEukZPrAFMAxWCXhc6pexJufZBdMjyp3rClBh6gMGp1JLcn/UHxvIHCZ0G0UnseJ8rb7teQ7OtbgBlBpMGJhfhZR7f9uGoRGqfdiP1Zvb/W0o/hpLBJUHFXGHQQ7SixYB2fUAXV5kGeOhLkKmImJ5VYvsrO2ajk4wFyNtFEaNQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xhr2bnFx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xhr2bnFx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CBC1C4CECD; Tue, 17 Sep 2024 14:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582686; bh=Ujo2ggpWsK2c23dBQVr2WlNq1lt94SVOQJZd+ZZqT5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xhr2bnFxx6Qe2WRGAYtU1rvX95LalQzsjFmtepTxfstZfY1gIJz4D6J15Av92AywL CqOfGOSxZ1k0o9rc3LuoquQZB97fiQ/fgfQE/lzOfrsrIqhzjeJHZ2K9+lRMVNJ7/7 fnXvHnDBAnMXxJa4vjm+LfnGEFS6xS4YSHce2NJ7uNKCGzZkhM/c9l9Trd1c4BtqIR BfU9OTtkFiJ33wjEWu8cvRyaTNdprCm8jpCAeDFZdMrkRx4KWOwHf4jCmFolSPYkVr ZUYDxNYoYWK8y/KTJLpzu1DpA8ydwcfqBNu86/Sw1gOdIOtOQGJToJYbvWMxDD7N6C tbhwVq4w+OhfQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 16/23] kbuild: use 'output' variable to create the output directory Date: Tue, 17 Sep 2024 23:16:44 +0900 Message-ID: <20240917141725.466514-17-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" $(KBUILD_OUTPUT) specifies the output directory of kernel builds. Use a more generic name, 'output', to better reflect this code hunk in the context of external module builds. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 254f05a1cc0f..7a76452049ea 100644 --- a/Makefile +++ b/Makefile @@ -176,18 +176,20 @@ export KBUILD_EXTRA_WARN # The O=3D assignment takes precedence over the KBUILD_OUTPUT environment # variable. =20 -# Do we want to change the working directory? ifeq ("$(origin O)", "command line") KBUILD_OUTPUT :=3D $(O) endif =20 -ifneq ($(KBUILD_OUTPUT),) +output :=3D $(KBUILD_OUTPUT) + +# Do we want to change the working directory? +ifneq ($(output),) # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' fi= rst. -$(shell mkdir -p "$(KBUILD_OUTPUT)") +$(shell mkdir -p "$(output)") # $(realpath ...) resolves symlinks -abs_output :=3D $(realpath $(KBUILD_OUTPUT)) -$(if $(abs_output),,$(error failed to create output directory "$(KBUILD_OU= TPUT)")) -endif # ifneq ($(KBUILD_OUTPUT),) +abs_output :=3D $(realpath $(output)) +$(if $(abs_output),,$(error failed to create output directory "$(output)")) +endif =20 ifneq ($(words $(subst :, ,$(abs_srctree))), 1) $(error source directory cannot contain spaces or colons) --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 0E30F194090; Tue, 17 Sep 2024 14:18:08 +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=1726582689; cv=none; b=B6qp/xjBZx2V/fUsZezKx+0o7BlfjfF5526RAh+Ids1YaKtABZoZbJQaZtP3RRLZC3gfl4N2CAzj1yWxsBLOAXlfrWR4fxczRxGbcK9YpRubNW6gLvjXRIR01gPowORw8DIXwjPyhul/BxepK8KNQPbcfvszjwQdaHS0lge3cHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582689; c=relaxed/simple; bh=rC19NpWl2LrUP5KgEEq6tX2ykKFGea+wJn+TOwWQ65k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F4V2dOw3ffCyebSz9Vtz30KEYXvmm6CXz8AtBlF1halb20XY2L07TZ1Yy4h75SnRefwvS8jbzhyK7OXMC80xo6KKOcP+T4DltDQldaT+jHRqeIoTnMvQepvUhJKdIG6akyi2Elqnt+Ke+CvZSXXpjrnMfNS+W5VVX9rB1MNgmWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GbAuieaB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GbAuieaB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31088C4CEC5; Tue, 17 Sep 2024 14:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582688; bh=rC19NpWl2LrUP5KgEEq6tX2ykKFGea+wJn+TOwWQ65k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GbAuieaBOcq4UwSovs/7O1oA27Zl7P2iltGJJDnuucQLOQNdUvauWS1hVjHprHRle JQ3tM/EZHYnvdtRUuxD++OAD3x7sXA8lSQPoy/lQaoEr0cU2kT3KF9/NlebINxnF/z cWnjBSuxO7amFrryjyIt30Tef3/gMdrdXowud6n50pkJwrI5BxhXyh4KFJ4GWZaXsK xhLScUhTFfo1lEuo5OD5nT4jVW59mn1vB+/LgVXbIhDrbMvXaChy5Acc+a8VGYr7It a+931lABvTmqrHNVsLmE6z2sfQjXnA0l7yBBoQeZaX2B/YHgVquHog9LmPHnlgkNtW 2uZKR08uevCWg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 17/23] kbuild: build external modules in their directory Date: Tue, 17 Sep 2024 23:16:45 +0900 Message-ID: <20240917141725.466514-18-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, Kbuild always operates in the output directory of the kernel, even when building external modules. This increases the risk of external module Makefiles attempting to write to the kernel directory. This commit switches the working directory to the external module directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from some build artifacts. The command for building external modules maintains backward compatibility, but Makefiles that rely on working in the kernel directory may break. In such cases, $(objtree) and $(srctree) should be used to refer to the output and source directories of the kernel. The appearance of the build log will change as follows: [Before] $ make -C /path/to/my/linux M=3D/path/to/my/externel/module make: Entering directory '/path/to/my/linux' CC [M] /path/to/my/externel/module/helloworld.o MODPOST /path/to/my/externel/module/Module.symvers CC [M] /path/to/my/externel/module/helloworld.mod.o CC [M] /path/to/my/externel/module/.module-common.o LD [M] /path/to/my/externel/module/helloworld.ko make: Leaving directory '/path/to/my/linux' [After] $ make -C /path/to/my/linux M=3D/path/to/my/externel/module make: Entering directory '/path/to/my/linux' make[1]: Entering directory '/path/to/my/externel/module' CC [M] helloworld.o MODPOST Module.symvers CC [M] helloworld.mod.o CC [M] .module-common.o LD [M] helloworld.ko make[1]: Leaving directory '/path/to/my/externel/module' make: Leaving directory '/path/to/my/linux' Printing "Entering directory" twice is cumbersome. This will be addressed later. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/dev-tools/coccinelle.rst | 19 +++++------- Makefile | 40 +++++++++++++++++--------- rust/Makefile | 4 +-- scripts/Makefile.compiler | 2 +- scripts/Makefile.modpost | 6 ++-- scripts/coccicheck | 6 ++-- scripts/package/install-extmod-build | 7 +++++ 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Documentation/dev-tools/coccinelle.rst b/Documentation/dev-too= ls/coccinelle.rst index 535ce126fb4f..80c83ce0babc 100644 --- a/Documentation/dev-tools/coccinelle.rst +++ b/Documentation/dev-tools/coccinelle.rst @@ -250,25 +250,20 @@ variables for .cocciconfig is as follows: - Your directory from which spatch is called is processed next - The directory provided with the ``--dir`` option is processed last, if u= sed =20 -Since coccicheck runs through make, it naturally runs from the kernel -proper dir; as such the second rule above would be implied for picking up a -.cocciconfig when using ``make coccicheck``. - ``make coccicheck`` also supports using M=3D targets. If you do not supply any M=3D target, it is assumed you want to target the entire kernel. The kernel coccicheck script has:: =20 - if [ "$KBUILD_EXTMOD" =3D "" ] ; then - OPTIONS=3D"--dir $srctree $COCCIINCLUDE" + if [ "$VPATH" ] ; then + OPTIONS=3D"--dir $VPATH $COCCIINCLUDE" else - OPTIONS=3D"--dir $KBUILD_EXTMOD $COCCIINCLUDE" + OPTIONS=3D"--dir . $COCCIINCLUDE" fi =20 -KBUILD_EXTMOD is set when an explicit target with M=3D is used. For both c= ases -the spatch ``--dir`` argument is used, as such third rule applies when whe= ther -M=3D is used or not, and when M=3D is used the target directory can have i= ts own -.cocciconfig file. When M=3D is not passed as an argument to coccicheck the -target directory is the same as the directory from where spatch was called. +When an explicit target is executed with a separate output directory, VPAT= H is +set to the target source directory. The third rule ensures the spatch read= s the +.cocciconfig from the target directory. When M=3D is used, the external mo= dule +directory can have its own.cocciconfig file. =20 If not using the kernel's coccicheck target, keep the above precedence order logic of .cocciconfig reading. If using the kernel's coccicheck targ= et, diff --git a/Makefile b/Makefile index 7a76452049ea..4db22c3a8555 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,20 @@ ifeq ("$(origin O)", "command line") KBUILD_OUTPUT :=3D $(O) endif =20 -output :=3D $(KBUILD_OUTPUT) +ifdef KBUILD_EXTMOD + ifdef KBUILD_OUTPUT + objtree :=3D $(realpath $(KBUILD_OUTPUT)) + $(if $(objtree),,$(error specified kernel directory "$(KBUILD_OUTP= UT)" does not exist)) + else + objtree :=3D $(CURDIR) + endif + output :=3D $(KBUILD_EXTMOD) +else + objtree :=3D . + output :=3D $(KBUILD_OUTPUT) +endif + +export objtree =20 # Do we want to change the working directory? ifneq ($(output),) @@ -248,8 +261,6 @@ ifneq ($(KBUILD_ABS_SRCTREE),) srctree :=3D $(abs_srctree) endif =20 -objtree :=3D . - VPATH :=3D =20 ifeq ($(KBUILD_EXTMOD),) @@ -258,7 +269,7 @@ VPATH :=3D $(srctree) endif endif =20 -export building_out_of_srctree srctree objtree VPATH +export building_out_of_srctree srctree VPATH =20 # To make sure we do not include .config for any of the *config targets # catch them early, and hand them over to scripts/kconfig/Makefile @@ -708,7 +719,7 @@ endif # in addition to whatever we do anyway. # Just "make" or "make all" shall build modules as well =20 -ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECM= DGOALS)),) +ifneq ($(filter all modules nsdeps compile_commands.json clang-%,$(MAKECMD= GOALS)),) KBUILD_MODULES :=3D 1 endif =20 @@ -1091,7 +1102,7 @@ export MODLIB =20 PHONY +=3D prepare0 =20 -export extmod_prefix =3D $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) +export extmod_prefix =3D export MODORDER :=3D $(extmod_prefix)modules.order export MODULES_NSDEPS :=3D $(extmod_prefix)modules.nsdeps =20 @@ -1789,14 +1800,10 @@ filechk_kernel.release =3D echo $(KERNELRELEASE) KBUILD_BUILTIN :=3D KBUILD_MODULES :=3D 1 =20 -build-dir :=3D $(KBUILD_EXTMOD) +build-dir :=3D . =20 -compile_commands.json: $(extmod_prefix)compile_commands.json -PHONY +=3D compile_commands.json - -clean-dirs :=3D $(KBUILD_EXTMOD) -clean: private rm-files :=3D $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTM= OD)/modules.nsdeps \ - $(KBUILD_EXTMOD)/compile_commands.json +clean-dirs :=3D . +clean: private rm-files :=3D Module.symvers modules.nsdeps compile_command= s.json =20 PHONY +=3D prepare # now expand this into a simple variable to reduce the cost of shell evalu= ations @@ -1938,7 +1945,7 @@ $(clean-dirs): =20 clean: $(clean-dirs) $(call cmd,rmfiles) - @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ + @find . $(RCS_FIND_IGNORE) \ \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '*.ko.*' \ -o -name '*.dtb' -o -name '*.dtbo' \ @@ -1971,7 +1978,12 @@ tags TAGS cscope gtags: FORCE PHONY +=3D rust-analyzer rust-analyzer: +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh +ifdef KBUILD_EXTMOD +# FIXME: external modules must not descend into a sub-directory of the ker= nel + $(Q)$(MAKE) $(build)=3D$(objtree)/rust src=3D$(srctree)/rust $@ +else $(Q)$(MAKE) $(build)=3Drust $@ +endif =20 # Script to generate missing namespace dependencies # ------------------------------------------------------------------------= --- diff --git a/rust/Makefile b/rust/Makefile index 8de3ebba9551..8a686ffbd3a2 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -350,8 +350,8 @@ rust-analyzer: $(Q)$(srctree)/scripts/generate_rust_analyzer.py \ --cfgs=3D'core=3D$(core-cfgs)' --cfgs=3D'alloc=3D$(alloc-cfgs)' \ $(realpath $(srctree)) $(realpath $(objtree)) \ - $(rustc_sysroot) $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \ - $(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json + $(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(realpath $(or $= (VPATH),.))) \ + > rust-project.json =20 redirect-intrinsics =3D \ __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 _= _truncdfsf2 __unordsf2 \ diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 92be0c9a13ee..4b80b525d386 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -13,7 +13,7 @@ cc-cross-prefix =3D $(firstword $(foreach c, $(1), \ $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) =20 # output directory for tests below -TMPOUT =3D $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ +TMPOUT =3D .tmp_$$$$ =20 # try-run # Usage: option =3D $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 12e7c15d099c..ccca705bc389 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -111,13 +111,13 @@ endif else =20 # set src + obj - they may be used in the modules's Makefile -obj :=3D $(KBUILD_EXTMOD) -src :=3D $(if $(VPATH),$(VPATH)/)$(obj) +obj :=3D . +src :=3D $(or $(VPATH),.) =20 # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS include $(kbuild-file) =20 -output-symdump :=3D $(KBUILD_EXTMOD)/Module.symvers +output-symdump :=3D Module.symvers =20 ifeq ($(wildcard $(objtree)/Module.symvers),) missing-input :=3D $(objtree)/Module.symvers diff --git a/scripts/coccicheck b/scripts/coccicheck index e52cb43fede6..6272fe4814cd 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -80,10 +80,10 @@ command results in a shift count error.' NPROC=3D1 else ONLINE=3D0 - if [ "$KBUILD_EXTMOD" =3D "" ] ; then - OPTIONS=3D"--dir $srctree $COCCIINCLUDE" + if [ "${VPATH+set}" ] ; then + OPTIONS=3D"--dir $VPATH $COCCIINCLUDE" else - OPTIONS=3D"--dir $KBUILD_EXTMOD $COCCIINCLUDE" + OPTIONS=3D"--dir . $COCCIINCLUDE" fi =20 # Use only one thread per core by default if hyperthreading is enabled diff --git a/scripts/package/install-extmod-build b/scripts/package/install= -extmod-build index d2c9cacecc0c..5d7d79a23bf9 100755 --- a/scripts/package/install-extmod-build +++ b/scripts/package/install-extmod-build @@ -53,6 +53,13 @@ mkdir -p "${destdir}" if [ "${CC}" !=3D "${HOSTCC}" ] && is_enabled CONFIG_CC_CAN_LINK; then echo "Rebuilding host programs with ${CC}..." =20 + # This leverages external module building. + # - Clear sub_make_done to allow the top-level Makefile to redo sub-make. + # - Filter out --no-print-directory to print "Entering directory" logs + # when Make changes the working directory. + unset sub_make_done + MAKEFLAGS=3D$(echo "${MAKEFLAGS}" | sed s/--no-print-directory//) + cat <<-'EOF' > "${destdir}/Kbuild" subdir-y :=3D scripts EOF --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 37C6D1940AB; Tue, 17 Sep 2024 14:18:10 +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=1726582691; cv=none; b=c0zCsz8fV8ByVHzsVmISyRHxOfnMXfrijYxLUUA0UBzYkbBLOfazy5ON8kdpp6OUGx07LHgqzLfGsxraybgqXGcpaC4YlgCciZOrKXpEJsJGs8x3PMOER7IdGBE5ChXE9hRqTkhDiWHskEHiBy4ed2xsiHozBOw15VE9ZttBiWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582691; c=relaxed/simple; bh=v3F59l//1EQnAHqTp5K6zCSernv13ZDiW1k6H5qe7cg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iOltvXPiFHGUY42sCf2+icpJY8EsfvzR5inQ9GFG1StBDNVqTQZDIOD6rGTLOlGCLaXNj2Tb3cmUMu0A3AtIdxU1CLpc9t31q72+nuQ2BlfJXsjskwRUKbP9W8ZgUTPUoarfsH+nX/A+ysVutVdpIoaNMuIKuOEf6LqkGwT17qU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sg+Cbsfg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sg+Cbsfg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 240A4C4CECF; Tue, 17 Sep 2024 14:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582690; bh=v3F59l//1EQnAHqTp5K6zCSernv13ZDiW1k6H5qe7cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sg+CbsfggQ1DwMg5dmajZbso8K5l8nvl3ZItaOU6Z/GnNbKX3B1OGxrhm2zG5P+Rv LdbUYnWXbqCgz4yCJ9D5cChgx6Eml8/vTG4FDf2Ls5cCzWGL9WlJ1GdqODA1cfrdWl X9WtC97VOAsg0qfZaV+ypgo2nzHcLZ1qmOIyow7gSjUkHuo7hGEuzF0wJKxtE3iyvw YoNiE9+mOqDhtatkb3OP5ar8TbcsGvnpSYHMMqTtBWzQqIvA7xUTwskROG6KynkZbe m1bm4eZN/hvPTMEInvxhx3jYdbluKV39HnRIHMMWBTsjG8XtYMiqRbGgUjuiZbl4rp yypdw+vYWigMQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 18/23] kbuild: remove extmod_prefix, MODORDER, MODULES_NSDEPS variables Date: Tue, 17 Sep 2024 23:16:46 +0900 Message-ID: <20240917141725.466514-19-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" With the previous changes, $(extmod_prefix), $(MODORDER), and $(MODULES_NSDEPS) are constant. (empty, modules.order, and modules.nsdeps, respectively). Remove these variables and hard-code their values. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 22 +++++++++------------- scripts/Makefile.modfinal | 2 +- scripts/Makefile.modinst | 2 +- scripts/Makefile.modpost | 6 +++--- scripts/nsdeps | 2 +- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 4db22c3a8555..9fbf7ef6e394 100644 --- a/Makefile +++ b/Makefile @@ -1102,10 +1102,6 @@ export MODLIB =20 PHONY +=3D prepare0 =20 -export extmod_prefix =3D -export MODORDER :=3D $(extmod_prefix)modules.order -export MODULES_NSDEPS :=3D $(extmod_prefix)modules.nsdeps - ifeq ($(KBUILD_EXTMOD),) =20 build-dir :=3D . @@ -1862,7 +1858,7 @@ endif =20 ifdef CONFIG_MODULES =20 -$(MODORDER): $(build-dir) +modules.order: $(build-dir) @: =20 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. @@ -1873,7 +1869,7 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1) endif =20 PHONY +=3D modules_check -modules_check: $(MODORDER) +modules_check: modules.order $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< =20 else # CONFIG_MODULES @@ -1914,15 +1910,15 @@ $(single-ko): single_modules $(single-no-ko): $(build-dir) @: =20 -# Remove MODORDER when done because it is not the real one. +# Remove modules.order when done because it is not the real one. PHONY +=3D single_modules single_modules: $(single-no-ko) modules_prepare - $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$(m:%.ko=3D%.o);) }= > $(MODORDER) + $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$(m:%.ko=3D%.o);) }= > modules.order $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif - $(Q)rm -f $(MODORDER) + $(Q)rm -f modules.order =20 single-goals :=3D $(addprefix $(build-dir)/, $(single-no-ko)) =20 @@ -1999,12 +1995,12 @@ nsdeps: modules quiet_cmd_gen_compile_commands =3D GEN $@ cmd_gen_compile_commands =3D $(PYTHON3) $< -a $(AR) -o $@ $(filter-o= ut $<, $(real-prereqs)) =20 -$(extmod_prefix)compile_commands.json: $(srctree)/scripts/clang-tools/gen_= compile_commands.py \ +compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands= .py \ $(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \ - $(if $(CONFIG_MODULES), $(MODORDER)) FORCE + $(if $(CONFIG_MODULES), modules.order) FORCE $(call if_changed,gen_compile_commands) =20 -targets +=3D $(extmod_prefix)compile_commands.json +targets +=3D compile_commands.json =20 PHONY +=3D clang-tidy clang-analyzer =20 @@ -2012,7 +2008,7 @@ ifdef CONFIG_CC_IS_CLANG quiet_cmd_clang_tools =3D CHECK $< cmd_clang_tools =3D $(PYTHON3) $(srctree)/scripts/clang-tools/run-cl= ang-tools.py $@ $< =20 -clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json +clang-tidy clang-analyzer: compile_commands.json $(call cmd,clang_tools) else clang-tidy clang-analyzer: diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 6d8aa3059ee2..1d787b867c6d 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -13,7 +13,7 @@ include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Makefile.lib =20 # find all modules listed in modules.order -modules :=3D $(call read-file, $(MODORDER)) +modules :=3D $(call read-file, modules.order) =20 __modfinal: $(modules:%.o=3D%.ko) @: diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 2d39d452c49e..1ec739d138b3 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -40,7 +40,7 @@ $(addprefix $(MODLIB)/, modules.builtin modules.builtin.m= odinfo modules.builtin. =20 endif =20 -modules :=3D $(call read-file, $(MODORDER)) +modules :=3D $(call read-file, modules.order) =20 ifeq ($(KBUILD_EXTMOD),) dst :=3D $(MODLIB)/kernel diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index ccca705bc389..586456c72e6d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -46,7 +46,7 @@ modpost-args =3D \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(KBUILD_MODPOST_WARN),-w) \ - $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ + $(if $(KBUILD_NSDEPS),-d modules.nsdeps) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)= \ $(if $(findstring 1, $(KBUILD_EXTRA_WARN)),-W) \ -o $@ @@ -61,8 +61,8 @@ endif # Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". ifdef KBUILD_MODULES -modpost-args +=3D -T $(MODORDER) -modpost-deps +=3D $(MODORDER) +modpost-args +=3D -T modules.order +modpost-deps +=3D modules.order endif =20 ifeq ($(KBUILD_EXTMOD),) diff --git a/scripts/nsdeps b/scripts/nsdeps index 8b4db63838ce..3192a3945871 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -57,4 +57,4 @@ generate_deps() { while read line do generate_deps $line -done < $MODULES_NSDEPS +done < modules.nsdeps --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 308B9194A4B; Tue, 17 Sep 2024 14:18:13 +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=1726582693; cv=none; b=gXzTizwG+7W1iB07M3jennmgt0Q9Ns1DBi/Ohdk2khCqsj2IBLVQQTkRcxJ323c2b5ZGgydGfmlfV9UMkZaNnFt5miwAE6nE4bwi97EI/ZRQEcIAccuSbnE1EMq/m4BSoUI6XOorhCGlBvyHlA633a6nJbwYty8HsRYIszsNMo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582693; c=relaxed/simple; bh=FI3kBAdkWmeCKCnshcw4HjVMuzXsQc84gzzbOu4ug78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NF507QhGFtfLEw+9xoSmtE476SYIteTEvu1xk6NgPCjX1Wr9cBDcV8zo7Vc5JP0L68x/ZZDP0Vth6G4DjEPzb5nVpEC3wv3pMlEIDf+C+YTmY5iMRNfnjSJ7FEl+KuP2SGdw2w0s8P7IguG6EtiTlMbxuoLqqx8X+JKfYbFoEaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KJdjwRDY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KJdjwRDY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61A21C4CECD; Tue, 17 Sep 2024 14:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582693; bh=FI3kBAdkWmeCKCnshcw4HjVMuzXsQc84gzzbOu4ug78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KJdjwRDYVqIaBYqJlmBD1QiMZBvwzt8Y03mjrrThgG1wa4NmXiSaI1c6ZazZ9AOcN bKKUWRAID9yfu2nltrNlxbFBoLLU35FGEXOUMhmlkykUXWvBYWmR/C3BiAIKnSRJGh Z35xx6zpvPycfYktWKWHDGVRBLQEifxRAd/xZd0HyOnMx1Sz69T3iRdH9KmYDGJ6ck +nX6Dvck8jhQEN/k8MMEouFICumxRFMlc2zLOTLxQ0oOWu5mWaMAFyhQ3N8eLBiwwg k5+heFtOIy6Y63S1bjDPpr1KsTW0E04AOepjB2t+ZntAQr/Z2vsx4RKv8ZSKrxc3TU Wa12r9NLkNXDA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 19/23] kbuild: support building external modules in a separate build directory Date: Tue, 17 Sep 2024 23:16:47 +0900 Message-ID: <20240917141725.466514-20-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" There has been a long-standing request to support building external modules in a separate build directory. This commit introduces a new environment variable, KBUILD_EXTMOD_OUTPUT, and its shorthand Make variable, MO. A simple usage: $ make -C M=3D MO=3D Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/kbuild.rst | 8 +++++- Documentation/kbuild/modules.rst | 5 +++- Makefile | 44 +++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.= rst index 716f6fb70829..66a9dc44ea28 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -132,12 +132,18 @@ Specify the output directory when building the kernel. This variable can also be used to point to the kernel output directory when building external modules using kernel build artifacts in a separate build directory. Please note that this does NOT specify the output directory for= the -external modules themselves. +external modules themselves. (Use KBUILD_EXTMOD_OUTPUT for that purpose.) =20 The output directory can also be specified using "O=3D...". =20 Setting "O=3D..." takes precedence over KBUILD_OUTPUT. =20 +KBUILD_EXTMOD_OUTPUT +-------------------- +Specify the output directory for external modules. + +Setting "MO=3D..." takes precedence over KBUILD_EXTMOD_OUTPUT. + KBUILD_EXTRA_WARN ----------------- Specify the extra build checks. The same value can be assigned by passing diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 3a6e7bdc0889..03347e13eeb5 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -95,7 +95,7 @@ executed to make module versioning work. of the kernel output directory if the kernel was built in a separate build directory.) =20 - make -C $KDIR M=3D$PWD + make -C $KDIR M=3D$PWD [MO=3D$BUILD_DIR] =20 -C $KDIR The directory that contains the kernel and relevant build @@ -109,6 +109,9 @@ executed to make module versioning work. directory where the external module (kbuild file) is located. =20 + MO=3D$BUILD_DIR + Speficies a separate output directory for the external module. + 2.3 Targets =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Makefile b/Makefile index 9fbf7ef6e394..b654baa0763a 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,10 @@ ifeq ("$(origin M)", "command line") KBUILD_EXTMOD :=3D $(M) endif =20 +ifeq ("$(origin MO)", "command line") + KBUILD_EXTMOD_OUTPUT :=3D $(MO) +endif + $(if $(word 2, $(KBUILD_EXTMOD)), \ $(error building multiple external modules is not supported)) =20 @@ -187,7 +191,11 @@ ifdef KBUILD_EXTMOD else objtree :=3D $(CURDIR) endif - output :=3D $(KBUILD_EXTMOD) + output :=3D $(or $(KBUILD_EXTMOD_OUTPUT),$(KBUILD_EXTMOD)) + # KBUILD_EXTMOD might be a relative path. Remember its absolute path b= efore + # Make changes the working directory. + export abs_extmodtree :=3D $(realpath $(KBUILD_EXTMOD)) + $(if $(abs_extmodtree),,$(error specified external module directory "$= (KBUILD_EXTMOD)" does not exist)) else objtree :=3D . output :=3D $(KBUILD_OUTPUT) @@ -246,7 +254,6 @@ else # need-sub-make ifeq ($(abs_srctree),$(CURDIR)) # building in the source tree srctree :=3D . - building_out_of_srctree :=3D else ifeq ($(abs_srctree)/,$(dir $(CURDIR))) # building in a subdirectory of the source tree @@ -254,22 +261,23 @@ else else srctree :=3D $(abs_srctree) endif - building_out_of_srctree :=3D 1 endif =20 ifneq ($(KBUILD_ABS_SRCTREE),) srctree :=3D $(abs_srctree) endif =20 -VPATH :=3D +export srctree =20 -ifeq ($(KBUILD_EXTMOD),) -ifdef building_out_of_srctree -VPATH :=3D $(srctree) -endif -endif +_vpath =3D $(or $(abs_extmodtree),$(srctree)) =20 -export building_out_of_srctree srctree VPATH +ifeq ($(realpath $(_vpath)),$(CURDIR)) +building_out_of_srctree :=3D +VPATH :=3D +else +export building_out_of_srctree :=3D 1 +export VPATH :=3D $(_vpath) +endif =20 # To make sure we do not include .config for any of the *config targets # catch them early, and hand them over to scripts/kconfig/Makefile @@ -550,7 +558,7 @@ USERINCLUDE :=3D \ LINUXINCLUDE :=3D \ -I$(srctree)/arch/$(SRCARCH)/include \ -I$(objtree)/arch/$(SRCARCH)/include/generated \ - $(if $(building_out_of_srctree),-I$(srctree)/include) \ + -I$(srctree)/include \ -I$(objtree)/include \ $(USERINCLUDE) =20 @@ -640,6 +648,7 @@ quiet_cmd_makefile =3D GEN Makefile } > Makefile =20 outputmakefile: +ifeq ($(KBUILD_EXTMOD),) @if [ -f $(srctree)/.config -o \ -d $(srctree)/include/config -o \ -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ @@ -649,7 +658,16 @@ outputmakefile: echo >&2 "***"; \ false; \ fi - $(Q)ln -fsn $(srctree) source +else + @if [ -f $(KBUILD_EXTMOD)/modules.order ]; then \ + echo >&2 "***"; \ + echo >&2 "*** The external module source tree is not clean."; \ + echo >&2 "*** Please run 'make -C $(abs_srctree) M=3D$(realpath $(KBUILD= _EXTMOD)) clean'"; \ + echo >&2 "***"; \ + false; \ + fi +endif + $(Q)ln -fsn $(_vpath) source $(call cmd,makefile) $(Q)test -e .gitignore || \ { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore @@ -1926,6 +1944,8 @@ KBUILD_MODULES :=3D 1 =20 endif =20 +prepare: outputmakefile + # Preset locale variables to speed up the build process. Limit locale # tweaks to this spot to avoid wrong language settings when running # make menuconfig etc. --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 B7491194AD6; Tue, 17 Sep 2024 14:18:15 +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=1726582695; cv=none; b=fvft7fx5OwayeKcJGWbfV/McVAWET/tkaggh1v9iHvfozZCgx8vKliJwj/2F1w1GqY7SQLJ1IjvPg/EmsLs2dsR0DfRd2IG+eKYym7mwt8TPJfxCzjo6tiUKk3K+/ftBxno6WW/gdkzEqpPQ02M9/kT89hHPAbe/6Fc2i3zYSUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582695; c=relaxed/simple; bh=6ovtfxPLSr9bMGDxuc9bLq1SSFe119PmyqlLKy/y1gI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h8oGr0EXo2xHT4xrr33qmQyggN+tRtF3eWaVr1SC/aGugUUiPDzRxAJEcYLlC7J6ALXbn5AOsSWfG3YHB7IoZAQAZtYX2/Tl7yPH86kfOLWI1YjTsYhDeLEcqM2NnHR2i+hjmaw2YyZvGJmj0kLkj1WemBHz59BTy2rIdbHDgWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SxcRo7Hx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SxcRo7Hx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F5C8C4CECD; Tue, 17 Sep 2024 14:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582695; bh=6ovtfxPLSr9bMGDxuc9bLq1SSFe119PmyqlLKy/y1gI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SxcRo7Hxr/XE+diRmR2zFq37e+ot4nD4aE1owbXAC0SQ+F2TWekZarZQ/uUuauT9C u0Jwa7AXmYwSGtP4c/RCPj4rTsDK47ns+fEEpYSJWDcxS/i0Vyc+IeVJ4izadvDoAV M0u0DZ5xBnR1WdhUuTLm0zDLJ8R+TSU37uzV4SIeiO0gBmMPupMbGvTf5oSOHRQF57 0iNR/bU/5lfz0GO25Qy4uJDeZPhq4TicVVqWAmwk3pinfopcGeKCfdi/l/GN3yWTQG 1f2a7U+Yf7lVcx0Ja4AjJTDfpJ0Ta2lzoLYyWngviZF2Zx8VSdCB+w+OYzV2j86pSt daeCHkYTSE9WQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 20/23] kbuild: support -fmacro-prefix-map for external modules Date: Tue, 17 Sep 2024 23:16:48 +0900 Message-ID: <20240917141725.466514-21-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" This commit makes -fmacro-prefix-map work for external modules built in a separate output directory. It improves the reproducibility of external modules and provides the benefits described in commit a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path"). When VPATH is not defined (e.g., when the kernel or external module is built in the source directory), this option is unnecessary. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b654baa0763a..ce646a6994a6 100644 --- a/Makefile +++ b/Makefile @@ -1027,8 +1027,10 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS +=3D -fconserve-stack endif =20 -# change __FILE__ to the relative path from the srctree -KBUILD_CPPFLAGS +=3D $(call cc-option,-fmacro-prefix-map=3D$(srctree)/=3D) +# change __FILE__ to the relative path to the source directory +ifdef VPATH +KBUILD_CPPFLAGS +=3D $(call cc-option,-fmacro-prefix-map=3D$(VPATH)/=3D) +endif =20 # include additional Makefiles when needed include-y :=3D scripts/Makefile.extrawarn --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 E8D41194C8F; Tue, 17 Sep 2024 14:18:17 +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=1726582698; cv=none; b=D43DPf7pEMYt4XstW53dcTB21/QogvXLMWVR+2fsv9j1gIpTBZCUjZ5a7VqxmSY1It9FFj4lKm7xQ+rOUC/hBOD7y85nvTig8M3QnDSREPXj7QMdVuIle2YF3WyvzEL0jwI7johOKxv1kwW25UiMaTnIrBvCKkHqaZZJMHzKl0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582698; c=relaxed/simple; bh=/5fq3didrGVAcPh4C5/Q4yo410TOLiRILJJC0tUs9Go=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JFwan9NsTcltTkiaVcWVS2unPBJ/ibOUnycr7v9VWVEBnPd/eRTaBldE+EdD/XiVUBWC3xq6V3LfcI5vqHm9UUIkAUw4ah4K7FVeI8IYc1672tR+3Ia1iW6P628Fpo5OKHwlfmsrVClmxq39g41OzhjBfz31D66ThyjdrbMjiTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T19nYlja; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T19nYlja" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD112C4CECD; Tue, 17 Sep 2024 14:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582697; bh=/5fq3didrGVAcPh4C5/Q4yo410TOLiRILJJC0tUs9Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T19nYlja1p0xgVKeZLU/WtpTcajsT9vIRdu+VTu6ffeetHV3TGr7u2PJTInnpQ81h xF6CCxARdatLfOpHWY7dD6BuacR33KEG9QrU+VRR+li7Pc1q1rDW1T3q/4lpbR0ZQn rukdp5z4ZvMhuAwlW6NsSCpte9bV8lLvyE/jEeWaXkzmb70n0ocyYsUejL9hdIV59o HqMpXEx98OZFDDvWbPt4tSdLWbYuuvaRclBeRj6HZe+Ud3KPXMBS5UIKSO8mxl30mu vFtO0GDDBkNjAEgNm6uMVYeYGGmoSlCn9S1ax+JTjUPo7noquQOLlPoLtRw0dIXtn9 o2qMBlcGa27Jw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 21/23] kbuild: use absolute path in the generated wrapper Makefile Date: Tue, 17 Sep 2024 23:16:49 +0900 Message-ID: <20240917141725.466514-22-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Keep the consistent behavior when this Makefile is invoked from another directory. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ce646a6994a6..9f0ba07e8f25 100644 --- a/Makefile +++ b/Makefile @@ -643,8 +643,9 @@ ifdef building_out_of_srctree =20 quiet_cmd_makefile =3D GEN Makefile cmd_makefile =3D { \ - echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \ - echo "include $(srctree)/Makefile"; \ + echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit";= \ + echo "export KBUILD_OUTPUT =3D $(CURDIR)"; \ + echo "include $(abs_srctree)/Makefile"; \ } > Makefile =20 outputmakefile: --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 B3F43185E6A; Tue, 17 Sep 2024 14:18:19 +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=1726582699; cv=none; b=CDNDtlma+90n3GYW+xss4MjsYgduoqGtYrFYTFfnW93Sz8WWvvl+G4kAzdXp+rB40D6JhuFFhh0JMd+Z/fhHDDAHAp6oQI9FfVIqKViWwTYgLCsa4I0cpvQoU+GkdeeM9mNHV9QxfrKh4ryiModMON7v8FmNrzm6WAugwejY/zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582699; c=relaxed/simple; bh=Ra2sKRWgqwv0KIZWzt1FwqFPZ+ccaJpIfL/OUlJKdGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jIHYCiAFO3fTOqAg75Z1Nnjn2Hp4ZUduODcjLb06IdLk9nm3Vd6ECKU/2DeSdxZ6wgMi9obiWILmjUqxidebriwKZ0hjs1GgVb01AvGsAr7sxM7LgbhYX7nwyVtppdhV/kvNrvvFmf1tR80R8GiNBYxn7fEnLKmIT6jcPFF1h8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gMyHmEtB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gMyHmEtB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F184DC4CEC5; Tue, 17 Sep 2024 14:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582699; bh=Ra2sKRWgqwv0KIZWzt1FwqFPZ+ccaJpIfL/OUlJKdGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMyHmEtBAND0LFpuaHHdvm0IL6/fXRl36eFKyQbZChRo2vlMflHk4XQ3s8gwIs8Ox G27dtJKz1R+zGfW9Y7vcs6rALMqJ3rGtHrZDkOoB3Js89lsHKyUaTlZNLEe3u9gDL+ QY/q84LuowH3vg7iunMQo/iAWsbjsXly2MgNK3O30VdX98lqlrSeAuseLjudBUlKlr FR2EQJsH/fiLABxt6Xni3qSQRQWjwCzyuDlesg18H4l+9169Gop4dT9xl07m5PSfLr l8rluzKhKEeaAfwDmtLIiglXraNgKkA5eEWoRLLf2lXQWPnnMbgrSfiwd6ebgZC6ku ZeWgf4Uqhk0bQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 22/23] kbuild: make wrapper Makefile more convenient for external modules Date: Tue, 17 Sep 2024 23:16:50 +0900 Message-ID: <20240917141725.466514-23-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" When Kbuild starts building in a separate output directory, it generates a wrapper Makefile, allowing you to invoke 'make' from the output directory. This commit makes it more convenient, so you can invoke 'make' without M=3D or MO=3D. First, you need to build external modules in a separate directory: $ make M=3D/path/to/module/source/dir MO=3D/path/to/module/build/dir Once the wrapper Makefile is generated in /path/to/module/build/dir, you can proceed as follows: $ cd /path/to/module/build/dir $ make Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9f0ba07e8f25..81603a50c757 100644 --- a/Makefile +++ b/Makefile @@ -641,10 +641,20 @@ ifdef building_out_of_srctree # At the same time when output Makefile generated, generate .gitignore to # ignore whole output directory =20 +ifdef KBUILD_EXTMOD +print_env_for_makefile =3D \ + echo "export KBUILD_OUTPUT =3D $(objtree)"; \ + echo "export KBUILD_EXTMOD =3D $(_vpath)" ; \ + echo "export KBUILD_EXTMOD_OUTPUT =3D $(CURDIR)" +else +print_env_for_makefile =3D \ + echo "export KBUILD_OUTPUT =3D $(CURDIR)" +endif + quiet_cmd_makefile =3D GEN Makefile cmd_makefile =3D { \ echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit";= \ - echo "export KBUILD_OUTPUT =3D $(CURDIR)"; \ + $(print_env_for_makefile); \ echo "include $(abs_srctree)/Makefile"; \ } > Makefile =20 --=20 2.43.0 From nobody Fri Nov 29 17:47:27 2024 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 628DE1974FE; Tue, 17 Sep 2024 14:18:22 +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=1726582702; cv=none; b=rhe6V0Yp69d5cWeBcd4NlJ1QuW0vERgN3H3XSjciFnsbfyctVM7dtaVNxRgpxyl98VCg/BSPJ4CzfzQfldqnGKu/tnQNk4Ud3gZTwm6TzkN5rvSAV5Yt0nNDfyVgFBPzBfetqWPSBatKc97V2b+eYSuYcOAELjbpYM/Yo/3myxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582702; c=relaxed/simple; bh=pVqPlXHwRAmKMtMxmsQTphSqu9eVJ5zq5Yus+QdHq+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFrJwUrqpPD6fKVonu1Kn2t2M1FXbI4bFHyjAWC4t2UlhYmn7b7P1xiRk28C02mxxNRLSFVYCBZg0WLuEBFn0GKwGTSF59xeqP8pesfp0F4ZMKfL7tBnBHivDTJqiceGcHfN5tNUGgpdhfutXNKnwaszgZRRzTaOP7K3AqshpeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qFZRWt3b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qFZRWt3b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32AF8C4CEC5; Tue, 17 Sep 2024 14:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582702; bh=pVqPlXHwRAmKMtMxmsQTphSqu9eVJ5zq5Yus+QdHq+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFZRWt3bLzlLXEazL48GBC+oGSAyKzF5TRwsK3RJi9kuKr7Wm+eTzqSILwkzH4l7t e7GF3zChXVOv/eL2+dq17FaFYgpGuKlqnTSgI3C77zxkQR6k6IC58Q6b199ewt+4iS 9xeqRkcEDLFM3aAt0l4AQhmXiAYQ2zGipdr3A2ovuX3yoIikkyf/mmTbttthFL9trF QxYX00wpSikIluRDyIqNdXjqKfXsLnn3FKCGw8vNIJwTbUhN3Xv0bv5c5Vfi1kcLjc cHDjtsj1NBLne3wa4+AI/4pXbIqjg4cGKByuzP3ssqKQil2NW8qSc79WJoWbv1qVz8 Zsvvwl0Jyw0Kw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 23/23] kbuild: allow to start building external module in any directory Date: Tue, 17 Sep 2024 23:16:51 +0900 Message-ID: <20240917141725.466514-24-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-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: quoted-printable Content-Type: text/plain; charset="utf-8" Unless an explicit O=3D option is provided, external module builds must start from the kernel directory. This can be achieved by using the -C option: $ make -C /path/to/kernel M=3D/path/to/external/module This commit allows starting external module builds from any directory, so you can also do the following: $ make -f /path/to/kernel/Makefile M=3D/path/to/external/module The key difference is that the -C option changes the working directory and parses the Makefile located there, while the -f option only specifies the Makefile to use. As shown in the examples in Documentation/kbuild/modules.rst, external modules usually have a wrapper Makefile that allows you to build them without specifying any make arguments. The Makefile typically contains a rule as follows: KDIR ?=3D /path/to/kernel default: $(MAKE) -C $(KDIR) M=3D$(CURDIR) $(MAKECMDGOALS) The log will appear as follows: $ make make -C /path/to/kernel M=3D/path/to/external/module make[1]: Entering directory '/path/to/kernel' make[2]: Entering directory '/path/to/exernal/module' CC [M] helloworld.o MODPOST Module.symvers CC [M] helloworld.mod.o CC [M] .module-common.o LD [M] helloworld.ko make[2]: Leaving directory '/path/to/exernal/module' make[1]: Leaving directory '/path/to/kernel' This changes the working directory twice because the -C option first switches to the kernel directory, and then Kbuild internally recurses back to the external module directory. With this commit, the wrapper Makefile can directly include the kernel Makefile: KDIR ?=3D /path/to/kernel export KBUILD_EXTMOD =3D $(CURDIR) include $(KDIR)/Makefile This avoids unnecessary sub-make invocations: $ make CC [M] helloworld.o MODPOST Module.symvers CC [M] helloworld.mod.o CC [M] .module-common.o LD [M] helloworld.ko Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda --- Documentation/kbuild/modules.rst | 21 +++++++++++++++++++++ Makefile | 8 ++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index 03347e13eeb5..5610cfa426bb 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -88,6 +88,12 @@ executed to make module versioning work. =20 $ make -C /lib/modules/`uname -r`/build M=3D$PWD modules_install =20 + Starting from Linux 6.13, you can use the -f option instead of -C. This + will avoid unnecessary change of the working directory. The external + module will be output to the directory where you invoke make. + + $ make -f /lib/modules/`uname -r`/build/Makefile M=3D$PWD + 2.2 Options =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 @@ -246,6 +252,21 @@ module 8123.ko, which is built from the following file= s:: consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest. =20 + Linux 6.13 and later support another way. The external module Makefile + can include the kernel Makefile directly, rather than invoking sub Make. + + Example 3:: + + --> filename: Kbuild + obj-m :=3D 8123.o + 8123-y :=3D 8123_if.o 8123_pci.o + + --> filename: Makefile + KDIR ?=3D /lib/modules/`uname -r`/build + export KBUILD_EXTMOD =3D $(CURDIR) + include $(KDIR)/Makefile + + 3.4 Building Multiple Modules =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =20 diff --git a/Makefile b/Makefile index 81603a50c757..88c160ac7b3c 100644 --- a/Makefile +++ b/Makefile @@ -189,9 +189,13 @@ ifdef KBUILD_EXTMOD objtree :=3D $(realpath $(KBUILD_OUTPUT)) $(if $(objtree),,$(error specified kernel directory "$(KBUILD_OUTP= UT)" does not exist)) else - objtree :=3D $(CURDIR) + objtree :=3D $(abs_srctree) endif - output :=3D $(or $(KBUILD_EXTMOD_OUTPUT),$(KBUILD_EXTMOD)) + # If Make is invoked from the kernel directory (either kernel + # source directory or kernel build directory), external modules + # are built in $(KBUILD_EXTMOD) for backward compatibility, + # otherwise, built in the current directory. + output :=3D $(or $(KBUILD_EXTMOD_OUTPUT),$(if $(filter $(CURDIR),$(obj= tree) $(abs_srctree)),$(KBUILD_EXTMOD))) # KBUILD_EXTMOD might be a relative path. Remember its absolute path b= efore # Make changes the working directory. export abs_extmodtree :=3D $(realpath $(KBUILD_EXTMOD)) --=20 2.43.0