12f7ab126SMiguel Ojeda# SPDX-License-Identifier: GPL-2.0 22f7ab126SMiguel Ojeda 348fadf44SCarlos Bilbao# Where to place rustdoc generated documentation 448fadf44SCarlos Bilbaorustdoc_output := $(objtree)/Documentation/output/rust/rustdoc 548fadf44SCarlos Bilbao 6d072acdaSGary Guoobj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o 72f7ab126SMiguel Ojedaalways-$(CONFIG_RUST) += exports_core_generated.h 82f7ab126SMiguel Ojeda 92f7ab126SMiguel Ojeda# Missing prototypes are expected in the helpers since these are exported 102f7ab126SMiguel Ojeda# for Rust only, thus there is no header nor prototypes. 1187634653SAndreas Hindborgobj-$(CONFIG_RUST) += helpers/helpers.o 1287634653SAndreas HindborgCFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations 132f7ab126SMiguel Ojeda 142f7ab126SMiguel Ojedaalways-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs 15d7659accSMiguel Ojedaobj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o 16392e34b6SDanilo Krummrichalways-$(CONFIG_RUST) += exports_helpers_generated.h \ 17e26fa546SGary Guo exports_bindings_generated.h exports_kernel_generated.h 182f7ab126SMiguel Ojeda 194e174665SAsahi Linaalways-$(CONFIG_RUST) += uapi/uapi_generated.rs 204e174665SAsahi Linaobj-$(CONFIG_RUST) += uapi.o 214e174665SAsahi Lina 22ecaa6ddfSGary Guoifdef CONFIG_RUST_BUILD_ASSERT_ALLOW 23ecaa6ddfSGary Guoobj-$(CONFIG_RUST) += build_error.o 24ecaa6ddfSGary Guoelse 25ecaa6ddfSGary Guoalways-$(CONFIG_RUST) += build_error.o 26ecaa6ddfSGary Guoendif 27ecaa6ddfSGary Guo 282f7ab126SMiguel Ojedaobj-$(CONFIG_RUST) += exports.o 292f7ab126SMiguel Ojeda 30a66d733dSMiguel Ojedaalways-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs 31a66d733dSMiguel Ojedaalways-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c 32a66d733dSMiguel Ojeda 33a66d733dSMiguel Ojedaobj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o 34a66d733dSMiguel Ojedaobj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o 35a66d733dSMiguel Ojeda 368af7a501SMiguel Ojedaalways-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs 37dff64b07SFUJITA Tomonoriifndef CONFIG_UML 38dff64b07SFUJITA Tomonorialways-$(subst y,$(CONFIG_RUST),$(CONFIG_BUG)) += kernel/generated_arch_warn_asm.rs kernel/generated_arch_reachable_asm.rs 39dff64b07SFUJITA Tomonoriendif 40169484abSAlice Ryhl 410730422bSTamir Duberstein# Avoids running `$(RUSTC)` when it may not be available. 422f7ab126SMiguel Ojedaifdef CONFIG_RUST 432f7ab126SMiguel Ojeda 440730422bSTamir Dubersteinlibmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type proc-macro - </dev/null) 450730422bSTamir Dubersteinlibmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name)) 460730422bSTamir Duberstein 47d7659accSMiguel Ojedalibpin_init_internal_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-type proc-macro - </dev/null) 48d7659accSMiguel Ojedalibpin_init_internal_extension := $(patsubst libpin_init_internal.%,%,$(libpin_init_internal_name)) 49d7659accSMiguel Ojeda 50d7659accSMiguel Ojedaalways-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name) 510730422bSTamir Duberstein 522f7ab126SMiguel Ojeda# `$(rust_flags)` is passed in case the user added `--sysroot`. 53ecab4115SMiguel Ojedarustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot) 542f7ab126SMiguel Ojedarustc_host_target := $(shell $(RUSTC) --version --verbose | grep -F 'host: ' | cut -d' ' -f2) 552f7ab126SMiguel OjedaRUST_LIB_SRC ?= $(rustc_sysroot)/lib/rustlib/src/rust/library 562f7ab126SMiguel Ojeda 579ffc80c8SMiguel Ojedaifneq ($(quiet),) 582f7ab126SMiguel Ojedarust_test_quiet=-q 592f7ab126SMiguel Ojedarustdoc_test_quiet=--test-args -q 60a66d733dSMiguel Ojedarustdoc_test_kernel_quiet=>/dev/null 612f7ab126SMiguel Ojedaendif 622f7ab126SMiguel Ojeda 632f7ab126SMiguel Ojedacore-cfgs = \ 642f7ab126SMiguel Ojeda --cfg no_fp_fmt_parse 652f7ab126SMiguel Ojeda 66f4daa80dSGary Guocore-edition := $(if $(call rustc-min-version,108700),2024,2021) 67f4daa80dSGary Guo 68abbf9a44SMiguel Ojeda# `rustdoc` did not save the target modifiers, thus workaround for 69abbf9a44SMiguel Ojeda# the time being (https://github.com/rust-lang/rust/issues/144521). 70abbf9a44SMiguel Ojedarustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18) 71abbf9a44SMiguel Ojeda 722c8725c1SMiguel Ojeda# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only 732c8725c1SMiguel Ojeda# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust 742c8725c1SMiguel Ojeda# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both 752c8725c1SMiguel Ojeda# issues skipping the flag. The former also applies to `RUSTDOC TK`. 762f7ab126SMiguel Ojedaquiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< 772f7ab126SMiguel Ojeda cmd_rustdoc = \ 782f7ab126SMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 792c8725c1SMiguel Ojeda $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ 802f7ab126SMiguel Ojeda $(rustc_target_flags) -L$(objtree)/$(obj) \ 816e6efc5fSMiguel Ojeda -Zunstable-options --generate-link-to-definition \ 8248fadf44SCarlos Bilbao --output $(rustdoc_output) \ 832f7ab126SMiguel Ojeda --crate-name $(subst rustdoc-,,$@) \ 84abbf9a44SMiguel Ojeda $(rustdoc_modifiers_workaround) \ 8571479eeeSMatthew Maurer $(if $(rustdoc_host),,--sysroot=/dev/null) \ 862f7ab126SMiguel Ojeda @$(objtree)/include/generated/rustc_cfg $< 872f7ab126SMiguel Ojeda 882f7ab126SMiguel Ojeda# The `html_logo_url` and `html_favicon_url` forms of the `doc` attribute 892f7ab126SMiguel Ojeda# can be used to specify a custom logo. However: 902f7ab126SMiguel Ojeda# - The given value is used as-is, thus it cannot be relative or a local file 912f7ab126SMiguel Ojeda# (unlike the non-custom case) since the generated docs have subfolders. 922f7ab126SMiguel Ojeda# - It requires adding it to every crate. 932f7ab126SMiguel Ojeda# - It requires changing `core` which comes from the sysroot. 942f7ab126SMiguel Ojeda# 952f7ab126SMiguel Ojeda# Using `-Zcrate-attr` would solve the last two points, but not the first. 962f7ab126SMiguel Ojeda# The https://github.com/rust-lang/rfcs/pull/3226 RFC suggests two new 972f7ab126SMiguel Ojeda# command-like flags to solve the issue. Meanwhile, we use the non-custom case 982f7ab126SMiguel Ojeda# and then retouch the generated files. 992f7ab126SMiguel Ojedarustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \ 100d7659accSMiguel Ojeda rustdoc-kernel rustdoc-pin_init 101*9e3bbbf5SMiguel Ojeda $(Q)grep -Ehro '<a href="srctree/([^"]+)"' $(rustdoc_output) | \ 102*9e3bbbf5SMiguel Ojeda cut -d'"' -f2 | cut -d/ -f2- | while read f; do \ 103*9e3bbbf5SMiguel Ojeda if [ ! -e "$(srctree)/$$f" ]; then \ 104*9e3bbbf5SMiguel Ojeda echo "warning: srctree/ link to $$f does not exist"; \ 105*9e3bbbf5SMiguel Ojeda fi \ 106*9e3bbbf5SMiguel Ojeda done 107cfd96726SMiguel Ojeda $(Q)cp $(srctree)/Documentation/images/logo.svg $(rustdoc_output)/static.files/ 108cfd96726SMiguel Ojeda $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/ 10948fadf44SCarlos Bilbao $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \ 110cfd96726SMiguel Ojeda -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \ 111cfd96726SMiguel Ojeda -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \ 112bc2e7d5cSMiguel Ojeda -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \ 113e2bad142SMasahiro Yamada -e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g' 114cfd96726SMiguel Ojeda $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \ 115cfd96726SMiguel Ojeda echo ".logo-container > img { object-fit: contain; }" >> $$f; done 1162f7ab126SMiguel Ojeda 1172f7ab126SMiguel Ojedarustdoc-macros: private rustdoc_host = yes 1182f7ab126SMiguel Ojedarustdoc-macros: private rustc_target_flags = --crate-type proc-macro \ 1192f7ab126SMiguel Ojeda --extern proc_macro 120252fea13SMiguel Ojedarustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE 121ecab4115SMiguel Ojeda +$(call if_changed,rustdoc) 1222f7ab126SMiguel Ojeda 123bef83245SMiguel Ojeda# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should 124bef83245SMiguel Ojeda# not be needed -- see https://github.com/rust-lang/rust/pull/128307. 125f4daa80dSGary Guorustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks 126f4daa80dSGary Guorustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs) 127252fea13SMiguel Ojedarustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE 128ecab4115SMiguel Ojeda +$(call if_changed,rustdoc) 1292f7ab126SMiguel Ojeda 1302f7ab126SMiguel Ojedarustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE 131ecab4115SMiguel Ojeda +$(call if_changed,rustdoc) 1322f7ab126SMiguel Ojeda 133d072acdaSGary Guorustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE 134ecab4115SMiguel Ojeda +$(call if_changed,rustdoc) 1352f7ab126SMiguel Ojeda 136d7659accSMiguel Ojedarustdoc-pin_init_internal: private rustdoc_host = yes 137d7659accSMiguel Ojedarustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ 138d7659accSMiguel Ojeda --extern proc_macro --crate-type proc-macro 139252fea13SMiguel Ojedarustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \ 140252fea13SMiguel Ojeda rustdoc-clean FORCE 141d7659accSMiguel Ojeda +$(call if_changed,rustdoc) 142d7659accSMiguel Ojeda 143d7659accSMiguel Ojedarustdoc-pin_init: private rustdoc_host = yes 144d7659accSMiguel Ojedarustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ 1459b2299afSBenno Lossin --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" 146dbd5058bSBenno Lossinrustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \ 147d7659accSMiguel Ojeda rustdoc-macros FORCE 148d7659accSMiguel Ojeda +$(call if_changed,rustdoc) 149d7659accSMiguel Ojeda 150d7659accSMiguel Ojedarustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \ 1510730422bSTamir Duberstein --extern build_error --extern macros \ 1524e174665SAsahi Lina --extern bindings --extern uapi 153d072acdaSGary Guorustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \ 154d7659accSMiguel Ojeda rustdoc-pin_init rustdoc-compiler_builtins $(obj)/$(libmacros_name) \ 1552f7ab126SMiguel Ojeda $(obj)/bindings.o FORCE 156ecab4115SMiguel Ojeda +$(call if_changed,rustdoc) 1572f7ab126SMiguel Ojeda 158252fea13SMiguel Ojedarustdoc-clean: FORCE 159252fea13SMiguel Ojeda $(Q)rm -rf $(rustdoc_output) 160252fea13SMiguel Ojeda 1612a87f8b0SMiguel Ojedaquiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $< 1622f7ab126SMiguel Ojeda cmd_rustc_test_library = \ 1632f7ab126SMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 1642a87f8b0SMiguel Ojeda $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ 1652f7ab126SMiguel Ojeda @$(objtree)/include/generated/rustc_cfg $(rustc_target_flags) \ 1662f7ab126SMiguel Ojeda --crate-type $(if $(rustc_test_library_proc),proc-macro,rlib) \ 1672f7ab126SMiguel Ojeda --out-dir $(objtree)/$(obj)/test --cfg testlib \ 1682f7ab126SMiguel Ojeda -L$(objtree)/$(obj)/test \ 1692f7ab126SMiguel Ojeda --crate-name $(subst rusttest-,,$(subst rusttestlib-,,$@)) $< 1702f7ab126SMiguel Ojeda 1719ffc80c8SMiguel Ojedarusttestlib-build_error: $(src)/build_error.rs FORCE 172ecab4115SMiguel Ojeda +$(call if_changed,rustc_test_library) 173ecaa6ddfSGary Guo 174d072acdaSGary Guorusttestlib-ffi: $(src)/ffi.rs FORCE 175d072acdaSGary Guo +$(call if_changed,rustc_test_library) 176d072acdaSGary Guo 1772f7ab126SMiguel Ojedarusttestlib-macros: private rustc_target_flags = --extern proc_macro 1782f7ab126SMiguel Ojedarusttestlib-macros: private rustc_test_library_proc = yes 1799ffc80c8SMiguel Ojedarusttestlib-macros: $(src)/macros/lib.rs FORCE 180ecab4115SMiguel Ojeda +$(call if_changed,rustc_test_library) 1812f7ab126SMiguel Ojeda 182d7659accSMiguel Ojedarusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \ 183d7659accSMiguel Ojeda --extern proc_macro 184d7659accSMiguel Ojedarusttestlib-pin_init_internal: private rustc_test_library_proc = yes 185dbd5058bSBenno Lossinrusttestlib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE 186d7659accSMiguel Ojeda +$(call if_changed,rustc_test_library) 187d7659accSMiguel Ojeda 188d7659accSMiguel Ojedarusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \ 189d7659accSMiguel Ojeda --extern macros --cfg kernel 190dbd5058bSBenno Lossinrusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \ 191d7659accSMiguel Ojeda rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE 192d7659accSMiguel Ojeda +$(call if_changed,rustc_test_library) 193d7659accSMiguel Ojeda 194d072acdaSGary Guorusttestlib-kernel: private rustc_target_flags = --extern ffi \ 195d7659accSMiguel Ojeda --extern build_error --extern macros --extern pin_init \ 196b2c261faSEthan D. Twardy --extern bindings --extern uapi 197d7659accSMiguel Ojedarusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \ 198d7659accSMiguel Ojeda rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \ 199d7659accSMiguel Ojeda $(obj)/bindings.o FORCE 200ecab4115SMiguel Ojeda +$(call if_changed,rustc_test_library) 2012f7ab126SMiguel Ojeda 202d072acdaSGary Guorusttestlib-bindings: private rustc_target_flags = --extern ffi 203d072acdaSGary Guorusttestlib-bindings: $(src)/bindings/lib.rs rusttestlib-ffi FORCE 2042f7ab126SMiguel Ojeda +$(call if_changed,rustc_test_library) 2052f7ab126SMiguel Ojeda 206d072acdaSGary Guorusttestlib-uapi: private rustc_target_flags = --extern ffi 207d072acdaSGary Guorusttestlib-uapi: $(src)/uapi/lib.rs rusttestlib-ffi FORCE 208ecab4115SMiguel Ojeda +$(call if_changed,rustc_test_library) 2094e174665SAsahi Lina 2102f7ab126SMiguel Ojedaquiet_cmd_rustdoc_test = RUSTDOC T $< 2112f7ab126SMiguel Ojeda cmd_rustdoc_test = \ 2128d3f5079SEthan D. Twardy RUST_MODFILE=test.rs \ 2132f7ab126SMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 2142f7ab126SMiguel Ojeda $(RUSTDOC) --test $(rust_common_flags) \ 21574981592SMiguel Ojeda -Zcrate-attr='feature(used_with_arg)' \ 2162f7ab126SMiguel Ojeda @$(objtree)/include/generated/rustc_cfg \ 2172f7ab126SMiguel Ojeda $(rustc_target_flags) $(rustdoc_test_target_flags) \ 2189ffc80c8SMiguel Ojeda $(rustdoc_test_quiet) \ 21948fadf44SCarlos Bilbao -L$(objtree)/$(obj)/test --output $(rustdoc_output) \ 2202f7ab126SMiguel Ojeda --crate-name $(subst rusttest-,,$@) $< 2212f7ab126SMiguel Ojeda 222a66d733dSMiguel Ojedaquiet_cmd_rustdoc_test_kernel = RUSTDOC TK $< 223a66d733dSMiguel Ojeda cmd_rustdoc_test_kernel = \ 224a66d733dSMiguel Ojeda rm -rf $(objtree)/$(obj)/test/doctests/kernel; \ 225a66d733dSMiguel Ojeda mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \ 226a66d733dSMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 2272c8725c1SMiguel Ojeda $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \ 228d7659accSMiguel Ojeda -L$(objtree)/$(obj) --extern ffi --extern pin_init \ 229d7659accSMiguel Ojeda --extern kernel --extern build_error --extern macros \ 230a66d733dSMiguel Ojeda --extern bindings --extern uapi \ 231a66d733dSMiguel Ojeda --no-run --crate-name kernel -Zunstable-options \ 23271479eeeSMatthew Maurer --sysroot=/dev/null \ 233abbf9a44SMiguel Ojeda $(rustdoc_modifiers_workaround) \ 234a66d733dSMiguel Ojeda --test-builder $(objtree)/scripts/rustdoc_test_builder \ 235a66d733dSMiguel Ojeda $< $(rustdoc_test_kernel_quiet); \ 236a66d733dSMiguel Ojeda $(objtree)/scripts/rustdoc_test_gen 237a66d733dSMiguel Ojeda 238a66d733dSMiguel Ojeda%/doctests_kernel_generated.rs %/doctests_kernel_generated_kunit.c: \ 239a66d733dSMiguel Ojeda $(src)/kernel/lib.rs $(obj)/kernel.o \ 240a66d733dSMiguel Ojeda $(objtree)/scripts/rustdoc_test_builder \ 241a66d733dSMiguel Ojeda $(objtree)/scripts/rustdoc_test_gen FORCE 242ecab4115SMiguel Ojeda +$(call if_changed,rustdoc_test_kernel) 243a66d733dSMiguel Ojeda 2442f7ab126SMiguel Ojeda# We cannot use `-Zpanic-abort-tests` because some tests are dynamic, 2452f7ab126SMiguel Ojeda# so for the moment we skip `-Cpanic=abort`. 2462a87f8b0SMiguel Ojedaquiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T $< 2472f7ab126SMiguel Ojeda cmd_rustc_test = \ 2482f7ab126SMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 2492a87f8b0SMiguel Ojeda $(RUSTC_OR_CLIPPY) --test $(rust_common_flags) \ 2502f7ab126SMiguel Ojeda @$(objtree)/include/generated/rustc_cfg \ 2512f7ab126SMiguel Ojeda $(rustc_target_flags) --out-dir $(objtree)/$(obj)/test \ 2522f7ab126SMiguel Ojeda -L$(objtree)/$(obj)/test \ 2532f7ab126SMiguel Ojeda --crate-name $(subst rusttest-,,$@) $<; \ 2542f7ab126SMiguel Ojeda $(objtree)/$(obj)/test/$(subst rusttest-,,$@) $(rust_test_quiet) \ 2552f7ab126SMiguel Ojeda $(rustc_test_run_flags) 2562f7ab126SMiguel Ojeda 25717d5efcbSMiguel Ojedarusttest: rusttest-macros 2582f7ab126SMiguel Ojeda 259b2c261faSEthan D. Twardyrusttest-macros: private rustc_target_flags = --extern proc_macro \ 260d7659accSMiguel Ojeda --extern macros --extern kernel --extern pin_init 2612f7ab126SMiguel Ojedarusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro 262b2c261faSEthan D. Twardyrusttest-macros: $(src)/macros/lib.rs \ 263d7659accSMiguel Ojeda rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE 264ecab4115SMiguel Ojeda +$(call if_changed,rustc_test) 265ecab4115SMiguel Ojeda +$(call if_changed,rustdoc_test) 2662f7ab126SMiguel Ojeda 2672f7ab126SMiguel Ojedaifdef CONFIG_CC_IS_CLANG 2682f7ab126SMiguel Ojedabindgen_c_flags = $(c_flags) 2692f7ab126SMiguel Ojedaelse 2702f7ab126SMiguel Ojeda# bindgen relies on libclang to parse C. Ideally, bindgen would support a GCC 2712f7ab126SMiguel Ojeda# plugin backend and/or the Clang driver would be perfectly compatible with GCC. 2722f7ab126SMiguel Ojeda# 2732f7ab126SMiguel Ojeda# For the moment, here we are tweaking the flags on the fly. This is a hack, 2742f7ab126SMiguel Ojeda# and some kernel configurations may not work (e.g. `GCC_PLUGIN_RANDSTRUCT` 2752f7ab126SMiguel Ojeda# if we end up using one of those structs). 2762f7ab126SMiguel Ojedabindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \ 2772f7ab126SMiguel Ojeda -mskip-rax-setup -mgeneral-regs-only -msign-return-address=% \ 2782f7ab126SMiguel Ojeda -mindirect-branch=thunk-extern -mindirect-branch-register \ 2792f7ab126SMiguel Ojeda -mfunction-return=thunk-extern -mrecord-mcount -mabi=lp64 \ 2802f7ab126SMiguel Ojeda -mindirect-branch-cs-prefix -mstack-protector-guard% -mtraceback=no \ 2812f7ab126SMiguel Ojeda -mno-pointers-to-nested-functions -mno-string \ 28213c23cb4SWANG Rui -mno-strict-align -mstrict-align -mdirect-extern-access \ 28313c23cb4SWANG Rui -mexplicit-relocs -mno-check-zero-division \ 2842f7ab126SMiguel Ojeda -fconserve-stack -falign-jumps=% -falign-loops=% \ 2852f7ab126SMiguel Ojeda -femit-struct-debug-baseonly -fno-ipa-cp-clone -fno-ipa-sra \ 2862f7ab126SMiguel Ojeda -fno-partial-inlining -fplugin-arg-arm_ssp_per_task_plugin-% \ 2872f7ab126SMiguel Ojeda -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \ 2882f7ab126SMiguel Ojeda -fzero-call-used-regs=% -fno-stack-clash-protection \ 289b0554488SAndrea Righi -fno-inline-functions-called-once -fsanitize=bounds-strict \ 290869b5016SZehui Xu -fstrict-flex-arrays=% -fmin-function-alignment=% \ 291977c4308SRudraksha Gupta -fzero-init-padding-bits=% -mno-fdpic \ 2922f7ab126SMiguel Ojeda --param=% --param asan-% 2932f7ab126SMiguel Ojeda 2942f7ab126SMiguel Ojeda# Derived from `scripts/Makefile.clang`. 2952f7ab126SMiguel OjedaBINDGEN_TARGET_x86 := x86_64-linux-gnu 296724a75acSJamie CunliffeBINDGEN_TARGET_arm64 := aarch64-linux-gnu 297ccb8ce52SChristian SchrreflBINDGEN_TARGET_arm := arm-linux-gnueabi 29813c23cb4SWANG RuiBINDGEN_TARGET_loongarch := loongarch64-linux-gnusf 2996b2dab17SThomas WeißschuhBINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH)) 3002f7ab126SMiguel OjedaBINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) 3012f7ab126SMiguel Ojeda 3022f7ab126SMiguel Ojeda# All warnings are inhibited since GCC builds are very experimental, 3032f7ab126SMiguel Ojeda# many GCC warnings are not supported by Clang, they may only appear in 3042f7ab126SMiguel Ojeda# some configurations, with new GCC versions, etc. 3052f7ab126SMiguel Ojedabindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) 3062f7ab126SMiguel Ojeda 307d966c3caSAndrea Righi# Auto variable zero-initialization requires an additional special option with 308d966c3caSAndrea Righi# clang that is going to be removed sometime in the future (likely in 309d966c3caSAndrea Righi# clang-18), so make sure to pass this option only if clang supports it 310d966c3caSAndrea Righi# (libclang major version < 16). 311d966c3caSAndrea Righi# 312d966c3caSAndrea Righi# https://github.com/llvm/llvm-project/issues/44842 313d966c3caSAndrea Righi# https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags 314d966c3caSAndrea Righiifdef CONFIG_INIT_STACK_ALL_ZERO 315d966c3caSAndrea Righilibclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p') 316d966c3caSAndrea Righiifeq ($(shell expr $(libclang_maj_ver) \< 16), 1) 317d966c3caSAndrea Righibindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang 318d966c3caSAndrea Righiendif 319d966c3caSAndrea Righiendif 320d966c3caSAndrea Righi 3212f7ab126SMiguel Ojedabindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ 3222f7ab126SMiguel Ojeda $(bindgen_extra_c_flags) 3232f7ab126SMiguel Ojedaendif 3242f7ab126SMiguel Ojeda 3252f7ab126SMiguel Ojedaifdef CONFIG_LTO 3262f7ab126SMiguel Ojedabindgen_c_flags_lto = $(filter-out $(CC_FLAGS_LTO), $(bindgen_c_flags)) 3272f7ab126SMiguel Ojedaelse 3282f7ab126SMiguel Ojedabindgen_c_flags_lto = $(bindgen_c_flags) 3292f7ab126SMiguel Ojedaendif 3302f7ab126SMiguel Ojeda 33175c1fd41SGary Guo# `-fno-builtin` is passed to avoid `bindgen` from using `clang` builtin 33275c1fd41SGary Guo# prototypes for functions like `memcpy` -- if this flag is not passed, 33375c1fd41SGary Guo# `bindgen`-generated prototypes use `c_ulong` or `c_uint` depending on 33475c1fd41SGary Guo# architecture instead of generating `usize`. 33575c1fd41SGary Guobindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__ 3362f7ab126SMiguel Ojeda 3377a5f93eaSMiguel Ojeda# Each `bindgen` release may upgrade the list of Rust target versions. By 3387a5f93eaSMiguel Ojeda# default, the highest stable release in their list is used. Thus we need to set 3397a5f93eaSMiguel Ojeda# a `--rust-target` to avoid future `bindgen` releases emitting code that 3407a5f93eaSMiguel Ojeda# `rustc` may not understand. On top of that, `bindgen` does not support passing 3417a5f93eaSMiguel Ojeda# an unknown Rust target version. 3427a5f93eaSMiguel Ojeda# 3437a5f93eaSMiguel Ojeda# Therefore, the Rust target for `bindgen` can be only as high as the minimum 3447a5f93eaSMiguel Ojeda# Rust version the kernel supports and only as high as the greatest stable Rust 3457a5f93eaSMiguel Ojeda# target supported by the minimum `bindgen` version the kernel supports (that 3467a5f93eaSMiguel Ojeda# is, if we do not test the actual `rustc`/`bindgen` versions running). 3477a5f93eaSMiguel Ojeda# 3487a5f93eaSMiguel Ojeda# Starting with `bindgen` 0.71.0, we will be able to set any future Rust version 3497a5f93eaSMiguel Ojeda# instead, i.e. we will be able to set here our minimum supported Rust version. 3502f7ab126SMiguel Ojedaquiet_cmd_bindgen = BINDGEN $@ 3512f7ab126SMiguel Ojeda cmd_bindgen = \ 3527a5f93eaSMiguel Ojeda $(BINDGEN) $< $(bindgen_target_flags) --rust-target 1.68 \ 353d072acdaSGary Guo --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests \ 35476501d19SMiguel Ojeda --no-debug '.*' --enable-function-attribute-detection \ 35508ab7865SAakash Sen Sharma -o $@ -- $(bindgen_c_flags_final) -DMODULE \ 3562f7ab126SMiguel Ojeda $(bindgen_target_cflags) $(bindgen_target_extra) 3572f7ab126SMiguel Ojeda 3582f7ab126SMiguel Ojeda$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ 359b1992c37SMasahiro Yamada $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) 36074376656SGary Guo$(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ 36174376656SGary Guo sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ 3622f7ab126SMiguel Ojeda$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ 3632f7ab126SMiguel Ojeda $(src)/bindgen_parameters FORCE 3642f7ab126SMiguel Ojeda $(call if_changed_dep,bindgen) 3652f7ab126SMiguel Ojeda 3664e174665SAsahi Lina$(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \ 367b1992c37SMasahiro Yamada $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) 3684e174665SAsahi Lina$(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \ 3694e174665SAsahi Lina $(src)/bindgen_parameters FORCE 3704e174665SAsahi Lina $(call if_changed_dep,bindgen) 3714e174665SAsahi Lina 3722f7ab126SMiguel Ojeda# See `CFLAGS_REMOVE_helpers.o` above. In addition, Clang on C does not warn 3732f7ab126SMiguel Ojeda# with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here 3742f7ab126SMiguel Ojeda# given it is `libclang`; but for consistency, future Clang changes and/or 3752f7ab126SMiguel Ojeda# a potential future GCC backend for `bindgen`, we disable it too. 3762f7ab126SMiguel Ojeda$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_flags = \ 37708ab7865SAakash Sen Sharma --blocklist-type '.*' --allowlist-var '' \ 37808ab7865SAakash Sen Sharma --allowlist-function 'rust_helper_.*' 3792f7ab126SMiguel Ojeda$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \ 3802f7ab126SMiguel Ojeda -I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations 3812f7ab126SMiguel Ojeda$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ; \ 3822f7ab126SMiguel Ojeda sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@ 38387634653SAndreas Hindborg$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE 3842f7ab126SMiguel Ojeda $(call if_changed_dep,bindgen) 3852f7ab126SMiguel Ojeda 386c59026c0SSami Tolvanenrust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(pfx|cfi|odr_asan)/ { printf $(2),$$3 }' 387ac61506bSSami Tolvanen 3882f7ab126SMiguel Ojedaquiet_cmd_exports = EXPORTS $@ 3892f7ab126SMiguel Ojeda cmd_exports = \ 390ac61506bSSami Tolvanen $(call rust_exports,$<,"EXPORT_SYMBOL_RUST_GPL(%s);\n") > $@ 3912f7ab126SMiguel Ojeda 3922f7ab126SMiguel Ojeda$(obj)/exports_core_generated.h: $(obj)/core.o FORCE 3932f7ab126SMiguel Ojeda $(call if_changed,exports) 3942f7ab126SMiguel Ojeda 395e26fa546SGary Guo# Even though Rust kernel modules should never use the bindings directly, 396e26fa546SGary Guo# symbols from the `bindings` crate and the C helpers need to be exported 397e26fa546SGary Guo# because Rust generics and inlined functions may not get their code generated 398e26fa546SGary Guo# in the crate where they are defined. Other helpers, called from non-inline 399e26fa546SGary Guo# functions, may not be exported, in principle. However, in general, the Rust 400e26fa546SGary Guo# compiler does not guarantee codegen will be performed for a non-inline 401e26fa546SGary Guo# function either. Therefore, we export all symbols from helpers and bindings. 402e26fa546SGary Guo# In the future, this may be revisited to reduce the number of exports after 403e26fa546SGary Guo# the compiler is informed about the places codegen is required. 404e26fa546SGary Guo$(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE 405e26fa546SGary Guo $(call if_changed,exports) 406e26fa546SGary Guo 4072f7ab126SMiguel Ojeda$(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE 4082f7ab126SMiguel Ojeda $(call if_changed,exports) 4092f7ab126SMiguel Ojeda 4102f7ab126SMiguel Ojeda$(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE 4112f7ab126SMiguel Ojeda $(call if_changed,exports) 4122f7ab126SMiguel Ojeda 4132f7ab126SMiguel Ojedaquiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ 4142f7ab126SMiguel Ojeda cmd_rustc_procmacro = \ 415d7659accSMiguel Ojeda $(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \ 41680bac83aSMatthew Maurer -Clinker-flavor=gcc -Clinker=$(HOSTCC) \ 417ceff0757SHONG Yifan -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \ 418295d8398SMasahiro Yamada --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \ 419295d8398SMasahiro Yamada --crate-type proc-macro \ 42036174d16SMiguel Ojeda --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \ 42136174d16SMiguel Ojeda @$(objtree)/include/generated/rustc_cfg $< 4222f7ab126SMiguel Ojeda 4232f7ab126SMiguel Ojeda# Procedural macros can only be used with the `rustc` that compiled it. 4240730422bSTamir Duberstein$(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE 425ecab4115SMiguel Ojeda +$(call if_changed_dep,rustc_procmacro) 4262f7ab126SMiguel Ojeda 427d7659accSMiguel Ojeda$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel 428dbd5058bSBenno Lossin$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE 429d7659accSMiguel Ojeda +$(call if_changed_dep,rustc_procmacro) 430d7659accSMiguel Ojeda 4312f7ab126SMiguel Ojedaquiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ 4322f7ab126SMiguel Ojeda cmd_rustc_library = \ 4332f7ab126SMiguel Ojeda OBJTREE=$(abspath $(objtree)) \ 4342f7ab126SMiguel Ojeda $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ 435f4daa80dSGary Guo $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \ 436295d8398SMasahiro Yamada --emit=dep-info=$(depfile) --emit=obj=$@ \ 437295d8398SMasahiro Yamada --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ 438295d8398SMasahiro Yamada --crate-type rlib -L$(objtree)/$(obj) \ 4392185242fSMasahiro Yamada --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ 44071479eeeSMatthew Maurer --sysroot=/dev/null \ 441c4d7f546SMiguel Ojeda $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \ 442c4d7f546SMiguel Ojeda $(cmd_objtool) 4432f7ab126SMiguel Ojeda 4442f7ab126SMiguel Ojedarust-analyzer: 4450730422bSTamir Duberstein $(Q)MAKEFLAGS= $(srctree)/scripts/generate_rust_analyzer.py \ 446f4daa80dSGary Guo --cfgs='core=$(core-cfgs)' $(core-edition) \ 447e2bad142SMasahiro Yamada $(realpath $(srctree)) $(realpath $(objtree)) \ 44813b25489SMasahiro Yamada $(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \ 44913b25489SMasahiro Yamada > rust-project.json 4502f7ab126SMiguel Ojeda 451cb7d9defSGary Guoredirect-intrinsics = \ 45202dfd63aSMiguel Ojeda __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \ 45302dfd63aSMiguel Ojeda __adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \ 454cb7d9defSGary Guo __muloti4 __multi3 \ 455cb7d9defSGary Guo __udivmodti4 __udivti3 __umodti3 456cb7d9defSGary Guo 457ccb8ce52SChristian Schrreflifdef CONFIG_ARM 458ccb8ce52SChristian Schrrefl # Add eabi initrinsics for ARM 32-bit 459ccb8ce52SChristian Schrrefl redirect-intrinsics += \ 460ccb8ce52SChristian Schrrefl __aeabi_fadd __aeabi_fmul __aeabi_fcmpeq __aeabi_fcmple __aeabi_fcmplt __aeabi_fcmpun \ 461ccb8ce52SChristian Schrrefl __aeabi_dadd __aeabi_dmul __aeabi_dcmple __aeabi_dcmplt __aeabi_dcmpun \ 462ccb8ce52SChristian Schrrefl __aeabi_uldivmod 463ccb8ce52SChristian Schrreflendif 464cb7d9defSGary Guoifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),) 465cb7d9defSGary Guo # These intrinsics are defined for ARM64 and RISCV64 466cb7d9defSGary Guo redirect-intrinsics += \ 467cb7d9defSGary Guo __ashrti3 \ 468cb7d9defSGary Guo __ashlti3 __lshrti3 469cb7d9defSGary Guoendif 470cb7d9defSGary Guo 471ac61506bSSami Tolvanenifdef CONFIG_MODVERSIONS 472ac61506bSSami Tolvanencmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \ 473ac61506bSSami Tolvanen $(call rust_exports,$@,"%s\n") | \ 474ac61506bSSami Tolvanen scripts/gendwarfksyms/gendwarfksyms \ 475ac61506bSSami Tolvanen $(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable) \ 476ac61506bSSami Tolvanen $(if $(KBUILD_SYMTYPES), --symtypes $(@:.o=.symtypes),) \ 477ac61506bSSami Tolvanen $@ >> $(dot-target).cmd) 478ac61506bSSami Tolvanenendif 479ac61506bSSami Tolvanen 480c4d7f546SMiguel Ojedadefine rule_rustc_library 481c4d7f546SMiguel Ojeda $(call cmd_and_fixdep,rustc_library) 482c4d7f546SMiguel Ojeda $(call cmd,gen_objtooldep) 483ac61506bSSami Tolvanen $(call cmd,gendwarfksyms) 484c4d7f546SMiguel Ojedaendef 485c4d7f546SMiguel Ojeda 486ac61506bSSami Tolvanendefine rule_rust_cc_library 487ac61506bSSami Tolvanen $(call if_changed_rule,cc_o_c) 488ac61506bSSami Tolvanen $(call cmd,force_checksrc) 489ac61506bSSami Tolvanen $(call cmd,gendwarfksyms) 490ac61506bSSami Tolvanenendef 491ac61506bSSami Tolvanen 492ac61506bSSami Tolvanen# helpers.o uses the same export mechanism as Rust libraries, so ensure symbol 493ac61506bSSami Tolvanen# versions are calculated for the helpers too. 494ac61506bSSami Tolvanen$(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE 495ac61506bSSami Tolvanen +$(call if_changed_rule,rust_cc_library) 496ac61506bSSami Tolvanen 497ac61506bSSami Tolvanen# Disable symbol versioning for exports.o to avoid conflicts with the actual 498ac61506bSSami Tolvanen# symbol versions generated from Rust objects. 499ac61506bSSami Tolvanen$(obj)/exports.o: private skip_gendwarfksyms = 1 500ac61506bSSami Tolvanen 5012f7ab126SMiguel Ojeda$(obj)/core.o: private skip_clippy = 1 502f4daa80dSGary Guo$(obj)/core.o: private skip_flags = --edition=2021 -Wunreachable_pub 503cb7d9defSGary Guo$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) 504f4daa80dSGary Guo$(obj)/core.o: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs) 505ac3e9726SMiguel Ojeda$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \ 506ac3e9726SMiguel Ojeda $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE 507c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 508ab0f4cedSDavid Gowifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),) 509f82811e2SJamie Cunliffe$(obj)/core.o: scripts/target.json 510f82811e2SJamie Cunliffeendif 5113bf67171SAlice RyhlKCOV_INSTRUMENT_core.o := n 5122f7ab126SMiguel Ojeda 513ac61506bSSami Tolvanen$(obj)/compiler_builtins.o: private skip_gendwarfksyms = 1 5142f7ab126SMiguel Ojeda$(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' 5152f7ab126SMiguel Ojeda$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE 516c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 5172f7ab126SMiguel Ojeda 518d7659accSMiguel Ojeda$(obj)/pin_init.o: private skip_gendwarfksyms = 1 519d7659accSMiguel Ojeda$(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \ 520d7659accSMiguel Ojeda --extern macros --cfg kernel 521dbd5058bSBenno Lossin$(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \ 522d7659accSMiguel Ojeda $(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE 523d7659accSMiguel Ojeda +$(call if_changed_rule,rustc_library) 524d7659accSMiguel Ojeda 525ac61506bSSami Tolvanen$(obj)/build_error.o: private skip_gendwarfksyms = 1 526ecaa6ddfSGary Guo$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE 527c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 528ecaa6ddfSGary Guo 529ac61506bSSami Tolvanen$(obj)/ffi.o: private skip_gendwarfksyms = 1 530d072acdaSGary Guo$(obj)/ffi.o: $(src)/ffi.rs $(obj)/compiler_builtins.o FORCE 531d072acdaSGary Guo +$(call if_changed_rule,rustc_library) 532d072acdaSGary Guo 533d072acdaSGary Guo$(obj)/bindings.o: private rustc_target_flags = --extern ffi 5342f7ab126SMiguel Ojeda$(obj)/bindings.o: $(src)/bindings/lib.rs \ 535d072acdaSGary Guo $(obj)/ffi.o \ 5362f7ab126SMiguel Ojeda $(obj)/bindings/bindings_generated.rs \ 5372f7ab126SMiguel Ojeda $(obj)/bindings/bindings_helpers_generated.rs FORCE 538c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 5392f7ab126SMiguel Ojeda 540d072acdaSGary Guo$(obj)/uapi.o: private rustc_target_flags = --extern ffi 541ac61506bSSami Tolvanen$(obj)/uapi.o: private skip_gendwarfksyms = 1 5424e174665SAsahi Lina$(obj)/uapi.o: $(src)/uapi/lib.rs \ 543d072acdaSGary Guo $(obj)/ffi.o \ 5444e174665SAsahi Lina $(obj)/uapi/uapi_generated.rs FORCE 545c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 5464e174665SAsahi Lina 547d7659accSMiguel Ojeda$(obj)/kernel.o: private rustc_target_flags = --extern ffi --extern pin_init \ 5484e174665SAsahi Lina --extern build_error --extern macros --extern bindings --extern uapi 549d7659accSMiguel Ojeda$(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o $(obj)/pin_init.o \ 5500730422bSTamir Duberstein $(obj)/$(libmacros_name) $(obj)/bindings.o $(obj)/uapi.o FORCE 551c4d7f546SMiguel Ojeda +$(call if_changed_rule,rustc_library) 5522f7ab126SMiguel Ojeda 553169484abSAlice Ryhlifdef CONFIG_JUMP_LABEL 5548af7a501SMiguel Ojeda$(obj)/kernel.o: $(obj)/kernel/generated_arch_static_branch_asm.rs 555169484abSAlice Ryhlendif 556dff64b07SFUJITA Tomonoriifndef CONFIG_UML 557dff64b07SFUJITA Tomonoriifdef CONFIG_BUG 558dff64b07SFUJITA Tomonori$(obj)/kernel.o: $(obj)/kernel/generated_arch_warn_asm.rs $(obj)/kernel/generated_arch_reachable_asm.rs 559dff64b07SFUJITA Tomonoriendif 560dff64b07SFUJITA Tomonoriendif 561169484abSAlice Ryhl 5622f7ab126SMiguel Ojedaendif # CONFIG_RUST 563