Skip to content

Commit

Permalink
chore: add parallel rust frontend and remove unused rust dependencies (
Browse files Browse the repository at this point in the history
…#7409)

### Description

Should improve compile times marginally, also added the new parallel
frontend.

Also includes some clippy fixes (`cargo-groups` seems to be broken).

`turbopack-cli`: 761 -> 719 compilation units
`turbo`: 574 -> 564 compilation units

Closes PACK-2525
  • Loading branch information
ForsakenHarmony committed Apr 9, 2024
1 parent 1bfe729 commit ac53aff
Show file tree
Hide file tree
Showing 74 changed files with 146 additions and 497 deletions.
19 changes: 10 additions & 9 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ CARGO_WORKSPACE_DIR = { value = "", relative = true }
TURBO_PNPM_WORKSPACE_DIR = { value = "", relative = true }

[build]
rustflags = ["--cfg", "tokio_unstable"]
rustflags = [
"--cfg",
"tokio_unstable",
"-Zshare-generics=y", # make the current crate share its generic instantiations
"-Zthreads=8", # parallel frontend https://blog.rust-lang.org/2023/11/09/parallel-rustc.html
"-Csymbol-mangling-version=v0",
]
rustdocflags = ["-Znormalize-docs"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"

[target.aarch64-apple-darwin]
linker = "rust-lld"

[alias]
xtask = "run --package xtask --"
tr-build = "build -p turbo"
Expand All @@ -21,11 +30,3 @@ tp-test = "nextest run --workspace --release --no-fail-fast --exclude turbo --ex
tp-bench-test = "test --benches --workspace --release --no-fail-fast --exclude turbopack-bench --exclude turbo --exclude turborepo-* --exclude turbopath --exclude wax --exclude globwalk --exclude globwatch --exclude pidlock"
tp-check = "check --workspace --exclude turbo --exclude turborepo-* --exclude turbopath --exclude wax --exclude globwalk --exclude globwatch --exclude pidlock"
tp-clippy = "clippy --workspace --exclude turbo --exclude turborepo-* --exclude turbopath --exclude wax --exclude globwalk --exclude globwatch --exclude pidlock"

[target.'cfg(all())']
rustflags = [
"--cfg",
"tokio_unstable",
"-Zshare-generics=y",
"-Csymbol-mangling-version=v0",
]
28 changes: 6 additions & 22 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ inputs:
targets:
description: "Comma-separated list of target triples to install for this toolchain"
required: false
components:
description: "Comma-separated list of components to be additionally installed"
required: false
github-token:
description: "GitHub token. You can pass secrets.GITHUB_TOKEN"
required: true
Expand All @@ -28,27 +25,14 @@ inputs:
runs:
using: "composite"
steps:
- name: "Get toolchain version from file"
id: file
shell: bash
run: echo "toolchain=$(cat ./rust-toolchain)" >> $GITHUB_OUTPUT

- name: "Set rust default environment"
shell: bash
run: |
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
# Enable faster sparse index on nightly
# https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862
echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV
- name: "Setup Rust toolchain"
uses: dtolnay/rust-toolchain@master
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.file.outputs.toolchain }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}
target: ${{ inputs.targets }}
# needed to not make it override the defaults
rustflags: ""
# we want more specific settings
cache: false

- name: "Set Windows default host to MinGW"
if: ${{ inputs.windows == 'true' }}
Expand Down
28 changes: 0 additions & 28 deletions .github/actions/setup-rust/matchers.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"problemMatcher": [
{
"owner": "cargo-common",
"pattern": [
{
"regexp": "^(warning|warn|error)(?:\\[(\\S*)\\])?: (.*)$",
"severity": 1,
"code": 2,
"message": 3
},
{
"regexp": "^(?:[\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 1,
"line": 2,
"column": 3
}
]
},
{
"owner": "cargo-test",
"pattern": [
Expand All @@ -28,17 +11,6 @@
"column": 4
}
]
},
{
"owner": "rustfmt",
"pattern": [
{
"regexp": "^(Diff in (\\S+)) at line (\\d+):",
"message": 1,
"file": 2,
"line": 3
}
]
}
]
}
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
components: rustfmt
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Run cargo fmt check
Expand Down Expand Up @@ -513,7 +512,6 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
components: clippy
targets: wasm32-unknown-unknown,wasm32-wasip1-threads

- name: Run cargo check release
Expand All @@ -539,7 +537,6 @@ jobs:
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
components: clippy
targets: wasm32-unknown-unknown
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
Loading

0 comments on commit ac53aff

Please sign in to comment.