From nobody Tue Dec 2 01:27:35 2025 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 4FD3E2E0939; Fri, 21 Nov 2025 11:05: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=1763723141; cv=none; b=sGtgW7GFaQ3HNV4O3UiGbL7a8RimKghTlfOvggwCWV1KghdA0yf5mluKK17H2z7BgXuNugTzrnffMaP4kb/tDPIuUe1MLbRVNSde9/8T6hnUclXOs1E/D1JJIELmLIfeCtR+v8jPY/utj8DQB0WBUjiCR11CgoiweFxUYCV2Hlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763723141; c=relaxed/simple; bh=kYzm6MdlwdysFX/9qMn2LBpF6+iBC9qhmJYsnGwDRvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CvB+JrS6/RjfZ1rrJxuy6ub1BdzS6xbwP7BuRuLUxGBJpJxvyFAyd0su5Vw4+AqWgcVuZrTCOg9TY9xS90NbEsiVDoHFTaHOj5F/g1i2y3GxJIHhN3cOweRFVkfLLOPFrGKk3kLiCu4YXGbmlzvDQ3d6Lefk6Letz8P2QwpNvnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NY1zYgqE; 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="NY1zYgqE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A74EC116C6; Fri, 21 Nov 2025 11:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763723141; bh=kYzm6MdlwdysFX/9qMn2LBpF6+iBC9qhmJYsnGwDRvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NY1zYgqESVnOcjqxIHvBv8wI8mk27exmnCqfqeLG5u36KgD3OW+Cc+zzRVpop5U0Z 9w2xoiGaP0jNIZMdwliaCGhWOdtw8VY+NaOr+eSY+hWr4+8LaLtjD1LfCU/HGx8HpA k11bLxU4jrnUoQ1PL01WfBpPRMydlfLp75bHPw5TUxbI1wh77YIjlq+nznrOpsW9eH Coqbkx4o+VQGxkAKH/wqTMp/K9kpaBLIiXPprxQg7PRexzaD/YRQBvwJADfnTspXxv 7UL4PLSug3CFxrpBbmvx3u1vxlJb4oawIUvpZok0n2XzHSO7bD7T21rymJoPuFe6Mz AUzb4zq+98iKg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMOxP-0000000EyXg-17NQ; Fri, 21 Nov 2025 12:05:39 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Alex Gaynor" , "Alice Ryhl" , "Andreas Hindborg" , "Benno Lossin" , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , "Boqun Feng" , "Carlos Bilbao" , "Danilo Krummrich" , "Gary Guo" , "Mauro Carvalho Chehab" , "Miguel Ojeda" , "Miguel Ojeda" , "Trevor Gross" , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: [PATCH v2 1/1] docs: makefile: move rustdoc check to the build wrapper Date: Fri, 21 Nov 2025 12:05:28 +0100 Message-ID: X-Mailer: git-send-email 2.51.1 In-Reply-To: References: 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 Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The makefile logic to detect if rust is enabled is not working the way it was expected: instead of using the current setup for CONFIG_RUST, it uses a cached version from a previous build. The root cause is that the current logic inside docs/Makefile uses a cached version of CONFIG_RUST, from the last time a non documentation target was executed. That's perfectly fine for Sphinx build, as it doesn't need to read or depend on any CONFIG_*. So, instead of relying at the cache, move the logic to the wrapper script and let it check the current content of .config, to verify if CONFIG_RUST was selected. Signed-off-by: Mauro Carvalho Chehab --- Documentation/Makefile | 6 ----- tools/docs/sphinx-build-wrapper | 41 +++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index fda2bef8d9d8..e96ac6dcac4f 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -42,12 +42,6 @@ FONTS_CONF_DENY_VF ?=3D $(HOME)/deny-vf # User-friendly check for sphinx-build HAVE_SPHINX :=3D $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then ech= o 1; else echo 0; fi) =20 -ifneq ($(wildcard $(srctree)/.config),) -ifeq ($(CONFIG_RUST),y) - RUSTDOC=3D--rustdoc -endif -endif - ifeq ($(HAVE_SPHINX),0) =20 .DEFAULT: diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrap= per index d4943d952e2a..7a5fcef25429 100755 --- a/tools/docs/sphinx-build-wrapper +++ b/tools/docs/sphinx-build-wrapper @@ -119,6 +119,29 @@ class SphinxBuilder: =20 return path =20 + def check_rust(self): + """ + Checks if Rust is enabled + """ + self.rustdoc =3D False + + config =3D os.path.join(self.srctree, ".config") + + if not os.path.isfile(config): + return + + re_rust =3D re.compile(r"CONFIG_RUST=3D(m|y)") + + try: + with open(config, "r", encoding=3D"utf-8") as fp: + for line in fp: + if re_rust.match(line): + self.rustdoc =3D True + return + + except OSError as e: + print(f"Failed to open {config}", file=3Dsys.stderr) + def get_sphinx_extra_opts(self, n_jobs): """ Get the number of jobs to be used for docs build passed via command @@ -236,6 +259,8 @@ class SphinxBuilder: =20 self.get_sphinx_extra_opts(n_jobs) =20 + self.check_rust() + # # If venv command line argument is specified, run Sphinx from venv # @@ -306,7 +331,7 @@ class SphinxBuilder: =20 return subprocess.call(cmd, *args, **pwargs) =20 - def handle_html(self, css, output_dir, rustdoc): + def handle_html(self, css, output_dir): """ Extra steps for HTML and epub output. =20 @@ -327,7 +352,8 @@ class SphinxBuilder: except (OSError, IOError) as e: print(f"Warning: Failed to copy CSS: {e}", file=3Dsys.stde= rr) =20 - if rustdoc: + if self.rustdoc: + print("Building rust docs") if "MAKE" in self.env: cmd =3D [self.env["MAKE"]] else: @@ -622,7 +648,7 @@ class SphinxBuilder: shutil.rmtree(self.builddir, ignore_errors=3DTrue) =20 def build(self, target, sphinxdirs=3DNone, - theme=3DNone, css=3DNone, paper=3DNone, deny_vf=3DNone, rust= doc=3DFalse, + theme=3DNone, css=3DNone, paper=3DNone, deny_vf=3DNone, skip_sphinx=3DFalse): """ Build documentation using Sphinx. This is the core function of this @@ -671,7 +697,7 @@ class SphinxBuilder: =20 args.extend(["-D", f"latex_elements.papersize=3D{paper}paper"]) =20 - if rustdoc: + if self.rustdoc: args.extend(["-t", "rustdoc"]) =20 if not sphinxdirs: @@ -749,7 +775,7 @@ class SphinxBuilder: # Ensure that each html/epub output will have needed static fi= les # if target in ["htmldocs", "epubdocs"]: - self.handle_html(css, output_dir, rustdoc) + self.handle_html(css, output_dir) =20 # # Step 2: Some targets (PDF and info) require an extra step once @@ -804,9 +830,6 @@ def main(): parser.add_argument('--deny-vf', help=3D"Configuration to deny variable fonts on pd= f builds") =20 - parser.add_argument('--rustdoc', action=3D"store_true", - help=3D"Enable rustdoc build. Requires CONFIG_RUST= ") - parser.add_argument("-v", "--verbose", action=3D'store_true', help=3D"place build in verbose mode") =20 @@ -834,7 +857,7 @@ def main(): =20 builder.build(args.target, sphinxdirs=3Dargs.sphinxdirs, theme=3Dargs.theme, css=3Dargs.css, paper=3Dargs.paper, - rustdoc=3Dargs.rustdoc, deny_vf=3Dargs.deny_vf, + deny_vf=3Dargs.deny_vf, skip_sphinx=3Dargs.skip_sphinx_build) =20 if __name__ =3D=3D "__main__": --=20 2.51.1