Message ID | 20250304225245.2033120-15-benno.lossin@proton.me (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | None | expand |
"Benno Lossin" <benno.lossin@proton.me> writes: > From: Miguel Ojeda <ojeda@kernel.org> > > Add infrastructure for moving the initialization API to its own crate. > Covers all make targets such as `rust-analyzer` and `rustdoc`. The tests > of pin-init are not added to `rusttest`, as they are already tested in > the user-space repository [1]. If it's not too much hassle, why not add them in the kernel as well? I would rather not have to go fetch the user space repo from github, in the event that I ever need to patch pin-init. > > Link: https://github.com/Rust-for-Linux/pin-init [1] > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> > Co-developed-by: Benno Lossin <benno.lossin@proton.me> > Signed-off-by: Benno Lossin <benno.lossin@proton.me> > --- > rust/Makefile | 75 +++++++++++++++++++++++------- > rust/pin-init/internal/src/_lib.rs | 3 ++ > rust/pin-init/internal/src/lib.rs | 4 ++ > rust/pin-init/src/_lib.rs | 5 ++ > scripts/Makefile.build | 2 +- > scripts/generate_rust_analyzer.py | 17 ++++++- > 6 files changed, 86 insertions(+), 20 deletions(-) > create mode 100644 rust/pin-init/internal/src/_lib.rs > create mode 100644 rust/pin-init/src/_lib.rs > > diff --git a/rust/Makefile b/rust/Makefile > index ea3849eb78f6..90310f0620eb 100644 > --- a/rust/Makefile > +++ b/rust/Makefile [...] > @@ -110,11 +113,24 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE > rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE > +$(call if_changed,rustdoc) > > -rustdoc-kernel: private rustc_target_flags = --extern ffi \ > +rustdoc-pin_init_internal: private rustdoc_host = yes > +rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ > + --extern proc_macro --crate-type proc-macro > +rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE > + +$(call if_changed,rustdoc) > + > +rustdoc-pin_init: private rustdoc_host = yes > +rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ > + --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" > +rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \ > + rustdoc-macros FORCE > + +$(call if_changed,rustdoc) Is it possible to do some code sharing here, such that when we add a crate, it's just a matter of putting the path/name on a list somewhere? Best regards, Andreas Hindborg
On Wed Mar 5, 2025 at 12:59 PM CET, Andreas Hindborg wrote: > "Benno Lossin" <benno.lossin@proton.me> writes: > >> From: Miguel Ojeda <ojeda@kernel.org> >> >> Add infrastructure for moving the initialization API to its own crate. >> Covers all make targets such as `rust-analyzer` and `rustdoc`. The tests >> of pin-init are not added to `rusttest`, as they are already tested in >> the user-space repository [1]. > > If it's not too much hassle, why not add them in the kernel as well? I > would rather not have to go fetch the user space repo from github, in > the event that I ever need to patch pin-init. I tried to add them, but encountered a lot of problems. Maybe the new build system can help with that. But if you insist, I can try to get them to work again in a different series now. The tests run every day in the GitHub CI and any changes that go through the pin-init-next tree will also be tested there before I submit any PRs. >> Link: https://github.com/Rust-for-Linux/pin-init [1] >> Signed-off-by: Miguel Ojeda <ojeda@kernel.org> >> Co-developed-by: Benno Lossin <benno.lossin@proton.me> >> Signed-off-by: Benno Lossin <benno.lossin@proton.me> >> --- >> rust/Makefile | 75 +++++++++++++++++++++++------- >> rust/pin-init/internal/src/_lib.rs | 3 ++ >> rust/pin-init/internal/src/lib.rs | 4 ++ >> rust/pin-init/src/_lib.rs | 5 ++ >> scripts/Makefile.build | 2 +- >> scripts/generate_rust_analyzer.py | 17 ++++++- >> 6 files changed, 86 insertions(+), 20 deletions(-) >> create mode 100644 rust/pin-init/internal/src/_lib.rs >> create mode 100644 rust/pin-init/src/_lib.rs >> >> diff --git a/rust/Makefile b/rust/Makefile >> index ea3849eb78f6..90310f0620eb 100644 >> --- a/rust/Makefile >> +++ b/rust/Makefile > > [...] > >> @@ -110,11 +113,24 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE >> rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE >> +$(call if_changed,rustdoc) >> >> -rustdoc-kernel: private rustc_target_flags = --extern ffi \ >> +rustdoc-pin_init_internal: private rustdoc_host = yes >> +rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ >> + --extern proc_macro --crate-type proc-macro >> +rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE >> + +$(call if_changed,rustdoc) >> + >> +rustdoc-pin_init: private rustdoc_host = yes >> +rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ >> + --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" >> +rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \ >> + rustdoc-macros FORCE >> + +$(call if_changed,rustdoc) > > Is it possible to do some code sharing here, such that when we add a > crate, it's just a matter of putting the path/name on a list somewhere? Miguel informed me that this Makefile won't exist in the new build system, so I'd rather not do that. --- Cheers, Benno
"Benno Lossin" <benno.lossin@proton.me> writes: > On Wed Mar 5, 2025 at 12:59 PM CET, Andreas Hindborg wrote: >> "Benno Lossin" <benno.lossin@proton.me> writes: >> >>> From: Miguel Ojeda <ojeda@kernel.org> >>> >>> Add infrastructure for moving the initialization API to its own crate. >>> Covers all make targets such as `rust-analyzer` and `rustdoc`. The tests >>> of pin-init are not added to `rusttest`, as they are already tested in >>> the user-space repository [1]. >> >> If it's not too much hassle, why not add them in the kernel as well? I >> would rather not have to go fetch the user space repo from github, in >> the event that I ever need to patch pin-init. > > I tried to add them, but encountered a lot of problems. Maybe the new > build system can help with that. But if you insist, I can try to get > them to work again in a different series now. > > The tests run every day in the GitHub CI and any changes that go through > the pin-init-next tree will also be tested there before I submit any > PRs. I _really_ think that the ability to run the tests should be present in the kernel repository. But I also do not want to block this series on it, if it is something that will be easier to achieve with the build system overhaul that is in the pipeline. > >>> Link: https://github.com/Rust-for-Linux/pin-init [1] >>> Signed-off-by: Miguel Ojeda <ojeda@kernel.org> >>> Co-developed-by: Benno Lossin <benno.lossin@proton.me> >>> Signed-off-by: Benno Lossin <benno.lossin@proton.me> >>> --- >>> rust/Makefile | 75 +++++++++++++++++++++++------- >>> rust/pin-init/internal/src/_lib.rs | 3 ++ >>> rust/pin-init/internal/src/lib.rs | 4 ++ >>> rust/pin-init/src/_lib.rs | 5 ++ >>> scripts/Makefile.build | 2 +- >>> scripts/generate_rust_analyzer.py | 17 ++++++- >>> 6 files changed, 86 insertions(+), 20 deletions(-) >>> create mode 100644 rust/pin-init/internal/src/_lib.rs >>> create mode 100644 rust/pin-init/src/_lib.rs >>> >>> diff --git a/rust/Makefile b/rust/Makefile >>> index ea3849eb78f6..90310f0620eb 100644 >>> --- a/rust/Makefile >>> +++ b/rust/Makefile >> >> [...] >> >>> @@ -110,11 +113,24 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE >>> rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE >>> +$(call if_changed,rustdoc) >>> >>> -rustdoc-kernel: private rustc_target_flags = --extern ffi \ >>> +rustdoc-pin_init_internal: private rustdoc_host = yes >>> +rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ >>> + --extern proc_macro --crate-type proc-macro >>> +rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE >>> + +$(call if_changed,rustdoc) >>> + >>> +rustdoc-pin_init: private rustdoc_host = yes >>> +rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ >>> + --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" >>> +rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \ >>> + rustdoc-macros FORCE >>> + +$(call if_changed,rustdoc) >> >> Is it possible to do some code sharing here, such that when we add a >> crate, it's just a matter of putting the path/name on a list somewhere? > > Miguel informed me that this Makefile won't exist in the new build > system, so I'd rather not do that. OK, cool. Best regards, Andreas Hindborg
On Wed, Mar 5, 2025 at 12:59 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: > > If it's not too much hassle, why not add them in the kernel as well? I > would rather not have to go fetch the user space repo from github, in > the event that I ever need to patch pin-init. If you need to patch it, then you should generally do so upstream -- this is supposed to be a vendored/sync'd library. Cheers, Miguel
On Wed, Mar 5, 2025 at 1:34 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: > > I _really_ think that the ability to run the tests should be present in > the kernel repository. But I also do not want to block this series on it, > if it is something that will be easier to achieve with the build system > overhaul that is in the pipeline. No, that is not the plan. Even with the new build system, this is supposed to be developed upstream as far as I understand, so you will need to run them there anyway. Unless there is a reason we could catch more bugs here, that is. Cheers, Miguel
On Wed Mar 5, 2025 at 1:50 PM CET, Miguel Ojeda wrote: > On Wed, Mar 5, 2025 at 1:34 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: >> >> I _really_ think that the ability to run the tests should be present in >> the kernel repository. But I also do not want to block this series on it, >> if it is something that will be easier to achieve with the build system >> overhaul that is in the pipeline. > > No, that is not the plan. Even with the new build system, this is > supposed to be developed upstream as far as I understand, so you will > need to run them there anyway. Yes, the plan is that development will happen on GitHub. I will of course continue to take patches via the list, but I would prefer if people make changes via GitHub PRs, since those run the CI (which also includes a lot more tests that I haven't vendored here). --- Cheers, Benno
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com> writes: > On Wed, Mar 5, 2025 at 1:34 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: >> >> I _really_ think that the ability to run the tests should be present in >> the kernel repository. But I also do not want to block this series on it, >> if it is something that will be easier to achieve with the build system >> overhaul that is in the pipeline. > > No, that is not the plan. Even with the new build system, this is > supposed to be developed upstream as far as I understand, so you will > need to run them there anyway. > > Unless there is a reason we could catch more bugs here, that is. I guess it would be no different than `syn`. But I think it is a shame that we move something that people could contribute to via the kernel development flow - out of the kernel development flow. Ultimately I guess this is for the maintainer to decide, and I don't have to like the decision. Best regards, Andreas Hindborg
On Wed Mar 5, 2025 at 3:19 PM CET, Andreas Hindborg wrote: > "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com> writes: > >> On Wed, Mar 5, 2025 at 1:34 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: >>> >>> I _really_ think that the ability to run the tests should be present in >>> the kernel repository. But I also do not want to block this series on it, >>> if it is something that will be easier to achieve with the build system >>> overhaul that is in the pipeline. >> >> No, that is not the plan. Even with the new build system, this is >> supposed to be developed upstream as far as I understand, so you will >> need to run them there anyway. >> >> Unless there is a reason we could catch more bugs here, that is. > > I guess it would be no different than `syn`. But I think it is a shame > that we move something that people could contribute to via the kernel > development flow - out of the kernel development flow. You *can* send patches via the list, I will pick them up and run them through the GitHub CI. Patches that arrive via GitHub will also go through the list and people can add their tags there. Also I don't think that pin-init will receive a lot of contributions in the first place. I do have a lot of changes planned for when we get `syn`, but other than that, I don't think it will change a lot in the future. --- Cheers, Benno
diff --git a/rust/Makefile b/rust/Makefile index ea3849eb78f6..90310f0620eb 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_RUST) += helpers/helpers.o CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs -obj-$(CONFIG_RUST) += bindings.o kernel.o +obj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o always-$(CONFIG_RUST) += exports_helpers_generated.h \ exports_bindings_generated.h exports_kernel_generated.h @@ -41,7 +41,10 @@ ifdef CONFIG_RUST libmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type proc-macro - </dev/null) libmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name)) -always-$(CONFIG_RUST) += $(libmacros_name) +libpin_init_internal_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-type proc-macro - </dev/null) +libpin_init_internal_extension := $(patsubst libpin_init_internal.%,%,$(libpin_init_internal_name)) + +always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name) # `$(rust_flags)` is passed in case the user added `--sysroot`. rustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot) @@ -80,7 +83,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< # command-like flags to solve the issue. Meanwhile, we use the non-custom case # and then retouch the generated files. rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \ - rustdoc-kernel + rustdoc-kernel rustdoc-pin_init $(Q)cp $(srctree)/Documentation/images/logo.svg $(rustdoc_output)/static.files/ $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/ $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \ @@ -110,11 +113,24 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE +$(call if_changed,rustdoc) -rustdoc-kernel: private rustc_target_flags = --extern ffi \ +rustdoc-pin_init_internal: private rustdoc_host = yes +rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ + --extern proc_macro --crate-type proc-macro +rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE + +$(call if_changed,rustdoc) + +rustdoc-pin_init: private rustdoc_host = yes +rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ + --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" +rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \ + rustdoc-macros FORCE + +$(call if_changed,rustdoc) + +rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \ --extern build_error --extern macros \ --extern bindings --extern uapi rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \ - rustdoc-compiler_builtins $(obj)/$(libmacros_name) \ + rustdoc-pin_init rustdoc-compiler_builtins $(obj)/$(libmacros_name) \ $(obj)/bindings.o FORCE +$(call if_changed,rustdoc) @@ -139,12 +155,24 @@ rusttestlib-macros: private rustc_test_library_proc = yes rusttestlib-macros: $(src)/macros/lib.rs FORCE +$(call if_changed,rustc_test_library) +rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \ + --extern proc_macro +rusttestlib-pin_init_internal: private rustc_test_library_proc = yes +rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE + +$(call if_changed,rustc_test_library) + +rusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \ + --extern macros --cfg kernel +rusttestlib-pin_init: $(src)/pin-init/src/_lib.rs rusttestlib-macros \ + rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE + +$(call if_changed,rustc_test_library) + rusttestlib-kernel: private rustc_target_flags = --extern ffi \ - --extern build_error --extern macros \ + --extern build_error --extern macros --extern pin_init \ --extern bindings --extern uapi -rusttestlib-kernel: $(src)/kernel/lib.rs \ - rusttestlib-bindings rusttestlib-uapi rusttestlib-build_error \ - $(obj)/$(libmacros_name) $(obj)/bindings.o FORCE +rusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \ + rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \ + $(obj)/bindings.o FORCE +$(call if_changed,rustc_test_library) rusttestlib-bindings: private rustc_target_flags = --extern ffi @@ -172,8 +200,8 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $< mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \ OBJTREE=$(abspath $(objtree)) \ $(RUSTDOC) --test $(rust_flags) \ - -L$(objtree)/$(obj) --extern ffi --extern kernel \ - --extern build_error --extern macros \ + -L$(objtree)/$(obj) --extern ffi --extern pin_init \ + --extern kernel --extern build_error --extern macros \ --extern bindings --extern uapi \ --no-run --crate-name kernel -Zunstable-options \ --sysroot=/dev/null \ @@ -203,18 +231,18 @@ quiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T $< rusttest: rusttest-macros rusttest-kernel rusttest-macros: private rustc_target_flags = --extern proc_macro \ - --extern macros --extern kernel + --extern macros --extern kernel --extern pin_init rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro rusttest-macros: $(src)/macros/lib.rs \ - rusttestlib-macros rusttestlib-kernel FORCE + rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE +$(call if_changed,rustc_test) +$(call if_changed,rustdoc_test) -rusttest-kernel: private rustc_target_flags = --extern ffi \ +rusttest-kernel: private rustc_target_flags = --extern ffi --extern pin_init \ --extern build_error --extern macros --extern bindings --extern uapi rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \ - rusttestlib-uapi FORCE + rusttestlib-uapi rusttestlib-pin_init FORCE +$(call if_changed,rustc_test) ifdef CONFIG_CC_IS_CLANG @@ -361,7 +389,7 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ cmd_rustc_procmacro = \ - $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ + $(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \ -Clinker-flavor=gcc -Clinker=$(HOSTCC) \ -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \ --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \ @@ -372,6 +400,10 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ $(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE +$(call if_changed_dep,rustc_procmacro) +$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel +$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/_lib.rs FORCE + +$(call if_changed_dep,rustc_procmacro) + quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ cmd_rustc_library = \ OBJTREE=$(abspath $(objtree)) \ @@ -451,6 +483,13 @@ $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE +$(call if_changed_rule,rustc_library) +$(obj)/pin_init.o: private skip_gendwarfksyms = 1 +$(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \ + --extern macros --cfg kernel +$(obj)/pin_init.o: $(src)/pin-init/src/_lib.rs $(obj)/compiler_builtins.o \ + $(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE + +$(call if_changed_rule,rustc_library) + $(obj)/build_error.o: private skip_gendwarfksyms = 1 $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE +$(call if_changed_rule,rustc_library) @@ -473,9 +512,9 @@ $(obj)/uapi.o: $(src)/uapi/lib.rs \ $(obj)/uapi/uapi_generated.rs FORCE +$(call if_changed_rule,rustc_library) -$(obj)/kernel.o: private rustc_target_flags = --extern ffi \ +$(obj)/kernel.o: private rustc_target_flags = --extern ffi --extern pin_init \ --extern build_error --extern macros --extern bindings --extern uapi -$(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o \ +$(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o $(obj)/pin_init.o \ $(obj)/$(libmacros_name) $(obj)/bindings.o $(obj)/uapi.o FORCE +$(call if_changed_rule,rustc_library) diff --git a/rust/pin-init/internal/src/_lib.rs b/rust/pin-init/internal/src/_lib.rs new file mode 100644 index 000000000000..0874cf04e4cb --- /dev/null +++ b/rust/pin-init/internal/src/_lib.rs @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + +//! Will be removed in a future commit, only exists to prevent compilation errors. diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs index bf66cbee2531..3146da5cc47c 100644 --- a/rust/pin-init/internal/src/lib.rs +++ b/rust/pin-init/internal/src/lib.rs @@ -1,5 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT +// When fixdep scans this, it will find this string `CONFIG_RUSTC_VERSION_TEXT` +// and thus add a dependency on `include/config/RUSTC_VERSION_TEXT`, which is +// touched by Kconfig when the version string from the compiler changes. + #[allow(missing_docs)] #[proc_macro_attribute] pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream { diff --git a/rust/pin-init/src/_lib.rs b/rust/pin-init/src/_lib.rs new file mode 100644 index 000000000000..e0918fd8e9e7 --- /dev/null +++ b/rust/pin-init/src/_lib.rs @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + +//! Will be removed in a future commit, only exists to prevent compilation errors. + +#![no_std] diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 993708d11874..08b6380933f5 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -237,7 +237,7 @@ rust_common_cmd = \ -Zallow-features=$(rust_allowed_features) \ -Zcrate-attr=no_std \ -Zcrate-attr='feature($(rust_allowed_features))' \ - -Zunstable-options --extern kernel \ + -Zunstable-options --extern pin_init --extern kernel \ --crate-type rlib -L $(objtree)/rust/ \ --crate-name $(basename $(notdir $@)) \ --sysroot=/dev/null \ diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py index aa8ea1a4dbe5..a44a4475d11f 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -93,10 +93,25 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): ) crates[-1]["env"]["OBJTREE"] = str(objtree.resolve(True)) + append_crate( + "pin_init_internal", + srctree / "rust" / "pin-init" / "internal" / "src" / "_lib.rs", + [], + cfg=["kernel"], + is_proc_macro=True, + ) + + append_crate( + "pin_init", + srctree / "rust" / "pin-init" / "src" / "_lib.rs", + ["core", "pin_init_internal", "macros"], + cfg=["kernel"], + ) + append_crate( "kernel", srctree / "rust" / "kernel" / "lib.rs", - ["core", "macros", "build_error", "bindings"], + ["core", "macros", "build_error", "bindings", "pin_init"], cfg=cfg, ) crates[-1]["source"] = {