Skip to content

Commit 07b4a16

Browse files
committed
rust: Use absolute paths to build Rust objects
We want to use caller_location to uniquely identify callsites, to automatically create lockdep classes without macros. The location filename in local code uses the relative path passed to the compiler, but if that code is generic and instantiated from another crate, the path becomes absolute. To make this work and keep the paths consistent, always pass an absolute path to the compiler. Then the Location path is always identical regardless of how the code is being compiled. Signed-off-by: Asahi Lina <[email protected]>
1 parent 65890fb commit 07b4a16

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
370370
--emit=dep-info=$(depfile) --emit=obj=$@ \
371371
--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
372372
--crate-type rlib -L$(objtree)/$(obj) \
373-
--crate-name $(patsubst %.o,%,$(notdir $@)) $< \
373+
--crate-name $(patsubst %.o,%,$(notdir $@)) $(abspath $<) \
374374
$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
375375

376376
rust-analyzer:

scripts/Makefile.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,27 +298,27 @@ rust_common_cmd = \
298298
# would not match each other.
299299

300300
quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
301-
cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<
301+
cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $(abspath $<)
302302

303303
$(obj)/%.o: $(src)/%.rs FORCE
304304
$(call if_changed_dep,rustc_o_rs)
305305

306306
quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
307307
cmd_rustc_rsi_rs = \
308-
$(rust_common_cmd) -Zunpretty=expanded $< >$@; \
308+
$(rust_common_cmd) -Zunpretty=expanded $(abspath $<) >$@; \
309309
command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@
310310

311311
$(obj)/%.rsi: $(src)/%.rs FORCE
312312
$(call if_changed_dep,rustc_rsi_rs)
313313

314314
quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
315-
cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $<
315+
cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $(abspath $<)
316316

317317
$(obj)/%.s: $(src)/%.rs FORCE
318318
$(call if_changed_dep,rustc_s_rs)
319319

320320
quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
321-
cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $<
321+
cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $(abspath $<)
322322

323323
$(obj)/%.ll: $(src)/%.rs FORCE
324324
$(call if_changed_dep,rustc_ll_rs)

0 commit comments

Comments
 (0)