Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6416023rwp; Mon, 17 Jul 2023 23:07:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUxYcx4MoqF0RnM2nJ7O/NIaIG3KxNRcEdkwV/gzAvOrbITMCF6QfjqimD/l3/mlbKdDix X-Received: by 2002:a17:907:7709:b0:992:91ce:4509 with SMTP id kw9-20020a170907770900b0099291ce4509mr10400595ejc.57.1689660422214; Mon, 17 Jul 2023 23:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689660422; cv=none; d=google.com; s=arc-20160816; b=xMRaO5Dxlvtri7CP9R7epbHFkGk3QMLa7YailoiL1iScbMSgfGi9YmYOgqiaCWgUCK Mct9kp7+5te1ys5Ifmy5uSVAUwFJeYFXnB3u6NQbUD4QUmclybNVEigkFDJTcj0navUt znK6LTbwuRTZZYnPqZ3W5U5/OskwCBc3kpYeqz3bZ2x6L25AYlhebUh2VEyu5HFfbpHV SMfRe8a7dN07jBi48DxbpkzQkcXIbknx5i9PmteyBJPLQcRDwq/lZlrwsXfNd6A/3gwI /ZavL8Ltx5dJGfZGJbfef2TfoxR0ARPFMBTzCju/UtKOWbFbA08a0nisP8w4moSue2hO 3fNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=k/N3LiKOSmyhFQkzkiStxvM6yAS/YRv78LBzWSeGzeY=; fh=mKR6j7Vi7skgMbwTZDlFCcR7Y+6HRFNBbME2zORdlDg=; b=YOmTdk30MzaoeS0/UYjgPhWufiAlc79SfCS04n6jP94Dded2Jh803u5tdS4yM/jb/U aDSRXJEK+z+sy5ySkGT/1P4mK7bAMGCfC+OPl4BKlqKNJzYsLy4T5JKlApIgbt6DKV5V W6XLkTN8d3s1+oCCC65bPkUwjK+yV/97kF1uFvdsqeRQxZLLtOo2zP6FJdhGe0g/0GpC kW35vJgNXALBYhKmIq99b/QwiM/KTdUEeVW7qTju03O9MMJO0RGlIA7otURhNTaldlfJ 6w/b6qdiKdu1tPav9529jUMCUjlIlFhwEpZyEiek/iaDLCEy6WjqZYiWkxmBuWhmF8Zr qOhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bKhQPfED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jo26-20020a170906f6da00b009930371a03csi694966ejb.1001.2023.07.17.23.06.38; Mon, 17 Jul 2023 23:07:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bKhQPfED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230399AbjGRFxF (ORCPT + 99 others); Tue, 18 Jul 2023 01:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjGRFw7 (ORCPT ); Tue, 18 Jul 2023 01:52:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64ADE56; Mon, 17 Jul 2023 22:52:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84EB96145F; Tue, 18 Jul 2023 05:52:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40276C433C7; Tue, 18 Jul 2023 05:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689659577; bh=PlSlsqHDqw67L6N41kdBC8ML9MQoqYiPEiBjjydxhOg=; h=From:To:Cc:Subject:Date:From; b=bKhQPfEDuI1pDq4l9wyUuymLSoTsnxo1GvrG/Es/WawS5X4hE9bWy9pTJh4yA3Nj3 MxlVo6XX6Gj8/xnDHz2Y1Ci9vcWiEF6yrrf7zj0A/O6vSRnU+YUfpuxxTV4cyWbiO2 J7Vnz71dErFpjiDiYSwddt5vEsl5o/pyV/pJO6s5SYBb5VVZymmk4LTXqMHo4d8mCt 5qPlnoKxOUTnr9/2jYQsbrXI+BnP8M7CBgaucPTRkZlw80JmvS5k7fODlR4/RXA331 iFxBLNeqLscvckubTDjfnFkDez1N1FU+N5cnW/t/jOTILQgUsENboSXYOozQDoo1cx Z5Uqa6u1j1Ktg== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Raphael Nestler , Andrea Righi , stable@vger.kernel.org Subject: [PATCH] kbuild: rust: avoid creating temporary files Date: Tue, 18 Jul 2023 07:52:35 +0200 Message-ID: <20230718055235.1050223-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `rustc` outputs by default the temporary files (i.e. the ones saved by `-Csave-temps`, such as `*.rcgu*` files) in the current working directory when `-o` and `--out-dir` are not given (even if `--emit=x=path` is given, i.e. it does not use those for temporaries). Since out-of-tree modules are compiled from the `linux` tree, `rustc` then tries to create them there, which may not be accessible. Thus pass `--out-dir` explicitly, even if it is just for the temporary files. Reported-by: Raphael Nestler Closes: https://github.com/Rust-for-Linux/linux/issues/1015 Reported-by: Andrea Righi Tested-by: Raphael Nestler Tested-by: Andrea Righi Cc: stable@vger.kernel.org Signed-off-by: Miguel Ojeda --- scripts/Makefile.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 6413342a03f4..82e3fb19fdaf 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -264,6 +264,9 @@ $(obj)/%.lst: $(src)/%.c FORCE rust_allowed_features := new_uninit +# `--out-dir` is required to avoid temporaries being created by `rustc` in the +# current working directory, which may be not accessible in the out-of-tree +# modules case. rust_common_cmd = \ RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ -Zallow-features=$(rust_allowed_features) \ @@ -272,7 +275,7 @@ rust_common_cmd = \ --extern alloc --extern kernel \ --crate-type rlib -L $(objtree)/rust/ \ --crate-name $(basename $(notdir $@)) \ - --emit=dep-info=$(depfile) + --out-dir $(dir $@) --emit=dep-info=$(depfile) # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit # will be used. We explicitly request `-Ccodegen-units=1` in any case, and base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 -- 2.41.0