Bug 1537643 - update cc crate; r=glandium

This update from the official sources brings in the changes that we were
using glandium's fork for, as well as changes enabling us to tweak more
settings on Windows.

Differential Revision: https://phabricator.services.mozilla.com/D25888

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-04-03 00:06:04 +00:00
Родитель 1916bd6570
Коммит 7eee5d9139
14 изменённых файлов: 606 добавлений и 453 удалений

Просмотреть файл

@ -17,11 +17,6 @@ git = "https://github.com/froydnj/winapi-rs"
branch = "aarch64"
replace-with = "vendored-sources"
[source."https://github.com/alexcrichton/cc-rs"]
git = "https://github.com/glandium/cc-rs"
branch = "1.0.23-clang-cl-aarch64"
replace-with = "vendored-sources"
[source."https://github.com/rust-lang-nursery/packed_simd"]
git = "https://github.com/hsivonen/packed_simd"
branch = "rust_1_32"

22
Cargo.lock сгенерированный
Просмотреть файл

@ -1,5 +1,3 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "Inflector"
version = "0.11.2"
@ -90,7 +88,7 @@ version = "0.2.4"
dependencies = [
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"cubeb 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
@ -157,7 +155,7 @@ name = "backtrace-sys"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -415,7 +413,7 @@ name = "bzip2-sys"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -426,8 +424,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
version = "1.0.23"
source = "git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64#2aa71628b1261b5515bd8668afca591669ba195d"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cert_storage"
@ -497,7 +495,7 @@ name = "cmake"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1576,7 +1574,7 @@ name = "libloading"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
]
@ -1628,7 +1626,7 @@ name = "lmdb-rkv-sys"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1744,7 +1742,7 @@ name = "miniz_oxide_c_api"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
"crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz_oxide 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3545,7 +3543,7 @@ dependencies = [
"checksum bzip2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3eafc42c44e0d827de6b1c131175098fe7fb53b8ce8a47e65cb3ea94688be24"
"checksum bzip2-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2c5162604199bbb17690ede847eaa6120a3f33d5ab4dcc8e7c25b16d849ae79b"
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
"checksum cc 1.0.23 (git+https://github.com/glandium/cc-rs?branch=1.0.23-clang-cl-aarch64)" = "<none>"
"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd"
"checksum cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc0086be9ca82f7fc89fc873435531cb898b86e850005850de1f820e2db6e9b"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"

Просмотреть файл

@ -60,6 +60,5 @@ codegen-units = 1
libudev-sys = { path = "dom/webauthn/libudev-sys" }
serde_derive = { git = "https://github.com/servo/serde", branch = "deserialize_from_enums9" }
winapi = { git = "https://github.com/froydnj/winapi-rs", branch = "aarch64" }
cc = { git = "https://github.com/glandium/cc-rs", branch = "1.0.23-clang-cl-aarch64" }
packed_simd = { git = "https://github.com/hsivonen/packed_simd", branch = "rust_1_32" }
target-lexicon = { git = "https://github.com/glandium/target-lexicon", branch = "thumbv7neon-v0.2" }

2
third_party/rust/cc/.cargo-checksum.json поставляемый
Просмотреть файл

