2021-02-22 08:42:19 +00:00
# Add the contents of this file to `config.toml` to enable "fast build" configuration. Please read the notes below.
2020-06-08 06:35:40 +00:00
# NOTE: For maximum performance, build using a nightly compiler
2021-04-27 00:46:41 +00:00
# If you are using rust stable, remove the "-Zshare-generics=y" below.
2020-06-08 06:35:40 +00:00
2020-01-21 11:11:16 +00:00
[ target . x86_64-unknown-linux-gnu ]
Documentation: simplify NixOS dependencies (#3527)
# Objective
The description of NixOS dependencies is extremely long and spends entire paragraphs just for simple line changes.
With this PR it should be much simpler.
## Solution
- Linking Vulkan in `build.rs` is less effective than adding it in LD_LIBRARY_PATH, so I removed the former (related to #1992);
- I put a simple comment explaining the line in the list of dependencies, instead of making entire paragraphs;
- Clang is not in an absolute path in `.cargo/config_fast_builds` anymore, so that there is no need to specify it in `docs/linux_dependencies.md` (didn't test if this breaks other distros, though I doubt it. Also, maybe it could also be done on Darwin for consistency?);
- Also added optional wayland dependencies.
A few notes:
- The x11 libraries will be linked only during the compilation phase. This means that if you use the `x11` feature without these libraries in the environment (for example because you forget to enter the nix shell before compiling), the program will still compile successfully but won't run. You'll have to `cargo clean` and recompile with the x11 libraries in the environment. I don't know if this is important enough to be added to the documentation, but it's not specified anywhere, though I don't think it's specific to NixOS;
- The wayland dependencies need to be put in LD_LIBRARY_PATH only in certain conditions (IIRC, only if using the `dynamic` feature) and the text doesn't specify it. Because putting them there doesn't increase the number of dependencies (they are already in buildInputs) or alter the performance, I doubt anyone will care;
- Should I comment out what isn't needed by default?
- ~I removed `cargo` from buildInputs. Ignoring the fact that it should be in nativeBuildInputs, having it in `shell.nix` allows to use stable Rust in case it's not in the system environment, but maybe the user wanted to use the version that was already in the system environment and will be caught by surprise. In my opinion, if someone is looking at a Bevy's documentation on NixOS, that user will either have Rust already in the system environment (eg. via rustup) or is capable to add the toolchain they want on shell.nix by themselves. This isn't exactly the place to explain how this works.~ ~EDIT: I replaced `cargo` with Rust from the [Oxalica overlay](https://github.com/oxalica/rust-overlay) in order to have the latest nightly.~ EDIT: Removed `cargo` from dependencies. See comments for details.
2022-01-10 17:05:13 +00:00
linker = "clang"
2024-01-25 19:07:51 +00:00
rustflags = [
"-Clink-arg=-fuse-ld=lld" , # Use LLD Linker
"-Zshare-generics=y" , # (Nightly) Make the current crate share its generic instantiations
2024-01-29 23:13:22 +00:00
"-Zthreads=0" , # (Nightly) Use improved multithreading with the recommended amount of threads.
2024-01-25 19:07:51 +00:00
]
2020-06-01 06:18:24 +00:00
2023-02-06 18:24:12 +00:00
# NOTE: you must install [Mach-O LLD Port](https://lld.llvm.org/MachO/index.html) on mac. you can easily do this by installing llvm which includes lld with the "brew" package manager:
# `brew install llvm`
2020-06-08 06:35:40 +00:00
[ target . x86_64-apple-darwin ]
2023-02-06 18:24:12 +00:00
rustflags = [
2024-01-25 19:07:51 +00:00
"-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld" , # Use LLD Linker
"-Zshare-generics=y" , # (Nightly) Make the current crate share its generic instantiations
2024-01-29 23:13:22 +00:00
"-Zthreads=0" , # (Nightly) Use improved multithreading with the recommended amount of threads.
2023-02-06 18:24:12 +00:00
]
2020-06-08 06:35:40 +00:00
2021-08-30 21:56:12 +00:00
[ target . aarch64-apple-darwin ]
2023-02-06 18:24:12 +00:00
rustflags = [
2024-01-25 19:07:51 +00:00
"-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld" , # Use LLD Linker
"-Zshare-generics=y" , # (Nightly) Make the current crate share its generic instantiations
2024-01-29 23:13:22 +00:00
"-Zthreads=0" , # (Nightly) Use improved multithreading with the recommended amount of threads.
2023-02-06 18:24:12 +00:00
]
2021-08-30 21:56:12 +00:00
2020-06-01 06:18:24 +00:00
[ target . x86_64-pc-windows-msvc ]
2024-01-29 23:13:22 +00:00
linker = "rust-lld.exe" # Use LLD Linker
rustflags = [
"-Zshare-generics=n" ,
"-Zthreads=0" , # (Nightly) Use improved multithreading with the recommended amount of threads.
]
2020-09-04 21:09:20 +00:00
# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
#[profile.dev]
2020-09-08 01:32:08 +00:00
#debug = 1