|
| 1 | +# Copy this file to `config.toml` to speed up your builds. |
| 2 | +# |
| 3 | +# # Faster linker |
| 4 | +# |
| 5 | +# One of the slowest aspects of compiling large Rust programs is the linking time. This file configures an |
| 6 | +# alternate linker that may improve build times. When choosing a new linker, you have two options: |
| 7 | +# |
| 8 | +# ## LLD |
| 9 | +# |
| 10 | +# LLD is a linker from the LLVM project that supports Linux, Windows, macOS, and Wasm. It has the greatest |
| 11 | +# platform support and the easiest installation process. It is enabled by default in this file for Windows. |
| 12 | +# LLD is the default linker in Rust itself for Linux, so no configuration is needed. |
| 13 | +# On macOS, the default linker yields higher performance than LLD and is used instead. |
| 14 | +# |
| 15 | +# To install, please scroll to the corresponding table for your target (eg. `[target.x86_64-pc-windows-msvc]` |
| 16 | +# for Windows) and follow the steps under `LLD linker`. |
| 17 | +# |
| 18 | +# For more information, please see LLD's website at <https://lld.llvm.org>. |
| 19 | +# |
| 20 | +# ## Mold |
| 21 | +# |
| 22 | +# Mold is a newer linker written by one of the authors of LLD. It boasts even greater performance, specifically |
| 23 | +# through its high parallelism, though it only supports Linux. |
| 24 | +# |
| 25 | +# Mold is disabled by default in this file. If you wish to enable it, follow the installation instructions for |
| 26 | +# your corresponding target, disable LLD by commenting out its `-Clink-arg=...` line (not applicable for Linux anymore), |
| 27 | +# and enable Mold by *uncommenting* its `-Clink-arg=...` line. |
| 28 | +# |
| 29 | +# There is a fork of Mold named Sold that supports macOS, but it is unmaintained and is about the same speed as |
| 30 | +# the default ld64 linker. For this reason, it is not included in this file. |
| 31 | +# |
| 32 | +# For more information, please see Mold's repository at <https://github.com/rui314/mold>. |
| 33 | +# |
| 34 | +# # Nightly configuration |
| 35 | +# |
| 36 | +# Be warned that the following features require nightly Rust, which is experimental and may contain bugs. If you |
| 37 | +# are having issues, skip this section and use stable Rust instead. |
| 38 | +# |
| 39 | +# There are a few unstable features that can improve performance. To use them, first install nightly Rust |
| 40 | +# through Rustup: |
| 41 | +# |
| 42 | +# ``` |
| 43 | +# rustup toolchain install nightly |
| 44 | +# ``` |
| 45 | +# |
| 46 | +# Finally, uncomment the lines under the `Nightly` heading for your corresponding target table (eg. |
| 47 | +# `[target.x86_64-unknown-linux-gnu]` for Linux) to enable the following features: |
| 48 | +# |
| 49 | +# ## `share-generics` |
| 50 | +# |
| 51 | +# Usually rustc builds each crate separately, then combines them all together at the end. `share-generics` forces |
| 52 | +# crates to share monomorphized generic code, so they do not duplicate work. |
| 53 | +# |
| 54 | +# In other words, instead of crate 1 generating `Foo<String>` and crate 2 generating `Foo<String>` separately, |
| 55 | +# only one crate generates `Foo<String>` and the other adds on to the pre-existing work. |
| 56 | +# |
| 57 | +# Note that you may have some issues with this flag on Windows. If compiling fails due to the 65k symbol limit, |
| 58 | +# you may have to disable this setting. For more information and possible solutions to this error, see |
| 59 | +# <https://github.com/bevyengine/bevy/issues/1110>. |
| 60 | +# |
| 61 | +# ## `threads` |
| 62 | +# |
| 63 | +# This option enables rustc's parallel frontend, which improves performance when parsing, type checking, borrow |
| 64 | +# checking, and more. We currently set `threads=0`, which defaults to the amount of cores in your CPU. |
| 65 | +# |
| 66 | +# For more information, see the blog post at <https://blog.rust-lang.org/2023/11/09/parallel-rustc.html>. |
| 67 | + |
1 | 68 | [target.x86_64-unknown-linux-gnu] |
2 | | -linker = "clang" |
3 | | -rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold", "-Zshare-generics=y"] |
| 69 | +rustflags = [ |
| 70 | + # Mold linker |
| 71 | + # |
| 72 | + # You may need to install it: |
| 73 | + # |
| 74 | + # - Ubuntu: `sudo apt-get install mold clang` |
| 75 | + # - Fedora: `sudo dnf install mold clang` |
| 76 | + # - Arch: `sudo pacman -S mold clang` |
| 77 | + "-Clink-arg=-fuse-ld=mold", |
| 78 | + |
| 79 | + # Nightly |
| 80 | + "-Zshare-generics=y", |
| 81 | + "-Zthreads=0", |
| 82 | +] |
| 83 | +# Some systems may experience linker performance issues when running doc tests. |
| 84 | +# See https://github.com/bevyengine/bevy/issues/12207 for details. |
| 85 | +rustdocflags = [ |
| 86 | + # Mold linker |
| 87 | + "-Clink-arg=-fuse-ld=mold", |
| 88 | +] |
| 89 | + |
| 90 | +[target.x86_64-apple-darwin] |
| 91 | +rustflags = [ |
| 92 | + # LLD linker |
| 93 | + # |
| 94 | + # The default ld64 linker is faster, you should continue using it instead. |
| 95 | + # |
| 96 | + # You may need to install it: |
| 97 | + # |
| 98 | + # Brew: `brew install llvm` |
| 99 | + # Manually: <https://lld.llvm.org/MachO/index.html> |
| 100 | + # "-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld", |
| 101 | + |
| 102 | + # Nightly |
| 103 | + # "-Zshare-generics=y", |
| 104 | + # "-Zthreads=0", |
| 105 | +] |
| 106 | + |
| 107 | +[target.aarch64-apple-darwin] |
| 108 | +rustflags = [ |
| 109 | + # LLD linker |
| 110 | + # |
| 111 | + # The default ld64 linker is faster, you should continue using it instead. |
| 112 | + # |
| 113 | + # You may need to install it: |
| 114 | + # |
| 115 | + # Brew: `brew install llvm` |
| 116 | + # Manually: <https://lld.llvm.org/MachO/index.html> |
| 117 | + # "-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld", |
4 | 118 |
|
5 | | -[unstable] |
6 | | -codegen-backend = true |
| 119 | + # Nightly |
| 120 | + # "-Zshare-generics=y", |
| 121 | + # "-Zthreads=0", |
| 122 | +] |
7 | 123 |
|
8 | | -[profile.dev] |
9 | | -codegen-backend = "cranelift" |
| 124 | +[target.x86_64-pc-windows-msvc] |
| 125 | +# LLD linker |
| 126 | +# |
| 127 | +# You may need to install it: |
| 128 | +# |
| 129 | +# ``` |
| 130 | +# cargo install -f cargo-binutils |
| 131 | +# rustup component add llvm-tools |
| 132 | +# ``` |
| 133 | +linker = "rust-lld.exe" |
| 134 | +rustdocflags = ["-Clinker=rust-lld.exe"] |
| 135 | +rustflags = [ |
| 136 | + # Nightly |
| 137 | + # "-Zshare-generics=n", # This needs to be off if you use dynamic linking on Windows. |
| 138 | + # "-Zthreads=0", |
| 139 | +] |
10 | 140 |
|
11 | | -[profile.dev.package."*"] |
12 | | -codegen-backend = "llvm" |
| 141 | +# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'. |
| 142 | +# In most cases the gains are negligible, but if you are on macOS and have slow compile times you should see significant gains. |
| 143 | +# [profile.dev] |
| 144 | +# debug = 1 |
0 commit comments