Re: [PATCH v4 21/28] rust: alloc: remove `GlobalAlloc` and `krealloc_aligned`

Danilo Krummrich
2024-08-07T23:16:32Z

On Wed, Aug 07, 2024 at 09:23:04PM +0000, Benno Lossin wrote:
> On 05.08.24 17:19, Danilo Krummrich wrote:
> > Now that we have all the `Allocator`s and the kernel `Box` and `Vec`
> > implementations in place, remove `GlobalAlloc` and `krealloc_aligned`.
>
> When I try to compile this patch, then I get this error:
>
> UPD include/generated/utsversion.h
> CC init/version-timestamp.o
> KSYMS .tmp_vmlinux0.kallsyms.S
> AS .tmp_vmlinux0.kallsyms.o
> LD .tmp_vmlinux1
> ld.lld: error: undefined symbol: __rust_realloc
> >>> referenced by usercopy_64.c
> >>> vmlinux.o:(alloc::raw_vec::finish_grow::<alloc::alloc::Global>)
>
> ld.lld: error: undefined symbol: __rust_alloc
> >>> referenced by usercopy_64.c
> >>> vmlinux.o:(alloc::raw_vec::finish_grow::<alloc::alloc::Global>)
> make[2]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
>
> So maybe the `#[global_allocator]` needs to stay until we remove the
> `alloc` dependency?

Yes, I think so. I compile checked the single patches with `M=rust` and
`M=drivers`, which only compiles, but doesn't link things, so it didn't catch
it.

>
> ---
> Cheers,
> Benno
>
> > Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> > ---
> > rust/kernel/alloc/allocator.rs | 63 ++--------------------------------
> > 1 file changed, 2 insertions(+), 61 deletions(-)
>