Skip to content

Commit 14ec91c

Browse files
committed
rust: kbuild: add host library support
Add the a host library rule that produces `.rlib` files to be used by the `macros` crate. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 4fdbdd6 commit 14ec91c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
*.o.*
4242
*.patch
4343
*.pyc
44+
*.rlib
4445
*.rmeta
4546
*.rpm
4647
*.rsi

rust/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE
410410
$(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
411411
$(call if_changed,exports)
412412

413+
quiet_cmd_rustc_hostlibrary = $(RUSTC_OR_CLIPPY_QUIET) H $@
414+
cmd_rustc_hostlibrary = \
415+
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
416+
$(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
417+
--emit=dep-info,link --crate-type rlib -O \
418+
--out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \
419+
--crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<; \
420+
mv $(objtree)/$(obj)/$(patsubst lib%.rlib,%,$(notdir $@)).d $(depfile); \
421+
sed -i '/^\#/d' $(depfile)
422+
413423
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
414424
cmd_rustc_procmacro = \
415425
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \

0 commit comments

Comments
 (0)