Now that we should be `objtool`-warning free, enable `objtool` for Rust too. Before this patch series, we were already getting warnings under e.g. IBT builds, since those would see Rust code via `vmlinux.o`.
Unified · Split
| @@ -344,7 +344,8 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L · 343 unmodified lines | ||
| 344 | 344 | --crate-type rlib -L$(objtree)/$(obj) \ |
| 345 | 345 | --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ |
| 346 | 346 | --sysroot=/dev/null \ |
| 347 | − $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) | |
| 347 | + $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \ | |
| 348 | + $(cmd_objtool) | |
| 348 | 349 | |
| 349 | 350 | rust-analyzer: |
| 350 | 351 | $(Q)$(srctree)/scripts/generate_rust_analyzer.py \ |
| @@ -366,44 +367,49 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),) · 15 unmodified lines | ||
| 366 | 367 | __ashlti3 __lshrti3 |
| 367 | 368 | endif |
| 368 | 369 | |
| 370 | +define rule_rustc_library | |
| 371 | + $(call cmd_and_fixdep,rustc_library) | |
| 372 | + $(call cmd,gen_objtooldep) | |
| 373 | +endef | |
| 374 | + | |
| 369 | 375 | $(obj)/core.o: private skip_clippy = 1 |
| 370 | 376 | $(obj)/core.o: private skip_flags = -Wunreachable_pub |
| 371 | 377 | $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) |
| 372 | 378 | $(obj)/core.o: private rustc_target_flags = $(core-cfgs) |
| 373 | 379 | $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE |
| 374 | − +$(call if_changed_dep,rustc_library) | |
| 380 | + +$(call if_changed_rule,rustc_library) | |
| 375 | 381 | ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),) |
| 376 | 382 | $(obj)/core.o: scripts/target.json |
| 377 | 383 | endif |
| 378 | 384 | |
| 379 | 385 | $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' |
| 380 | 386 | $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE |
| 381 | − +$(call if_changed_dep,rustc_library) | |
| 387 | + +$(call if_changed_rule,rustc_library) | |
| 382 | 388 | |
| 383 | 389 | $(obj)/alloc.o: private skip_clippy = 1 |
| 384 | 390 | $(obj)/alloc.o: private skip_flags = -Wunreachable_pub |
| 385 | 391 | $(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs) |
| 386 | 392 | $(obj)/alloc.o: $(RUST_LIB_SRC)/alloc/src/lib.rs $(obj)/compiler_builtins.o FORCE |
| 387 | − +$(call if_changed_dep,rustc_library) | |
| 393 | + +$(call if_changed_rule,rustc_library) | |
| 388 | 394 | |
| 389 | 395 | $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE |
| 390 | − +$(call if_changed_dep,rustc_library) | |
| 396 | + +$(call if_changed_rule,rustc_library) | |
| 391 | 397 | |
| 392 | 398 | $(obj)/bindings.o: $(src)/bindings/lib.rs \ |
| 393 | 399 | $(obj)/compiler_builtins.o \ |
| 394 | 400 | $(obj)/bindings/bindings_generated.rs \ |
| 395 | 401 | $(obj)/bindings/bindings_helpers_generated.rs FORCE |
| 396 | − +$(call if_changed_dep,rustc_library) | |
| 402 | + +$(call if_changed_rule,rustc_library) | |
| 397 | 403 | |
| 398 | 404 | $(obj)/uapi.o: $(src)/uapi/lib.rs \ |
| 399 | 405 | $(obj)/compiler_builtins.o \ |
| 400 | 406 | $(obj)/uapi/uapi_generated.rs FORCE |
| 401 | − +$(call if_changed_dep,rustc_library) | |
| 407 | + +$(call if_changed_rule,rustc_library) | |
| 402 | 408 | |
| 403 | 409 | $(obj)/kernel.o: private rustc_target_flags = --extern alloc \ |
| 404 | 410 | --extern build_error --extern macros --extern bindings --extern uapi |
| 405 | 411 | $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \ |
| 406 | 412 | $(obj)/libmacros.so $(obj)/bindings.o $(obj)/uapi.o FORCE |
| 407 | − +$(call if_changed_dep,rustc_library) | |
| 413 | + +$(call if_changed_rule,rustc_library) | |
| 408 | 414 | |
| 409 | 415 | endif # CONFIG_RUST |
| @@ -288,10 +288,15 @@ rust_common_cmd = \ · 287 unmodified lines | ||
| 288 | 288 | # would not match each other. |
| 289 | 289 | |
| 290 | 290 | quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ |
| 291 | − cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< | |
| 291 | + cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< $(cmd_objtool) | |
| 292 | + | |
| 293 | +define rule_rustc_o_rs | |
| 294 | + $(call cmd_and_fixdep,rustc_o_rs) | |
| 295 | + $(call cmd,gen_objtooldep) | |
| 296 | +endef | |
| 292 | 297 | |
| 293 | 298 | $(obj)/%.o: $(obj)/%.rs FORCE |
| 294 | − +$(call if_changed_dep,rustc_o_rs) | |
| 299 | + +$(call if_changed_rule,rustc_o_rs) | |
| 295 | 300 | |
| 296 | 301 | quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ |
| 297 | 302 | cmd_rustc_rsi_rs = \ |