All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: Suppress searching builtin sysroot
@ 2023-10-31 20:10 Matthew Maurer
  2023-11-27 13:58 ` Alice Ryhl
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthew Maurer @ 2023-10-31 20:10 UTC (permalink / raw)
  To: Jamie.Cunliffe, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Masahiro Yamada
  Cc: will, Matthew Maurer, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, rust-for-linux, linux-kernel,
	linux-kbuild

By default, if Rust is passed `--target=foo` rather than a target.json
file, it will infer a default sysroot if that component is installed. As
the proposed aarch64 support uses `aarch64-unknown-none` rather than a
target.json file, this is needed to prevent rustc from being confused
between the custom kernel sysroot and the pre-installed one.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---

This patch is prompted by the issue I encountered at
https://lore.kernel.org/all/CAGSQo01pOixiPXkW867h4vPUaAjtKtHGKhkV-rpifJvKxAf4Ww@mail.gmail.com/
but should be generically more hermetic even if we don't end up landing
that patch.

 rust/Makefile          | 1 +
 scripts/Makefile.build | 1 +
 2 files changed, 2 insertions(+)

diff --git a/rust/Makefile b/rust/Makefile
index a27f35f924ec..0403e88e19fd 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -400,6 +400,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
 		--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
 		--crate-type rlib -L$(objtree)/$(obj) \
 		--crate-name $(patsubst %.o,%,$(notdir $@)) $< \
+		--sysroot=/dev/null \
 	$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
 
 rust-analyzer:
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 82e3fb19fdaf..6e4ee513cc3c 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -275,6 +275,7 @@ rust_common_cmd = \
 	--extern alloc --extern kernel \
 	--crate-type rlib -L $(objtree)/rust/ \
 	--crate-name $(basename $(notdir $@)) \
+	--sysroot=/dev/null \
 	--out-dir $(dir $@) --emit=dep-info=$(depfile)
 
 # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit
-- 
2.42.0.820.g83a721a137-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: Suppress searching builtin sysroot
  2023-10-31 20:10 [PATCH] rust: Suppress searching builtin sysroot Matthew Maurer
@ 2023-11-27 13:58 ` Alice Ryhl
  2023-11-28 21:14 ` Boqun Feng
  2023-12-13 18:45 ` Miguel Ojeda
  2 siblings, 0 replies; 5+ messages in thread
From: Alice Ryhl @ 2023-11-27 13:58 UTC (permalink / raw)
  To: Matthew Maurer
  Cc: Jamie.Cunliffe, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Masahiro Yamada, will, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild

On Tue, Oct 31, 2023 at 9:18 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> By default, if Rust is passed `--target=foo` rather than a target.json
> file, it will infer a default sysroot if that component is installed. As
> the proposed aarch64 support uses `aarch64-unknown-none` rather than a
> target.json file, this is needed to prevent rustc from being confused
> between the custom kernel sysroot and the pre-installed one.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

I guess these are the only places where we need the sysroot parameter
because the other rustc invocations compile for the host target
instead?

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: Suppress searching builtin sysroot
  2023-10-31 20:10 [PATCH] rust: Suppress searching builtin sysroot Matthew Maurer
  2023-11-27 13:58 ` Alice Ryhl
@ 2023-11-28 21:14 ` Boqun Feng
  2023-12-01  1:47   ` Boqun Feng
  2023-12-13 18:45 ` Miguel Ojeda
  2 siblings, 1 reply; 5+ messages in thread
From: Boqun Feng @ 2023-11-28 21:14 UTC (permalink / raw)
  To: Matthew Maurer
  Cc: Jamie.Cunliffe, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Masahiro Yamada, will, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, rust-for-linux, linux-kernel,
	linux-kbuild, Catalin Marinas

[Cc Catalin as well]

On Tue, Oct 31, 2023 at 08:10:14PM +0000, Matthew Maurer wrote:
> By default, if Rust is passed `--target=foo` rather than a target.json
> file, it will infer a default sysroot if that component is installed. As
> the proposed aarch64 support uses `aarch64-unknown-none` rather than a
> target.json file, this is needed to prevent rustc from being confused
> between the custom kernel sysroot and the pre-installed one.
> 
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---
> 
> This patch is prompted by the issue I encountered at
> https://lore.kernel.org/all/CAGSQo01pOixiPXkW867h4vPUaAjtKtHGKhkV-rpifJvKxAf4Ww@mail.gmail.com/
> but should be generically more hermetic even if we don't end up landing
> that patch.
> 

I'm able to reproduce the issue you mentioned here after
`rustup target add aarch64-unknown-none`, and your patch fixed that.

Tested-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

>  rust/Makefile          | 1 +
>  scripts/Makefile.build | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/rust/Makefile b/rust/Makefile
> index a27f35f924ec..0403e88e19fd 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -400,6 +400,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
>  		--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
>  		--crate-type rlib -L$(objtree)/$(obj) \
>  		--crate-name $(patsubst %.o,%,$(notdir $@)) $< \
> +		--sysroot=/dev/null \
>  	$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
>  
>  rust-analyzer:
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 82e3fb19fdaf..6e4ee513cc3c 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -275,6 +275,7 @@ rust_common_cmd = \
>  	--extern alloc --extern kernel \
>  	--crate-type rlib -L $(objtree)/rust/ \
>  	--crate-name $(basename $(notdir $@)) \
> +	--sysroot=/dev/null \
>  	--out-dir $(dir $@) --emit=dep-info=$(depfile)
>  
>  # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit
> -- 
> 2.42.0.820.g83a721a137-goog
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: Suppress searching builtin sysroot
  2023-11-28 21:14 ` Boqun Feng
@ 2023-12-01  1:47   ` Boqun Feng
  0 siblings, 0 replies; 5+ messages in thread
