Re: [PATCH v3] Kbuild: fix issues with rustc-option

From: Miguel Ojeda
Date: Wed Oct 09 2024 - 08:59:06 EST


On Wed, Oct 9, 2024 at 1:42 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> Note that RUSTC_BOOTSTRAP is also defined in the top-level Makefile, but
> its value is unfortunately *not* inherited from the environment. That

I would perhaps say ", but Make-exported variables are not inherited"
or similar to be a bit more precise (because the external environment,
as in the `make` environment, is exported unlike those variables).

> not look for the standard library. It's not possible to instead supply a
> standard library to rustc, as we need `rustc-option` before the Rust
> standard library is compiled.

The error message mentions `std`, so to clarify I would perhaps add
".... standard library (i.e. `core`)" or similar, i.e. one could think
`no_std` is enough otherwise (which would be better if we could, since
it is stable unlike `no_core`, but we don't want it here either).

> The -o and --out-dir parameters are altered to fix this warning:
>
> warning: ignoring --out-dir flag due to -o flag
>
> The --sysroot flag is provided as we would otherwise require it to be
> present in KBUILD_RUSTFLAGS. The --emit=obj flag is used to write the
> resulting rlib to /dev/null instead of writing it to a file in
> $(TMPOUT).

"the resulting object file" (i.e. the rlib is not written even if we
wrote to a file).

> I verified that the Kconfig version of rustc-option doesn't have the
> same issues.

Thanks for checking this. We may want to make it closer to what we do
her, but that can be done later.

Cheers,
Miguel