Skip to content

Commit

Permalink
chore: remove unused rust dependencies (#62176)
Browse files Browse the repository at this point in the history
### What?

Toolchain is updated as well.

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

Depends on vercel/turborepo#7409

Closes PACK-2526
  • Loading branch information
ForsakenHarmony authored Apr 16, 2024
1 parent 2a1e170 commit ce69d02
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 342 deletions.
20 changes: 11 additions & 9 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
CARGO_WORKSPACE_DIR = { value = "", relative = true }

[build]

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 = []

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

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

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

Expand All @@ -27,11 +37,3 @@ rustflags = [

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.'cfg(all())']
rustflags = [
"--cfg",
"tokio_unstable",
"-Zshare-generics=y",
"-Csymbol-mangling-version=v0",
]
54 changes: 5 additions & 49 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,17 @@ 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
skip-install:
description: 'Sets environment variables without installing the rust toolchain'
required: false

runs:
using: 'composite'
steps:
- name: 'Get toolchain version from file'
id: file
shell: bash
run: echo "toolchain=$(cat ./rust-toolchain)" >> $GITHUB_OUTPUT

- shell: bash
run: |
: force toolchain version
echo "RUST_TOOLCHAIN=${{ steps.file.outputs.toolchain }}" >> $GITHUB_ENV
- shell: bash
run: |
: disable incremental compilation
if [ -z "${CARGO_INCREMENTAL+set}" ]; then
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable colors in Cargo output
if [ -z "${CARGO_TERM_COLOR+set}" ]; then
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable rust backtrace
if [ -z "${RUST_BACKTRACE+set}" ]; then
echo RUST_BACKTRACE=short >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable faster cargo sparse registry
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" ]; then
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
fi
- name: 'Setup Rust toolchain'
uses: dtolnay/rust-toolchain@master
if: ${{ !inputs.skip-install }}
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: ''
cache: false

- name: 'Add cargo problem matchers'
shell: bash
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ jobs:
set -e &&
apt update &&
apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup show &&
rustup target add x86_64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
unset CC_x86_64_unknown_linux_gnu && unset CC &&
Expand All @@ -177,8 +176,7 @@ jobs:
set -e &&
apk update &&
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup show &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
cd packages/next-swc && npm run build-native-release -- --target x86_64-unknown-linux-musl &&
Expand All @@ -197,8 +195,7 @@ jobs:
apt update &&
apt install -y pkg-config xz-utils dav1d libdav1d-dev &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup show &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
Expand All @@ -220,8 +217,7 @@ jobs:
apk add --no-cache libc6-compat pkgconfig dav1d libdav1d dav1d-dev &&
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup show &&
rustup target add aarch64-unknown-linux-musl &&
cd packages/next-swc && npm run build-native-release -- --target aarch64-unknown-linux-musl &&
llvm-strip -x native/next-swc.*.node
Expand Down Expand Up @@ -255,11 +251,11 @@ jobs:
check-latest: true
- run: corepack enable

# we always want to run this to set environment variables
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.settings.target }}
skip-install: ${{ matrix.settings.docker }}

- name: normalize versions
run: node scripts/normalize-version-bump.js
Expand Down Expand Up @@ -292,7 +288,7 @@ jobs:

- name: Build in docker
if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e RUST_TOOLCHAIN -e RUST_BACKTRACE -e NAPI_CLI_VERSION -e CARGO_TERM_COLOR -e CARGO_INCREMENTAL -e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL -e TURBO_API -e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_REMOTE_ONLY -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build --entrypoint=bash ${{ matrix.settings.docker }} -c "${{ matrix.settings.build }}"
run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e RUST_BACKTRACE -e NAPI_CLI_VERSION -e CARGO_TERM_COLOR -e CARGO_INCREMENTAL -e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL -e TURBO_API -e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_REMOTE_ONLY -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build --entrypoint=bash ${{ matrix.settings.docker }} -c "${{ matrix.settings.build }}"

- name: cache build
if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ jobs:
- name: Install Rust
uses: ./.github/actions/setup-rust
if: ${{ inputs.skipNativeBuild != 'yes' || inputs.needsNextest == 'yes' || inputs.needsRust == 'yes' }}
with:
components: rustfmt, clippy

- name: 'Install mold linker'
if: ${{ inputs.mold == 'yes' }}
Expand Down
Loading

0 comments on commit ce69d02

Please sign in to comment.