Rust 1.34.2 contig.toml 選項梳理

# Sample TOML configuration file for building Rust.
#
# To configure rustbuild, copy this file to the directory from which you will be
# running the build, and name it config.toml.
#
# All options are commented out by default in this file, and they're commented
# out with their default values. The build system by default looks for
# `config.toml` in the current directory of a build for build configuration, but
# a custom configuration file can also be specified with `--config` to the build
# system.

本文摘取config.toml.example中的注釋信息并進行說明皇帮,該文件中的所有選項都被注釋掉了,#后就是它們在不被指定時的默認(rèn)值蛋辈。

[llvm]

# =============================================================================
# Tweaking how LLVM is compiled
# =============================================================================

LLVM配置属拾。

enabled

# Indicates whether rustc will support compilation with LLVM
# note: rustc does not compile without LLVM at the moment
#enabled = true

指定rustc是否支持和LLVM一起編譯,目前Rust只能依賴于LLVM冷溶,因此該選項總是為true渐白。

optimize

# Indicates whether the LLVM build is a Release or Debug build
#optimize = true

指定LLVM的Release/Debug版本。

thin-lto

# Indicates whether LLVM should be built with ThinLTO. Note that this will
# only succeed if you use clang, lld, llvm-ar, and llvm-ranlib in your C/C++
# toolchain (see the `cc`, `cxx`, `linker`, `ar`, and `ranlib` options below).
# More info at: https://clang.llvm.org/docs/ThinLTO.html#clang-bootstrap
#thin-lto = false

當(dāng)編譯用的C/C++工具鏈為LLVM時逞频,可以指定ThinLTO(用于節(jié)約鏈接時優(yōu)化的時空開支)纯衍。

release-debuginfo

# Indicates whether an LLVM Release build should include debug info
#release-debuginfo = false

指定構(gòu)建的Release版LLVM是否帶有調(diào)試信息。

assertions

# Indicates whether the LLVM assertions are enabled or not
#assertions = false

指定是否在編譯時進行斷言檢查苗胀。

ccache

# Indicates whether ccache is used when building LLVM
#ccache = false
# or alternatively ...
#ccache = "/path/to/ccache"

指定是否使用ccache(compiler cache)襟诸,該工具可以將編譯結(jié)果緩存起來,下次編譯盡量使用先前的緩存以節(jié)省編譯時間基协。

version-check

# If an external LLVM root is specified, we automatically check the version by
# default to make sure it's within the range that we're expecting, but setting
# this flag will indicate that this version check should not be done.
#version-check = true

如果指定使用外部的LLVM歌亲,會核對其版本以確定是在可接受的范圍,該選項可關(guān)閉這一步驟澜驮。

static-libstdcpp

# Link libstdc++ statically into the librustc_llvm instead of relying on a
# dynamic version to be available.
#static-libstdcpp = false

指定libstdc++庫動態(tài)鏈接還是靜態(tài)鏈接到librustc_llvm中陷揪。

ninja

# Tell the LLVM build system to use Ninja instead of the platform default for
# the generated build system. This can sometimes be faster than make, for
# example.
#ninja = false

指定是否使用ninja工具(而非make)進行構(gòu)建。

targets

# LLVM targets to build support for.
# Note: this is NOT related to Rust compilation targets. However, as Rust is
# dependent on LLVM for code generation, turning targets off here WILL lead to
# the resulting rustc being unable to compile for the disabled architectures.
# Also worth pointing out is that, in case support for new targets are added to
# LLVM, enabling them here doesn't mean Rust is automatically gaining said
# support. You'll need to write a target specification at least, and most
# likely, teach rustc about the C ABI of the target. Get in touch with the
# Rust team and file an issue if you need assistance in porting!
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX;Hexagon"

指定LLVM支持的目標(biāo)平臺杂穷,得是Rust的超集悍缠。

experimental-targets

# LLVM experimental targets to build support for. These targets are specified in
# the same format as above, but since these targets are experimental, they are
# not built by default and the experimental Rust compilation targets that depend
# on them will not work unless the user opts in to building them. By default the
# `WebAssembly` and `RISCV` targets are enabled when compiling LLVM from scratch.
#experimental-targets = "WebAssembly;RISCV"

指定尚處在實驗階段的目標(biāo)平臺。

link-jobs