From: Boqun Feng @ 2023-12-01  1:47 UTC (permalink / raw)
  To: Matthew Maurer
  Cc: Jamie.Cunliffe, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Masahiro Yamada, will, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, rust-for-linux, linux-kernel,
	linux-kbuild, Catalin Marinas

On Tue, Nov 28, 2023 at 01:14:41PM -0800, Boqun Feng wrote:
> [Cc Catalin as well]
> 
> On Tue, Oct 31, 2023 at 08:10:14PM +0000, Matthew Maurer wrote:
> > By default, if Rust is passed `--target=foo` rather than a target.json
> > file, it will infer a default sysroot if that component is installed. As
> > the proposed aarch64 support uses `aarch64-unknown-none` rather than a
> > target.json file, this is needed to prevent rustc from being confused
> > between the custom kernel sysroot and the pre-installed one.
> > 
> > Signed-off-by: Matthew Maurer <mmaurer@google.com>
> > ---
> > 
> > This patch is prompted by the issue I encountered at
> > https://lore.kernel.org/all/CAGSQo01pOixiPXkW867h4vPUaAjtKtHGKhkV-rpifJvKxAf4Ww@mail.gmail.com/
> > but should be generically more hermetic even if we don't end up landing
> > that patch.
> > 
> 
> I'm able to reproduce the issue you mentioned here after
> `rustup target add aarch64-unknown-none`, and your patch fixed that.
> 
> Tested-by: Boqun Feng <boqun.feng@gmail.com>
> 

Looks like I spoke too soon... we need another fix onto this:

diff --git a/rust/Makefile b/rust/Makefile
index eda32ff757b1..c573d8881686 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -178,6 +178,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
                --extern build_error --extern macros \
                --extern bindings --extern uapi \
                --no-run --crate-name kernel -Zunstable-options \
+               --sysroot=/dev/null \
                --test-builder $(objtree)/scripts/rustdoc_test_builder \
                $< $(rustdoc_test_kernel_quiet); \
        $(objtree)/scripts/rustdoc_test_gen

, this is for kernel doc test as kunit test.

Needless to say, I also have tested with that and confirm it fixes the
issue.

Regards,
Boqun

> Regards,
> Boqun
> 
> >  rust/Makefile          | 1 +
> >  scripts/Makefile.build | 1 +
> >  2 files changed, 2 insertions(+)
> > 
> > diff --git a/rust/Makefile b/rust/Makefile
> > index a27f35f924ec..0403e88e19fd 100644
> > --- a/rust/Makefile
> > +++ b/rust/Makefile
> > @@ -400,6 +400,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
> >  		--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
> >  		--crate-type rlib -L$(objtree)/$(obj) \
> >  		--crate-name $(patsubst %.o,%,$(notdir $@)) $< \
> > +		--sysroot=/dev/null \
> >  	$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
> >  
> >  rust-analyzer:
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 82e3fb19fdaf..6e4ee513cc3c 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -275,6 +275,7 @@ rust_common_cmd = \
> >  	--extern alloc --extern kernel \
> >  	--crate-type rlib -L $(objtree)/rust/ \
> >  	--crate-name $(basename $(notdir $@)) \
> > +	--sysroot=/dev/null \
> >  	--out-dir $(dir $@) --emit=dep-info=$(depfile)
> >  
> >  # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit
> > -- 
> > 2.42.0.820.g83a721a137-goog
> > 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: Suppress searching builtin sysroot
  2023-10-31 20:10 [PATCH] rust: Suppress searching builtin sysroot Matthew Maurer
  2023-11-27 13:58 ` Alice Ryhl
  2023-11-28 21:14 ` Boqun Feng
@ 2023-12-13 18:45 ` Miguel Ojeda
  2 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2023-12-13 18:45 UTC (permalink / raw)
  To: Matthew Maurer
  Cc: Jamie.Cunliffe, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Masahiro Yamada, will, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild

On Tue, Oct 31, 2023 at 9:18 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> By default, if Rust is passed `--target=foo` rather than a target.json
> file, it will infer a default sysroot if that component is installed. As
> the proposed aarch64 support uses `aarch64-unknown-none` rather than a
> target.json file, this is needed to prevent rustc from being confused
> between the custom kernel sysroot and the pre-installed one.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

Applied to `rust-next`. I added Boqun's fix for `rusttest` as well as
a fix for `rustdoc` (which requires a conditional for host crates like
`macros`); and added a couple `Links` to the arm64 discussions.

I would appreciate extra testing for this one (please use `rust-next`
commits in that case).

Thanks everyone!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-13 18:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 20:10 [PATCH] rust: Suppress searching builtin sysroot Matthew Maurer
2023-11-27 13:58 ` Alice Ryhl
2023-11-28 21:14 ` Boqun Feng
2023-12-01  1:47   ` Boqun Feng
2023-12-13 18:45 ` Miguel Ojeda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.