Message ID | 20230718055235.1050223-1-ojeda@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1541577vqt; Mon, 17 Jul 2023 23:29:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnHzG9o7xa89bgCyZIW8IaZd7SozyNoKXFLFE/7EvytQjJL5DnLh6epEMkrnsoxFj5tYKY X-Received: by 2002:a17:902:8210:b0:1b9:e8e4:620e with SMTP id x16-20020a170902821000b001b9e8e4620emr11370946pln.47.1689661789993; Mon, 17 Jul 2023 23:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689661789; cv=none; d=google.com; s=arc-20160816; b=wrXo0DBWTDa0RUZXAlpJgaymtD2DE0+WsMThYhsOAAMbzjRVLJcYookX1cjRiMKV5M onBUZ/Q2Iic++c/6cGFbeeBBLiRns/bsH3TiFt3EKyK641qEN+bH3Guusy3UH/8idZuP +676mXfKaOwCzmb4DmmB+jI0k8Y/iGLSYmuy7y8as/Fb8Jic2K1t4x/GwqUbqStwXHd3 7PnmeBH2Z5ubEqSTBnZUmBHCQIV8U8mgW/gpHgg7231NMgtKaHsb1Sfj/dkA/y7Ik2hK 8ds14ygFxQQ9RqvtxwynpIeV5pAZNmiGRuzrHAJ+9jaT9NxpvPHByrEb3vNy+E6K3EX0 YydA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020a170902eccf00b001a1e0fd406csi1209700plh.217.2023.07.17.23.29.37; Mon, 17 Jul 2023 23:29:49 -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 S230400AbjGRFxF (ORCPT <rfc822;daweilics@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <ojeda@kernel.org> To: Masahiro Yamada <masahiroy@kernel.org>, Miguel Ojeda <ojeda@kernel.org>, Wedson Almeida Filho <wedsonaf@gmail.com>, Alex Gaynor <alex.gaynor@gmail.com> Cc: Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Benno Lossin <benno.lossin@proton.me>, Alice Ryhl <aliceryhl@google.com>, Andreas Hindborg <a.hindborg@samsung.com>, linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Raphael Nestler <raphael.nestler@gmail.com>, Andrea Righi <andrea.righi@canonical.com>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771738801272783421 X-GMAIL-MSGID: 1771738801272783421 |
Series |
kbuild: rust: avoid creating temporary files
|
|
Commit Message
Miguel Ojeda
July 18, 2023, 5:52 a.m. UTC
`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 <raphael.nestler@gmail.com> Closes: https://github.com/Rust-for-Linux/linux/issues/1015 Reported-by: Andrea Righi <andrea.righi@canonical.com> Tested-by: Raphael Nestler <raphael.nestler@gmail.com> Tested-by: Andrea Righi <andrea.righi@canonical.com> Cc: stable@vger.kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> --- scripts/Makefile.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
Comments
On Tue, Jul 18, 2023 at 07:52:35AM +0200, Miguel Ojeda wrote: > `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 <raphael.nestler@gmail.com> > Closes: https://github.com/Rust-for-Linux/linux/issues/1015 > Reported-by: Andrea Righi <andrea.righi@canonical.com> > Tested-by: Raphael Nestler <raphael.nestler@gmail.com> > Tested-by: Andrea Righi <andrea.righi@canonical.com> > Cc: stable@vger.kernel.org > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Seems reasonable to me. Reviewed-by: Nathan Chancellor <nathan@kernel.org> > --- > 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 >
On 7/18/23 02:52, Miguel Ojeda wrote: > `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 <raphael.nestler@gmail.com> > Closes: https://github.com/Rust-for-Linux/linux/issues/1015 > Reported-by: Andrea Righi <andrea.righi@canonical.com> > Tested-by: Raphael Nestler <raphael.nestler@gmail.com> > Tested-by: Andrea Righi <andrea.righi@canonical.com> > Cc: stable@vger.kernel.org > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> > --- > [...] Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
On Tue, Jul 18, 2023 at 2:52 PM Miguel Ojeda <ojeda@kernel.org> wrote: > > `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 <raphael.nestler@gmail.com> > Closes: https://github.com/Rust-for-Linux/linux/issues/1015 > Reported-by: Andrea Righi <andrea.righi@canonical.com> > Tested-by: Raphael Nestler <raphael.nestler@gmail.com> > Tested-by: Andrea Righi <andrea.righi@canonical.com> > Cc: stable@vger.kernel.org > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> > --- Applied to linux-kbuild/fixes. Thanks. I believe this is a fix, so I will include it in my next pull request. > 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 >
On Thu, Jul 20, 2023 at 7:18 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > Applied to linux-kbuild/fixes. Thanks. > > I believe this is a fix, so I will include it > in my next pull request. Thanks Masahiro! Yeah, it can be considered a fix. By the way, in case you want: Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") I guess it can be also considered a feature (e.g. "supporting more setups"), but having the temporaries created where they were was unintentional. Cheers, Miguel
On Fri, Jul 21, 2023 at 2:30 AM Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > > On Thu, Jul 20, 2023 at 7:18 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > Applied to linux-kbuild/fixes. Thanks. > > > > I believe this is a fix, so I will include it > > in my next pull request. > > Thanks Masahiro! Yeah, it can be considered a fix. By the way, in case you want: > > Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") Maybe, the following was a breakage. commit 295d8398c67e314d99bb070f38883f83fe94a97a Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sat Jan 7 18:18:15 2023 +0900 kbuild: specify output names separately for each emission type from rustc Before that, rust_common_cmd had --out-dir. BTW, do we also need to fix scripts/Makefile.host in case the external module Makefile creates host programs? > I guess it can be also considered a feature (e.g. "supporting more > setups"), but having the temporaries created where they were was > unintentional.
On Thu, Jul 20, 2023 at 8:35 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > Maybe, the following was a breakage. > > commit 295d8398c67e314d99bb070f38883f83fe94a97a > Author: Masahiro Yamada <masahiroy@kernel.org> > Date: Sat Jan 7 18:18:15 2023 +0900 > > kbuild: specify output names separately for each emission type from rustc > > Before that, rust_common_cmd had --out-dir. That's right, good catch! > BTW, do we also need to fix scripts/Makefile.host > in case the external module Makefile creates host programs? Indeed, we need it too. [1] would fix it (tested it with a trivial out-of-tree Rust hostprog). Do you want me to send it separately? i.e. to avoid losing the `Tested-by`s etc. that we already got for this one, which is the important one since that actually has users. The hostprogs fix is not really critical for stable, since it is unlikely there are users at all (we just got the first in-tree real user in the Rust+KUnit integration coming into 6.6), but I guess it does not hurt for the same reason. Thanks! Cheers, Miguel [1] diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 7aea9005e497..54adf2e2ec51 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -86,7 +86,7 @@ hostc_flags = -Wp,-MMD,$(depfile) \ hostcxx_flags = -Wp,-MMD,$(depfile) \ $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ $(HOSTCXXFLAGS_$(target-stem).o) -hostrust_flags = --emit=dep-info=$(depfile) \ +hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \ $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ $(HOSTRUSTFLAGS_$(target-stem))
On Sun, Jul 23, 2023 at 12:52 AM Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > > On Thu, Jul 20, 2023 at 8:35 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > Maybe, the following was a breakage. > > > > commit 295d8398c67e314d99bb070f38883f83fe94a97a > > Author: Masahiro Yamada <masahiroy@kernel.org> > > Date: Sat Jan 7 18:18:15 2023 +0900 > > > > kbuild: specify output names separately for each emission type from rustc > > > > Before that, rust_common_cmd had --out-dir. > > That's right, good catch! > > > BTW, do we also need to fix scripts/Makefile.host > > in case the external module Makefile creates host programs? > > Indeed, we need it too. [1] would fix it (tested it with a trivial > out-of-tree Rust hostprog). > > Do you want me to send it separately? i.e. to avoid losing the > `Tested-by`s etc. that we already got for this one, which is the > important one since that actually has users. > > The hostprogs fix is not really critical for stable, since it is > unlikely there are users at all (we just got the first in-tree real > user in the Rust+KUnit integration coming into 6.6), but I guess it > does not hurt for the same reason. Can you send v2 with the following squashed? I think it makes sense to fix both if we add Fixes: 295d8398c67e ("kbuild: specify output names separately for each emission type from rustc") > Thanks! > > Cheers, > Miguel > > [1] > > diff --git a/scripts/Makefile.host b/scripts/Makefile.host > index 7aea9005e497..54adf2e2ec51 100644 > --- a/scripts/Makefile.host > +++ b/scripts/Makefile.host > @@ -86,7 +86,7 @@ hostc_flags = -Wp,-MMD,$(depfile) \ > hostcxx_flags = -Wp,-MMD,$(depfile) \ > $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ > $(HOSTCXXFLAGS_$(target-stem).o) > -hostrust_flags = --emit=dep-info=$(depfile) \ > +hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \ > $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ > $(HOSTRUSTFLAGS_$(target-stem))
On Sun, Jul 23, 2023 at 2:05 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Sun, Jul 23, 2023 at 12:52 AM Miguel Ojeda > <miguel.ojeda.sandonis@gmail.com> wrote: > > > > On Thu, Jul 20, 2023 at 8:35 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > > > Maybe, the following was a breakage. > > > > > > commit 295d8398c67e314d99bb070f38883f83fe94a97a > > > Author: Masahiro Yamada <masahiroy@kernel.org> > > > Date: Sat Jan 7 18:18:15 2023 +0900 > > > > > > kbuild: specify output names separately for each emission type from rustc > > > > > > Before that, rust_common_cmd had --out-dir. > > > > That's right, good catch! > > > > > BTW, do we also need to fix scripts/Makefile.host > > > in case the external module Makefile creates host programs? > > > > Indeed, we need it too. [1] would fix it (tested it with a trivial > > out-of-tree Rust hostprog). > > > > Do you want me to send it separately? i.e. to avoid losing the > > `Tested-by`s etc. that we already got for this one, which is the > > important one since that actually has users. > > > > The hostprogs fix is not really critical for stable, since it is > > unlikely there are users at all (we just got the first in-tree real > > user in the Rust+KUnit integration coming into 6.6), but I guess it > > does not hurt for the same reason. > > > Can you send v2 with the following squashed? > > > I think it makes sense to fix both if we add > Fixes: 295d8398c67e ("kbuild: specify output names separately for each > emission type from rustc") I dropped v1 for now, expecting to get v2 soon.
On Sun, Jul 23, 2023 at 7:06 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > Can you send v2 with the following squashed? > > I think it makes sense to fix both if we add > Fixes: 295d8398c67e ("kbuild: specify output names separately for each > emission type from rustc") Both done [1] -- I marked the `Tested-by`s with "# non-hostprogs" to avoid losing the tags. Thanks! [1] https://lore.kernel.org/rust-for-linux/20230723142128.194339-1-ojeda@kernel.org/ Cheers, Miguel
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