# Cap the number of parallel linker invocations when compiling LLVM.
# This can be useful when building LLVM with debug info, which significantly
# increases the size of binaries and consequently the memory required by
# each linker process.
# If absent or 0, linker invocations are treated like any other job and
# controlled by rustbuild's -j parameter.
#link-jobs = 0

指定鏈接線程數(shù)耐量,為0時跟隨Rust構(gòu)建的-j參數(shù)飞蚓。

link-shared

# When invoking `llvm-config` this configures whether the `--shared` argument is
# passed to prefer linking to shared libraries.
#link-shared = false

如果使用了llvm-config工具,該選項用于指定靜態(tài)鏈接還是動態(tài)鏈接拴鸵。

version-suffix

# When building llvm, this configures what is being appended to the version.
# If absent, we let the version as-is.
#version-suffix = "-rust"

指定所生成的LLVM版本的后綴玷坠。由于我們的目的是在Rust蜗搔,通常把LLVM視為中間產(chǎn)物,該選項所謂不大八堡。

clang-cl

# On MSVC you can compile LLVM with clang-cl, but the test suite doesn't pass
# with clang-cl, so this is special in that it only compiles LLVM with clang-cl
#clang-cl = '/path/to/clang-cl.exe'

MSVC專用樟凄,指定使用clang-cl編譯LLVM。

cflags兄渺、cxxflags缝龄、ldflags

# Pass extra compiler and linker flags to the LLVM CMake build.
#cflags = "-fextra-flag"
#cxxflags = "-fextra-flag"
#ldflags = "-Wl,extra-flag"

構(gòu)建LLVM時,傳給cmake的編譯和鏈接參數(shù)挂谍。

use-libcxx

# Use libc++ when building LLVM instead of libstdc++. This is the default on
# platforms already use libc++ as the default C++ library, but this option
# allows you to use libc++ even on platforms when it's not. You need to ensure
# that your host compiler ships with libc++.
#use-libcxx = true

指定使用libc++(LLVM的C++標(biāo)準(zhǔn)庫叔壤,支持C++11)代替libstdc++(gcc的C++標(biāo)準(zhǔn)庫)。

use-linker

# The value specified here will be passed as `-DLLVM_USE_LINKER` to CMake.
#use-linker = "lld"

指定LLVM的連接器口叙,作為-DLLVM_USE_LINKER參數(shù)傳給cmake炼绘。

[build]

# =============================================================================
# General build configuration options
# =============================================================================

構(gòu)建配置。

build

# Build triple for the original snapshot compiler. This must be a compiler that
# nightlies are already produced for. The current platform must be able to run
# binaries of this build triple and the nightly will be used to bootstrap the
# first compiler.
#build = "x86_64-unknown-linux-gnu"    # defaults to your host platform

構(gòu)建平臺妄田。

host

# In addition to the build triple, other triples to produce full compiler
# toolchains for. Each of these triples will be bootstrapped from the build
# triple and then will continue to bootstrap themselves. This platform must
# currently be able to run all of the triples provided here.
#host = ["x86_64-unknown-linux-gnu"]   # defaults to just the build triple

運行平臺俺亮。

target

# In addition to all host triples, other triples to produce the standard library
# for. Each host triple will be used to produce a copy of the standard library
# for each target triple.
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple

目標(biāo)平臺。

cargo

# Instead of downloading the src/stage0.txt version of Cargo specified, use
# this Cargo binary instead to build all Rust code
#cargo = "/path/to/bin/cargo"

指定構(gòu)建所用的cargo疟呐,構(gòu)建Rust 1.34.2所用的是cargo 0.34.0脚曾,可預(yù)先安裝到指定路徑,缺省時boostrap會默認(rèn)從官網(wǎng)下載并自動解壓到臨時目錄build/cache/2019-02-28中使用启具。

rustc

# Instead of downloading the src/stage0.txt version of the compiler
# specified, use this rustc binary instead as the stage0 snapshot compiler.
#rustc = "/path/to/bin/rustc"

指定構(gòu)建所用的rustc本讥,構(gòu)建Rust 1.34.2所用的是rustc 1.33.0,可預(yù)先安裝到指定路徑鲁冯,缺省時boostrap會默認(rèn)從官網(wǎng)下載并自動解壓到臨時目錄build/cache/2019-02-28中使用拷沸。

docs

# Flag to specify whether any documentation is built. If false, rustdoc and
# friends will still be compiled but they will not be used to generate any
# documentation.
#docs = true

指定是否生成文檔,如否薯演,可自行使用rustdoc工具按需生成堵漱。

compiler-docs

