rust-lang / rust-lang/rust

Too long compile time with implementing a trait function

Open
#129,776 4 comments 0 reactions 1 assignee View on GitHub

@dianqk is already working on this.

Since Sep 29, 2024.

A-LLVM C-bug I-compiletime T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I found that implementing a specific trait function causes too long compile time.

If there is expression function implementation at https://github.com/veryl-lang/veryl/blob/3516e3c73a62a9d74301336a4cf7d11013445e57/crates/emitter/src/emitter.rs#L984 , compilation time is 1600s.
And if the implmentation is commented out, compilation time is 5s.

If codegen-units = 1 is specified, there is no problem.

The reproduce way is here:

git clone https://github.com/veryl-lang/veryl -b v0.12.0
cd veryl
git submodule update --init
sed -i 's/codegen/#codegen/' Cargo.toml
rm ./crates/parser/build.rs

# remove `expression` function implementation
sed -i '984,992d' ./crates/emitter/src/emitter.rs

# compile dependencies at first
cargo build --release --manifest-path crates/emitter/Cargo.toml

# There is not `expression` function implementation
# about 5s
touch  ./crates/emitter/src/emitter.rs
time cargo build --release --manifest-path crates/emitter/Cargo.toml

# There is `expression` function implementation
# about 1600s
git checkout ./crates/emitter/src/emitter.rs
time cargo build --release --manifest-path crates/emitter/Cargo.toml
Meta

rustc --version --verbose:

rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7
Backtrace

<backtrace>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.