Message ID | 20230714-classless_lockdep-v1-3-229b9671ce31@asahilina.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2389134vqm; Fri, 14 Jul 2023 02:58:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlF7rqvpy8ADsxftpZs1kRTRXR2KQp+wgu8/7S0IiVctuT45SbUQaV/1cSCWhInNZK9L8inJ X-Received: by 2002:a05:6870:a553:b0:19f:4dc2:428e with SMTP id p19-20020a056870a55300b0019f4dc2428emr5043130oal.14.1689328708507; Fri, 14 Jul 2023 02:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689328708; cv=none; d=google.com; s=arc-20160816; b=sUcYgyfV/BItU8JxBTMxLT0R4l3rLGa4K5PMQL0jlstopExV7H7nTpPDnESzYwaoLC WPhHR+S1hHOcP4ptxcBE0M3HvtjUU3kvxhVApC0WJ9nsZgefD9ASD07z6sZB0pb+8zRI J27v/eV3itsmpRUFp0okYZ/aXQFBFfLQQAiKuhwaAL2wRUi6ks94UMR0b1CrayPTxlzz YKUe4RYvQo23APanWysbQgallqaF3nZ9QSA5ygTmz0isrY0BnpnnQLq6AhDpx5+1j0gQ HA7bpOMfw/fhJvl7CH89jB2XbA5rhQZZohzgVz3WYkC5kBixHDfIr6gN3sHGPCErfLiz FGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=LC5DY38kik48NUewwaKSepqPI5//Vq4bbXMq0GhxIvs=; fh=P69duW5QZmRj9b1Pp5XKOSqIgFMUDbjoyFZWqOwQYzw=; b=p/S8uVLZUN7XPNJiGq0On42nzinYUEkMPYYBoVid4wWJTPDxY6mlsmmi0xrXs91Gaf e0YdbokqX33U0HNSRvbaPR914eS3/WrbAlZvqtgk75FojRrE+Vw0Tttzvyh6NROHpbcX sW17TZj1Aj0QPBL00lUDw5uS4aRFvc2T0q4WjKY/lQHgP2oT0QghGVE9VqpCiFn4BSV/ nrVKkebp8DRfosc67D+MONfSZgW//pV79Jjk1+ObqLDrIXY2tIbfOZq+WMJzvjIcBFKs 3z3+XW4KuZVDT/HyI19jyRbUNogX23l0/7jlnA02CLbDj9NxjC1z6UtkNAHJMewPIbvS GKJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=Rv070+Mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w21-20020a634755000000b0053b8874cee6si6637658pgk.358.2023.07.14.02.58.15; Fri, 14 Jul 2023 02:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=Rv070+Mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235978AbjGNJc1 (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Fri, 14 Jul 2023 05:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235922AbjGNJcH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 14 Jul 2023 05:32:07 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3719235A7; Fri, 14 Jul 2023 02:31:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id 6CA745BC42; Fri, 14 Jul 2023 09:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1689326065; bh=VAWao2XqqfaUrUG4eX38dF7EKCEUq2ZmTgp3mGFnUog=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Rv070+McVf53L+fSrNOclnynR56VOM4amtL7xuLQwcaK+e19Wsy1rNkvqbg6WcsiY 0MnUjP+vlKz8e6ztLv/VZ9thIOOFcPh0OWjANftlA2mnzK0dim3oF0fgNYG43698xB 2hdwNHSrKhAT/ten+6mJY64iGCuS7pi9/uEKjn1hjFJZSnfhXRZNDVOMVr91DxgTgi J0zWbSZ5CC8aYPK4M53RQmC7CirFTX2n9Tg6KW0Wujo0/4J7KIjn4pOV7Qtb/yJMH6 jcssZJ/U1sfZiokColgbsAoU+/s9Jf/eYAtM85nCAY7a0ZBn2JjFj9InCXH9KY+eOV 83Kma93HKnxpA== From: Asahi Lina <lina@asahilina.net> Date: Fri, 14 Jul 2023 18:13:55 +0900 Subject: [PATCH RFC 03/11] rust: Use absolute paths to build Rust objects MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230714-classless_lockdep-v1-3-229b9671ce31@asahilina.net> References: <20230714-classless_lockdep-v1-0-229b9671ce31@asahilina.net> In-Reply-To: <20230714-classless_lockdep-v1-0-229b9671ce31@asahilina.net> To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Benno Lossin <benno.lossin@proton.me>, Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, Tom Rix <trix@redhat.com>, Daniel Vetter <daniel@ffwll.ch> Cc: Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>, Alyssa Rosenzweig <alyssa@rosenzweig.io>, asahi@lists.linux.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, Asahi Lina <lina@asahilina.net> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1689326040; l=2695; i=lina@asahilina.net; s=20230221; h=from:subject:message-id; bh=VAWao2XqqfaUrUG4eX38dF7EKCEUq2ZmTgp3mGFnUog=; b=Mei8TIbhg8193HQ30Z4+6AvQI9I9bSJA87f41daFHByxLcwEs3OLPMiDdbvZqxkvrxSyz2Yw4 CfwDvXCA5JUDiUEQ/kiBq9bICTiHOt+It/8iffq7+3VXjaJJiug42AT X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=Qn8jZuOtR1m5GaiDfTrAoQ4NE1XoYVZ/wmt5YtXWFC4= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771389539686843552 X-GMAIL-MSGID: 1771389539686843552 |
Series |
rust: Implicit lock class creation & Arc Lockdep integration
|
|
Commit Message
Asahi Lina
July 14, 2023, 9:13 a.m. UTC
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 <lina@asahilina.net>
---
rust/Makefile | 2 +-
scripts/Makefile.build | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
Comments
On Fri, 14 Jul 2023 18:13:55 +0900 Asahi Lina <lina@asahilina.net> wrote: > 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. I wonder if this can have some reproducible build implications. We probably also need to use remap-path-prefix? > > Signed-off-by: Asahi Lina <lina@asahilina.net> > --- > rust/Makefile | 2 +- > scripts/Makefile.build | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/rust/Makefile b/rust/Makefile > index 7c9d9f11aec5..552f023099c8 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -369,7 +369,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L > --emit=dep-info=$(depfile) --emit=obj=$@ \ > --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ > --crate-type rlib -L$(objtree)/$(obj) \ > - --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ > + --crate-name $(patsubst %.o,%,$(notdir $@)) $(abspath $<) \ > $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) > > rust-analyzer: > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > index 6413342a03f4..c925b90ebd80 100644 > --- a/scripts/Makefile.build > +++ b/scripts/Makefile.build > @@ -283,27 +283,27 @@ rust_common_cmd = \ > # would not match each other. > > quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ > - cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< > + cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $(abspath $<) > > $(obj)/%.o: $(src)/%.rs FORCE > $(call if_changed_dep,rustc_o_rs) > > quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ > cmd_rustc_rsi_rs = \ > - $(rust_common_cmd) -Zunpretty=expanded $< >$@; \ > + $(rust_common_cmd) -Zunpretty=expanded $(abspath $<) >$@; \ > command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@ > > $(obj)/%.rsi: $(src)/%.rs FORCE > $(call if_changed_dep,rustc_rsi_rs) > > quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ > - cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $< > + cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $(abspath $<) > > $(obj)/%.s: $(src)/%.rs FORCE > $(call if_changed_dep,rustc_s_rs) > > quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ > - cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $< > + cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $(abspath $<) > > $(obj)/%.ll: $(src)/%.rs FORCE > $(call if_changed_dep,rustc_ll_rs) >
On 15/07/2023 23.35, Gary Guo wrote: > On Fri, 14 Jul 2023 18:13:55 +0900 > Asahi Lina <lina@asahilina.net> wrote: > >> 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. > > I wonder if this can have some reproducible build implications. We > probably also need to use remap-path-prefix? We already end up with absolute paths in objects anyway, just not consistently. If it were consistently relative paths that would be fine too, but it looks like Rust likes to internally absolute-ize some paths, that's why I wrote this patch to make it always like that. TIL about remap-path-prefix, that looks very useful! I'll give it a try. > >> >> Signed-off-by: Asahi Lina <lina@asahilina.net> >> --- >> rust/Makefile | 2 +- >> scripts/Makefile.build | 8 ++++---- >> 2 files changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/rust/Makefile b/rust/Makefile >> index 7c9d9f11aec5..552f023099c8 100644 >> --- a/rust/Makefile >> +++ b/rust/Makefile >> @@ -369,7 +369,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L >> --emit=dep-info=$(depfile) --emit=obj=$@ \ >> --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ >> --crate-type rlib -L$(objtree)/$(obj) \ >> - --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ >> + --crate-name $(patsubst %.o,%,$(notdir $@)) $(abspath $<) \ >> $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) >> >> rust-analyzer: >> diff --git a/scripts/Makefile.build b/scripts/Makefile.build >> index 6413342a03f4..c925b90ebd80 100644 >> --- a/scripts/Makefile.build >> +++ b/scripts/Makefile.build >> @@ -283,27 +283,27 @@ rust_common_cmd = \ >> # would not match each other. >> >> quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ >> - cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< >> + cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $(abspath $<) >> >> $(obj)/%.o: $(src)/%.rs FORCE >> $(call if_changed_dep,rustc_o_rs) >> >> quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ >> cmd_rustc_rsi_rs = \ >> - $(rust_common_cmd) -Zunpretty=expanded $< >$@; \ >> + $(rust_common_cmd) -Zunpretty=expanded $(abspath $<) >$@; \ >> command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@ >> >> $(obj)/%.rsi: $(src)/%.rs FORCE >> $(call if_changed_dep,rustc_rsi_rs) >> >> quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ >> - cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $< >> + cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $(abspath $<) >> >> $(obj)/%.s: $(src)/%.rs FORCE >> $(call if_changed_dep,rustc_s_rs) >> >> quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ >> - cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $< >> + cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $(abspath $<) >> >> $(obj)/%.ll: $(src)/%.rs FORCE >> $(call if_changed_dep,rustc_ll_rs) >> > > ~~ Lina
diff --git a/rust/Makefile b/rust/Makefile index 7c9d9f11aec5..552f023099c8 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -369,7 +369,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L --emit=dep-info=$(depfile) --emit=obj=$@ \ --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ --crate-type rlib -L$(objtree)/$(obj) \ - --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ + --crate-name $(patsubst %.o,%,$(notdir $@)) $(abspath $<) \ $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) rust-analyzer: diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 6413342a03f4..c925b90ebd80 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -283,27 +283,27 @@ rust_common_cmd = \ # would not match each other. quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ - cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< + cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $(abspath $<) $(obj)/%.o: $(src)/%.rs FORCE $(call if_changed_dep,rustc_o_rs) quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ cmd_rustc_rsi_rs = \ - $(rust_common_cmd) -Zunpretty=expanded $< >$@; \ + $(rust_common_cmd) -Zunpretty=expanded $(abspath $<) >$@; \ command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@ $(obj)/%.rsi: $(src)/%.rs FORCE $(call if_changed_dep,rustc_rsi_rs) quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ - cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $< + cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $(abspath $<) $(obj)/%.s: $(src)/%.rs FORCE $(call if_changed_dep,rustc_s_rs) quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ - cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $< + cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $(abspath $<) $(obj)/%.ll: $(src)/%.rs FORCE $(call if_changed_dep,rustc_ll_rs)