# Indicate whether the compiler should be documented in addition to the standard
# library and facade crates.
#compiler-docs = false

指定(除了庫之外)是否生成編譯器本身的文檔。

submodules

# Indicate whether submodules are managed and updated automatically.
#submodules = true

指定是否使用Git子模塊管理工具Submodules涣仿。當(dāng)ignore-git = false時,如果項目中沒有使用Submodules示惊,該選項需關(guān)閉好港。

fast-submodules

# Update submodules only when the checked out commit in the submodules differs
# from what is committed in the main rustc repo.
#fast-submodules = true

使用Submodules時,指定僅當(dāng)子模塊有提交時才進行更新米罚,提高效率钧汹。

gdb

# The path to (or name of) the GDB executable to use. This is only used for
# executing the debuginfo test suite.
#gdb = "gdb"

指定gdb路徑。

nodejs

# The node.js executable to use. Note that this is only used for the emscripten
# target when running tests, otherwise this can be omitted.
#nodejs = "node"

用于在構(gòu)建emscripten版本時指定nodejs录择。

python

# Python interpreter to use for various tasks throughout the build, notably
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
# Note that Python 2 is currently required.
#python = "python2.7"

指定bootstrap所用的python拔莱。

locked-deps

# Force Cargo to check that Cargo.lock describes the precise dependency
# set that all the Cargo.toml files create, instead of updating it.
#locked-deps = false

指定cargo是否檢查Cargo.lock碗降。

vendor

# Indicate whether the vendored sources are used for Rust dependencies or not
#vendor = false

指定是否使用源碼中攜帶的三方crate(位于vendor目錄),若否塘秦,bootstrap將從crates.io所需crate讼渊,速度比較慢,可在.cargo/config中配置鏡像站尊剔。

full-bootstrap

# Typically the build system will build the rust compiler twice. The second
# compiler, however, will simply use its own libraries to link against. If you
# would rather to perform a full bootstrap, compiling the compiler three times,
# then you can set this option to true. You shouldn't ever need to set this
# option to true.
#full-bootstrap = false

默認(rèn)的bootstrap只進行到stage2爪幻,該選項指定是否進行stage3。

extended

# Enable a build of the extended rust tool set which is not only the compiler
# but also tools such as Cargo. This will also produce "combined installers"
# which are used to install Rust and Cargo together. This is disabled by
# default.
#extended = false

指定是否生成除rustc外的其他工具须误,包括cargo挨稿、clippy、miri京痢、rls奶甘、rustdoc、rustfmt祭椰、rust-gdb臭家、rust-gdbgui、rust-lldb等吭产。雖然說明中特別指出可以生成combined installers(總安裝包)侣监,但實踐表明并不能。

tools

# Installs chosen set of extended tools if enables. By default builds all.
# If chosen tool failed to build the installation fails.
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"]

配合extended食用臣淤,指定要生成哪些工具橄霉,默認(rèn)生成全部。

verbose

# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
#verbose = 0

指定是否輸出詳細(xì)的構(gòu)建命令邑蒋。

sanitizers

# Build the sanitizer runtimes
#sanitizers = false

指定是否構(gòu)建內(nèi)存檢測工具集sanitizers姓蜂。

profiler

# Build the profiler runtime
#profiler = false

指定是否構(gòu)建優(yōu)化工具PGO

cargo-native-static

# Indicates whether the native libraries linked into Cargo will be statically
# linked or not.
#cargo-native-static = false

指定cargo的依賴庫是否靜態(tài)鏈接到cargo医吊。

low-priority

# Run the build with low priority, by setting the process group's "nice" value
# to +10 on Unix platforms, and by using a "low priority" job object on Windows.
#low-priority = false

指定是否降低構(gòu)建的優(yōu)先級钱慢,因為構(gòu)建一次很占系統(tǒng)資源。

configure-args

# Arguments passed to the `./configure` script, used during distcheck. You
# probably won't fill this in but rather it's filled in by the `./configure`
# script.
#configure-args = []

使用./configure自動生成config.toml時卿堂,這里存著該腳本收到的參數(shù)束莫,手動配置config.toml時不用管該選項。

local-rebuild

# Indicates that a local rebuild is occurring instead of a full bootstrap,
# essentially skipping stage0 as the local compiler is recompiling itself again.
#local-rebuild = false

指定是否為一次重新編譯草描,可以跳過stage0览绿。

print-step-timings