@ -1 +1 @@
{"files":{".travis.yml":"7b18272b20d4b58996deb3e2d5d76f15a27d6a63a061abeefb6553a2b8650736","Cargo.toml":"45aa71f2057dae228d798a6c696576ade44cdd3ec75163b6f95deed4a728bd31","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3eeb4b0488908876c439a87cfe2bec6d550b37388993b2d8863fb1c587a84f46","appveyor.yml":"ab45bfdcf2596f357225a54e730c34d518a8f3ad56c2ed33af682cfd45bddc02","src/bin/gcc-shim.rs":"d6be9137cb48b86891e7b263adbf492e1193ffe682db9ba4a88eb1079b874b58","src/com.rs":"8b9a54af5400c259f877126cc68ea63ada4fe66e84c9b840711c95e570b15774","src/lib.rs":"6e2019557cc4effaaf5f4715f89f6e77fe4796946bce6f767d4d735dc539a934","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"f5c45afc99ad3b7c1311242bc4baf37e861d740ab81bf6ca90e2aa283672e65a","src/winapi.rs":"d7929b36130e33f1caa6bd444b378b83023b2b82d589c6e0ab38c4ff6c950da8","src/windows_registry.rs":"e31ce7a3273d67f99387edf28c5a9b4d6efab8f03fe446079c2b1ede6a21ffdb","tests/cc_env.rs":"bf7b14aa52af04294f648b2934f0f1830c5a0bdac1676310b8aa1f61458e7782","tests/support/mod.rs":"80dc87e54025197104cfb62d1af7a3400a3a0ddf0f2d98ea4ef4111cb1f0c890","tests/test.rs":"653b7d9ad6503aaf2ffc6c9b86014dbad456b53bcd124c9de4714067f49e5095"},"package":null}
{"files":{"Cargo.toml":"13b4fcd3d3f5fa9fa28c6714fe82f142f366c8f2a30a218ef6c1128ec20c31bc","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"190336dc7613f3b991580c39170b72967cafbd4c2d96ca2681249a8d5df2b1af","azure-pipelines.yml":"bb1c0c4147eeff07ddf230ca7535cd15a8acd05f8d431bf90988cd0647bb0775","ci/azure-install-rust.yml":"358198fb3cb23dd145434f777edde39c652ae390a5d64caf634a00dd78007286","ci/azure-steps.yml":"34b8c5dfab1c0a298b0a71e14daf15b82af07e2fb8d85684c4ccbf9f7f95ffb8","src/bin/gcc-shim.rs":"d6be9137cb48b86891e7b263adbf492e1193ffe682db9ba4a88eb1079b874b58","src/com.rs":"8b9a54af5400c259f877126cc68ea63ada4fe66e84c9b840711c95e570b15774","src/lib.rs":"6217a06cc91af81df4affa92d78619fbaa3f57ffe5b7780d19373a9353a60415","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"f5c45afc99ad3b7c1311242bc4baf37e861d740ab81bf6ca90e2aa283672e65a","src/winapi.rs":"d7929b36130e33f1caa6bd444b378b83023b2b82d589c6e0ab38c4ff6c950da8","src/windows_registry.rs":"8671c26da1e0f206fc1ef48d42a4ffe95dc93575093ee2b23e112be996a02b66","tests/cc_env.rs":"bf7b14aa52af04294f648b2934f0f1830c5a0bdac1676310b8aa1f61458e7782","tests/support/mod.rs":"80dc87e54025197104cfb62d1af7a3400a3a0ddf0f2d98ea4ef4111cb1f0c890","tests/test.rs":"d839b2bcdb367180e537c0d26cb2d918d5ddfc587801c7051f4955d25688ea7d"},"package":"30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd"}

64
third_party/rust/cc/.travis.yml поставляемый
Просмотреть файл

@ -1,64 +0,0 @@
language: rust
sudo: false
matrix:
include:
- rust: 1.16.0
install:
script: cargo build
- rust: stable
env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- rust: stable
env: TARGET=i686-unknown-linux-gnu
- os: osx
env: TARGET=x86_64-apple-darwin NO_ADD=1
- os: osx
env: TARGET=aarch64-apple-ios NO_RUN=--no-run TARGET_SYSROOT=$(xcrun -sdk iphoneos --show-sdk-path)
- rust: beta
env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- rust: nightly
env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
- rust: nightly
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
install:
script:
- cargo doc --no-deps --all-features
after_success:
- travis-cargo --only nightly doc-upload
install:
- if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi
script:
- cargo build --verbose
# FIXME: no idea why `--test-threads=1` is required on the OSX builder, it
# just randomly broke one day when the travis image was upgraded, and
# debugging turned up no easily found source of bugs...
#
# good build - https://travis-ci.org/alexcrichton/cc-rs/builds/409602374
# bad build - https://travis-ci.org/alexcrichton/cc-rs/builds/410489079
#
# Those are using the same compiler, same commit, same... everything. Except
# the OSX image! No idea what changed...
- cargo test --verbose $NO_RUN -- --test-threads=1
- cargo test --verbose --features parallel $NO_RUN -- --test-threads=1
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET $NO_RUN
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET --features parallel $NO_RUN
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET --release $NO_RUN
- cargo doc
- cargo clean && cargo build
- rustdoc --test README.md -L target/debug -L target/debug/deps
env:
global:
secure: "CBtqrudgE0PS8x3kTr44jKbC2D4nfnmdYVecooNm0qnER4B4TSvZpZSQoCgKK6k4BYQuOSyFTOwYx6M79w39ZMOgyCP9ytB+tyMWL0/+ZuUQL04yVg4M5vd3oJMkOaXbvG56ncgPyFrseY+FPDg+mXAzvJk/nily37YXjkQj2D0="
notifications:
email:
on_success: never
addons:
apt:
packages:
- g++-multilib

44
third_party/rust/cc/Cargo.toml поставляемый
Просмотреть файл

@ -1,29 +1,33 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "cc"
version = "1.0.23"
version = "1.0.34"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/cc-rs"
exclude = ["/.travis.yml", "/appveyor.yml"]
description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n"
homepage = "https://github.com/alexcrichton/cc-rs"
documentation = "https://docs.rs/cc"
description = """
A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust
code.
"""
keywords = ["build-dependencies"]
readme = "README.md"
categories = ["development-tools"]
[badges]
travis-ci = { repository = "alexcrichton/cc-rs" }
appveyor = { repository = "alexcrichton/cc-rs" }
[dependencies]
rayon = { version = "1.0", optional = true }
keywords = ["build-dependencies"]
categories = ["development-tools::build-utils"]
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/cc-rs"
[dependencies.rayon]
version = "1.0"
optional = true
[dev-dependencies.tempdir]
version = "0.3"
[features]
parallel = ["rayon"]
[dev-dependencies]
tempdir = "0.3"

6
third_party/rust/cc/README.md поставляемый
Просмотреть файл

@ -2,8 +2,7 @@
A library to compile C/C++/assembly into a Rust library/application.
[![Build Status](https://travis-ci.org/alexcrichton/cc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/cc-rs)
[![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/cc-rs)
[![Build Status](https://dev.azure.com/alexcrichton/cc-rs/_apis/build/status/alexcrichton.cc-rs?branchName=master)](https://dev.azure.com/alexcrichton/cc-rs/_build/latest?definitionId=5&branchName=master)
[Documentation](https://docs.rs/cc)
@ -77,6 +76,7 @@ number of different environment variables.
certain `TARGET`s, it also is assumed to know about other flags (most
common is `-fPIC`).
* `AR` - the `ar` (archiver) executable to use to build the static library.
* `CRATE_CC_NO_DEFAULTS` - the default compiler flags may cause conflicts in some cross compiling scenarios. Setting this variable will disable the generation of default compiler flags.
Each of these variables can also be supplied with certain prefixes and suffixes,
in the following prioritized order:
@ -88,7 +88,7 @@ in the following prioritized order:
If none of these variables exist, cc-rs uses built-in defaults
In addition to the the above optional environment variables, `cc-rs` has some
In addition to the above optional environment variables, `cc-rs` has some
functions with hard requirements on some variables supplied by [cargo's
build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`,
and `HOST` variables.

55
third_party/rust/cc/appveyor.yml поставляемый
Просмотреть файл

@ -1,55 +0,0 @@
environment:
# At the time this was added AppVeyor was having troubles with checking
# revocation of SSL certificates of sites like static.rust-lang.org and what
# we think is crates.io. The libcurl HTTP client by default checks for
# revocation on Windows and according to a mailing list [1] this can be
# disabled.
#
# The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL
# revocation checking on Windows in libcurl. Note, though, that rustup, which
# we're using to download Rust here, also uses libcurl as the default backend.
# Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation
# checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to
# use the Hyper instead of libcurl backend. Both Hyper and libcurl use
# schannel on Windows but it appears that Hyper configures it slightly
# differently such that revocation checking isn't turned on by default.
#
# [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html
RUSTUP_USE_HYPER: 1
CARGO_HTTP_CHECK_REVOKE: false
matrix:
- TARGET: x86_64-pc-windows-msvc
ARCH: amd64
VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
- TARGET: x86_64-pc-windows-msvc
ARCH: amd64
VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
- TARGET: i686-pc-windows-msvc
ARCH: x86
VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
- TARGET: i686-pc-windows-msvc
ARCH: x86
VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
- TARGET: x86_64-pc-windows-gnu
MSYS_BITS: 64
- TARGET: i686-pc-windows-gnu
MSYS_BITS: 32
install:
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- if defined VS call "%VS%" %ARCH%
- set PATH=%PATH%;C:\Program Files (x86)\Rust\bin
- if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin
- rustc -V
- cargo -V
build: false
test_script:
- cargo test --target %TARGET%
- cargo test --features parallel --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --features parallel --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --release --target %TARGET%

87
third_party/rust/cc/azure-pipelines.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,87 @@
trigger:
- master
jobs:
- job: min
displayName: Minimum Rust
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: 1.16.0
- script: cargo build
- job: Linux
pool:
vmImage: ubuntu-16.04
strategy:
matrix:
x86_64:
TARGET: x86_64-unknown-linux-gnu
i686:
TARGET: i686-unknown-linux-gnu
x86_64-beta:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: beta
x86_64-nightly:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: nightly
- job: macOS
pool:
vmImage: macos-10.13
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64:
TARGET: x86_64-apple-darwin
aarch64-ios:
TARGET: aarch64-apple-ios
NO_RUN: --no-run
- job: Windows_vs2019
pool:
vmImage: windows-2019
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
- job: Windows_vs2017
pool:
vmImage: vs2017-win2016
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
i686-msvc:
TARGET: i686-pc-windows-msvc
x86_64-gnu:
TARGET: x86_64-pc-windows-gnu
i686-gnu:
TARGET: i686-pc-windows-gnu
- job: Windows_vs2015
pool:
vmImage: vs2015-win2012r2
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
i686-msvc:
TARGET: i686-pc-windows-msvc
- job: docs
steps:
- template: ci/azure-install-rust.yml
- script: cargo doc --no-deps --all-features
- script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
GITHUB_DEPLOY_KEY: $(GITHUB_DEPLOY_KEY)

23
third_party/rust/cc/ci/azure-install-rust.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,23 @@
steps:
- bash: |
set -e
toolchain=$TOOLCHAIN
if [ "$toolchain" = "" ]; then
toolchain=stable
fi
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain
echo "##vso[task.prependpath]$HOME/.cargo/bin"
displayName: Install rust (unix)
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain stable-%TARGET%
echo ##vso[task.prependpath]%USERPROFILE%\.cargo\bin
displayName: Install rust (windows)
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: |
rustc -Vv
cargo -V
displayName: Query rust and cargo versions

17
third_party/rust/cc/ci/azure-steps.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,17 @@
steps:
- template: azure-install-rust.yml
- bash: rustup target add $TARGET
displayName: Install Rust target
- script: cargo build
displayName: "Normal build"
- bash: cargo test $NO_RUN -- --test-threads 1
displayName: "Crate tests"
- bash: cargo test $NO_RUN --features parallel -- --test-threads 1
displayName: "Crate tests (parallel)"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET
displayName: "cc-test tests"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --features parallel
displayName: "cc-test tests (parallel)"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --release
displayName: "cc-test tests (release)"

623
third_party/rust/cc/src/lib.rs поставляемый
Просмотреть файл

@ -55,6 +55,7 @@
#![doc(html_root_url = "https://docs.rs/cc/1.0")]
#![cfg_attr(test, deny(warnings))]
#![allow(deprecated)]
#![deny(missing_docs)]
#[cfg(feature = "parallel")]
@ -112,12 +113,14 @@ pub struct Build {
archiver: Option<PathBuf>,
cargo_metadata: bool,
pic: Option<bool>,
use_plt: Option<bool>,
static_crt: Option<bool>,
shared_flag: Option<bool>,
static_flag: Option<bool>,
warnings_into_errors: bool,
warnings: Option<bool>,
extra_warnings: Option<bool>,
env_cache: Arc<Mutex<HashMap<String, Option<String>>>>,
}
/// Represents the types of errors that may occur while using cc-rs.
@ -318,10 +321,12 @@ impl Build {
archiver: None,
cargo_metadata: true,
pic: None,
use_plt: None,
static_crt: None,
warnings: None,
extra_warnings: None,
warnings_into_errors: false,
env_cache: Arc::new(Mutex::new(HashMap::new())),
}
}
@ -820,6 +825,21 @@ impl Build {
self
}
/// Configures whether the Procedure Linkage Table is used for indirect
/// calls into shared libraries.
///
/// The PLT is used to provide features like lazy binding, but introduces
/// a small performance loss due to extra pointer indirection. Setting
/// `use_plt` to `false` can provide a small performance increase.
///
/// Note that skipping the PLT requires a recent version of GCC/Clang.
///
/// This only applies to ELF targets. It has no effect on other platforms.
pub fn use_plt(&mut self, use_plt: bool) -> &mut Build {
self.use_plt = Some(use_plt);
self
}
/// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
///
/// This option defaults to `false`, and affect only msvc targets.
@ -936,7 +956,7 @@ impl Build {
fn compile_objects(&self, objs: &[Object]) -> Result<(), Error> {
use self::rayon::prelude::*;
if let Ok(amt) = env::var("NUM_JOBS") {
if let Some(amt) = self.getenv("NUM_JOBS") {
if let Ok(amt) = amt.parse() {
let _ = rayon::ThreadPoolBuilder::new()
.num_threads(amt)
@ -1073,250 +1093,20 @@ impl Build {
let target = self.get_target()?;
let mut cmd = self.get_base_compiler()?;
let envflags = self.envflags(if self.cpp { "CXXFLAGS" } else { "CFLAGS" });
// Non-target flags
// If the flag is not conditioned on target variable, it belongs here :)
match cmd.family {
ToolFamily::Msvc { .. } => {
assert!(!self.cuda,
"CUDA C++ compilation not supported for MSVC, yet... but you are welcome to implement it :)");
// Disable default flag generation via environment variable or when
// certain cross compiling arguments are set
let use_defaults = self.getenv("CRATE_CC_NO_DEFAULTS").is_none();
cmd.args.push("/nologo".into());
let crt_flag = match self.static_crt {
Some(true) => "/MT",
Some(false) => "/MD",
None => {
let features =
env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
if features.contains("crt-static") {
"/MT"
} else {
"/MD"
}
}
};
cmd.args.push(crt_flag.into());
match &opt_level[..] {
// Msvc uses /O1 to enable all optimizations that minimize code size.
"z" | "s" | "1" => cmd.args.push("/O1".into()),
// -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2.
"2" | "3" => cmd.args.push("/O2".into()),
_ => {}
}
}
ToolFamily::Gnu | ToolFamily::Clang => {
// arm-linux-androideabi-gcc 4.8 shipped with Android NDK does
// not support '-Oz'
if opt_level == "z" && cmd.family != ToolFamily::Clang {
cmd.args.push("-Os".into());
} else {
cmd.args.push(format!("-O{}", opt_level).into());
}
if !target.contains("-ios") {
cmd.push_cc_arg("-ffunction-sections".into());
cmd.push_cc_arg("-fdata-sections".into());
}
if self.pic.unwrap_or(!target.contains("windows-gnu")) {
cmd.push_cc_arg("-fPIC".into());
}
}
}
for arg in self.envflags(if self.cpp { "CXXFLAGS" } else { "CFLAGS" }) {
cmd.args.push(arg.into());
if use_defaults {
self.add_default_flags(&mut cmd, &target, &opt_level)?;
} else {
println!("Info: default compiler flags are disabled");
}
if self.get_debug() {
if self.cuda {
let nvcc_debug_flag = cmd.family.nvcc_debug_flag().into();
cmd.args.push(nvcc_debug_flag);
}
let family = cmd.family;
family.add_debug_flags(&mut cmd);
}
// Target flags
match cmd.family {
ToolFamily::Clang => {
cmd.args.push(format!("--target={}", target).into());
}
ToolFamily::Msvc { clang_cl } => {
if clang_cl {
if target.contains("x86_64") {
cmd.args.push("-m64".into());
} else if target.contains("86") {
cmd.args.push("-m32".into());
cmd.args.push("/arch:IA32".into());
} else {
cmd.args.push(format!("--target={}", target).into());
}
} else {
if target.contains("i586") {
cmd.args.push("/ARCH:IA32".into());
}
}
}
ToolFamily::Gnu => {
if target.contains("i686") || target.contains("i586") {
cmd.args.push("-m32".into());
} else if target == "x86_64-unknown-linux-gnux32" {
cmd.args.push("-mx32".into());
} else if target.contains("x86_64") || target.contains("powerpc64") {
cmd.args.push("-m64".into());
}
if self.static_flag.is_none() {
let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
if features.contains("crt-static") {
cmd.args.push("-static".into());
}
}
// armv7 targets get to use armv7 instructions
if (target.starts_with("armv7") || target.starts_with("thumbv7")) && target.contains("-linux-") {
cmd.args.push("-march=armv7-a".into());
}
// (x86 Android doesn't say "eabi")
if target.contains("-androideabi") && target.contains("v7") {
// -march=armv7-a handled above
cmd.args.push("-mthumb".into());
if !target.contains("neon") {
// On android we can guarantee some extra float instructions
// (specified in the android spec online)
// NEON guarantees even more; see below.
cmd.args.push("-mfpu=vfpv3-d16".into());
}
cmd.args.push("-mfloat-abi=softfp".into());
}
if target.contains("neon") {
cmd.args.push("-mfpu=neon-vfpv4".into());
}
if target.starts_with("armv4t-unknown-linux-") {
cmd.args.push("-march=armv4t".into());
cmd.args.push("-marm".into());
cmd.args.push("-mfloat-abi=soft".into());
}
if target.starts_with("armv5te-unknown-linux-") {
cmd.args.push("-march=armv5te".into());
cmd.args.push("-marm".into());
cmd.args.push("-mfloat-abi=soft".into());
}
// For us arm == armv6 by default
if target.starts_with("arm-unknown-linux-") {
cmd.args.push("-march=armv6".into());
cmd.args.push("-marm".into());
}
// We can guarantee some settings for FRC
if target.starts_with("arm-frc-") {
cmd.args.push("-march=armv7-a".into());
cmd.args.push("-mcpu=cortex-a9".into());
cmd.args.push("-mfpu=vfpv3".into());
cmd.args.push("-mfloat-abi=softfp".into());
cmd.args.push("-marm".into());
}
// Turn codegen down on i586 to avoid some instructions.
if target.starts_with("i586-unknown-linux-") {
cmd.args.push("-march=pentium".into());
}
// Set codegen level for i686 correctly
if target.starts_with("i686-unknown-linux-") {
cmd.args.push("-march=i686".into());
}
// Looks like `musl-gcc` makes is hard for `-m32` to make its way
// all the way to the linker, so we need to actually instruct the
// linker that we're generating 32-bit executables as well. This'll
// typically only be used for build scripts which transitively use
// these flags that try to compile executables.
if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" {
cmd.args.push("-Wl,-melf_i386".into());
}
if target.starts_with("thumb") {
cmd.args.push("-mthumb".into());
if target.ends_with("eabihf") {
cmd.args.push("-mfloat-abi=hard".into())
}
}
if target.starts_with("thumbv6m") {
cmd.args.push("-march=armv6s-m".into());
}
if target.starts_with("thumbv7em") {
cmd.args.push("-march=armv7e-m".into());
if target.ends_with("eabihf") {
cmd.args.push("-mfpu=fpv4-sp-d16".into())
}
}
if target.starts_with("thumbv7m") {
cmd.args.push("-march=armv7-m".into());
}
if target.starts_with("armebv7r") | target.starts_with("armv7r") {
if target.starts_with("armeb") {
cmd.args.push("-mbig-endian".into());
} else {
cmd.args.push("-mlittle-endian".into());
}
// ARM mode
cmd.args.push("-marm".into());
// R Profile
cmd.args.push("-march=armv7-r".into());
if target.ends_with("eabihf") {
// Calling convention
cmd.args.push("-mfloat-abi=hard".into());
// lowest common denominator FPU
// (see Cortex-R4 technical reference manual)
cmd.args.push("-mfpu=vfpv3-d16".into())
} else {
// Calling convention
cmd.args.push("-mfloat-abi=soft".into());
}
}
}
}
if target.contains("-ios") {
// FIXME: potential bug. iOS is always compiled with Clang, but Gcc compiler may be
// detected instead.
self.ios_flags(&mut cmd)?;
}
if self.static_flag.unwrap_or(false) {
cmd.args.push("-static".into());
}
if self.shared_flag.unwrap_or(false) {
cmd.args.push("-shared".into());
}
if self.cpp {
match (self.cpp_set_stdlib.as_ref(), cmd.family) {
(None, _) => {}
(Some(stdlib), ToolFamily::Gnu) | (Some(stdlib), ToolFamily::Clang) => {
cmd.push_cc_arg(format!("-stdlib=lib{}", stdlib).into());
}
_ => {
println!(
"cargo:warning=cpp_set_stdlib is specified, but the {:?} compiler \
does not support this option, ignored",
cmd.family
);
}
}
for arg in envflags {
cmd.push_cc_arg(arg.into());
}
for directory in self.include_directories.iter() {
@ -1371,6 +1161,285 @@ impl Build {
Ok(cmd)
}
fn add_default_flags(&self, cmd: &mut Tool, target: &str, opt_level: &str) -> Result<(), Error> {
// Non-target flags
// If the flag is not conditioned on target variable, it belongs here :)
match cmd.family {
ToolFamily::Msvc { .. } => {
assert!(!self.cuda,
"CUDA C++ compilation not supported for MSVC, yet... but you are welcome to implement it :)");
cmd.args.push("/nologo".into());
let crt_flag = match self.static_crt {
Some(true) => "/MT",
Some(false) => "/MD",
None => {
let features =
self.getenv("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
if features.contains("crt-static") {
"/MT"
} else {
"/MD"
}
}
};
cmd.args.push(crt_flag.into());
match &opt_level[..] {
// Msvc uses /O1 to enable all optimizations that minimize code size.
"z" | "s" | "1" => cmd.push_opt_unless_duplicate("/O1".into()),
// -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2.
"2" | "3" => cmd.push_opt_unless_duplicate("/O2".into()),
_ => {}
}
}
ToolFamily::Gnu | ToolFamily::Clang => {
// arm-linux-androideabi-gcc 4.8 shipped with Android NDK does
// not support '-Oz'
if opt_level == "z" && cmd.family != ToolFamily::Clang {
cmd.push_opt_unless_duplicate("-Os".into());
} else {
cmd.push_opt_unless_duplicate(format!("-O{}", opt_level).into());
}
if !target.contains("-ios") {
cmd.push_cc_arg("-ffunction-sections".into());
cmd.push_cc_arg("-fdata-sections".into());
}
if self.pic.unwrap_or(!target.contains("windows-gnu")) {
cmd.push_cc_arg("-fPIC".into());
// PLT only applies if code is compiled with PIC support,
// and only for ELF targets.
if target.contains("linux") && !self.use_plt.unwrap_or(true) {
cmd.push_cc_arg("-fno-plt".into());
}
}
}
}
if self.get_debug() {
if self.cuda {
let nvcc_debug_flag = cmd.family.nvcc_debug_flag().into();
cmd.args.push(nvcc_debug_flag);
}
let family = cmd.family;
family.add_debug_flags(cmd);
}
// Target flags
match cmd.family {
ToolFamily::Clang => {
cmd.args.push(format!("--target={}", target).into());
}
ToolFamily::Msvc { clang_cl } => {
if clang_cl {
if target.contains("x86_64") {
cmd.args.push("-m64".into());
} else if target.contains("86") {
cmd.args.push("-m32".into());
cmd.args.push("/arch:IA32".into());
} else {
cmd.args.push(format!("--target={}", target).into());
}
} else {
if target.contains("i586") {
cmd.args.push("/ARCH:IA32".into());
}
}
// There is a check in corecrt.h that will generate a
// compilation error if
// _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is
// not defined to 1. The check was added in Windows
// 8 days because only store apps were allowed on ARM.
// This changed with the release of Windows 10 IoT Core.
// The check will be going away in future versions of
// the SDK, but for all released versions of the
// Windows SDK it is required.
if target.contains("arm") || target.contains("thumb") {
cmd.args.push("/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into());
}
}
ToolFamily::Gnu => {
if target.contains("i686") || target.contains("i586") {
cmd.args.push("-m32".into());
} else if target == "x86_64-unknown-linux-gnux32" {
cmd.args.push("-mx32".into());
} else if target.contains("x86_64") || target.contains("powerpc64") {
cmd.args.push("-m64".into());
}
if self.static_flag.is_none() {
let features = self.getenv("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
if features.contains("crt-static") {
cmd.args.push("-static".into());
}
}
// armv7 targets get to use armv7 instructions
if (target.starts_with("armv7") || target.starts_with("thumbv7")) && target.contains("-linux-") {
cmd.args.push("-march=armv7-a".into());
}
// (x86 Android doesn't say "eabi")
if target.contains("-androideabi") && target.contains("v7") {
// -march=armv7-a handled above
cmd.args.push("-mthumb".into());
if !target.contains("neon") {
// On android we can guarantee some extra float instructions
// (specified in the android spec online)
// NEON guarantees even more; see below.
cmd.args.push("-mfpu=vfpv3-d16".into());
}
cmd.args.push("-mfloat-abi=softfp".into());
}
if target.contains("neon") {
cmd.args.push("-mfpu=neon-vfpv4".into());
}
if target.starts_with("armv4t-unknown-linux-") {
cmd.args.push("-march=armv4t".into());
cmd.args.push("-marm".into());
cmd.args.push("-mfloat-abi=soft".into());
}
if target.starts_with("armv5te-unknown-linux-") {
cmd.args.push("-march=armv5te".into());
cmd.args.push("-marm".into());
cmd.args.push("-mfloat-abi=soft".into());
}
// For us arm == armv6 by default
if target.starts_with("arm-unknown-linux-") {
cmd.args.push("-march=armv6".into());
cmd.args.push("-marm".into());
if target.ends_with("hf") {
cmd.args.push("-mfpu=vfp".into());
} else {
cmd.args.push("-mfloat-abi=soft".into());
}
}
// We can guarantee some settings for FRC
if target.starts_with("arm-frc-") {
cmd.args.push("-march=armv7-a".into());
cmd.args.push("-mcpu=cortex-a9".into());
cmd.args.push("-mfpu=vfpv3".into());
cmd.args.push("-mfloat-abi=softfp".into());
cmd.args.push("-marm".into());
}
// Turn codegen down on i586 to avoid some instructions.
if target.starts_with("i586-unknown-linux-") {
cmd.args.push("-march=pentium".into());
}
// Set codegen level for i686 correctly
if target.starts_with("i686-unknown-linux-") {
cmd.args.push("-march=i686".into());
}
// Looks like `musl-gcc` makes is hard for `-m32` to make its way
// all the way to the linker, so we need to actually instruct the
// linker that we're generating 32-bit executables as well. This'll
// typically only be used for build scripts which transitively use
// these flags that try to compile executables.
if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" {
cmd.args.push("-Wl,-melf_i386".into());
}
if target.starts_with("thumb") {
cmd.args.push("-mthumb".into());
if target.ends_with("eabihf") {
cmd.args.push("-mfloat-abi=hard".into())
}
}
if target.starts_with("thumbv6m") {
cmd.args.push("-march=armv6s-m".into());
}
if target.starts_with("thumbv7em") {
cmd.args.push("-march=armv7e-m".into());
if target.ends_with("eabihf") {
cmd.args.push("-mfpu=fpv4-sp-d16".into())
}
}
if target.starts_with("thumbv7m") {
cmd.args.push("-march=armv7-m".into());
}
if target.starts_with("thumbv8m.base") {
cmd.args.push("-march=armv8-m.base".into());
}
if target.starts_with("thumbv8m.main") {
cmd.args.push("-march=armv8-m.main".into());
if target.ends_with("eabihf") {
cmd.args.push("-mfpu=fpv5-sp-d16".into())
}
}
if target.starts_with("armebv7r") | target.starts_with("armv7r") {
if target.starts_with("armeb") {
cmd.args.push("-mbig-endian".into());
} else {
cmd.args.push("-mlittle-endian".into());
}
// ARM mode
cmd.args.push("-marm".into());
// R Profile
cmd.args.push("-march=armv7-r".into());
if target.ends_with("eabihf") {
// Calling convention
cmd.args.push("-mfloat-abi=hard".into());
// lowest common denominator FPU
// (see Cortex-R4 technical reference manual)
cmd.args.push("-mfpu=vfpv3-d16".into())
} else {
// Calling convention
cmd.args.push("-mfloat-abi=soft".into());
}
}
}
}
if target.contains("-ios") {
// FIXME: potential bug. iOS is always compiled with Clang, but Gcc compiler may be
// detected instead.
self.ios_flags(cmd)?;
}
if self.static_flag.unwrap_or(false) {
cmd.args.push("-static".into());
}
if self.shared_flag.unwrap_or(false) {
cmd.args.push("-shared".into());
}
if self.cpp {
match (self.cpp_set_stdlib.as_ref(), cmd.family) {
(None, _) => {}
(Some(stdlib), ToolFamily::Gnu) | (Some(stdlib), ToolFamily::Clang) => {
cmd.push_cc_arg(format!("-stdlib=lib{}", stdlib).into());
}
_ => {
println!(
"cargo:warning=cpp_set_stdlib is specified, but the {:?} compiler \
does not support this option, ignored",
cmd.family
);
}
}
}
Ok(())
}
fn has_flags(&self) -> bool {
let flags_env_var_name = if self.cpp { "CXXFLAGS" } else { "CFLAGS" };
let flags_env_var_value = self.get_var(flags_env_var_name);
@ -1418,12 +1487,7 @@ impl Build {
let objects: Vec<_> = objs.iter().map(|obj| obj.dst.clone()).collect();
let target = self.get_target()?;
if target.contains("msvc") {
let mut cmd = match self.archiver {
Some(ref s) => self.cmd(s),
None => windows_registry::find(&target, "lib.exe")
.unwrap_or_else(|| self.cmd("lib.exe")),
};
let (mut cmd, program) = self.get_ar()?;
let mut out = OsString::from("/OUT:");
out.push(dst);
cmd.arg(out).arg("/nologo");
@ -1468,7 +1532,7 @@ impl Build {
} else {
cmd.args(&objects).args(&self.objects);
}
run(&mut cmd, "lib.exe")?;
run(&mut cmd, &program)?;
// The Rust compiler will look for libfoo.a and foo.lib, but the
// MSVC linker will also be passed foo.lib, so be sure that both
@ -1649,10 +1713,10 @@ impl Build {
}
} else if target.contains("android") {
let target = target
.replace("armv7", "arm")
.replace("armv7neon", "arm")
.replace("thumbv7", "arm")
.replace("thumbv7neon", "arm");
.replace("armv7", "arm")
.replace("thumbv7neon", "arm")
.replace("thumbv7", "arm");
let gnu_compiler = format!("{}-{}", target, gnu);
let clang_compiler = format!("{}-{}", target, clang);
// Check if gnu compiler is present
@ -1664,6 +1728,8 @@ impl Build {
}
} else if target.contains("cloudabi") {
format!("{}-{}", target, traditional)
} else if target == "wasm32-unknown-wasi" || target == "wasm32-unknown-unknown" {
"clang".to_string()
} else if self.get_host()? != target {
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
let cc_env = self.getenv("CROSS_COMPILE");
@ -1716,6 +1782,9 @@ impl Build {
"thumbv7em-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabihf" => Some("arm-none-eabi"),
"thumbv7m-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.base-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabihf" => Some("arm-none-eabi"),
"x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"),
"x86_64-unknown-linux-musl" => Some("musl"),
@ -1905,9 +1974,10 @@ impl Build {
if let Ok(p) = self.get_var("AR") {
return Ok((self.cmd(&p), p));
}
let program = if self.get_target()?.contains("android") {
format!("{}-ar", self.get_target()?.replace("armv7", "arm"))
} else if self.get_target()?.contains("emscripten") {
let target = self.get_target()?;
let program = if target.contains("android") {
format!("{}-ar", target.replace("armv7", "arm"))
} else if target.contains("emscripten") {
// Windows use bat files so we have to be a bit more specific
if cfg!(windows) {
let mut cmd = self.cmd("cmd");
@ -1916,6 +1986,11 @@ impl Build {
}
"emar".to_string()
} else if target.contains("msvc") {
match windows_registry::find(&target, "lib.exe") {
Some(t) => return Ok((t, "lib.exe".to_string())),
None => "lib.exe".to_string(),
}
} else {
"ar".to_string()
};
@ -1963,8 +2038,13 @@ impl Build {
}
fn getenv(&self, v: &str) -> Option<String> {
let mut cache = self.env_cache.lock().unwrap();
if let Some(val) = cache.get(v) {
return val.clone()
}
let r = env::var(v).ok();
self.print(&format!("{} = {:?}", v, r));
cache.insert(v.to_string(), r.clone());
r
}
@ -2043,6 +2123,41 @@ impl Tool {
self.args.push(flag);
}
fn is_duplicate_opt_arg(&self, flag: &OsString) -> bool {
let flag = flag.to_str().unwrap();
let mut chars = flag.chars();
// Only duplicate check compiler flags
if self.is_like_msvc() {
if chars.next() != Some('/') {
return false;
}
} else if self.is_like_gnu() || self.is_like_clang() {
if chars.next() != Some('-') {
return false;
}
}
// Check for existing optimization flags (-O, /O)
if chars.next() == Some('O') {
return self.args().iter().any(|ref a|
a.to_str().unwrap_or("").chars().nth(1) == Some('O')
);
}
// TODO Check for existing -m..., -m...=..., /arch:... flags
return false;
}
/// Don't push optimization arg if it conflicts with existing args
fn push_opt_unless_duplicate(&mut self, flag: OsString) {
if self.is_duplicate_opt_arg(&flag) {
println!("Info: Ignoring duplicate arg {:?}", &flag);
} else {
self.push_cc_arg(flag);
}
}
/// Converts this compiler into a `Command` that's ready to be run.
///
/// This is useful for when the compiler needs to be executed and the

96
third_party/rust/cc/src/windows_registry.rs поставляемый
Просмотреть файл

@ -103,6 +103,8 @@ pub enum VsVers {
Vs14,
/// Visual Studio 15 (2017)
Vs15,
/// Visual Studio 16 (2019)
Vs16,
/// Hidden variant that should not be matched on. Callers that want to
/// handle an enumeration of `VsVers` instances should always have a default
@ -128,6 +130,7 @@ pub fn find_vs_version() -> Result<VsVers, String> {
match env::var("VisualStudioVersion") {
Ok(version) => match &version[..] {
"16.0" => Ok(VsVers::Vs16),
"15.0" => Ok(VsVers::Vs15),
"14.0" => Ok(VsVers::Vs14),
"12.0" => Ok(VsVers::Vs12),
@ -144,7 +147,9 @@ pub fn find_vs_version() -> Result<VsVers, String> {
_ => {
// Check for the presense of a specific registry key
// that indicates visual studio is installed.
if impl_::has_msbuild_version("15.0") {
if impl_::has_msbuild_version("16.0") {
Ok(VsVers::Vs16)
} else if impl_::has_msbuild_version("15.0") {
Ok(VsVers::Vs15)
} else if impl_::has_msbuild_version("14.0") {
Ok(VsVers::Vs14)
@ -174,7 +179,7 @@ mod impl_ {
use std::io::Read;
use registry::{RegistryKey, LOCAL_MACHINE};
use com;
use setup_config::{SetupConfiguration, SetupInstance};
use setup_config::{EnumSetupInstances, SetupConfiguration, SetupInstance};
use Tool;
@ -217,11 +222,15 @@ mod impl_ {
// Note that much of this logic can be found [online] wrt paths, COM, etc.
//
// [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/
pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
fn vs15_instances() -> Option<EnumSetupInstances> {
otry!(com::initialize().ok());
let config = otry!(SetupConfiguration::new().ok());
let iter = otry!(config.enum_all_instances().ok());
config.enum_all_instances().ok()
}
pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
let iter = otry!(vs15_instances());
for instance in iter {
let instance = otry!(instance.ok());
let tool = tool_from_vs15_instance(tool, target, &instance);
@ -233,6 +242,44 @@ mod impl_ {
None
}
// While the paths to Visual Studio 2017's devenv and MSBuild could
// potentially be retrieved from the registry, finding them via
// SetupConfiguration has shown to be [more reliable], and is preferred
// according to Microsoft. To help head off potential regressions though,
// we keep the registry method as a fallback option.
//
// [more reliable]: https://github.com/alexcrichton/cc-rs/pull/331
fn find_tool_in_vs15_path(tool: &str, target: &str) -> Option<Tool> {
let mut path = match vs15_instances() {
Some(instances) => instances
.filter_map(|instance| {
instance
.ok()
.and_then(|instance| instance.installation_path().ok())
}).map(|path| PathBuf::from(path).join(tool))
.find(|ref path| path.is_file()),
None => None,
};
if path.is_none() {
let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7";
path = LOCAL_MACHINE
.open(key.as_ref())
.ok()
.and_then(|key| key.query_str("15.0").ok())
.map(|path| PathBuf::from(path).join(tool))
.filter(|ref path| path.is_file());
}
path.map(|path| {
let mut tool = Tool::new(path);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}
tool
})
}
fn tool_from_vs15_instance(tool: &str, target: &str, instance: &SetupInstance) -> Option<Tool> {
let (bin_path, host_dylib_path, lib_path, include_path) =
otry!(vs15_vc_paths(target, instance));
@ -523,8 +570,8 @@ mod impl_ {
("i586", X86_64) | ("i686", X86_64) => vec![("amd64_x86", "amd64"), ("", "")],
("x86_64", X86) => vec![("x86_amd64", "")],
("x86_64", X86_64) => vec![("amd64", "amd64"), ("x86_amd64", "")],
("arm", X86) => vec![("x86_arm", "")],
("arm", X86_64) => vec![("amd64_arm", "amd64"), ("x86_arm", "")],
("arm", X86) | ("thumbv7a", X86) => vec![("x86_arm", "")],
("arm", X86_64) | ("thumbv7a", X86_64) => vec![("amd64_arm", "amd64"), ("x86_arm", "")],
_ => vec![],
}
}
@ -534,7 +581,7 @@ mod impl_ {
match arch {
"i586" | "i686" => Some("x86"),
"x86_64" => Some("x64"),
"arm" => Some("arm"),
"arm" | "thumbv7a" => Some("arm"),
"aarch64" => Some("arm64"),
_ => None,
}
@ -546,7 +593,7 @@ mod impl_ {
match arch {
"i586" | "i686" => Some(""),
"x86_64" => Some("amd64"),
"arm" => Some("arm"),
"arm" | "thumbv7a" => Some("arm"),
"aarch64" => Some("arm64"),
_ => None,
}
@ -595,7 +642,7 @@ mod impl_ {
for subkey in key.iter().filter_map(|k| k.ok()) {
let val = subkey
.to_str()
.and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok());
.and_then(|s| s.trim_start_matches("v").replace(".", "").parse().ok());
let val = match val {
Some(s) => s,
None => continue,
@ -631,19 +678,7 @@ mod impl_ {
}
fn find_devenv_vs15(target: &str) -> Option<Tool> {
let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7";
LOCAL_MACHINE
.open(key.as_ref())
.ok()
.and_then(|key| key.query_str("15.0").ok())
.map(|path| {
let path = PathBuf::from(path).join(r"Common7\IDE\devenv.exe");
let mut tool = Tool::new(path);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}
tool
})
find_tool_in_vs15_path(r"Common7\IDE\devenv.exe", target)
}
// see http://stackoverflow.com/questions/328017/path-to-msbuild
@ -657,22 +692,7 @@ mod impl_ {
}
fn find_msbuild_vs15(target: &str) -> Option<Tool> {
// Seems like this could also go through SetupConfiguration,
// or that find_msvc_15 could just use this registry key
// instead of the COM interface.
let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7";
LOCAL_MACHINE
.open(key.as_ref())
.ok()
.and_then(|key| key.query_str("15.0").ok())
.map(|path| {
let path = PathBuf::from(path).join(r"MSBuild\15.0\Bin\MSBuild.exe");
let mut tool = Tool::new(path);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}
tool
})
find_tool_in_vs15_path(r"MSBuild\15.0\Bin\MSBuild.exe", target)
}
fn find_old_msbuild(target: &str) -> Option<Tool> {

14
third_party/rust/cc/tests/test.rs поставляемый
Просмотреть файл

@ -197,6 +197,20 @@ fn gnu_i686_pic() {
}
}
#[test]
fn gnu_x86_64_no_plt() {
let target = "x86_64-unknown-linux-gnu";
let test = Test::gnu();
test.gcc()
.pic(true)
.use_plt(false)
.target(&target)
.host(&target)
.file("foo.c")
.compile("foo");
test.cmd(0).must_have("-fno-plt");
}
#[test]
fn gnu_set_stdlib() {
let test = Test::gnu();