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