# Print out how long each rustbuild step took (mostly intended for CI and
# tracking over time)
#print-step-timings = false

指定是否輸出構(gòu)建過程中每一步的耗時。

[install]

# =============================================================================
# General install configuration options
# =============================================================================

安裝配置穗慕。

prefix饿敲、sysconfdir、docdir逛绵、bindir怀各、libdir倔韭、mandir、datadir瓢对、infodir寿酌、localstatedir

# Instead of installing to /usr/local, install to this path instead.
#prefix = "/usr/local"

# Where to install system configuration files
# If this is a relative path, it will get installed in `prefix` above
#sysconfdir = "/etc"

# Where to install documentation in `prefix` above
#docdir = "share/doc/rust"

# Where to install binaries in `prefix` above
#bindir = "bin"

# Where to install libraries in `prefix` above
#libdir = "lib"

# Where to install man pages in `prefix` above
#mandir = "share/man"

# Where to install data in `prefix` above (currently unused)
#datadir = "share"

# Where to install additional info in `prefix` above (currently unused)
#infodir = "share/info"

# Where to install local state (currently unused)
# If this is a relative path, it will get installed in `prefix` above
#localstatedir = "/var/lib"

指定安裝路徑。

[rust]

# =============================================================================
# Options for compiling Rust code itself
# =============================================================================

Rust編譯配置沥曹。

optimize

# Whether or not to optimize the compiler and standard library.
#
# Note: the slowness of the non optimized compiler compiling itself usually
#       outweighs the time gains in not doing optimizations, therefore a
#       full bootstrap takes much more time with `optimize` set to false.
#optimize = true

指定是否使用O2編譯份名。

debug

# Indicates that the build should be configured for debugging Rust. A
# `debug`-enabled compiler and standard library will be somewhat
# slower (due to e.g. checking of debug assertions) but should remain
# usable.
#
# Note: If this value is set to `true`, it will affect a number of
#       configuration options below as well, if they have been left
#       unconfigured in this file.
#
# Note: changes to the `debug` setting do *not* affect `optimize`
#       above. In theory, a "maximally debuggable" environment would
#       set `optimize` to `false` above to assist the introspection
#       facilities of debuggers like lldb and gdb. To recreate such an
#       environment, explicitly set `optimize` to `false` and `debug`
#       to `true`. In practice, everyone leaves `optimize` set to
#       `true`, because an unoptimized rustc with debugging
#       enabled becomes *unusably slow* (e.g. rust-lang/rust#24840
#       reported a 25x slowdown) and bootstrapping the supposed
#       "maximally debuggable" environment (notably libstd) takes
#       hours to build.
#
#debug = false

指定是否為debug版本。

codegen-units

# Number of codegen units to use for each compiler invocation. A value of 0
# means "the number of cores on this machine", and 1+ is passed through to the
# compiler.
#codegen-units = 1

指定二進制代碼生成階段的LLVM工作線程數(shù)妓美。按理說該選項能很大程度加快構(gòu)建速度僵腺,但實測效果并不明顯。

codegen-units-std

# Sets the number of codegen units to build the standard library with,
# regardless of what the codegen-unit setting for the rest of the compiler is.
#codegen-units-std = 1

std庫可獨立指定二進制代碼生成階段的LLVM工作線程數(shù)壶栋,該選項不允許為0辰如。

debug-assertions

# Whether or not debug assertions are enabled for the compiler and standard
# library.
#debug-assertions = false

指定是否啟用debug_assert!宏,在構(gòu)建過程中進行一些斷言檢查贵试。該宏在O0時默認(rèn)啟用琉兜,詳見src/libcore/macros.rs中的注釋:

/// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
/// optimized builds by default. An optimized build will omit all
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
/// compiler. This makes `debug_assert!` useful for checks that are too
/// expensive to be present in a release build but may be helpful during
/// development.

debuginfo、debuginfo-lines毙玻、debuginfo-only-std豌蟋、debuginfo-tools

# Whether or not debuginfo is emitted
#debuginfo = false

# Whether or not line number debug information is emitted
#debuginfo-lines = false

# Whether or not to only build debuginfo for the standard library if enabled.
# If enabled, this will not compile the compiler with debuginfo, just the
# standard library.
#debuginfo-only-std = false

# Enable debuginfo for the extended tools: cargo, rls, rustfmt
# Adding debuginfo makes them several times larger.
#debuginfo-tools = false

指定是否添加調(diào)試信息。

backtrace

# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
#backtrace = true

指定程序panic時是否打印回溯信息桑滩。配合debuginfo-lines=true食用更佳梧疲,以下摘自src/doc/rustc-guide/src/compiler-debugging.md

In the default configuration, you don't have line numbers enabled, so the
backtrace looks like this:

stack backtrace:
  0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
  1: std::sys_common::backtrace::_print
  2: std::panicking::default_hook::{{closure}}
  3: std::panicking::default_hook
  4: std::panicking::rust_panic_with_hook
  5: std::panicking::begin_panic
  (~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
 32: rustc_typeck::check_crate
 33: <std::thread::local::LocalKey<T>>::with
 34: <std::thread::local::LocalKey<T>>::with
 35: rustc::ty::context::TyCtxt::create_and_enter
 36: rustc_driver::driver::compile_input
 37: rustc_driver::run_compiler

If you want line numbers for the stack trace, you can enable
debuginfo-lines=true or debuginfo=true in your config.toml and rebuild the
compiler. Then the backtrace will look like this:

stack backtrace:
  (~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
            at /home/user/rust/src/librustc_typeck/check/cast.rs:110
  7: rustc_typeck::check::cast::CastCheck::check
            at /home/user/rust/src/librustc_typeck/check/cast.rs:572
            at /home/user/rust/src/librustc_typeck/check/cast.rs:460
            at /home/user/rust/src/librustc_typeck/check/cast.rs:370
  (~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
 33: rustc_driver::driver::compile_input
            at /home/user/rust/src/librustc_driver/driver.rs:1010
            at /home/user/rust/src/librustc_driver/driver.rs:212
 34: rustc_driver::run_compiler
            at /home/user/rust/src/librustc_driver/lib.rs:253

incremental

# Whether to always use incremental compilation when building rustc
#incremental = false

指定是否采用增量編譯。

parallel-compiler

# Build a multi-threaded rustc
#parallel-compiler = false

指定是否生成多線程rustc运准。

default-linker

# The default linker that will be hard-coded into the generated compiler for
# targets that don't specify linker explicitly in their target specifications.
# Note that this is not the linker used to link said compiler.
#default-linker = "cc"

指定內(nèi)嵌到編譯器中的默認(rèn)鏈接器幌氮,在不指定-C linker時使用。注意不是構(gòu)建編譯器本身時所用的鏈接器胁澳。

channel

# The "channel" for the Rust build to produce. The stable/beta channels only
# allow using stable features, whereas the nightly and dev channels allow using
# nightly features
#channel = "dev"

指定Rust的構(gòu)建版本该互,devnightlystable韭畸。由于源碼中許多特性需要nightly支持宇智,一般只在發(fā)布時指定為stable

rpath

# By default the `rustc` executable is built with `-Wl,-rpath` flags on Unix
# platforms to ensure that the compiler is usable by default from the build
# directory (as it links to a number of dynamic libraries). This may not be
# desired in distributions, for example.
#rpath = true

該選項通過-C link-args=-Wl,-rpath,$ORIGIN/../lib告知編譯器共享庫的搜索路徑(連接器ld通過-rpath設(shè)置運行時共享庫的搜索路徑)胰丁,使其可以直接在build目錄下運行普筹。

verbose-tests

# Emits extraneous output from tests to ensure that failures of the test
# harness are debuggable just from logfiles.
#verbose-tests = false

指定使用測試框架進行測試時是否輸出詳細(xì)信息。

optimize-tests隘马、debuginfo-tests

# Flag indicating whether tests are compiled with optimizations (the -O flag) or
# with debuginfo (the -g flag)
#optimize-tests = true
#debuginfo-tests = true

設(shè)置使用測試框架進行測試時的-O-g選項。

codegen-tests

# Flag indicating whether codegen tests will be run or not. If you get an error
# saying that the FileCheck executable is missing, you may want to disable this.
# Also see the target's llvm-filecheck option.
#codegen-tests = true

指定測試框架是否測試用于驗證LLVM的子集src/test/codegen妻顶。使用二進制LLVM時酸员,如果該選項打開(默認(rèn)就是打開)蜒车,需要指定llvm-filecheck

ignore-git

# Flag indicating whether git info will be retrieved from .git automatically.
# Having the git information can cause a lot of rebuilds during development.
# Note: If this attribute is not explicitly set (e.g. if left commented out) it
# will default to true if channel = "dev", but will default to false otherwise.
#ignore-git = true

指定是否忽略Git信息幔嗦。使用Git管理源碼時酿愧,打開該選項可在rustc -Vrustc -vV添加Git提交本版的哈希碼和日期。

dist-src

# When creating source tarballs whether or not to create a source tarball.
#dist-src = false

指定是否生成源碼tar包邀泉,需要交付源碼時才打開嬉挡。目前不清楚該選項在哪發(fā)揮作用,經(jīng)驗證./x.py dist受下面的src-tarball影響汇恤。

test-miri

# Whether to also run the Miri tests suite when running tests.
# As a side-effect also generates MIR for all libraries.
#test-miri = false

指定使用測試框架進行測試時是否測試miri(src/tools/miri/tests)庞钢,也可以使用./x.py test src/tools/miri單獨進行測試。

save-toolstates

# After building or testing extended tools (e.g. clippy and rustfmt), append the
# result (broken, compiling, testing) into this JSON file.
#save-toolstates = "/path/to/toolstates.json"

指定工具集構(gòu)建或測試結(jié)果的日志路徑因谎。

codegen-backends

# This is an array of the codegen backends that will be compiled for the rustc
# that's being compiled. The default is to only build the LLVM codegen backend,
# but you can also optionally enable the "emscripten" backend for asm.js or
# make this an empty array (but that probably won't get too far in the
# bootstrap)
#codegen-backends = ["llvm"]

指定編譯器后端基括,目前只能是LLVM。

codegen-backends-dir

# This is the name of the directory in which codegen backends will get installed
#codegen-backends-dir = "codegen-backends"

自定義后端目標(biāo)碼生成庫坐在的目錄名稱财岔,默認(rèn)為codegen-backendslib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so)风皿。

wasm-syscall

# Flag indicating whether `libstd` calls an imported function to handle basic IO
# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
# target, as without this option the test output will not be captured.
#wasm-syscall = false

WebAssembly專用。

lld

# Indicates whether LLD will be compiled and made available in the sysroot for
# rustc to execute.
#lld = false

指定是否構(gòu)建LLD匠璧。

llvm-tools

# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
# sysroot.
#llvm-tools = false

指定是否將生成的LLVM工具集添加至Rust的可執(zhí)行路徑桐款。

lldb

# Indicates whether LLDB will be made available in the sysroot.
# This is only built if LLVM is also being built.
#lldb = false

指定是否構(gòu)建LLDB

deny-warnings

# Whether to deny warnings in crates
#deny-warnings = true

指定是否禁用warning夷恍。

backtrace-on-ice

# Print backtrace on internal compiler errors during bootstrap
#backtrace-on-ice = false

指定bootstrap過程中遇到編譯器內(nèi)部錯誤時是否打印回溯信息魔眨。

verify-llvm-ir

# Whether to verify generated LLVM IR
#verify-llvm-ir = false

指定生成LLVM IR后是否進行確認(rèn)。

remap-debuginfo

# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
# generally only set for releases
#remap-debuginfo = false

重定向調(diào)試信息裁厅?

jemalloc

# Link the compiler against `jemalloc`, where on Linux and OSX it should
# override the default allocator for rustc and LLVM.
#jemalloc = false

指定是否使用jemalloc代替默認(rèn)的內(nèi)存分配器冰沙。

test-compare-mode

# Run tests in various test suites with the "nll compare mode" in addition to
# running the tests in normal mode. Largely only used on CI and during local
# development of NLL
#test-compare-mode = false

指定測試框架測試模式(常規(guī)或NLL),針對src/test/ui子集执虹,其部分用例有常規(guī)結(jié)果和NLL結(jié)果兩個stderr對比文件拓挥。

NLL是non-lexical lifetimes的意思,作為Rust編譯器的擴展特性(通過#![feature(nll)]開啟)袋励,意在優(yōu)化借用檢查侥啤。若無NLL,若某個變量被借用后又被更新會編譯不過茬故,開啟NLL后盖灸,編譯器能識別借用與更新并不沖突的情況而允許通過。

? [譯] Rust - None Lexical Lifetimes (NLL) 使用指南

Rust防范「內(nèi)存不安全」代碼的原則極其清晰明了磺芭。如果你對同一塊內(nèi)存存在多個引用赁炎,就不要試圖對這塊內(nèi)存做修改;如果你需要對一塊內(nèi)存做修改钾腺,就不要同時保留多個引用徙垫。只要保證了這個原則讥裤,我們就可以保證內(nèi)存安全。它在實踐中發(fā)揮了強大的作用姻报,可以幫助我們盡早發(fā)現(xiàn)問題己英。這個原則是Rust的立身之本、生命之基吴旋、活力之源损肛。

這個原則是沒問題的,但是荣瑟,初始的實現(xiàn)版本有一個主要問題治拿,那就是它讓借用指針的生命周期規(guī)則與普通對象的生命周期規(guī)則一樣,是按作用域來確定的褂傀。所有的變量忍啤、借用的生命周期就是從它的聲明開始,到當(dāng)前整個語句塊結(jié)束仙辟。這個設(shè)計被稱為Lexical Lifetime同波,因為生命周期是嚴(yán)格和詞法中的作用域范圍綁定的。這個策略實現(xiàn)起來非常簡單叠国,但它可能過于保守了未檩,某些情況下借用的范圍被過度拉長了,以至于某些實質(zhì)上是安全的代碼也被阻止了粟焊。在某些場景下冤狡,限制了程序員的發(fā)揮。

——《深入淺出Rust》

[target.x86_64-unknown-linux-gnu]

# =============================================================================
# Options for specific targets
#
# Each of the following options is scoped to the specific target triple in
# question and is used for determining how to compile each target.
# =============================================================================

目標(biāo)平臺配置项棠,可額外增加其他目標(biāo)平臺的配置悲雳。

cc、cxx香追、ar合瓢、ranlib、linker

# C compiler to be used to compiler C code. Note that the
# default value is platform specific, and if not specified it may also depend on
# what platform is crossing to what platform.
#cc = "cc"

# C++ compiler to be used to compiler C++ code (e.g. LLVM and our LLVM shims).
# This is only used for host targets.
#cxx = "c++"

# Archiver to be used to assemble static libraries compiled from C/C++ code.
# Note: an absolute path should be used, otherwise LLVM build will break.
#ar = "ar"

# Ranlib to be used to assemble static libraries compiled from C/C++ code.
# Note: an absolute path should be used, otherwise LLVM build will break.
#ranlib = "ranlib"

# Linker to be used to link Rust code. Note that the
# default value is platform specific, and if not specified it may also depend on
# what platform is crossing to what platform.
#linker = "cc"

編譯透典、鏈接工具晴楔。

llvm-config

# Path to the `llvm-config` binary of the installation of a custom LLVM to link
# against. Note that if this is specified we don't compile LLVM at all for this
# target.
#llvm-config = "../path/to/llvm/root/bin/llvm-config"

指定llvm-config工具的安裝路徑,該選項旨在使用現(xiàn)成的二進制LLVM峭咒,可省去編譯LLVM的時間税弃。debug-assertions打開時需配合llvm-filecheck選項食用。

使用現(xiàn)成LLVM時凑队,dist包中將不包含在src/bootstrap/lib.rs中指定的LLVM工具:

const LLVM_TOOLS: &[&str] = &[
    "llvm-nm", // used to inspect binaries; it shows symbol names, their sizes and visibility
    "llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume
    "llvm-objdump", // used to disassemble programs
    "llvm-profdata", // used to inspect and merge files generated by profiles
    "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide
    "llvm-size", // used to prints the size of the linker sections of a program
    "llvm-strip", // used to discard symbols from binary files to reduce their size
];

llvm-filecheck

# Normally the build system can find LLVM's FileCheck utility, but if
# not, you can specify an explicit file name for it.
#llvm-filecheck = "/path/to/FileCheck"

指定LLVM文件檢查工具FileCheck的路徑则果,與llvm-config位于同一目錄時無需指定。有趣的是,隨便給個叫FileCheck的文件就可以避免boostrap報找不到短条。

android-ndk

# If this target is for Android, this option will be required to specify where
# the NDK for the target lives. This is used to find the C compiler to link and
# build native code.
#android-ndk = "/path/to/ndk"

指定安卓開發(fā)套件NDK(Native Development Kit)的路徑导匣。

crt-static

# Force static or dynamic linkage of the standard library for this target. If
# this target is a host for rustc, this will also affect the linkage of the
# compiler itself. This is useful for building rustc on targets that normally
# only use static libraries. If unset, the target's default linkage is used.
#crt-static = false

指定目標(biāo)平臺的std庫是動態(tài)還是靜態(tài)鏈接。

musl-root

# The root location of the MUSL installation directory. The library directory
# will also need to contain libunwind.a for an unwinding implementation. Note
# that this option only makes sense for MUSL targets that produce statically
# linked binaries
#musl-root = "..."

MUSL專用茸时。

qemu-rootfs

# Used in testing for configuring where the QEMU images are located, you
# probably don't want to use this.
#qemu-rootfs = "..."

QEMU專用。

[dist]

# =============================================================================
# Distribution options
#
# These options are related to distribution, mostly for the Rust project itself.
# You probably won't need to concern yourself with any of these options
# =============================================================================

發(fā)布配置赋访。

sign-folder

# This is the folder of artifacts that the build system will sign. All files in
# this directory will be signed with the default gpg key using the system `gpg`
# binary. The `asc` and `sha256` files will all be output into the standard dist
# output folder (currently `build/dist`)
#
# This folder should be populated ahead of time before the build system is
# invoked.
#sign-folder = "path/to/folder/to/sign"

指定需要gpg加密的目錄可都。

gpg-password-file

# This is a file which contains the password of the default gpg key. This will
# be passed to `gpg` down the road when signing all files in `sign-folder`
# above. This should be stored in plaintext.
#gpg-password-file = "path/to/gpg/password"

指定gpg密鑰文件。

upload-addr

# The remote address that all artifacts will eventually be uploaded to. The
# build system generates manifests which will point to these urls, and for the
# manifests to be correct they'll have to have the right URLs encoded.
#
# Note that this address should not contain a trailing slash as file names will
# be appended to it.
#upload-addr = "https://example.com/folder"

指定線上發(fā)布的網(wǎng)址(上傳地址)蚓耽。

src-tarball

# Whether to build a plain source tarball to upload
# We disable that on Windows not to override the one already uploaded on S3
# as the one built on Windows will contain backslashes in paths causing problems
# on linux
#src-tarball = true

指定是否生成源碼tar包渠牲,需要交付源碼時才打開。

missing-tools

# Whether to allow failures when building tools
#missing-tools = false

指定構(gòu)建工具時是否允許出錯步悠。


2020年8月7日签杈、10~12日 無錫

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市鼎兽,隨后出現(xiàn)的幾起案子答姥,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,126評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異栓始,居然都是意外死亡蠢莺,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評論 2 382
  • 文/潘曉璐 我一進店門技俐,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事祈噪。” “怎么了尚辑?”我有些...
    開封第一講書人閱讀 152,445評論 0 341
  • 文/不壞的土叔 我叫張陵辑鲤,是天一觀的道長。 經(jīng)常有香客問我腌巾,道長遂填,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,185評論 1 278
  • 正文 為了忘掉前任澈蝙,我火速辦了婚禮吓坚,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘灯荧。我一直安慰自己礁击,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 64,178評論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著哆窿,像睡著了一般链烈。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上挚躯,一...
    開封第一講書人閱讀 48,970評論 1 284
  • 那天强衡,我揣著相機與錄音,去河邊找鬼码荔。 笑死漩勤,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的缩搅。 我是一名探鬼主播越败,決...
    沈念sama閱讀 38,276評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼硼瓣!你這毒婦竟也來了究飞?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,927評論 0 259
  • 序言:老撾萬榮一對情侶失蹤堂鲤,失蹤者是張志新(化名)和其女友劉穎亿傅,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體筑累,經(jīng)...
    沈念sama閱讀 43,400評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡袱蜡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 35,883評論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了慢宗。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片坪蚁。...
    茶點故事閱讀 37,997評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖镜沽,靈堂內(nèi)的尸體忽然破棺而出敏晤,到底是詐尸還是另有隱情,我是刑警寧澤缅茉,帶...
    沈念sama閱讀 33,646評論 4 322
  • 正文 年R本政府宣布嘴脾,位于F島的核電站,受9級特大地震影響蔬墩,放射性物質(zhì)發(fā)生泄漏译打。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,213評論 3 307
  • 文/蒙蒙 一拇颅、第九天 我趴在偏房一處隱蔽的房頂上張望奏司。 院中可真熱鬧,春花似錦樟插、人聲如沸韵洋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,204評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽搪缨。三九已至食拜,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間副编,已是汗流浹背负甸。 一陣腳步聲響...
    開封第一講書人閱讀 31,423評論 1 260
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留痹届,地道東北人惑惶。 一個月前我還...
    沈念sama閱讀 45,423評論 2 352
  • 正文 我出身青樓,卻偏偏與公主長得像短纵,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子僵控,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,722評論 2 345