| 1 |
|
| 2 |
|
| 3 |
|
| 4 | rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
|
| 5 |
|
| 6 |
|
| 7 | clean-files := host/
|
| 8 |
|
| 9 | obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
|
| 10 | always-$(CONFIG_RUST) += exports_core_generated.h
|
| 11 |
|
| 12 | obj-$(CONFIG_RUST) += zerocopy.o
|
| 13 |
|
| 14 | ifdef CONFIG_RUST_INLINE_HELPERS
|
| 15 | always-$(CONFIG_RUST) += helpers/helpers.bc helpers/helpers_module.bc
|
| 16 | else
|
| 17 | obj-$(CONFIG_RUST) += helpers/helpers.o
|
| 18 | always-$(CONFIG_RUST) += exports_helpers_generated.h
|
| 19 | endif
|
| 20 |
|
| 21 |
|
| 22 | CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations
|
| 23 |
|
| 24 | always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
|
| 25 | obj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o
|
| 26 | always-$(CONFIG_RUST) += exports_bindings_generated.h exports_kernel_generated.h
|
| 27 |
|
| 28 | always-$(CONFIG_RUST) += uapi/uapi_generated.rs
|
| 29 | obj-$(CONFIG_RUST) += uapi.o
|
| 30 |
|
| 31 | ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
|
| 32 | obj-$(CONFIG_RUST) += build_error.o
|
| 33 | else
|
| 34 | always-$(CONFIG_RUST) += build_error.o
|
| 35 | endif
|
| 36 |
|
| 37 | obj-$(CONFIG_RUST) += exports.o
|
| 38 |
|
| 39 | always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
|
| 40 |
|
| 41 | always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
|
| 42 | always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
|
| 43 |
|
| 44 | obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
|
| 45 | obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
|
| 46 |
|
| 47 | always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs
|
| 48 | ifndef CONFIG_UML
|
| 49 | always-$(subst y,$(CONFIG_RUST),$(CONFIG_BUG)) += kernel/generated_arch_warn_asm.rs kernel/generated_arch_reachable_asm.rs
|
| 50 | endif
|
| 51 |
|
| 52 |
|
| 53 | ifdef CONFIG_RUST
|
| 54 |
|
| 55 | procmacro-name = $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name $(1) --crate-type proc-macro - </dev/null)
|
| 56 | procmacro-extension := $(patsubst libname.%,%,$(call procmacro-name,name))
|
| 57 |
|
| 58 | libzerocopy_derive_name := $(call procmacro-name,zerocopy_derive)
|
| 59 | libmacros_name := $(call procmacro-name,macros)
|
| 60 | libpin_init_internal_name := $(call procmacro-name,pin_init_internal)
|
| 61 |
|
| 62 | always-$(CONFIG_RUST) += $(libzerocopy_derive_name) $(libmacros_name) $(libpin_init_internal_name)
|
| 63 |
|
| 64 |
|
| 65 | rustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot)
|
| 66 | rustc_host_target := $(shell $(RUSTC) --version --verbose | grep -F 'host: ' | cut -d' ' -f2)
|
| 67 | RUST_LIB_SRC ?= $(rustc_sysroot)/lib/rustlib/src/rust/library
|
| 68 |
|
| 69 | ifneq ($(quiet),)
|
| 70 | rust_test_quiet=-q
|
| 71 | rustdoc_test_quiet=--test-args -q
|
| 72 | rustdoc_test_kernel_quiet=>/dev/null
|
| 73 | endif
|
| 74 |
|
| 75 | cfgs-to-flags = $(patsubst %,--cfg='%',$1)
|
| 76 |
|
| 77 | core-cfgs := \
|
| 78 | no_fp_fmt_parse
|
| 79 |
|
| 80 | core-edition := $(if $(call rustc-min-version,108700),2024,2021)
|
| 81 |
|
| 82 | core-skip_flags := \
|
| 83 | --edition=2021 \
|
| 84 | -Wunreachable_pub
|
| 85 |
|
| 86 | core-flags := \
|
| 87 | --edition=$(core-edition) \
|
| 88 | $(call cfgs-to-flags,$(core-cfgs))
|
| 89 |
|
| 90 | zerocopy-cfgs := \
|
| 91 | no_fp_fmt_parse
|
| 92 |
|
| 93 | zerocopy-flags := \
|
| 94 | --cap-lints=allow \
|
| 95 | $(call cfgs-to-flags,$(zerocopy-cfgs))
|
| 96 |
|
| 97 | zerocopy-envs := \
|
| 98 | CARGO_PKG_VERSION=0.8.54
|
| 99 |
|
| 100 | proc_macro2-cfgs := \
|
| 101 | feature="proc-macro" \
|
| 102 | wrap_proc_macro \
|
| 103 | $(if $(call rustc-min-version,108800),proc_macro_span_file proc_macro_span_location)
|
| 104 |
|
| 105 | proc_macro2-flags := \
|
| 106 | --cap-lints=allow \
|
| 107 | $(call cfgs-to-flags,$(proc_macro2-cfgs))
|
| 108 |
|
| 109 | quote-cfgs := \
|
| 110 | feature="proc-macro"
|
| 111 |
|
| 112 | quote-skip_flags := \
|
| 113 | --edition=2021
|
| 114 |
|
| 115 | quote-flags := \
|
| 116 | --edition=2018 \
|
| 117 | --cap-lints=allow \
|
| 118 | --extern proc_macro2 \
|
| 119 | $(call cfgs-to-flags,$(quote-cfgs))
|
| 120 |
|
| 121 |
|
| 122 | syn-cfgs := \
|
| 123 | feature="clone-impls" \
|
| 124 | feature="derive" \
|
| 125 | feature="full" \
|
| 126 | feature="parsing" \
|
| 127 | feature="printing" \
|
| 128 | feature="proc-macro" \
|
| 129 | feature="visit" \
|
| 130 | feature="visit-mut"
|
| 131 |
|
| 132 | syn-flags := \
|
| 133 | --cap-lints=allow \
|
| 134 | --extern proc_macro2 \
|
| 135 | --extern quote \
|
| 136 | $(call cfgs-to-flags,$(syn-cfgs))
|
| 137 |
|
| 138 | zerocopy_derive-cfgs := \
|
| 139 | zerocopy_unstable_linux
|
| 140 |
|
| 141 | zerocopy_derive-flags := \
|
| 142 | --cap-lints=allow \
|
| 143 | --extern proc_macro2 \
|
| 144 | --extern quote \
|
| 145 | --extern syn \
|
| 146 | $(call cfgs-to-flags,$(zerocopy_derive-cfgs))
|
| 147 |
|
| 148 | pin_init_internal-cfgs := \
|
| 149 | kernel USE_RUSTC_FEATURES
|
| 150 |
|
| 151 | pin_init_internal-flags := \
|
| 152 | --extern proc_macro2 \
|
| 153 | --extern quote \
|
| 154 | --extern syn \
|
| 155 | $(call cfgs-to-flags,$(pin_init_internal-cfgs))
|
| 156 |
|
| 157 | pin_init-cfgs := \
|
| 158 | kernel USE_RUSTC_FEATURES
|
| 159 |
|
| 160 | pin_init-flags := \
|
| 161 | --extern pin_init_internal \
|
| 162 | --extern macros \
|
| 163 | $(call cfgs-to-flags,$(pin_init-cfgs))
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 | rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
|
| 168 |
|
| 169 |
|
| 170 | doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
|
| 171 |
|
| 172 | quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
|
| 173 | cmd_rustdoc = \
|
| 174 | $(rustc_target_envs) \
|
| 175 | OBJTREE=$(abspath $(objtree)) \
|
| 176 | $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-scope=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
|
| 177 | $(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
|
| 178 | -Zunstable-options --generate-link-to-definition \
|
| 179 | --output $(rustdoc_output) \
|
| 180 | --crate-name $(subst rustdoc-,,$@) \
|
| 181 | $(rustdoc_modifiers_workaround) \
|
| 182 | $(if $(rustdoc_host),,--sysroot=/dev/null) \
|
| 183 | @$(objtree)/include/generated/rustc_cfg $<
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 | rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
|
| 197 | rustdoc-kernel rustdoc-pin_init rustdoc-zerocopy rustdoc-zerocopy_derive
|
| 198 | $(Q)grep -Ehro '<a href="srctree/([^"]+)"' $(rustdoc_output) | \
|
| 199 | cut -d'"' -f2 | cut -d/ -f2- | while read f; do \
|
| 200 | if [ ! -e "$(srctree)/$$f" ]; then \
|
| 201 | echo "warning: srctree/ link to $$f does not exist"; \
|
| 202 | fi \
|
| 203 | done
|
| 204 | $(Q)cp $(srctree)/Documentation/images/logo.svg $(rustdoc_output)/static.files/
|
| 205 | $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/
|
| 206 | $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
|
| 207 | -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
|
| 208 | -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
|
| 209 | -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \
|
| 210 | -e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g'
|
| 211 | $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
|
| 212 | echo ".logo-container > img { object-fit: contain; }" >> $$f; done
|
| 213 |
|
| 214 | rustdoc-proc_macro2: private rustdoc_host = yes
|
| 215 | rustdoc-proc_macro2: private rustc_target_flags = $(proc_macro2-flags)
|
| 216 | rustdoc-proc_macro2: $(src)/proc-macro2/lib.rs rustdoc-clean FORCE
|
| 217 | +$(call if_changed,rustdoc)
|
| 218 |
|
| 219 | rustdoc-quote: private rustdoc_host = yes
|
| 220 | rustdoc-quote: private rustc_target_flags = $(quote-flags)
|
| 221 | rustdoc-quote: private skip_flags = $(quote-skip_flags)
|
| 222 | rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE
|
| 223 | +$(call if_changed,rustdoc)
|
| 224 |
|
| 225 | rustdoc-syn: private rustdoc_host = yes
|
| 226 | rustdoc-syn: private rustc_target_flags = $(syn-flags)
|
| 227 | rustdoc-syn: $(src)/syn/lib.rs rustdoc-clean rustdoc-quote FORCE
|
| 228 | +$(call if_changed,rustdoc)
|
| 229 |
|
| 230 | rustdoc-zerocopy_derive: private rustdoc_host = yes
|
| 231 | rustdoc-zerocopy_derive: private rustc_target_flags = $(zerocopy_derive-flags) \
|
| 232 | --extern proc_macro --crate-type proc-macro
|
| 233 | rustdoc-zerocopy_derive: $(src)/zerocopy-derive/lib.rs rustdoc-clean rustdoc-syn FORCE
|
| 234 | +$(call if_changed,rustdoc)
|
| 235 |
|
| 236 | rustdoc-macros: private rustdoc_host = yes
|
| 237 | rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
|
| 238 | --extern proc_macro --extern proc_macro2 --extern quote --extern syn
|
| 239 | rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 \
|
| 240 | rustdoc-quote rustdoc-syn FORCE
|
| 241 | +$(call if_changed,rustdoc)
|
| 242 |
|
| 243 | rustdoc-core: private skip_flags = $(core-skip_flags)
|
| 244 | rustdoc-core: private rustc_target_flags = $(core-flags)
|
| 245 | rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
|
| 246 | +$(call if_changed,rustdoc)
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 | rustdoc-compiler_builtins: private is-kernel-object := y
|
| 252 | rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
|
| 253 | +$(call if_changed,rustdoc)
|
| 254 |
|
| 255 | rustdoc-zerocopy: private rustc_target_envs := $(zerocopy-envs)
|
| 256 | rustdoc-zerocopy: private is-kernel-object := y
|
| 257 | rustdoc-zerocopy: private rustc_target_flags = $(zerocopy-flags) \
|
| 258 | --extend-css $(src)/zerocopy/rustdoc/style.css
|
| 259 | rustdoc-zerocopy: $(src)/zerocopy/src/lib.rs rustdoc-clean rustdoc-core FORCE
|
| 260 | +$(call if_changed,rustdoc)
|
| 261 |
|
| 262 | rustdoc-ffi: private is-kernel-object := y
|
| 263 | rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
|
| 264 | +$(call if_changed,rustdoc)
|
| 265 |
|
| 266 | rustdoc-pin_init_internal: private rustdoc_host = yes
|
| 267 | rustdoc-pin_init_internal: private rustc_target_flags = $(pin_init_internal-flags) \
|
| 268 | --extern proc_macro --crate-type proc-macro
|
| 269 | rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
|
| 270 | rustdoc-clean rustdoc-proc_macro2 rustdoc-quote rustdoc-syn FORCE
|
| 271 | +$(call if_changed,rustdoc)
|
| 272 |
|
| 273 | rustdoc-pin_init: private rustdoc_host = yes
|
| 274 | rustdoc-pin_init: private rustc_target_flags = $(pin_init-flags) \
|
| 275 | --extern pin_init_internal=$(objtree)/$(obj)/$(libpin_init_internal_name) \
|
| 276 | --extern alloc --cfg feature=\"alloc\"
|
| 277 | rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
|
| 278 | rustdoc-macros FORCE
|
| 279 | +$(call if_changed,rustdoc)
|
| 280 |
|
| 281 | rustdoc-kernel: private is-kernel-object := y
|
| 282 | rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
|
| 283 | --extern build_error --extern macros \
|
| 284 | --extern bindings --extern uapi \
|
| 285 | --extern zerocopy --extern zerocopy_derive
|
| 286 | rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \
|
| 287 | rustdoc-pin_init rustdoc-compiler_builtins $(obj)/$(libmacros_name) \
|
| 288 | $(obj)/bindings.o FORCE
|
| 289 | +$(call if_changed,rustdoc)
|
| 290 |
|
| 291 | rustdoc-clean: FORCE
|
| 292 | $(Q)rm -rf $(rustdoc_output)
|
| 293 |
|
| 294 | quiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $<
|
| 295 | cmd_rustc_test_library = \
|
| 296 | $(rustc_target_envs) \
|
| 297 | OBJTREE=$(abspath $(objtree)) \
|
| 298 | $(RUSTC_OR_CLIPPY) $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
|
| 299 | @$(objtree)/include/generated/rustc_cfg \
|
| 300 | --crate-type $(if $(rustc_test_library_proc),proc-macro,rlib) \
|
| 301 | --out-dir $(objtree)/$(obj)/test --cfg testlib \
|
| 302 | -L$(objtree)/$(obj)/test \
|
| 303 | --crate-name $(subst rusttest-,,$(subst rusttestlib-,,$@)) $<
|
| 304 |
|
| 305 | rusttestlib-zerocopy: private rustc_target_envs := $(zerocopy-envs)
|
| 306 | rusttestlib-zerocopy: private rustc_target_flags = $(zerocopy-flags)
|
| 307 | rusttestlib-zerocopy: $(src)/zerocopy/src/lib.rs FORCE
|
| 308 | +$(call if_changed,rustc_test_library)
|
| 309 |
|
| 310 | rusttestlib-build_error: $(src)/build_error.rs FORCE
|
| 311 | +$(call if_changed,rustc_test_library)
|
| 312 |
|
| 313 | rusttestlib-ffi: $(src)/ffi.rs FORCE
|
| 314 | +$(call if_changed,rustc_test_library)
|
| 315 |
|
| 316 | rusttestlib-proc_macro2: private rustc_target_flags = $(proc_macro2-flags)
|
| 317 | rusttestlib-proc_macro2: $(src)/proc-macro2/lib.rs FORCE
|
| 318 | +$(call if_changed,rustc_test_library)
|
| 319 |
|
| 320 | rusttestlib-quote: private skip_flags = $(quote-skip_flags)
|
| 321 | rusttestlib-quote: private rustc_target_flags = $(quote-flags)
|
| 322 | rusttestlib-quote: $(src)/quote/lib.rs rusttestlib-proc_macro2 FORCE
|
| 323 | +$(call if_changed,rustc_test_library)
|
| 324 |
|
| 325 | rusttestlib-syn: private rustc_target_flags = $(syn-flags)
|
| 326 | rusttestlib-syn: $(src)/syn/lib.rs rusttestlib-quote FORCE
|
| 327 | +$(call if_changed,rustc_test_library)
|
| 328 |
|
| 329 | rusttestlib-zerocopy_derive: private rustc_target_flags = $(zerocopy_derive-flags) \
|
| 330 | --extern proc_macro
|
| 331 | rusttestlib-zerocopy_derive: private rustc_test_library_proc = yes
|
| 332 | rusttestlib-zerocopy_derive: $(src)/zerocopy-derive/lib.rs rusttestlib-syn FORCE
|
| 333 | +$(call if_changed,rustc_test_library)
|
| 334 |
|
| 335 | rusttestlib-macros: private rustc_target_flags = --extern proc_macro \
|
| 336 | --extern proc_macro2 --extern quote --extern syn
|
| 337 | rusttestlib-macros: private rustc_test_library_proc = yes
|
| 338 | rusttestlib-macros: $(src)/macros/lib.rs \
|
| 339 | rusttestlib-proc_macro2 rusttestlib-quote rusttestlib-syn FORCE
|
| 340 | +$(call if_changed,rustc_test_library)
|
| 341 |
|
| 342 | rusttestlib-pin_init_internal: private rustc_target_flags = $(pin_init_internal-flags) \
|
| 343 | --extern proc_macro
|
| 344 | rusttestlib-pin_init_internal: private rustc_test_library_proc = yes
|
| 345 | rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
|
| 346 | rusttestlib-proc_macro2 rusttestlib-quote rusttestlib-syn FORCE
|
| 347 | +$(call if_changed,rustc_test_library)
|
| 348 |
|
| 349 | rusttestlib-pin_init: private rustc_target_flags = $(pin_init-flags)
|
| 350 | rusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \
|
| 351 | rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE
|
| 352 | +$(call if_changed,rustc_test_library)
|
| 353 |
|
| 354 | rusttestlib-kernel: private rustc_target_flags = --extern ffi \
|
| 355 | --extern build_error --extern macros --extern pin_init \
|
| 356 | --extern bindings --extern uapi \
|
| 357 | --extern zerocopy=$(objtree)/$(obj)/test/libzerocopy.rlib \
|
| 358 | --extern zerocopy_derive=$(objtree)/$(obj)/test/$(libzerocopy_derive_name)
|
| 359 | rusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \
|
| 360 | rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \
|
| 361 | $(obj)/bindings.o rusttestlib-zerocopy rusttestlib-zerocopy_derive FORCE
|
| 362 | +$(call if_changed,rustc_test_library)
|
| 363 |
|
| 364 | rusttestlib-bindings: private rustc_target_flags = --extern ffi --extern pin_init
|
| 365 | rusttestlib-bindings: $(src)/bindings/lib.rs rusttestlib-ffi rusttestlib-pin_init FORCE
|
| 366 | +$(call if_changed,rustc_test_library)
|
| 367 |
|
| 368 | rusttestlib-uapi: private rustc_target_flags = --extern ffi --extern pin_init
|
| 369 | rusttestlib-uapi: $(src)/uapi/lib.rs rusttestlib-ffi rusttestlib-pin_init FORCE
|
| 370 | +$(call if_changed,rustc_test_library)
|
| 371 |
|
| 372 | quiet_cmd_rustdoc_test = RUSTDOC T $<
|
| 373 | cmd_rustdoc_test = \
|
| 374 | $(rustc_target_envs) \
|
| 375 | RUST_MODFILE=test.rs \
|
| 376 | OBJTREE=$(abspath $(objtree)) \
|
| 377 | $(RUSTDOC) --test $(rust_common_flags) \
|
| 378 | -Zcrate-attr='feature(used_with_arg)' \
|
| 379 | @$(objtree)/include/generated/rustc_cfg \
|
| 380 | $(rustc_target_flags) $(rustdoc_test_target_flags) \
|
| 381 | $(rustdoc_test_quiet) \
|
| 382 | -L$(objtree)/$(obj)/test --output $(rustdoc_output) \
|
| 383 | --crate-name $(subst rusttest-,,$@) $<
|
| 384 |
|
| 385 | quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
|
| 386 | cmd_rustdoc_test_kernel = \
|
| 387 | rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
|
| 388 | mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
|
| 389 | $(rustc_target_envs) \
|
| 390 | OBJTREE=$(abspath $(objtree)) \
|
| 391 | $(RUSTDOC) --test $(filter-out --remap-path-scope=%,$(rust_flags)) \
|
| 392 | -L$(objtree)/$(obj) --extern ffi --extern pin_init \
|
| 393 | --extern kernel --extern build_error --extern macros \
|
| 394 | --extern bindings --extern uapi \
|
| 395 | --extern zerocopy --extern zerocopy_derive \
|
| 396 | --no-run --crate-name kernel -Zunstable-options \
|
| 397 | --sysroot=/dev/null \
|
| 398 | $(doctests_modifiers_workaround) \
|
| 399 | --test-builder $(objtree)/scripts/rustdoc_test_builder \
|
| 400 | $< $(rustdoc_test_kernel_quiet); \
|
| 401 | $(objtree)/scripts/rustdoc_test_gen
|
| 402 |
|
| 403 | %/doctests_kernel_generated.rs %/doctests_kernel_generated_kunit.c: \
|
| 404 | $(src)/kernel/lib.rs $(obj)/kernel.o \
|
| 405 | $(objtree)/scripts/rustdoc_test_builder \
|
| 406 | $(objtree)/scripts/rustdoc_test_gen FORCE
|
| 407 | +$(call if_changed,rustdoc_test_kernel)
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 | quiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T $<
|
| 412 | cmd_rustc_test = \
|
| 413 | $(rustc_target_envs) \
|
| 414 | OBJTREE=$(abspath $(objtree)) \
|
| 415 | $(RUSTC_OR_CLIPPY) --test $(rust_common_flags) \
|
| 416 | @$(objtree)/include/generated/rustc_cfg \
|
| 417 | $(rustc_target_flags) --out-dir $(objtree)/$(obj)/test \
|
| 418 | -L$(objtree)/$(obj)/test \
|
| 419 | --crate-name $(subst rusttest-,,$@) $<; \
|
| 420 | $(objtree)/$(obj)/test/$(subst rusttest-,,$@) $(rust_test_quiet) \
|
| 421 | $(rustc_test_run_flags)
|
| 422 |
|
| 423 | rusttest: rusttest-macros
|
| 424 |
|
| 425 | rusttest-macros: private rustc_target_flags = --extern proc_macro \
|
| 426 | --extern macros --extern kernel --extern pin_init \
|
| 427 | --extern proc_macro2 --extern quote --extern syn
|
| 428 | rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
|
| 429 | rusttest-macros: $(src)/macros/lib.rs \
|
| 430 | rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE
|
| 431 | +$(call if_changed,rustc_test)
|
| 432 | +$(call if_changed,rustdoc_test)
|
| 433 |
|
| 434 | ifdef CONFIG_CC_IS_CLANG
|
| 435 | bindgen_c_flags = $(c_flags)
|
| 436 | else
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 | bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
|
| 444 | -mskip-rax-setup -mgeneral-regs-only -msign-return-address=% \
|
| 445 | -mindirect-branch=thunk-extern -mindirect-branch-register \
|
| 446 | -mfunction-return=thunk-extern -mrecord-mcount -mabi=lp64 \
|
| 447 | -mindirect-branch-cs-prefix -mstack-protector-guard% -mtraceback=no \
|
| 448 | -mno-pointers-to-nested-functions -mno-string \
|
| 449 | -mno-strict-align -mstrict-align -mdirect-extern-access \
|
| 450 | -mexplicit-relocs -mno-check-zero-division \
|
| 451 | -fconserve-stack -falign-jumps=% -falign-loops=% \
|
| 452 | -femit-struct-debug-baseonly -fno-ipa-cp-clone -fno-ipa-sra \
|
| 453 | -fno-partial-inlining -fplugin-arg-arm_ssp_per_task_plugin-% \
|
| 454 | -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \
|
| 455 | -fzero-call-used-regs=% -fno-stack-clash-protection \
|
| 456 | -fno-inline-functions-called-once -fsanitize=bounds-strict \
|
| 457 | -fstrict-flex-arrays=% -fmin-function-alignment=% \
|
| 458 | -fzero-init-padding-bits=% -mno-fdpic \
|
| 459 | -fdiagnostics-show-context -fdiagnostics-show-context=% \
|
| 460 | --param=% --param asan-% -fno-isolate-erroneous-paths-dereference \
|
| 461 | -ffixed-r2 -mmultiple -mno-readonly-in-sdata
|
| 462 |
|
| 463 |
|
| 464 | BINDGEN_TARGET_x86 := x86_64-linux-gnu
|
| 465 | BINDGEN_TARGET_arm64 := aarch64-linux-gnu
|
| 466 | BINDGEN_TARGET_arm := arm-linux-gnueabi
|
| 467 | BINDGEN_TARGET_loongarch := loongarch64-linux-gnusf
|
| 468 | BINDGEN_TARGET_s390 := s390x-linux-gnu
|
| 469 |
|
| 470 | BINDGEN_TARGET_i386 := i386-linux-gnu
|
| 471 |
|
| 472 | ifdef CONFIG_PPC64
|
| 473 | BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
|
| 474 | else
|
| 475 | BINDGEN_TARGET_powerpc := powerpc-linux-gnu
|
| 476 | endif
|
| 477 |
|
| 478 | BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
|
| 479 | BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 | bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 | ifdef CONFIG_INIT_STACK_ALL_ZERO
|
| 494 | libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
|
| 495 | ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
|
| 496 | bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
|
| 497 | endif
|
| 498 | endif
|
| 499 |
|
| 500 | bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
|
| 501 | $(bindgen_extra_c_flags)
|
| 502 | endif
|
| 503 |
|
| 504 | ifdef CONFIG_LTO
|
| 505 | bindgen_c_flags_lto = $(filter-out $(CC_FLAGS_LTO), $(bindgen_c_flags))
|
| 506 | else
|
| 507 | bindgen_c_flags_lto = $(bindgen_c_flags)
|
| 508 | endif
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 | bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__
|
| 515 |
|
| 516 |
|
| 517 | quiet_cmd_bindgen = BINDGEN $@
|
| 518 | cmd_bindgen = \
|
| 519 | $(BINDGEN) $< $(bindgen_target_flags) --rust-target 1.85 \
|
| 520 | --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests \
|
| 521 | --no-debug '.*' --enable-function-attribute-detection \
|
| 522 | -o $@ -- $(bindgen_c_flags_final) -DMODULE \
|
| 523 | $(bindgen_target_cflags) $(bindgen_target_extra)
|
| 524 |
|
| 525 | $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
|
| 526 | $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
|
| 527 | $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \
|
| 528 | sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@
|
| 529 | $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
|
| 530 | $(src)/bindgen_parameters FORCE
|
| 531 | $(call if_changed_dep,bindgen)
|
| 532 |
|
| 533 | $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \
|
| 534 | $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
|
| 535 | $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \
|
| 536 | $(src)/bindgen_parameters FORCE
|
| 537 | $(call if_changed_dep,bindgen)
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 | $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_flags = \
|
| 544 | --blocklist-type '.*' --allowlist-var '' \
|
| 545 | --allowlist-function 'rust_helper_.*'
|
| 546 | $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \
|
| 547 | -I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
|
| 548 | $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ; \
|
| 549 | sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/
|
| 550 | $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
|
| 551 | $(call if_changed_dep,bindgen)
|
| 552 |
|
| 553 | quiet_cmd_rust_helper = HELPER $@
|
| 554 | cmd_rust_helper = \
|
| 555 | $(CC) $(filter-out $(CFLAGS_REMOVE_helpers/helpers.o), $(c_flags)) \
|
| 556 | -c -g0 $< -emit-llvm -o $@
|
| 557 |
|
| 558 | $(obj)/helpers/helpers.bc: private part-of-builtin := y
|
| 559 | $(obj)/helpers/helpers_module.bc: private part-of-module := y
|
| 560 | $(obj)/helpers/helpers.bc $(obj)/helpers/helpers_module.bc: $(src)/helpers/helpers.c FORCE
|
| 561 | +$(call if_changed_dep,rust_helper)
|
| 562 |
|
| 563 | rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(pfx|cfi|odr_asan)/ { printf $(2),$$3 }'
|
| 564 |
|
| 565 | quiet_cmd_exports = EXPORTS $@
|
| 566 | cmd_exports = \
|
| 567 | $(call rust_exports,$<,"EXPORT_SYMBOL_RUST_GPL(%s);\n") > $@
|
| 568 |
|
| 569 | $(obj)/exports_core_generated.h: $(obj)/core.o FORCE
|
| 570 | $(call if_changed,exports)
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 | $(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE
|
| 582 | $(call if_changed,exports)
|
| 583 |
|
| 584 | $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE
|
| 585 | $(call if_changed,exports)
|
| 586 |
|
| 587 | $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
|
| 588 | $(call if_changed,exports)
|
| 589 |
|
| 590 | quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@
|
| 591 | cmd_rustc_procmacrolibrary = \
|
| 592 | $(rustc_target_envs) \
|
| 593 | $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
|
| 594 | $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
|
| 595 | --emit=dep-info=$(depfile) --emit=link=$@ --crate-type rlib -O \
|
| 596 | --out-dir $(objtree)/$(obj)/host -L$(objtree)/$(obj)/host \
|
| 597 | --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<
|
| 598 |
|
| 599 | $(obj)/host/libproc_macro2.rlib: private skip_clippy = 1
|
| 600 | $(obj)/host/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
|
| 601 | $(obj)/host/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
|
| 602 | +$(call if_changed_dep,rustc_procmacrolibrary)
|
| 603 |
|
| 604 | $(obj)/host/libquote.rlib: private skip_clippy = 1
|
| 605 | $(obj)/host/libquote.rlib: private skip_flags = $(quote-skip_flags)
|
| 606 | $(obj)/host/libquote.rlib: private rustc_target_flags = $(quote-flags)
|
| 607 | $(obj)/host/libquote.rlib: $(src)/quote/lib.rs $(obj)/host/libproc_macro2.rlib FORCE
|
| 608 | +$(call if_changed_dep,rustc_procmacrolibrary)
|
| 609 |
|
| 610 | $(obj)/host/libsyn.rlib: private skip_clippy = 1
|
| 611 | $(obj)/host/libsyn.rlib: private rustc_target_flags = $(syn-flags)
|
| 612 | $(obj)/host/libsyn.rlib: $(src)/syn/lib.rs $(obj)/host/libquote.rlib FORCE
|
| 613 | +$(call if_changed_dep,rustc_procmacrolibrary)
|
| 614 |
|
| 615 | quiet_cmd_rustc_procmacro = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) P $@
|
| 616 | cmd_rustc_procmacro = \
|
| 617 | $(rustc_target_envs) \
|
| 618 | $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) $(rust_common_flags) $(rustc_target_flags) \
|
| 619 | -Clinker-flavor=gcc -Clinker=$(HOSTCC) \
|
| 620 | -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
|
| 621 | --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
|
| 622 | --crate-type proc-macro -L$(objtree)/$(obj)/host \
|
| 623 | --crate-name $(patsubst lib%.$(procmacro-extension),%,$(notdir $@)) \
|
| 624 | @$(objtree)/include/generated/rustc_cfg $<
|
| 625 |
|
| 626 |
|
| 627 | $(obj)/$(libzerocopy_derive_name): private skip_clippy = 1
|
| 628 | $(obj)/$(libzerocopy_derive_name): private rustc_target_flags = $(zerocopy_derive-flags)
|
| 629 | $(obj)/$(libzerocopy_derive_name): $(src)/zerocopy-derive/lib.rs $(obj)/host/libproc_macro2.rlib \
|
| 630 | $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
|
| 631 | +$(call if_changed_dep,rustc_procmacro)
|
| 632 |
|
| 633 | $(obj)/$(libmacros_name): private rustc_target_flags = \
|
| 634 | --extern proc_macro2 --extern quote --extern syn
|
| 635 | $(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/host/libproc_macro2.rlib \
|
| 636 | $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
|
| 637 | +$(call if_changed_dep,rustc_procmacro)
|
| 638 |
|
| 639 | $(obj)/$(libpin_init_internal_name): private rustc_target_flags = $(pin_init_internal-flags)
|
| 640 | $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \
|
| 641 | $(obj)/host/libproc_macro2.rlib $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
|
| 642 | +$(call if_changed_dep,rustc_procmacro)
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 | quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@
|
| 647 | cmd_rustc_library = \
|
| 648 | $(rustc_target_envs) \
|
| 649 | OBJTREE=$(abspath $(objtree)) \
|
| 650 | $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
|
| 651 | $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \
|
| 652 | --emit=dep-info=$(depfile) --emit=$(if $(link_helper),llvm-bc=$(patsubst %.o,%.bc,$@),obj=$@) \
|
| 653 | --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
|
| 654 | --crate-type rlib -L$(objtree)/$(obj) \
|
| 655 | --crate-name $(patsubst %.o,%,$(notdir $@)) $< \
|
| 656 | --sysroot=/dev/null \
|
| 657 | -Zunstable-options \
|
| 658 | $(if $(link_helper),;$(LLVM_LINK) --internalize --suppress-warnings $(patsubst %.o,%.bc,$@) \
|
| 659 | $(obj)/helpers/helpers$(if $(part-of-module),_module).bc -o $(patsubst %.o,%.m.bc,$@); \
|
| 660 | $(CC) $(CLANG_FLAGS) $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS)) \
|
| 661 | $(CC_FLAGS_RUST_INLINE_HELPERS) -Wno-override-module -c $(patsubst %.o,%.m.bc,$@) -o $@ \
|
| 662 | $(cmd_ld_single)) \
|
| 663 | $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \
|
| 664 | $(cmd_objtool)
|
| 665 |
|
| 666 | rust-analyzer:
|
| 667 | $(Q)MAKEFLAGS= $(srctree)/scripts/generate_rust_analyzer.py \
|
| 668 | --cfgs='core=$(core-cfgs)' $(core-edition) \
|
| 669 | --cfgs='zerocopy=$(zerocopy-cfgs)' \
|
| 670 | --cfgs='proc_macro2=$(proc_macro2-cfgs)' \
|
| 671 | --cfgs='quote=$(quote-cfgs)' \
|
| 672 | --cfgs='syn=$(syn-cfgs)' \
|
| 673 | --cfgs='zerocopy_derive=$(zerocopy_derive-cfgs)' \
|
| 674 | --cfgs='pin_init_internal=$(pin_init_internal-cfgs)' \
|
| 675 | --cfgs='pin_init=$(pin_init-cfgs)' \
|
| 676 | --envs='zerocopy=$(zerocopy-envs)' \
|
| 677 | $(realpath $(srctree)) $(realpath $(objtree)) \
|
| 678 | $(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \
|
| 679 | > rust-project.json
|
| 680 |
|
| 681 | redirect-intrinsics = \
|
| 682 | __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \
|
| 683 | __adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \
|
| 684 | __muloti4 __multi3 \
|
| 685 | __udivmodti4 __udivti3 __umodti3
|
| 686 |
|
| 687 | ifdef CONFIG_ARM
|
| 688 |
|
| 689 | redirect-intrinsics += \
|
| 690 | __aeabi_fadd __aeabi_fmul __aeabi_fcmpeq __aeabi_fcmple __aeabi_fcmplt __aeabi_fcmpun \
|
| 691 | __aeabi_dadd __aeabi_dmul __aeabi_dcmple __aeabi_dcmplt __aeabi_dcmpun \
|
| 692 | __aeabi_uldivmod
|
| 693 | endif
|
| 694 | ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
|
| 695 |
|
| 696 | redirect-intrinsics += \
|
| 697 | __ashrti3 \
|
| 698 | __ashlti3 __lshrti3
|
| 699 | endif
|
| 700 | ifdef CONFIG_PPC32
|
| 701 | redirect-intrinsics += \
|
| 702 | __udivdi3 __umoddi3
|
| 703 | endif
|
| 704 |
|
| 705 | ifdef CONFIG_MODVERSIONS
|
| 706 | cmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \
|
| 707 | $(call rust_exports,$@,"%s\n") | \
|
| 708 | scripts/gendwarfksyms/gendwarfksyms \
|
| 709 | $(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable) \
|
| 710 | $(if $(KBUILD_SYMTYPES), --symtypes $(@:.o=.symtypes),) \
|
| 711 | $@ >> $(dot-target).cmd)
|
| 712 | endif
|
| 713 |
|
| 714 | define rule_rustc_library
|
| 715 | $(call cmd_and_fixdep,rustc_library)
|
| 716 | $(call cmd,gen_objtooldep)
|
| 717 | $(call cmd,gendwarfksyms)
|
| 718 | endef
|
| 719 |
|
| 720 | define rule_rust_cc_library
|
| 721 | $(call if_changed_rule,cc_o_c)
|
| 722 | $(call cmd,force_checksrc)
|
| 723 | $(call cmd,gendwarfksyms)
|
| 724 | endef
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 | $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE
|
| 729 | +$(call if_changed_rule,rust_cc_library)
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 | $(obj)/exports.o: private skip_gendwarfksyms = 1
|
| 734 |
|
| 735 | $(obj)/core.o: private skip_clippy = 1
|
| 736 | $(obj)/core.o: private skip_flags = $(core-skip_flags)
|
| 737 | $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
|
| 738 | $(obj)/core.o: private rustc_target_flags = $(core-flags)
|
| 739 | $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
|
| 740 | $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
|
| 741 | +$(call if_changed_rule,rustc_library)
|
| 742 | ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
|
| 743 | $(obj)/core.o: scripts/target.json
|
| 744 | endif
|
| 745 | KCOV_INSTRUMENT_core.o := n
|
| 746 |
|
| 747 | $(obj)/compiler_builtins.o: private skip_gendwarfksyms = 1
|
| 748 | $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
|
| 749 | $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
|
| 750 | +$(call if_changed_rule,rustc_library)
|
| 751 |
|
| 752 | $(obj)/zerocopy.o: private skip_clippy = 1
|
| 753 | $(obj)/zerocopy.o: private skip_gendwarfksyms = 1
|
| 754 | $(obj)/zerocopy.o: private rustc_target_envs := $(zerocopy-envs)
|
| 755 | $(obj)/zerocopy.o: private rustc_target_flags = $(zerocopy-flags)
|
| 756 | $(obj)/zerocopy.o: $(src)/zerocopy/src/lib.rs $(obj)/compiler_builtins.o FORCE
|
| 757 | +$(call if_changed_rule,rustc_library)
|
| 758 |
|
| 759 | $(obj)/pin_init.o: private skip_gendwarfksyms = 1
|
| 760 | $(obj)/pin_init.o: private rustc_target_flags = $(pin_init-flags)
|
| 761 | $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
|
| 762 | $(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
|
| 763 | +$(call if_changed_rule,rustc_library)
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 | $(obj)/build_error.o: private is-kernel-object := y
|
| 769 | $(obj)/build_error.o: private skip_gendwarfksyms = 1
|
| 770 | $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
|
| 771 | +$(call if_changed_rule,rustc_library)
|
| 772 |
|
| 773 | $(obj)/ffi.o: private skip_gendwarfksyms = 1
|
| 774 | $(obj)/ffi.o: $(src)/ffi.rs $(obj)/compiler_builtins.o FORCE
|
| 775 | +$(call if_changed_rule,rustc_library)
|
| 776 |
|
| 777 | $(obj)/bindings.o: private rustc_target_flags = --extern ffi --extern pin_init
|
| 778 | $(obj)/bindings.o: $(src)/bindings/lib.rs \
|
| 779 | $(obj)/ffi.o \
|
| 780 | $(obj)/pin_init.o \
|
| 781 | $(obj)/bindings/bindings_generated.rs \
|
| 782 | $(obj)/bindings/bindings_helpers_generated.rs FORCE
|
| 783 | +$(call if_changed_rule,rustc_library)
|
| 784 |
|
| 785 | $(obj)/uapi.o: private rustc_target_flags = --extern ffi --extern pin_init
|
| 786 | $(obj)/uapi.o: private skip_gendwarfksyms = 1
|
| 787 | $(obj)/uapi.o: $(src)/uapi/lib.rs \
|
| 788 | $(obj)/ffi.o \
|
| 789 | $(obj)/pin_init.o \
|
| 790 | $(obj)/uapi/uapi_generated.rs FORCE
|
| 791 | +$(call if_changed_rule,rustc_library)
|
| 792 |
|
| 793 | $(obj)/kernel.o: private rustc_target_flags = --extern ffi --extern pin_init \
|
| 794 | --extern build_error --extern macros --extern bindings --extern uapi \
|
| 795 | --extern zerocopy --extern zerocopy_derive
|
| 796 | $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o $(obj)/pin_init.o \
|
| 797 | $(obj)/$(libmacros_name) $(obj)/bindings.o $(obj)/uapi.o \
|
| 798 | $(obj)/zerocopy.o $(obj)/$(libzerocopy_derive_name) FORCE
|
| 799 | +$(call if_changed_rule,rustc_library)
|
| 800 |
|
| 801 | ifdef CONFIG_JUMP_LABEL
|
| 802 | $(obj)/kernel.o: $(obj)/kernel/generated_arch_static_branch_asm.rs
|
| 803 | endif
|
| 804 | ifndef CONFIG_UML
|
| 805 | ifdef CONFIG_BUG
|
| 806 | $(obj)/kernel.o: $(obj)/kernel/generated_arch_warn_asm.rs $(obj)/kernel/generated_arch_reachable_asm.rs
|
| 807 | endif
|
| 808 | endif
|
| 809 |
|
| 810 | ifdef CONFIG_RUST_INLINE_HELPERS
|
| 811 | $(obj)/kernel.o: private link_helper = 1
|
| 812 | $(obj)/kernel.o: $(obj)/helpers/helpers.bc
|
| 813 | endif
|
| 814 |
|
| 815 | endif
|