From 961f49165a00098cc59750b785f9b78ed8c8b9a5 Mon Sep 17 00:00:00 2001 From: S John CD Date: Sun, 24 Dec 2023 23:24:06 +0000 Subject: [PATCH] imprpve compile speed in dev --- .cargo/config.toml | 137 ++++++++++++++++++++++++++++++++++++++- .devcontainer/Dockerfile | 2 +- justfile | 18 +++-- 3 files changed, 149 insertions(+), 8 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 851167e3..773a491a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,138 @@ +# Reference: https://doc.rust-lang.org/cargo/reference/config.html + +# paths = ["/path/to/override"] # path dependency overrides + +# [alias] # command aliases +# rr = "run --release" +# recursive_example = "rr --example recursions" +# space_example = ["run", "--release", "--", "\"command list\""] + [build] -#rustflags = ["-C", "link-arg=-fuse-ld=lld"] +# jobs = 1 # number of parallel jobs, defaults to # of CPUs +# rustc = "rustc" # the rust compiler tool +# rustc-wrapper = "…" # run this wrapper instead of `rustc` +# rustc-workspace-wrapper = "…" # run this wrapper instead of `rustc` for workspace members +# rustdoc = "rustdoc" # the doc generator tool +# target = "triple" # build for the target triple (ignored by `cargo install`) +# target-dir = "target" # path of where to place all generated artifacts target-dir="/cargo-target-rust_howto/target" +# rustflags = ["…", "…"] # custom flags to pass to all compiler invocations +# rustflags = ["-C", "link-arg=-fuse-ld=lld"] +# rustdocflags = ["…", "…"] # custom flags to pass to rustdoc +# incremental = true # whether or not to enable incremental compilation +# dep-info-basedir = "…" # path for the base directory for targets in depfiles + +# [doc] +# browser = "chromium" # browser to use with `cargo doc --open`, +# # overrides the `BROWSER` environment variable + +# [env] +# # Set ENV_VAR_NAME=value for any process run by Cargo +# ENV_VAR_NAME = "value" +# # Set even if already present in environment +# ENV_VAR_NAME_2 = { value = "value", force = true } +# # Value is relative to .cargo directory containing `config.toml`, make absolute +# ENV_VAR_NAME_3 = { value = "relative/path", relative = true } + +# [future-incompat-report] +# frequency = 'always' # when to display a notification about a future incompat report + +# [cargo-new] +# vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none') + +# [http] +# debug = false # HTTP debugging +# proxy = "host:port" # HTTP proxy in libcurl format +# ssl-version = "tlsv1.3" # TLS version to use +# ssl-version.max = "tlsv1.3" # maximum TLS version +# ssl-version.min = "tlsv1.1" # minimum TLS version +# timeout = 30 # timeout for each HTTP request, in seconds +# low-speed-limit = 10 # network timeout threshold (bytes/sec) +# cainfo = "cert.pem" # path to Certificate Authority (CA) bundle +# check-revoke = true # check for SSL certificate revocation +# multiplexing = true # HTTP/2 multiplexing +# user-agent = "…" # the user-agent header + +# [install] +# root = "/some/path" # `cargo install` destination directory + +# [net] +# retry = 3 # network retries +# git-fetch-with-cli = true # use the `git` executable for git operations +# offline = true # do not access the network + +# [net.ssh] +# known-hosts = ["..."] # known SSH host keys + +# [patch.] +# # Same keys as for [patch] in Cargo.toml + +# [profile.] # Modify profile settings via config. +# inherits = "dev" # Inherits settings from [profile.dev]. +# opt-level = 0 # Optimization level. +# debug = true # Include debug info. +# split-debuginfo = '...' # Debug info splitting behavior. +# debug-assertions = true # Enables debug assertions. +# overflow-checks = true # Enables runtime integer overflow checks. +# lto = false # Sets link-time optimization. +# panic = 'unwind' # The panic strategy. +# incremental = true # Incremental compilation. +# codegen-units = 16 # Number of code generation units. +# rpath = false # Sets the rpath linking option. +# strip = "none" # Removes symbols or debuginfo. +# [profile..build-override] # Overrides build-script settings. +# # Same keys for a normal profile. +# [profile..package.] # Override profile for a package. +# # Same keys for a normal profile (minus `panic`, `lto`, and `rpath`). + +# [registries.] # registries other than crates.io +# index = "…" # URL of the registry index +# token = "…" # authentication token for the registry + +# [registry] +# default = "…" # name of the default registry +# token = "…" # authentication token for crates.io + +# [source.] # source definition and replacement +# replace-with = "…" # replace this source with the given named source +# directory = "…" # path to a directory source +# registry = "…" # URL to a registry source +# local-registry = "…" # path to a local registry source +# git = "…" # URL of a git repository source +# branch = "…" # branch name for the git repository +# tag = "…" # tag name for the git repository +# rev = "…" # revision for the git repository + +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] + +## Another variant: +# [target.x86_64-unknown-linux-gnu] +# linker = "/usr/bin/clang" +# rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"] + +# [target.] +# linker = "…" # linker to use +# runner = "…" # wrapper to run executables +# rustflags = ["…", "…"] # custom flags for `rustc` + +# [target.] +# runner = "…" # wrapper to run executables +# rustflags = ["…", "…"] # custom flags for `rustc` + +# [target..] # `links` build script override +# rustc-link-lib = ["foo"] +# rustc-link-search = ["/path/to/foo"] +# rustc-flags = ["-L", "/some/path"] +# rustc-cfg = ['key="value"'] +# rustc-env = {key = "value"} +# rustc-cdylib-link-arg = ["…"] +# metadata_key1 = "value" +# metadata_key2 = "value" + +# [term] +# quiet = false # whether cargo output is quiet +# verbose = false # whether cargo provides verbose output +# color = 'auto' # whether cargo colorizes output +# progress.when = 'auto' # whether cargo shows progress bar +# progress.width = 80 # width of progress bar diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fee3fa24..1ca027d7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/devcontainers/rust:bookworm as final SHELL ["bash", "-c"] RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install wget fzf \ + && apt-get -y install wget fzf lld clang \ && apt-get autoremove -y && apt-get clean -y ## Install fmt and clippy diff --git a/justfile b/justfile index e6a5ce12..31386dd4 100644 --- a/justfile +++ b/justfile @@ -22,16 +22,10 @@ xclippy: # Check all projects in the xmpl folder (and all of their dependencies) for errors xcheck: for d in {{examples}}; do ( echo $d; cargo check --package $d ); done -# cargo check --workspace --all-targets --all-features # Compile all projects in the xmpl folder xbuild: for d in {{examples}}; do ( echo $d; cargo build --package $d ); done -# cargo build --workspace --all-targets --all-features - -# Test all projects -#xtest: -# cargo test --workspace --all-targets --all-features # Build the book from its markdown files (incl. testing of the examples embedded in the markdown) build: @@ -56,3 +50,15 @@ serve: # Update Cargo.lock dependencies for all projects (incl. dependencies used by the book and the xmpl folder) update: cargo update + +# Check all projects +checkall: + cargo check --workspace --all-targets --all-features + +# Build all projects +buildall: + cargo build --workspace --all-targets --all-features --timings + +# Test all projects +testall: + cargo test --workspace --all-targets --all-features