History

kbuild: use the upstream `alloc` crate

Switch away from our fork of the `alloc` crate. We remove it altogether in the next commit.

Wedson Almeida Filho committed 2 years ago

Commit 11795ae1 parent 03989773 files · +5 −14Browse files

Unified · Split

3 files
  1. rust/Makefile +3 −13
  2. rust/kernel/str.rs +1 −0
  3. scripts/generate_rust_analyzer.py +1 −1
rust/Makefile+3−13
@@ -61,15 +61,9 @@ core-cfgs = \ · 60 unmodified lines
61 --cfg no_fp_fmt_parse61 --cfg no_fp_fmt_parse
62 62
63alloc-cfgs = \63alloc-cfgs = \
64 --cfg no_borrow \
65 --cfg no_fmt \
66 --cfg no_global_oom_handling \64 --cfg no_global_oom_handling \
67 --cfg no_macros \
68 --cfg no_rc \65 --cfg no_rc \
69 --cfg no_str \66 --cfg no_sync
70 --cfg no_string \
71 --cfg no_sync \
72 --cfg no_thin
73 67
74quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<68quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
75 cmd_rustdoc = \69 cmd_rustdoc = \
@@ -123,7 +117,7 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE · 47 unmodified lines
123# due to things that are "configured out" vs. entirely non-existing ones.117# due to things that are "configured out" vs. entirely non-existing ones.
124rustdoc-alloc: private rustc_target_flags = $(alloc-cfgs) \118rustdoc-alloc: private rustc_target_flags = $(alloc-cfgs) \
125 -Arustdoc::broken_intra_doc_links119 -Arustdoc::broken_intra_doc_links
126rustdoc-alloc: $(src)/alloc/lib.rs rustdoc-core rustdoc-compiler_builtins FORCE120rustdoc-alloc: $(RUST_LIB_SRC)/alloc/src/lib.rs rustdoc-core rustdoc-compiler_builtins FORCE
127 +$(call if_changed,rustdoc)121 +$(call if_changed,rustdoc)
128 122
129rustdoc-kernel: private rustc_target_flags = --extern alloc \123rustdoc-kernel: private rustc_target_flags = --extern alloc \
@@ -219,8 +213,6 @@ rusttest: rusttest-macros rusttest-kernel · 89 unmodified lines
219# - `cargo` only considers the use case of building the standard library213# - `cargo` only considers the use case of building the standard library
220# to use it in a given package. Thus we need to create a dummy package214# to use it in a given package. Thus we need to create a dummy package
221# and pick the generated libraries from there.215# and pick the generated libraries from there.
222# - Since we only keep a subset of upstream `alloc` in-tree, we need
223# to recreate it on the fly by putting our sources on top.
224# - The usual ways of modifying the dependency graph in `cargo` do not seem216# - The usual ways of modifying the dependency graph in `cargo` do not seem
225# to apply for the `-Zbuild-std` steps, thus we have to mislead it217# to apply for the `-Zbuild-std` steps, thus we have to mislead it
226# by modifying the sources in the sysroot.218# by modifying the sources in the sysroot.
@@ -239,8 +231,6 @@ quiet_cmd_rustsysroot = RUSTSYSROOT · 12 unmodified lines
239 rm -rf $(objtree)/$(obj)/test; \231 rm -rf $(objtree)/$(obj)/test; \
240 mkdir -p $(objtree)/$(obj)/test; \232 mkdir -p $(objtree)/$(obj)/test; \
241 cp -a $(rustc_sysroot) $(objtree)/$(obj)/test/sysroot; \233 cp -a $(rustc_sysroot) $(objtree)/$(obj)/test/sysroot; \
242 cp -r $(srctree)/$(src)/alloc/* \
243 $(objtree)/$(obj)/test/sysroot/lib/rustlib/src/rust/library/alloc/src; \
244 echo '\#!/bin/sh' > $(objtree)/$(obj)/test/rustc_sysroot; \234 echo '\#!/bin/sh' > $(objtree)/$(obj)/test/rustc_sysroot; \
245 echo "$(RUSTC) --sysroot=$(abspath $(objtree)/$(obj)/test/sysroot) \"\$$@\"" \235 echo "$(RUSTC) --sysroot=$(abspath $(objtree)/$(obj)/test/sysroot) \"\$$@\"" \
246 >> $(objtree)/$(obj)/test/rustc_sysroot; \236 >> $(objtree)/$(obj)/test/rustc_sysroot; \
@@ -448,7 +438,7 @@ $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE · 201 unmodified lines
448$(obj)/alloc.o: private skip_clippy = 1438$(obj)/alloc.o: private skip_clippy = 1
449$(obj)/alloc.o: private skip_flags = -Dunreachable_pub439$(obj)/alloc.o: private skip_flags = -Dunreachable_pub
450$(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs)440$(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs)
451$(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE441$(obj)/alloc.o: $(RUST_LIB_SRC)/alloc/src/lib.rs $(obj)/compiler_builtins.o FORCE
452 +$(call if_changed_dep,rustc_library)442 +$(call if_changed_dep,rustc_library)
453 443
454$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE444$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
rust/kernel/str.rs+1−0
@@ -2,6 +2,7 @@ · 1 unmodified line
2 2
3//! String representations.3//! String representations.
4 4
5use crate::alloc::vec_ext::VecExt;
5use alloc::alloc::AllocError;6use alloc::alloc::AllocError;
6use alloc::vec::Vec;7use alloc::vec::Vec;
7use core::fmt::{self, Write};8use core::fmt::{self, Write};
scripts/generate_rust_analyzer.py+1−1
@@ -66,7 +66,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 65 unmodified lines
66 66
67 append_crate(67 append_crate(
68 "alloc",68 "alloc",
69 srctree / "rust" / "alloc" / "lib.rs",69 sysroot_src / "alloc" / "src" / "lib.rs",
70 ["core", "compiler_builtins"],70 ["core", "compiler_builtins"],
71 cfg=crates_cfgs.get("alloc", []),71 cfg=crates_cfgs.get("alloc", []),
72 )72 )