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 | --crate-type rlib -L$(objtree)/$(obj) \ | 344 | --crate-type rlib -L$(objtree)/$(obj) \ |
| 345 | --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ | 345 | --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ |
| 346 | --sysroot=/dev/null \ | 346 | --sysroot=/dev/null \ |
| 347 | $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) | 347 | $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \ |
| 348 | $(cmd_objtool) | ||
| 348 | 349 | ||
| 349 | rust-analyzer: | 350 | rust-analyzer: |
| 350 | $(Q)$(srctree)/scripts/generate_rust_analyzer.py \ | 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 | __ashlti3 __lshrti3 | 367 | __ashlti3 __lshrti3 |
| 367 | endif | 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 | $(obj)/core.o: private skip_clippy = 1 | 375 | $(obj)/core.o: private skip_clippy = 1 |
| 370 | $(obj)/core.o: private skip_flags = -Wunreachable_pub | 376 | $(obj)/core.o: private skip_flags = -Wunreachable_pub |
| 371 | $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) | 377 | $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) |
| 372 | $(obj)/core.o: private rustc_target_flags = $(core-cfgs) | 378 | $(obj)/core.o: private rustc_target_flags = $(core-cfgs) |
| 373 | $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE | 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 | ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),) | 381 | ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),) |
| 376 | $(obj)/core.o: scripts/target.json | 382 | $(obj)/core.o: scripts/target.json |
| 377 | endif | 383 | endif |
| 378 | 384 | ||
| 379 | $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' | 385 | $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' |
| 380 | $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE | 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 | $(obj)/alloc.o: private skip_clippy = 1 | 389 | $(obj)/alloc.o: private skip_clippy = 1 |
| 384 | $(obj)/alloc.o: private skip_flags = -Wunreachable_pub | 390 | $(obj)/alloc.o: private skip_flags = -Wunreachable_pub |
| 385 | $(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs) | 391 | $(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs) |
| 386 | $(obj)/alloc.o: $(RUST_LIB_SRC)/alloc/src/lib.rs $(obj)/compiler_builtins.o FORCE | 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 | $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE | 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 | $(obj)/bindings.o: $(src)/bindings/lib.rs \ | 398 | $(obj)/bindings.o: $(src)/bindings/lib.rs \ |
| 393 | $(obj)/compiler_builtins.o \ | 399 | $(obj)/compiler_builtins.o \ |
| 394 | $(obj)/bindings/bindings_generated.rs \ | 400 | $(obj)/bindings/bindings_generated.rs \ |
| 395 | $(obj)/bindings/bindings_helpers_generated.rs FORCE | 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 | $(obj)/uapi.o: $(src)/uapi/lib.rs \ | 404 | $(obj)/uapi.o: $(src)/uapi/lib.rs \ |
| 399 | $(obj)/compiler_builtins.o \ | 405 | $(obj)/compiler_builtins.o \ |
| 400 | $(obj)/uapi/uapi_generated.rs FORCE | 406 | $(obj)/uapi/uapi_generated.rs FORCE |
| 401 | +$(call if_changed_dep,rustc_library) | 407 | +$(call if_changed_rule,rustc_library) |
| 402 | 408 | ||
| 403 | $(obj)/kernel.o: private rustc_target_flags = --extern alloc \ | 409 | $(obj)/kernel.o: private rustc_target_flags = --extern alloc \ |
| 404 | --extern build_error --extern macros --extern bindings --extern uapi | 410 | --extern build_error --extern macros --extern bindings --extern uapi |
| 405 | $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \ | 411 | $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \ |
| 406 | $(obj)/libmacros.so $(obj)/bindings.o $(obj)/uapi.o FORCE | 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 | endif # CONFIG_RUST | 415 | endif # CONFIG_RUST |
| @@ -288,10 +288,15 @@ rust_common_cmd = \ · 287 unmodified lines | |||
| 288 | # would not match each other. | 288 | # would not match each other. |
| 289 | 289 | ||
| 290 | quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ | 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 | $(obj)/%.o: $(obj)/%.rs FORCE | 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 | quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ | 301 | quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ |
| 297 | cmd_rustc_rsi_rs = \ | 302 | cmd_rustc_rsi_rs = \ |