From e2d5f526480797f8f0a71e7e39ebd358832f6b66 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Fri, 17 May 2024 10:53:01 -0700 Subject: [PATCH 1/2] Switch from ld (the default linker) to using lld for GNU Linux targets Copies changes from https://github.com/vercel/turbo/pull/8166 --- .cargo/config.toml | 13 ++++++++++--- .github/actions/setup-rust/action.yml | 5 +++++ contributing/core/developing.md | 21 ++++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 954f1158bd388..57f77ab7c02c6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -22,11 +22,18 @@ rustflags = ["-C", "target-feature=+crt-static"] [target.aarch64-pc-windows-msvc] linker = "rust-lld" -[target.aarch64-apple-darwin] +[target.'cfg(target_os = "macos")'] linker = "rust-lld" -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" +[target.'cfg(all(target_os = "linux", target_env = "gnu"))'] +rustflags = [ + "--cfg", + "tokio_unstable", + "-Zshare-generics=y", + "-Zthreads=8", + "-Csymbol-mangling-version=v0", + "-Clink-arg=-fuse-ld=lld", +] [target.aarch64-unknown-linux-musl] linker = "aarch64-linux-musl-gcc" diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml index b64b23b584ced..aeac13a92142a 100644 --- a/.github/actions/setup-rust/action.yml +++ b/.github/actions/setup-rust/action.yml @@ -16,6 +16,11 @@ runs: rustflags: '' cache: false + - name: 'Install LLD (LLVM Linker) for Linux' + if: runner.os == 'Linux' + shell: bash + run: sudo apt-get -y update && sudo apt-get install -y lld + - name: 'Add cargo problem matchers' shell: bash run: echo "::add-matcher::${{ github.action_path }}/matchers.json" diff --git a/contributing/core/developing.md b/contributing/core/developing.md index 0d434024ca048..30a67aef03532 100644 --- a/contributing/core/developing.md +++ b/contributing/core/developing.md @@ -4,10 +4,21 @@ - All pull requests should be opened against `canary`. - The changes on the `canary` branch are published to the `@canary` tag on npm regularly. -To develop locally: +## Dependencies + +- Install Rust and Cargo via [rustup](https://rustup.rs). +- Install the [GitHub CLI](https://github.com/cli/cli#installation). +- Enable pnpm: + ``` + corepack enable pnpm + ``` +- (Linux) Install LLD, the LLVM linker: + ``` + sudo apt install lld + ``` + +## Local Development -1. Install Rust and Cargo via [rustup](https://rustup.rs). -1. Install the [GitHub CLI](https://github.com/cli/cli#installation). 1. Clone the Next.js repository (download only recent commits for faster clone): ``` gh repo clone vercel/next.js -- --filter=blob:none --branch canary --single-branch @@ -16,10 +27,6 @@ To develop locally: ``` git checkout -b MY_BRANCH_NAME origin/canary ``` -1. Enable pnpm: - ``` - corepack enable pnpm - ``` 1. Install the dependencies with: ``` pnpm install From 3d9a77f052d6a64cb90fc2fc08dffd375fa6f93f Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Mon, 5 Aug 2024 19:33:12 -0400 Subject: [PATCH 2/2] Use `-Clinker-flavor` instead --- .cargo/config.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 57f77ab7c02c6..22d6bc740f05c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -31,8 +31,10 @@ rustflags = [ "tokio_unstable", "-Zshare-generics=y", "-Zthreads=8", + "-Zunstable-options", "-Csymbol-mangling-version=v0", - "-Clink-arg=-fuse-ld=lld", + "-Clinker-flavor=gnu-lld-cc", + "-Clink-self-contained=+linker", ] [target.aarch64-unknown-linux-musl]