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中的注释信息并进行说明,该文件中的所有选项都被注释掉了,#后就是它们在不被指定时的默认值。

[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

当编译用的C/C++工具链为LLVM时,可以指定ThinLTO(用于节约链接时优化的时空开支)。

release-debuginfo

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

指定构建的Release版LLVM是否带有调试信息。

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),该工具可以将编译结果缓存起来,下次编译尽量使用先前的缓存以节省编译时间。

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,会核对其版本以确定是在可接受的范围,该选项可关闭这一步骤。

static-libstdcpp

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

指定libstdc++库动态链接还是静态链接到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)进行构建。

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支持的目标平台,得是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"

指定尚处在实验阶段的目标平台。

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

指定链接线程数,为0时跟随Rust构建的-j参数。

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工具,该选项用于指定静态链接还是动态链接。

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视为中间产物,该选项所谓不大。

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"

构建LLVM时,传给cmake的编译和链接参数。

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++标准库,支持C++11)代替libstdc++(gcc的C++标准库)。

use-linker

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

指定LLVM的连接器,作为-DLLVM_USE_LINKER参数传给cmake

[build]

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

构建配置。

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

构建平台。

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

目标平台。

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"

指定构建所用的cargo,构建Rust 1.34.2所用的是cargo 0.34.0,可预先安装到指定路径,缺省时boostrap会默认从官网下载并自动解压到临时目录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"

指定构建所用的rustc,构建Rust 1.34.2所用的是rustc 1.33.0,可预先安装到指定路径,缺省时boostrap会默认从官网下载并自动解压到临时目录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。当ignore-git = false时,如果项目中没有使用Submodules,该选项需关闭。

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时,指定仅当子模块有提交时才进行更新,提高效率。

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"

用于在构建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

默认的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食用,指定要生成哪些工具,默认生成全部。

verbose

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

指定是否输出详细的构建命令。

sanitizers

# Build the sanitizer runtimes
#sanitizers = false

指定是否构建内存检测工具集sanitizers

profiler

# Build the profiler runtime
#profiler = false

指定是否构建优化工具PGO

cargo-native-static

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

指定cargo的依赖库是否静态链接到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

指定是否降低构建的优先级,因为构建一次很占系统资源。

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时,这里存着该脚本收到的参数,手动配置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

指定是否输出构建过程中每一步的耗时。

[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工作线程数。按理说该选项能很大程度加快构建速度,但实测效果并不明显。

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工作线程数,该选项不允许为0。

debug-assertions

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

指定是否启用debug_assert!宏,在构建过程中进行一些断言检查。该宏在O0时默认启用,详见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

指定是否添加调试信息。

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"

指定内嵌到编译器中的默认链接器,在不指定-C linker时使用。注意不是构建编译器本身时所用的链接器。

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的构建版本,devnightlystable。由于源码中许多特性需要nightly支持,一般只在发布时指定为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设置运行时共享库的搜索路径),使其可以直接在build目录下运行。

verbose-tests

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

指定使用测试框架进行测试时是否输出详细信息。

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

设置使用测试框架进行测试时的-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时,如果该选项打开(默认就是打开),需要指定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包,需要交付源码时才打开。目前不清楚该选项在哪发挥作用,经验证./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"

指定工具集构建或测试结果的日志路径。

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"

自定义后端目标码生成库坐在的目录名称,默认为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

指定是否构建LLD

llvm-tools

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

指定是否将生成的LLVM工具集添加至Rust的可执行路径。

lldb

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

指定是否构建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过程中遇到编译器内部错误时是否打印回溯信息。

verify-llvm-ir

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

指定生成LLVM IR后是否进行确认。

remap-debuginfo

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

重定向调试信息?

jemalloc

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

指定是否使用jemalloc代替默认的内存分配器。

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

指定测试框架测试模式(常规或NLL),针对src/test/ui子集,其部分用例有常规结果和NLL结果两个stderr对比文件。

NLL是non-lexical lifetimes的意思,作为Rust编译器的扩展特性(通过#![feature(nll)]开启),意在优化借用检查。若无NLL,若某个变量被借用后又被更新会编译不过,开启NLL后,编译器能识别借用与更新并不冲突的情况而允许通过。

☞ [译] Rust - None Lexical Lifetimes (NLL) 使用指南

Rust防范「内存不安全」代码的原则极其清晰明了。如果你对同一块内存存在多个引用,就不要试图对这块内存做修改;如果你需要对一块内存做修改,就不要同时保留多个引用。只要保证了这个原则,我们就可以保证内存安全。它在实践中发挥了强大的作用,可以帮助我们尽早发现问题。这个原则是Rust的立身之本、生命之基、活力之源。

这个原则是没问题的,但是,初始的实现版本有一个主要问题,那就是它让借用指针的生命周期规则与普通对象的生命周期规则一样,是按作用域来确定的。所有的变量、借用的生命周期就是从它的声明开始,到当前整个语句块结束。这个设计被称为Lexical Lifetime,因为生命周期是严格和词法中的作用域范围绑定的。这个策略实现起来非常简单,但它可能过于保守了,某些情况下借用的范围被过度拉长了,以至于某些实质上是安全的代码也被阻止了。在某些场景下,限制了程序员的发挥。

——《深入浅出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.
# =============================================================================

目标平台配置,可额外增加其他目标平台的配置。

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工具的安装路径,该选项旨在使用现成的二进制LLVM,可省去编译LLVM的时间。debug-assertions打开时需配合llvm-filecheck选项食用。

使用现成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"

指定安卓开发套件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

指定目标平台的std库是动态还是静态链接。

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
# =============================================================================

发布配置。

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"

指定线上发布的网址(上传地址)。

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

指定构建工具时是否允许出错。


2020年8月7日、10~12日 无锡

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 162,050评论 4 370
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,538评论 1 306
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 111,673评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,622评论 0 218
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,047评论 3 295
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,974评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,129评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,893评论 0 209
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,654评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,828评论 2 254
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,297评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,619评论 3 262
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,326评论 3 243
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,176评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,975评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,118评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,909评论 2 278