Makefile 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Where to place rustdoc generated documentation
  3. rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
  4. obj-$(CONFIG_RUST) += core.o compiler_builtins.o
  5. always-$(CONFIG_RUST) += exports_core_generated.h
  6. # Missing prototypes are expected in the helpers since these are exported
  7. # for Rust only, thus there is no header nor prototypes.
  8. obj-$(CONFIG_RUST) += helpers/helpers.o
  9. CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations
  10. always-$(CONFIG_RUST) += libmacros.so
  11. no-clean-files += libmacros.so
  12. always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
  13. obj-$(CONFIG_RUST) += alloc.o bindings.o kernel.o
  14. always-$(CONFIG_RUST) += exports_alloc_generated.h exports_helpers_generated.h \
  15. exports_bindings_generated.h exports_kernel_generated.h
  16. always-$(CONFIG_RUST) += uapi/uapi_generated.rs
  17. obj-$(CONFIG_RUST) += uapi.o
  18. ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
  19. obj-$(CONFIG_RUST) += build_error.o
  20. else
  21. always-$(CONFIG_RUST) += build_error.o
  22. endif
  23. obj-$(CONFIG_RUST) += exports.o
  24. always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
  25. always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
  26. obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
  27. obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
  28. # Avoids running `$(RUSTC)` for the sysroot when it may not be available.
  29. ifdef CONFIG_RUST
  30. # `$(rust_flags)` is passed in case the user added `--sysroot`.
  31. rustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot)
  32. rustc_host_target := $(shell $(RUSTC) --version --verbose | grep -F 'host: ' | cut -d' ' -f2)
  33. RUST_LIB_SRC ?= $(rustc_sysroot)/lib/rustlib/src/rust/library
  34. ifneq ($(quiet),)
  35. rust_test_quiet=-q
  36. rustdoc_test_quiet=--test-args -q
  37. rustdoc_test_kernel_quiet=>/dev/null
  38. endif
  39. core-cfgs = \
  40. --cfg no_fp_fmt_parse
  41. alloc-cfgs = \
  42. --cfg no_global_oom_handling \
  43. --cfg no_rc \
  44. --cfg no_sync
  45. quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
  46. cmd_rustdoc = \
  47. OBJTREE=$(abspath $(objtree)) \
  48. $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
  49. $(rustc_target_flags) -L$(objtree)/$(obj) \
  50. -Zunstable-options --generate-link-to-definition \
  51. --output $(rustdoc_output) \
  52. --crate-name $(subst rustdoc-,,$@) \
  53. $(if $(rustdoc_host),,--sysroot=/dev/null) \
  54. @$(objtree)/include/generated/rustc_cfg $<
  55. # The `html_logo_url` and `html_favicon_url` forms of the `doc` attribute
  56. # can be used to specify a custom logo. However:
  57. # - The given value is used as-is, thus it cannot be relative or a local file
  58. # (unlike the non-custom case) since the generated docs have subfolders.
  59. # - It requires adding it to every crate.
  60. # - It requires changing `core` which comes from the sysroot.
  61. #
  62. # Using `-Zcrate-attr` would solve the last two points, but not the first.
  63. # The https://github.com/rust-lang/rfcs/pull/3226 RFC suggests two new
  64. # command-like flags to solve the issue. Meanwhile, we use the non-custom case
  65. # and then retouch the generated files.
  66. rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
  67. rustdoc-alloc rustdoc-kernel
  68. $(Q)cp $(srctree)/Documentation/images/logo.svg $(rustdoc_output)/static.files/
  69. $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/
  70. $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
  71. -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
  72. -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
  73. -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \
  74. -e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g'
  75. $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
  76. echo ".logo-container > img { object-fit: contain; }" >> $$f; done
  77. rustdoc-macros: private rustdoc_host = yes
  78. rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
  79. --extern proc_macro
  80. rustdoc-macros: $(src)/macros/lib.rs FORCE
  81. +$(call if_changed,rustdoc)
  82. rustdoc-core: private rustc_target_flags = $(core-cfgs)
  83. rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
  84. +$(call if_changed,rustdoc)
  85. rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
  86. +$(call if_changed,rustdoc)
  87. # We need to allow `rustdoc::broken_intra_doc_links` because some
  88. # `no_global_oom_handling` functions refer to non-`no_global_oom_handling`
  89. # functions. Ideally `rustdoc` would have a way to distinguish broken links
  90. # due to things that are "configured out" vs. entirely non-existing ones.
  91. rustdoc-alloc: private rustc_target_flags = $(alloc-cfgs) \
  92. -Arustdoc::broken_intra_doc_links
  93. rustdoc-alloc: $(RUST_LIB_SRC)/alloc/src/lib.rs rustdoc-core rustdoc-compiler_builtins FORCE
  94. +$(call if_changed,rustdoc)
  95. rustdoc-kernel: private rustc_target_flags = --extern alloc \
  96. --extern build_error --extern macros=$(objtree)/$(obj)/libmacros.so \
  97. --extern bindings --extern uapi
  98. rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-macros \
  99. rustdoc-compiler_builtins rustdoc-alloc $(obj)/libmacros.so \
  100. $(obj)/bindings.o FORCE
  101. +$(call if_changed,rustdoc)
  102. quiet_cmd_rustc_test_library = RUSTC TL $<
  103. cmd_rustc_test_library = \
  104. OBJTREE=$(abspath $(objtree)) \
  105. $(RUSTC) $(rust_common_flags) \
  106. @$(objtree)/include/generated/rustc_cfg $(rustc_target_flags) \
  107. --crate-type $(if $(rustc_test_library_proc),proc-macro,rlib) \
  108. --out-dir $(objtree)/$(obj)/test --cfg testlib \
  109. -L$(objtree)/$(obj)/test \
  110. --crate-name $(subst rusttest-,,$(subst rusttestlib-,,$@)) $<
  111. rusttestlib-build_error: $(src)/build_error.rs FORCE
  112. +$(call if_changed,rustc_test_library)
  113. rusttestlib-macros: private rustc_target_flags = --extern proc_macro
  114. rusttestlib-macros: private rustc_test_library_proc = yes
  115. rusttestlib-macros: $(src)/macros/lib.rs FORCE
  116. +$(call if_changed,rustc_test_library)
  117. rusttestlib-bindings: $(src)/bindings/lib.rs FORCE
  118. +$(call if_changed,rustc_test_library)
  119. rusttestlib-uapi: $(src)/uapi/lib.rs FORCE
  120. +$(call if_changed,rustc_test_library)
  121. quiet_cmd_rustdoc_test = RUSTDOC T $<
  122. cmd_rustdoc_test = \
  123. OBJTREE=$(abspath $(objtree)) \
  124. $(RUSTDOC) --test $(rust_common_flags) \
  125. @$(objtree)/include/generated/rustc_cfg \
  126. $(rustc_target_flags) $(rustdoc_test_target_flags) \
  127. $(rustdoc_test_quiet) \
  128. -L$(objtree)/$(obj)/test --output $(rustdoc_output) \
  129. --crate-name $(subst rusttest-,,$@) $<
  130. quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
  131. cmd_rustdoc_test_kernel = \
  132. rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
  133. mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
  134. OBJTREE=$(abspath $(objtree)) \
  135. $(RUSTDOC) --test $(rust_flags) \
  136. -L$(objtree)/$(obj) --extern alloc --extern kernel \
  137. --extern build_error --extern macros \
  138. --extern bindings --extern uapi \
  139. --no-run --crate-name kernel -Zunstable-options \
  140. --sysroot=/dev/null \
  141. --test-builder $(objtree)/scripts/rustdoc_test_builder \
  142. $< $(rustdoc_test_kernel_quiet); \
  143. $(objtree)/scripts/rustdoc_test_gen
  144. %/doctests_kernel_generated.rs %/doctests_kernel_generated_kunit.c: \
  145. $(src)/kernel/lib.rs $(obj)/kernel.o \
  146. $(objtree)/scripts/rustdoc_test_builder \
  147. $(objtree)/scripts/rustdoc_test_gen FORCE
  148. +$(call if_changed,rustdoc_test_kernel)
  149. # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
  150. # so for the moment we skip `-Cpanic=abort`.
  151. quiet_cmd_rustc_test = RUSTC T $<
  152. cmd_rustc_test = \
  153. OBJTREE=$(abspath $(objtree)) \
  154. $(RUSTC) --test $(rust_common_flags) \
  155. @$(objtree)/include/generated/rustc_cfg \
  156. $(rustc_target_flags) --out-dir $(objtree)/$(obj)/test \
  157. -L$(objtree)/$(obj)/test \
  158. --crate-name $(subst rusttest-,,$@) $<; \
  159. $(objtree)/$(obj)/test/$(subst rusttest-,,$@) $(rust_test_quiet) \
  160. $(rustc_test_run_flags)
  161. rusttest: rusttest-macros rusttest-kernel
  162. rusttest-macros: private rustc_target_flags = --extern proc_macro
  163. rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
  164. rusttest-macros: $(src)/macros/lib.rs FORCE
  165. +$(call if_changed,rustc_test)
  166. +$(call if_changed,rustdoc_test)
  167. rusttest-kernel: private rustc_target_flags = --extern alloc \
  168. --extern build_error --extern macros --extern bindings --extern uapi
  169. rusttest-kernel: $(src)/kernel/lib.rs \
  170. rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \
  171. rusttestlib-uapi FORCE
  172. +$(call if_changed,rustc_test)
  173. +$(call if_changed,rustc_test_library)
  174. ifdef CONFIG_CC_IS_CLANG
  175. bindgen_c_flags = $(c_flags)
  176. else
  177. # bindgen relies on libclang to parse C. Ideally, bindgen would support a GCC
  178. # plugin backend and/or the Clang driver would be perfectly compatible with GCC.
  179. #
  180. # For the moment, here we are tweaking the flags on the fly. This is a hack,
  181. # and some kernel configurations may not work (e.g. `GCC_PLUGIN_RANDSTRUCT`
  182. # if we end up using one of those structs).
  183. bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
  184. -mskip-rax-setup -mgeneral-regs-only -msign-return-address=% \
  185. -mindirect-branch=thunk-extern -mindirect-branch-register \
  186. -mfunction-return=thunk-extern -mrecord-mcount -mabi=lp64 \
  187. -mindirect-branch-cs-prefix -mstack-protector-guard% -mtraceback=no \
  188. -mno-pointers-to-nested-functions -mno-string \
  189. -mno-strict-align -mstrict-align \
  190. -fconserve-stack -falign-jumps=% -falign-loops=% \
  191. -femit-struct-debug-baseonly -fno-ipa-cp-clone -fno-ipa-sra \
  192. -fno-partial-inlining -fplugin-arg-arm_ssp_per_task_plugin-% \
  193. -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \
  194. -fzero-call-used-regs=% -fno-stack-clash-protection \
  195. -fno-inline-functions-called-once -fsanitize=bounds-strict \
  196. -fstrict-flex-arrays=% -fmin-function-alignment=% \
  197. -fzero-init-padding-bits=% \
  198. --param=% --param asan-%
  199. # Derived from `scripts/Makefile.clang`.
  200. BINDGEN_TARGET_x86 := x86_64-linux-gnu
  201. BINDGEN_TARGET_arm64 := aarch64-linux-gnu
  202. BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
  203. # All warnings are inhibited since GCC builds are very experimental,
  204. # many GCC warnings are not supported by Clang, they may only appear in
  205. # some configurations, with new GCC versions, etc.
  206. bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
  207. # Auto variable zero-initialization requires an additional special option with
  208. # clang that is going to be removed sometime in the future (likely in
  209. # clang-18), so make sure to pass this option only if clang supports it
  210. # (libclang major version < 16).
  211. #
  212. # https://github.com/llvm/llvm-project/issues/44842
  213. # https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags
  214. ifdef CONFIG_INIT_STACK_ALL_ZERO
  215. libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
  216. ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
  217. bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
  218. endif
  219. endif
  220. bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
  221. $(bindgen_extra_c_flags)
  222. endif
  223. ifdef CONFIG_LTO
  224. bindgen_c_flags_lto = $(filter-out $(CC_FLAGS_LTO), $(bindgen_c_flags))
  225. else
  226. bindgen_c_flags_lto = $(bindgen_c_flags)
  227. endif
  228. bindgen_c_flags_final = $(bindgen_c_flags_lto) -D__BINDGEN__
  229. # Each `bindgen` release may upgrade the list of Rust target versions. By
  230. # default, the highest stable release in their list is used. Thus we need to set
  231. # a `--rust-target` to avoid future `bindgen` releases emitting code that
  232. # `rustc` may not understand. On top of that, `bindgen` does not support passing
  233. # an unknown Rust target version.
  234. #
  235. # Therefore, the Rust target for `bindgen` can be only as high as the minimum
  236. # Rust version the kernel supports and only as high as the greatest stable Rust
  237. # target supported by the minimum `bindgen` version the kernel supports (that
  238. # is, if we do not test the actual `rustc`/`bindgen` versions running).
  239. #
  240. # Starting with `bindgen` 0.71.0, we will be able to set any future Rust version
  241. # instead, i.e. we will be able to set here our minimum supported Rust version.
  242. quiet_cmd_bindgen = BINDGEN $@
  243. cmd_bindgen = \
  244. $(BINDGEN) $< $(bindgen_target_flags) --rust-target 1.68 \
  245. --use-core --with-derive-default --ctypes-prefix core::ffi --no-layout-tests \
  246. --no-debug '.*' --enable-function-attribute-detection \
  247. -o $@ -- $(bindgen_c_flags_final) -DMODULE \
  248. $(bindgen_target_cflags) $(bindgen_target_extra)
  249. $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
  250. $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
  251. $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \
  252. sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@
  253. $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
  254. $(src)/bindgen_parameters FORCE
  255. $(call if_changed_dep,bindgen)
  256. $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \
  257. $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
  258. $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \
  259. $(src)/bindgen_parameters FORCE
  260. $(call if_changed_dep,bindgen)
  261. # See `CFLAGS_REMOVE_helpers.o` above. In addition, Clang on C does not warn
  262. # with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
  263. # given it is `libclang`; but for consistency, future Clang changes and/or
  264. # a potential future GCC backend for `bindgen`, we disable it too.
  265. $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_flags = \
  266. --blocklist-type '.*' --allowlist-var '' \
  267. --allowlist-function 'rust_helper_.*'
  268. $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \
  269. -I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
  270. $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ; \
  271. sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@
  272. $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
  273. $(call if_changed_dep,bindgen)
  274. quiet_cmd_exports = EXPORTS $@
  275. cmd_exports = \
  276. $(NM) -p --defined-only $< \
  277. | awk '$$2~/(T|R|D|B)/ && $$3!~/__cfi/ {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@
  278. $(obj)/exports_core_generated.h: $(obj)/core.o FORCE
  279. $(call if_changed,exports)
  280. $(obj)/exports_alloc_generated.h: $(obj)/alloc.o FORCE
  281. $(call if_changed,exports)
  282. # Even though Rust kernel modules should never use the bindings directly,
  283. # symbols from the `bindings` crate and the C helpers need to be exported
  284. # because Rust generics and inlined functions may not get their code generated
  285. # in the crate where they are defined. Other helpers, called from non-inline
  286. # functions, may not be exported, in principle. However, in general, the Rust
  287. # compiler does not guarantee codegen will be performed for a non-inline
  288. # function either. Therefore, we export all symbols from helpers and bindings.
  289. # In the future, this may be revisited to reduce the number of exports after
  290. # the compiler is informed about the places codegen is required.
  291. $(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE
  292. $(call if_changed,exports)
  293. $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE
  294. $(call if_changed,exports)
  295. $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
  296. $(call if_changed,exports)
  297. quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
  298. cmd_rustc_procmacro = \
  299. $(RUSTC_OR_CLIPPY) $(rust_common_flags) \
  300. -Clinker-flavor=gcc -Clinker=$(HOSTCC) \
  301. -Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \
  302. --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
  303. --crate-type proc-macro \
  304. --crate-name $(patsubst lib%.so,%,$(notdir $@)) $<
  305. # Procedural macros can only be used with the `rustc` that compiled it.
  306. $(obj)/libmacros.so: $(src)/macros/lib.rs FORCE
  307. +$(call if_changed_dep,rustc_procmacro)
  308. quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@
  309. cmd_rustc_library = \
  310. OBJTREE=$(abspath $(objtree)) \
  311. $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
  312. $(filter-out $(skip_flags),$(rust_flags) $(rustc_target_flags)) \
  313. --emit=dep-info=$(depfile) --emit=obj=$@ \
  314. --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
  315. --crate-type rlib -L$(objtree)/$(obj) \
  316. --crate-name $(patsubst %.o,%,$(notdir $@)) $< \
  317. --sysroot=/dev/null \
  318. $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \
  319. $(cmd_objtool)
  320. rust-analyzer:
  321. $(Q)$(srctree)/scripts/generate_rust_analyzer.py \
  322. --cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
  323. $(realpath $(srctree)) $(realpath $(objtree)) \
  324. $(rustc_sysroot) $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
  325. $(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
  326. redirect-intrinsics = \
  327. __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \
  328. __adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \
  329. __muloti4 __multi3 \
  330. __udivmodti4 __udivti3 __umodti3
  331. ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
  332. # These intrinsics are defined for ARM64 and RISCV64
  333. redirect-intrinsics += \
  334. __ashrti3 \
  335. __ashlti3 __lshrti3
  336. endif
  337. define rule_rustc_library
  338. $(call cmd_and_fixdep,rustc_library)
  339. $(call cmd,gen_objtooldep)
  340. endef
  341. $(obj)/core.o: private skip_clippy = 1
  342. $(obj)/core.o: private skip_flags = -Wunreachable_pub
  343. $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
  344. $(obj)/core.o: private rustc_target_flags = $(core-cfgs)
  345. $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
  346. $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
  347. +$(call if_changed_rule,rustc_library)
  348. ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
  349. $(obj)/core.o: scripts/target.json
  350. endif
  351. $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
  352. $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
  353. +$(call if_changed_rule,rustc_library)
  354. $(obj)/alloc.o: private skip_clippy = 1
  355. $(obj)/alloc.o: private skip_flags = -Wunreachable_pub
  356. $(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs)
  357. $(obj)/alloc.o: $(RUST_LIB_SRC)/alloc/src/lib.rs $(obj)/compiler_builtins.o FORCE
  358. +$(call if_changed_rule,rustc_library)
  359. $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
  360. +$(call if_changed_rule,rustc_library)
  361. $(obj)/bindings.o: $(src)/bindings/lib.rs \
  362. $(obj)/compiler_builtins.o \
  363. $(obj)/bindings/bindings_generated.rs \
  364. $(obj)/bindings/bindings_helpers_generated.rs FORCE
  365. +$(call if_changed_rule,rustc_library)
  366. $(obj)/uapi.o: $(src)/uapi/lib.rs \
  367. $(obj)/compiler_builtins.o \
  368. $(obj)/uapi/uapi_generated.rs FORCE
  369. +$(call if_changed_rule,rustc_library)
  370. $(obj)/kernel.o: private rustc_target_flags = --extern alloc \
  371. --extern build_error --extern macros --extern bindings --extern uapi
  372. $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \
  373. $(obj)/libmacros.so $(obj)/bindings.o $(obj)/uapi.o FORCE
  374. +$(call if_changed_rule,rustc_library)
  375. endif # CONFIG_RUST