Skip to content

Remove #[macro_use] extern crate tracing from rustc_codegen_gcc.#129768

Closed
nnethercote wants to merge 1 commit into
rust-lang:masterfrom
nnethercote:rm-extern-crate-tracing-rustc_codegen_gcc
Closed

Remove #[macro_use] extern crate tracing from rustc_codegen_gcc.#129768
nnethercote wants to merge 1 commit into
rust-lang:masterfrom
nnethercote:rm-extern-crate-tracing-rustc_codegen_gcc

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

So that tracing is treated more like smallvec and tempfile, i.e. explicitly mentioned in the Cargo.toml file.

r? @antoyo

So that `tracing` is treated more like `smallvec` and `tempfile`, i.e.
explicitly mentioned in the `Cargo.toml` file.
@rustbot

rustbot commented Aug 30, 2024

Copy link
Copy Markdown
Collaborator

Failed to set assignee to antoyo: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 30, 2024
@rustbot

rustbot commented Aug 30, 2024

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@nnethercote

nnethercote commented Aug 30, 2024

Copy link
Copy Markdown
Contributor Author

Background: I have been removing extern crate tracing for all rustc_* crates, e.g. see #129767. I think it's reasonable to do the same for rustc_codegen_gcc? But I know it's a bit different to other crates (e.g. has its own Cargo.{toml,lock} files) so I'm not 100% sure about it.

@GuillaumeGomez

Copy link
Copy Markdown
Member

Looks good to me. I'll just wait for @antoyo to confirm before approving it.

@antoyo antoyo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against this change as this brings a number of unneeded dependencies.
If there's a way to not bring any new dependency, I would be OK with this.

@nnethercote

Copy link
Copy Markdown
Contributor Author

There is something going on that I don't understand here.

I tried making a trivial crate with this Cargo.toml:

[package]
name = "tracing-test"
version = "0.1.0"
edition = "2021"

[dependencies]
tracing = "0.1"

and this src/main.rs:

#[macro_use]
extern crate tracing;

fn main() {
    info!("Hello, world!");
}

and the Cargo.lock file gets all those dependencies like tracing, pin-project-lite, quote, etc. If I remove tracing from the Cargo.toml it doesn't compile, unsurprisingly.

How does the #[macro_use] extern crate tracing work in the rustc_codegen_gcc case? How does it let tracing macros be used seemingly without introducing dependencies on tracing and its dependent crates?

@antoyo

antoyo commented Aug 30, 2024

Copy link
Copy Markdown
Contributor

Maybe this crate is provided the same way as the other rustc crates like rustc_apfloat, rustc_ast, rustc_hir, …?
I don't know how this work, though.

@nnethercote

Copy link
Copy Markdown
Contributor Author

I asked on Zulip, it comes from the sysroot. Any crate used elsewhere in rustc can be used via extern crate. Which means we can actually use extern crate with more crates and shrink Cargo.lock. I filed #129876 to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants