Bug 1943149 - build(rust): upgrade cc 1.0.89 → 1.2.10
`cc` upstream breaks a few things that have been handled by prior patches motivated specifically by this upgrade: 1. `cc::Build` now rejects unknown targets not baked in. This breaks `swgl`'s usage of the `SWGL` target. We migrated away from this behavior in D235480. 2. `cc::Build::is_like_msvc`'s underlying logic changed, and now does not return `true`. This is because of a regression in toolchain classification heuristics, and has been worked around in D236305. Differential Revision: https://phabricator.services.mozilla.com/D236029
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -717,12 +717,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.89"
|
||||
version = "1.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723"
|
||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
2
third_party/rust/cc/.cargo-checksum.json
vendored
2
third_party/rust/cc/.cargo-checksum.json
vendored
@@ -1 +1 @@
|
||||
{"files":{"Cargo.lock":"cfcc30c65888ca9642ffc2d3c4294f416aa1789f1ce40362841e4eeb298a628b","Cargo.toml":"1288f536f4ddf6bcdc664a91a070aad2ebd7c6edc32ce24e8d6bc04c2cd64d49","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"f1ddbede208a5b78333a25dac0a7598e678e9b601a7d99a791069bddaf180dfe","src/command_helpers.rs":"3ef95bdcd79a43406fdab275d8a8f45ba787876399b54df34068955ec0109e69","src/lib.rs":"91efa8f9242266752658edd66ee607ce30635f4c30710508a99eb62e7b3c54da","src/parallel/async_executor.rs":"4ce24435fff6b6555b43fee042c16bd65d4150d0346567f246b9190d85b45983","src/parallel/job_token.rs":"0676c3177b5be9d7ede483bf4bd45c5ca0f5511073e4d1c9f181a0bc83db05dc","src/parallel/mod.rs":"aaffed5ad3dc0d28641533ab0d6f522bf34a059d4b1a239dc4d217cb5d58e232","src/parallel/stderr.rs":"a2d18ba3f2e04deb9047ece9ab7ca5452d9a76b515afbe20a76307e31597f34b","src/tool.rs":"172cfcbecd7c6a363ea841a48a10a75b0a01e83b83c0691107c601598b68dedf","src/windows/com.rs":"be1564756c9f3ef1398eafeed7b54ba610caba28e8f6258d28a997737ebf9535","src/windows/find_tools.rs":"9234fe7ab27b0259c6fa9fb47826e7d1a3d1d2c7c4042ef7153ab90ccb9a3412","src/windows/mod.rs":"42f1ad7fee35a17686b003e6aa520d3d1940d47d2f531d626e9ae0c48ba49005","src/windows/registry.rs":"c521b72c825e8095843e73482ffa810ed066ad8bb9f86e6db0c5c143c171aba1","src/windows/setup_config.rs":"754439cbab492afd44c9755abcbec1a41c9b2c358131cee2df13c0e996dbbec8","src/windows/vs_instances.rs":"76e3cee74b5fd38ddaf533bba11fe401667c50dda5f9d064099840893eaa7587","src/windows/winapi.rs":"250d51c1826d1a2329e9889dd9f058cfce253dbf2a678b076147c6cdb5db046c","src/windows/windows_sys.rs":"f6b90b87f23e446284bde86749b53858c0d37b8a43515ed8d0e90b1ac8cf7771"},"package":"a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723"}
|
||||
{"files":{"CHANGELOG.md":"144410378452f9244b3a99c0f01333def90aa2bd3ef482772476847e90dd5e71","Cargo.lock":"884eb9a775ef49854bcdd44396ee86e013f8075094953d00b4d351683faa6772","Cargo.toml":"97c12cb35611ee6b470f647e60c1fb323c813bc7bcd0e7b6e314a2242a6dbe1d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"f1ddbede208a5b78333a25dac0a7598e678e9b601a7d99a791069bddaf180dfe","clippy.toml":"aa7850db4350883c8f373bd0d6b4d19bf3b75f13c1c238e24368c109cb52fb1d","src/command_helpers.rs":"511429ff0130a7c5a5c1db29939a78af4f7fb84e6e4293e721c6deceffd28245","src/detect_compiler_family.c":"97ca4b021495611e828becea6187add37414186a16dfedd26c2947cbce6e8b2f","src/flags.rs":"0223f041db5a3ee44957bd91a21a7bca17ef49f88ed0e383e5183f7057f2f3c9","src/lib.rs":"0996fc14a436b663acffd4c34a937ae7c5c00fc480b3efe3466ce3480e737f28","src/parallel/async_executor.rs":"4ce24435fff6b6555b43fee042c16bd65d4150d0346567f246b9190d85b45983","src/parallel/job_token.rs":"018a01cb00182270bbcb68e31e7a7c5c621a95f086e4c68cfa2bf557ac24e5f2","src/parallel/mod.rs":"bd9c1334d17d138c281961c690b8d8118a2d6295a7d6cd7296826255436fa063","src/parallel/stderr.rs":"74384d41198740a6fce0877f144262db09fb091225fa8fbfa771314bb11487c6","src/target.rs":"a51ceae6ae98ebec79caff1a294e90305babd7b0c2e9325abb6ea0b756f2fdc4","src/target/apple.rs":"6afbecac9f66aa72db55694413532f80b2753f28466a6213d1aa901a03c78bcd","src/target/generated.rs":"2697079f91ecc8e18c4047ab8090c6b85ece56db24768c9442d8509af1d2b564","src/target/llvm.rs":"e1db4a7fb8b905ee9853781f2fcc64a9d3b48154e4c8b6cb12f5373c5935da6e","src/target/parser.rs":"4f2129a24273d62bf8ab339098e7f758e4e42b0df369dd2b0eb1b20726be91f8","src/tempfile.rs":"ebafb5b0e5d08b0706916ed911d4245240e60c3e2d0c9a1630c520842988a2b3","src/tool.rs":"d3cdedda02018386436a8fa27548f94ee753114ac98f8ce64bd45ab6b6d8ea61","src/utilities.rs":"52b30b24a1c31cdefb105309ee5220cfc9fca76eaf4e6d6509c3e19f431448fe","src/windows/com.rs":"a2800ddb81215fff2bf618336f5c4ff8e8bdb746dd18b795873c7304b3f2a5e3","src/windows/find_tools.rs":"90c831db5f502bfbdaa6d6d55cbdc7097aa819b0c3b41fdb007d18bdedc7a24e","src/windows/mod.rs":"34cfa201cfbcac7ccaa3ea5295d3e4200439af3cc5c6433baf81502596040a89","src/windows/registry.rs":"c521b72c825e8095843e73482ffa810ed066ad8bb9f86e6db0c5c143c171aba1","src/windows/setup_config.rs":"754439cbab492afd44c9755abcbec1a41c9b2c358131cee2df13c0e996dbbec8","src/windows/vs_instances.rs":"946527cf8fd32c3472f6a2884dcdec290763101097334c7478f9c24c3950db6b","src/windows/winapi.rs":"250d51c1826d1a2329e9889dd9f058cfce253dbf2a678b076147c6cdb5db046c","src/windows/windows_sys.rs":"324a391634b956c0ce67b611998b677caf5a1a6e25e6ed749a7d8f7a185f14c9","src/windows/windows_targets.rs":"5b4648ebc22b028caca9f4b4bf8881fe2d094b7bec217264ba2e6e2c49d1ccee"},"package":"13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"}
|
||||
379
third_party/rust/cc/CHANGELOG.md
vendored
Normal file
379
third_party/rust/cc/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,379 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.2.10](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.9...cc-v1.2.10) - 2025-01-17
|
||||
|
||||
### Other
|
||||
|
||||
- Fix CC_FORCE_DISABLE=0 evaluating to true ([#1371](https://github.com/rust-lang/cc-rs/pull/1371))
|
||||
- Regenerate target info ([#1369](https://github.com/rust-lang/cc-rs/pull/1369))
|
||||
- Make hidden lifetimes explicit. ([#1366](https://github.com/rust-lang/cc-rs/pull/1366))
|
||||
|
||||
## [1.2.9](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.8...cc-v1.2.9) - 2025-01-12
|
||||
|
||||
### Other
|
||||
|
||||
- Don't pass inherited PGO flags to GNU compilers (#1363)
|
||||
- Adjusted zig cc judgment and avoided zigbuild errors([#1360](https://github.com/rust-lang/cc-rs/pull/1360)) ([#1361](https://github.com/rust-lang/cc-rs/pull/1361))
|
||||
- Fix compilation on macOS using clang and fix compilation using zig-cc ([#1364](https://github.com/rust-lang/cc-rs/pull/1364))
|
||||
|
||||
## [1.2.8](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.7...cc-v1.2.8) - 2025-01-11
|
||||
|
||||
### Other
|
||||
|
||||
- Add `is_like_clang_cl()` getter (#1357)
|
||||
- Fix clippy error in lib.rs ([#1356](https://github.com/rust-lang/cc-rs/pull/1356))
|
||||
- Regenerate target info ([#1352](https://github.com/rust-lang/cc-rs/pull/1352))
|
||||
- Fix compiler family detection issue with clang-cl on macOS ([#1328](https://github.com/rust-lang/cc-rs/pull/1328))
|
||||
- Update `windows-bindgen` dependency ([#1347](https://github.com/rust-lang/cc-rs/pull/1347))
|
||||
- Fix clippy warnings ([#1346](https://github.com/rust-lang/cc-rs/pull/1346))
|
||||
|
||||
## [1.2.7](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.6...cc-v1.2.7) - 2025-01-03
|
||||
|
||||
### Other
|
||||
|
||||
- Regenerate target info ([#1342](https://github.com/rust-lang/cc-rs/pull/1342))
|
||||
- Document new supported architecture names in windows::find
|
||||
- Make is_flag_supported_inner take an &Tool ([#1337](https://github.com/rust-lang/cc-rs/pull/1337))
|
||||
- Fix is_flag_supported on msvc ([#1336](https://github.com/rust-lang/cc-rs/pull/1336))
|
||||
- Allow using Visual Studio target names in `find_tool` ([#1335](https://github.com/rust-lang/cc-rs/pull/1335))
|
||||
|
||||
## [1.2.6](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.5...cc-v1.2.6) - 2024-12-27
|
||||
|
||||
### Other
|
||||
|
||||
- Don't inherit the `/Oy` flag for 64-bit targets ([#1330](https://github.com/rust-lang/cc-rs/pull/1330))
|
||||
|
||||
## [1.2.5](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.4...cc-v1.2.5) - 2024-12-19
|
||||
|
||||
### Other
|
||||
|
||||
- Check linking when testing if compiler flags are supported ([#1322](https://github.com/rust-lang/cc-rs/pull/1322))
|
||||
|
||||
## [1.2.4](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.3...cc-v1.2.4) - 2024-12-13
|
||||
|
||||
### Other
|
||||
|
||||
- Add support for C/C++ compiler for Neutrino QNX: `qcc` ([#1319](https://github.com/rust-lang/cc-rs/pull/1319))
|
||||
- use -maix64 instead of -m64 ([#1307](https://github.com/rust-lang/cc-rs/pull/1307))
|
||||
|
||||
## [1.2.3](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.2...cc-v1.2.3) - 2024-12-06
|
||||
|
||||
### Other
|
||||
|
||||
- Improve detection of environment when compiling from msbuild or msvc ([#1310](https://github.com/rust-lang/cc-rs/pull/1310))
|
||||
- Better error message when failing on unknown targets ([#1313](https://github.com/rust-lang/cc-rs/pull/1313))
|
||||
- Optimize RustcCodegenFlags ([#1305](https://github.com/rust-lang/cc-rs/pull/1305))
|
||||
|
||||
## [1.2.2](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.1...cc-v1.2.2) - 2024-11-29
|
||||
|
||||
### Other
|
||||
|
||||
- Inherit flags from rustc ([#1279](https://github.com/rust-lang/cc-rs/pull/1279))
|
||||
- Add support for using sccache wrapper with cuda/nvcc ([#1304](https://github.com/rust-lang/cc-rs/pull/1304))
|
||||
- Fix msvc stdout not shown on error ([#1303](https://github.com/rust-lang/cc-rs/pull/1303))
|
||||
- Regenerate target info ([#1301](https://github.com/rust-lang/cc-rs/pull/1301))
|
||||
- Fix compilation of C++ code for armv7-unknown-linux-gnueabihf ([#1298](https://github.com/rust-lang/cc-rs/pull/1298))
|
||||
- Fetch target info from Cargo even if `Build::target` is manually set ([#1299](https://github.com/rust-lang/cc-rs/pull/1299))
|
||||
- Fix two files with different extensions having the same object name ([#1295](https://github.com/rust-lang/cc-rs/pull/1295))
|
||||
- Allow disabling cc's ability to compile via env var CC_FORCE_DISABLE ([#1292](https://github.com/rust-lang/cc-rs/pull/1292))
|
||||
- Regenerate target info ([#1293](https://github.com/rust-lang/cc-rs/pull/1293))
|
||||
|
||||
## [1.2.1](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.0...cc-v1.2.1) - 2024-11-14
|
||||
|
||||
### Other
|
||||
|
||||
- When invoking `cl -?`, set stdin to null ([#1288](https://github.com/rust-lang/cc-rs/pull/1288))
|
||||
|
||||
## [1.2.0](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.37...cc-v1.2.0) - 2024-11-11
|
||||
|
||||
### Added
|
||||
|
||||
- add i686-pc-windows-gnullvm prefix detection ([#1283](https://github.com/rust-lang/cc-rs/pull/1283))
|
||||
|
||||
### Other
|
||||
|
||||
- Allow only specifying the architecture ([#1285](https://github.com/rust-lang/cc-rs/pull/1285))
|
||||
- Fix WASM vs. WASI options ([#1284](https://github.com/rust-lang/cc-rs/pull/1284))
|
||||
|
||||
## [1.1.37](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.36...cc-v1.1.37) - 2024-11-08
|
||||
|
||||
### Other
|
||||
|
||||
- Use relative directory for obj files hash ([#1270](https://github.com/rust-lang/cc-rs/pull/1270))
|
||||
- Regenerate target info ([#1280](https://github.com/rust-lang/cc-rs/pull/1280))
|
||||
|
||||
## [1.1.36](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.35...cc-v1.1.36) - 2024-11-05
|
||||
|
||||
### Other
|
||||
|
||||
- Fix CUDA build with clang++. ([#1273](https://github.com/rust-lang/cc-rs/pull/1273))
|
||||
|
||||
## [1.1.35](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.34...cc-v1.1.35) - 2024-11-04
|
||||
|
||||
### Other
|
||||
|
||||
- Remove support for FRC ([#1268](https://github.com/rust-lang/cc-rs/pull/1268))
|
||||
- Do not add -fPIC by default on UEFI targets ([#1263](https://github.com/rust-lang/cc-rs/pull/1263))
|
||||
- Use -windows-gnu for all UEFI targets ([#1264](https://github.com/rust-lang/cc-rs/pull/1264))
|
||||
|
||||
## [1.1.34](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.33...cc-v1.1.34) - 2024-11-02
|
||||
|
||||
### Other
|
||||
|
||||
- Remove redundant flags ([#1256](https://github.com/rust-lang/cc-rs/pull/1256))
|
||||
|
||||
## [1.1.33](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.32...cc-v1.1.33) - 2024-11-02
|
||||
|
||||
### Other
|
||||
|
||||
- Reduce size of `cc::Build` and size of generated targets ([#1257](https://github.com/rust-lang/cc-rs/pull/1257))
|
||||
|
||||
## [1.1.32](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.31...cc-v1.1.32) - 2024-11-02
|
||||
|
||||
### Other
|
||||
|
||||
- Use `rustc`'s knowledge of LLVM/Clang target triples ([#1252](https://github.com/rust-lang/cc-rs/pull/1252))
|
||||
- Use Cargo's target information when possible ([#1225](https://github.com/rust-lang/cc-rs/pull/1225))
|
||||
|
||||
## [1.1.31](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.30...cc-v1.1.31) - 2024-10-19
|
||||
|
||||
### Other
|
||||
|
||||
- Add comment explaining why cc does not rebuild on env PATH change ([#1247](https://github.com/rust-lang/cc-rs/pull/1247))
|
||||
|
||||
## [1.1.30](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.29...cc-v1.1.30) - 2024-10-11
|
||||
|
||||
### Other
|
||||
|
||||
- Don't pass -fPIC by default on wasm ([#1245](https://github.com/rust-lang/cc-rs/pull/1245))
|
||||
|
||||
## [1.1.29](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.28...cc-v1.1.29) - 2024-10-11
|
||||
|
||||
### Other
|
||||
|
||||
- Regenerate target info ([#1243](https://github.com/rust-lang/cc-rs/pull/1243))
|
||||
|
||||
## [1.1.28](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.27...cc-v1.1.28) - 2024-10-06
|
||||
|
||||
### Other
|
||||
|
||||
- Environment variables: For one accepting boolean, treat "0", "false" and empty env as false ([#1238](https://github.com/rust-lang/cc-rs/pull/1238))
|
||||
|
||||
## [1.1.27](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.26...cc-v1.1.27) - 2024-10-06
|
||||
|
||||
### Other
|
||||
|
||||
- Revert "Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))" ([#1237](https://github.com/rust-lang/cc-rs/pull/1237))
|
||||
- Disable `CC_ENABLE_DEBUG_OUTPUT` if it is set to "0" ([#1234](https://github.com/rust-lang/cc-rs/pull/1234))
|
||||
|
||||
## [1.1.26](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.25...cc-v1.1.26) - 2024-10-06
|
||||
|
||||
### Other
|
||||
|
||||
- Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))
|
||||
|
||||
## [1.1.25](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.24...cc-v1.1.25) - 2024-10-05
|
||||
|
||||
### Other
|
||||
|
||||
- Remove incorrect "lib" prefixes in CXXSTDLIB doc comments ([#1228](https://github.com/rust-lang/cc-rs/pull/1228))
|
||||
|
||||
## [1.1.24](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.23...cc-v1.1.24) - 2024-10-01
|
||||
|
||||
### Other
|
||||
|
||||
- Fix wasm32-wasip1-threads: shared-memory disallowed due to not compiled with 'atomics' or 'bulk-memory' features ([#1221](https://github.com/rust-lang/cc-rs/pull/1221))
|
||||
- Reduce the need for the host target triple ([#1224](https://github.com/rust-lang/cc-rs/pull/1224))
|
||||
- Add auto cancellation for CI jobs ([#1222](https://github.com/rust-lang/cc-rs/pull/1222))
|
||||
|
||||
## [1.1.23](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.22...cc-v1.1.23) - 2024-09-30
|
||||
|
||||
### Other
|
||||
|
||||
- Update doc for detecting changes/upgrades of compilers ([#1218](https://github.com/rust-lang/cc-rs/pull/1218))
|
||||
|
||||
## [1.1.22](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.21...cc-v1.1.22) - 2024-09-27
|
||||
|
||||
### Other
|
||||
|
||||
- Don't rerun if PATH changes ([#1215](https://github.com/rust-lang/cc-rs/pull/1215))
|
||||
|
||||
## [1.1.21](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.20...cc-v1.1.21) - 2024-09-18
|
||||
|
||||
### Other
|
||||
|
||||
- disable pic for targets that end in `-none` ([#1212](https://github.com/rust-lang/cc-rs/pull/1212))
|
||||
|
||||
## [1.1.20](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.19...cc-v1.1.20) - 2024-09-17
|
||||
|
||||
### Other
|
||||
|
||||
- Add buildcache as known Rust and C/C++ compiler wrapper ([#1209](https://github.com/rust-lang/cc-rs/pull/1209))
|
||||
|
||||
## [1.1.19](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.18...cc-v1.1.19) - 2024-09-15
|
||||
|
||||
### Other
|
||||
|
||||
- Add support arm64e-apple-darwin ([#1207](https://github.com/rust-lang/cc-rs/pull/1207))
|
||||
|
||||
## [1.1.18](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.17...cc-v1.1.18) - 2024-09-07
|
||||
|
||||
### Other
|
||||
- Fixed unsoundness in `StderrForwarder::forward_available` ([#1203](https://github.com/rust-lang/cc-rs/pull/1203))
|
||||
|
||||
## [1.1.17](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.16...cc-v1.1.17) - 2024-09-06
|
||||
|
||||
### Fixed
|
||||
- fix finding toolchains when invoked by msbuild ([#1201](https://github.com/rust-lang/cc-rs/pull/1201))
|
||||
|
||||
## [1.1.16](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.15...cc-v1.1.16) - 2024-09-04
|
||||
|
||||
### Other
|
||||
- Treat VxWorks wr-cc as a Gnu compiler ([#1198](https://github.com/rust-lang/cc-rs/pull/1198))
|
||||
|
||||
## [1.1.15](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.14...cc-v1.1.15) - 2024-08-26
|
||||
|
||||
### Other
|
||||
- Add -mfloat-abi=hard as a default argument when using any arm/thumb-none-eabihf target ([#1194](https://github.com/rust-lang/cc-rs/pull/1194))
|
||||
|
||||
## [1.1.14](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.13...cc-v1.1.14) - 2024-08-23
|
||||
|
||||
### Other
|
||||
- allow finding tools from path if VisualStudioDir is set
|
||||
|
||||
## [1.1.13](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.12...cc-v1.1.13) - 2024-08-16
|
||||
|
||||
### Other
|
||||
- Fix detect family: should detect emscripten as clang, closes [#1185](https://github.com/rust-lang/cc-rs/pull/1185) ([#1186](https://github.com/rust-lang/cc-rs/pull/1186))
|
||||
|
||||
## [1.1.12](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.11...cc-v1.1.12) - 2024-08-15
|
||||
|
||||
### Other
|
||||
- improve docs ([#1183](https://github.com/rust-lang/cc-rs/pull/1183))
|
||||
|
||||
## [1.1.11](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.10...cc-v1.1.11) - 2024-08-14
|
||||
|
||||
### Other
|
||||
- Add support for parsing shell encoded `*FLAGS` ([#1181](https://github.com/rust-lang/cc-rs/pull/1181))
|
||||
- Replace vector of tuples with BTreeMap which already is sorted and free of duplicates ([#1177](https://github.com/rust-lang/cc-rs/pull/1177))
|
||||
|
||||
## [1.1.10](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.9...cc-v1.1.10) - 2024-08-11
|
||||
|
||||
### Other
|
||||
- Remap Windows targets triples to their LLVM counterparts ([#1176](https://github.com/rust-lang/cc-rs/pull/1176))
|
||||
|
||||
## [1.1.9](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.8...cc-v1.1.9) - 2024-08-11
|
||||
|
||||
### Other
|
||||
- Add custom CC wrapper to the wrapper whitelist ([#1175](https://github.com/rust-lang/cc-rs/pull/1175))
|
||||
|
||||
## [1.1.8](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.7...cc-v1.1.8) - 2024-08-06
|
||||
|
||||
### Other
|
||||
- Fix broken link in docs.rs ([#1173](https://github.com/rust-lang/cc-rs/pull/1173))
|
||||
|
||||
## [1.1.7](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.6...cc-v1.1.7) - 2024-07-29
|
||||
|
||||
### Other
|
||||
- add `.objects` ([#1166](https://github.com/rust-lang/cc-rs/pull/1166))
|
||||
|
||||
## [1.1.6](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.5...cc-v1.1.6) - 2024-07-19
|
||||
|
||||
### Other
|
||||
- Clippy fixes ([#1163](https://github.com/rust-lang/cc-rs/pull/1163))
|
||||
|
||||
## [1.1.5](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.4...cc-v1.1.5) - 2024-07-15
|
||||
|
||||
### Other
|
||||
- Fix cyclic compilation: Use vendored once_cell ([#1154](https://github.com/rust-lang/cc-rs/pull/1154))
|
||||
|
||||
## [1.1.4](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.3...cc-v1.1.4) - 2024-07-14
|
||||
|
||||
### Other
|
||||
- Support compiling on wasm targets (Supersede [#1068](https://github.com/rust-lang/cc-rs/pull/1068)) ([#1160](https://github.com/rust-lang/cc-rs/pull/1160))
|
||||
|
||||
## [1.1.3](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.2...cc-v1.1.3) - 2024-07-14
|
||||
|
||||
### Other
|
||||
- Reduce msrv to 1.63 ([#1158](https://github.com/rust-lang/cc-rs/pull/1158))
|
||||
- Revert "Use raw-dylib for windows-sys ([#1137](https://github.com/rust-lang/cc-rs/pull/1137))" ([#1157](https://github.com/rust-lang/cc-rs/pull/1157))
|
||||
- Fix typos ([#1152](https://github.com/rust-lang/cc-rs/pull/1152))
|
||||
- Fix `doc_lazy_continuation` lints ([#1153](https://github.com/rust-lang/cc-rs/pull/1153))
|
||||
|
||||
## [1.1.2](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.1...cc-v1.1.2) - 2024-07-12
|
||||
|
||||
### Other
|
||||
- Add empty `jobserver` feature. ([#1150](https://github.com/rust-lang/cc-rs/pull/1150))
|
||||
|
||||
## [1.1.1](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.0...cc-v1.1.1) - 2024-07-12
|
||||
|
||||
### Other
|
||||
- Fix is_flag_supported not respecting emit_rerun_if_env_changed ([#1147](https://github.com/rust-lang/cc-rs/pull/1147)) ([#1148](https://github.com/rust-lang/cc-rs/pull/1148))
|
||||
|
||||
## [1.1.0](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.106...cc-v1.1.0) - 2024-07-08
|
||||
|
||||
### Added
|
||||
- add cargo_output to eliminate last vestiges of stdout pollution ([#1141](https://github.com/rust-lang/cc-rs/pull/1141))
|
||||
|
||||
## [1.0.106](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.105...cc-v1.0.106) - 2024-07-08
|
||||
|
||||
### Other
|
||||
- Drop support for Visual Studio 12 (2013) ([#1046](https://github.com/rust-lang/cc-rs/pull/1046))
|
||||
- Use raw-dylib for windows-sys ([#1137](https://github.com/rust-lang/cc-rs/pull/1137))
|
||||
- Bump msrv to 1.67 ([#1143](https://github.com/rust-lang/cc-rs/pull/1143))
|
||||
- Bump msrv to 1.65 ([#1140](https://github.com/rust-lang/cc-rs/pull/1140))
|
||||
- Fix clippy warnings ([#1138](https://github.com/rust-lang/cc-rs/pull/1138))
|
||||
|
||||
## [1.0.105](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.104...cc-v1.0.105) - 2024-07-07
|
||||
|
||||
### Other
|
||||
- Regenerate windows sys bindings ([#1132](https://github.com/rust-lang/cc-rs/pull/1132))
|
||||
- Fix generate-windows-sys-bindings ([#1133](https://github.com/rust-lang/cc-rs/pull/1133))
|
||||
- Fix gen-windows-sys-binding ([#1130](https://github.com/rust-lang/cc-rs/pull/1130))
|
||||
- Fix gen-windows-sys-binding ([#1127](https://github.com/rust-lang/cc-rs/pull/1127))
|
||||
- Update windows-bindgen requirement from 0.57 to 0.58 ([#1123](https://github.com/rust-lang/cc-rs/pull/1123))
|
||||
|
||||
## [1.0.104](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.103...cc-v1.0.104) - 2024-07-01
|
||||
|
||||
### Other
|
||||
- Fixed link break about compile-time-requirements ([#1118](https://github.com/rust-lang/cc-rs/pull/1118))
|
||||
|
||||
## [1.0.103](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.102...cc-v1.0.103) - 2024-06-30
|
||||
|
||||
### Other
|
||||
- Fix compilation for wasm: env WASI_SYSROOT should be optional ([#1114](https://github.com/rust-lang/cc-rs/pull/1114))
|
||||
|
||||
## [1.0.102](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.101...cc-v1.0.102) - 2024-06-29
|
||||
|
||||
### Other
|
||||
- Fix invalid wasi targets compatibility ([#1105](https://github.com/rust-lang/cc-rs/pull/1105))
|
||||
- Speedup regenerate-target-info and regenerate-windows-sys ([#1110](https://github.com/rust-lang/cc-rs/pull/1110))
|
||||
|
||||
## [1.0.101](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.100...cc-v1.0.101) - 2024-06-25
|
||||
|
||||
### Other
|
||||
- Use `Build::getenv` instead of `env::var*` in anywhere that makes sense ([#1103](https://github.com/rust-lang/cc-rs/pull/1103))
|
||||
|
||||
## [1.0.100](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.99...cc-v1.0.100) - 2024-06-23
|
||||
|
||||
### Other
|
||||
- Update publish.yml to use release-plz ([#1101](https://github.com/rust-lang/cc-rs/pull/1101))
|
||||
- Accept `OsStr` instead of `str` for flags ([#1100](https://github.com/rust-lang/cc-rs/pull/1100))
|
||||
- Use `dep:` syntax to avoid implicit features. ([#1099](https://github.com/rust-lang/cc-rs/pull/1099))
|
||||
- Minor clippy fixes. ([#1098](https://github.com/rust-lang/cc-rs/pull/1098))
|
||||
- Fix WASI compilation for C++ ([#1083](https://github.com/rust-lang/cc-rs/pull/1083))
|
||||
- Regenerate windows sys bindings ([#1096](https://github.com/rust-lang/cc-rs/pull/1096))
|
||||
- Rename regenerate-windows-sys to regenerate-windows-sys.yml ([#1095](https://github.com/rust-lang/cc-rs/pull/1095))
|
||||
- Create regenerate-windows-sys.yml ([#1094](https://github.com/rust-lang/cc-rs/pull/1094))
|
||||
- Update windows-bindgen requirement from 0.56 to 0.57 ([#1091](https://github.com/rust-lang/cc-rs/pull/1091))
|
||||
- Eagerly close tempfile to fix [#1082](https://github.com/rust-lang/cc-rs/pull/1082) ([#1087](https://github.com/rust-lang/cc-rs/pull/1087))
|
||||
- Output msvc.exe in the output directory ([#1090](https://github.com/rust-lang/cc-rs/pull/1090))
|
||||
- Fix clippy warnings on Windows ([#1088](https://github.com/rust-lang/cc-rs/pull/1088))
|
||||
- Don't try to free DLL on drop ([#1089](https://github.com/rust-lang/cc-rs/pull/1089))
|
||||
- Fix panic safety issue in StderrForwarder ([#1079](https://github.com/rust-lang/cc-rs/pull/1079))
|
||||
113
third_party/rust/cc/Cargo.lock
generated
vendored
113
third_party/rust/cc/Cargo.lock
generated
vendored
@@ -4,16 +4,17 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.2"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.89"
|
||||
version = "1.2.10"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
@@ -25,9 +26,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
@@ -35,36 +36,53 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.28"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6"
|
||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.153"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.13"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.31"
|
||||
version = "0.38.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
||||
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
@@ -74,35 +92,50 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.1"
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
@@ -111,42 +144,48 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.4"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
24
third_party/rust/cc/Cargo.toml
vendored
24
third_party/rust/cc/Cargo.toml
vendored
@@ -11,15 +11,21 @@
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
rust-version = "1.53"
|
||||
rust-version = "1.63"
|
||||
name = "cc"
|
||||
version = "1.0.89"
|
||||
version = "1.2.10"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
build = false
|
||||
exclude = [
|
||||
"/.github",
|
||||
"tests",
|
||||
"src/bin",
|
||||
]
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
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
|
||||
@@ -33,18 +39,26 @@ categories = ["development-tools::build-utils"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/cc-rs"
|
||||
|
||||
[lib]
|
||||
name = "cc"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies.jobserver]
|
||||
version = "0.1.20"
|
||||
version = "0.1.30"
|
||||
optional = true
|
||||
default-features = false
|
||||
|
||||
[dependencies.shlex]
|
||||
version = "1.3.0"
|
||||
|
||||
[dev-dependencies.tempfile]
|
||||
version = "3"
|
||||
|
||||
[features]
|
||||
jobserver = []
|
||||
parallel = [
|
||||
"libc",
|
||||
"jobserver",
|
||||
"dep:libc",
|
||||
"dep:jobserver",
|
||||
]
|
||||
|
||||
[target."cfg(unix)".dependencies.libc]
|
||||
|
||||
5
third_party/rust/cc/clippy.toml
vendored
Normal file
5
third_party/rust/cc/clippy.toml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
disallowed-methods = [
|
||||
{ path = "std::env::var_os", reason = "Please use Build::getenv" },
|
||||
{ path = "std::env::var", reason = "Please use Build::getenv" },
|
||||
]
|
||||
doc-valid-idents = ["AppleClang", "OpenBSD", ".."]
|
||||
198
third_party/rust/cc/src/command_helpers.rs
vendored
198
third_party/rust/cc/src/command_helpers.rs
vendored
@@ -1,6 +1,7 @@
|
||||
//! Miscellaneous helpers for running commands
|
||||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::hash_map,
|
||||
ffi::OsString,
|
||||
fmt::Display,
|
||||
@@ -22,15 +23,32 @@ pub(crate) struct CargoOutput {
|
||||
pub(crate) metadata: bool,
|
||||
pub(crate) warnings: bool,
|
||||
pub(crate) debug: bool,
|
||||
pub(crate) output: OutputKind,
|
||||
checked_dbg_var: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
/// Different strategies for handling compiler output (to stdout)
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) enum OutputKind {
|
||||
/// Forward the output to this process' stdout ([`Stdio::inherit()`])
|
||||
Forward,
|
||||
/// Discard the output ([`Stdio::null()`])
|
||||
Discard,
|
||||
/// Capture the result (`[Stdio::piped()`])
|
||||
Capture,
|
||||
}
|
||||
|
||||
impl CargoOutput {
|
||||
pub(crate) fn new() -> Self {
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
Self {
|
||||
metadata: true,
|
||||
warnings: true,
|
||||
debug: std::env::var_os("CC_ENABLE_DEBUG_OUTPUT").is_some(),
|
||||
output: OutputKind::Forward,
|
||||
debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") {
|
||||
Some(v) => v != "0" && v != "false" && v != "",
|
||||
None => false,
|
||||
},
|
||||
checked_dbg_var: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
@@ -64,6 +82,14 @@ impl CargoOutput {
|
||||
Stdio::null()
|
||||
}
|
||||
}
|
||||
|
||||
fn stdio_for_output(&self) -> Stdio {
|
||||
match self.output {
|
||||
OutputKind::Capture => Stdio::piped(),
|
||||
OutputKind::Forward => Stdio::inherit(),
|
||||
OutputKind::Discard => Stdio::null(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct StderrForwarder {
|
||||
@@ -72,6 +98,8 @@ pub(crate) struct StderrForwarder {
|
||||
is_non_blocking: bool,
|
||||
#[cfg(feature = "parallel")]
|
||||
bytes_available_failed: bool,
|
||||
/// number of bytes buffered in inner
|
||||
bytes_buffered: usize,
|
||||
}
|
||||
|
||||
const MIN_BUFFER_CAPACITY: usize = 100;
|
||||
@@ -83,6 +111,7 @@ impl StderrForwarder {
|
||||
.stderr
|
||||
.take()
|
||||
.map(|stderr| (stderr, Vec::with_capacity(MIN_BUFFER_CAPACITY))),
|
||||
bytes_buffered: 0,
|
||||
#[cfg(feature = "parallel")]
|
||||
is_non_blocking: false,
|
||||
#[cfg(feature = "parallel")]
|
||||
@@ -90,12 +119,9 @@ impl StderrForwarder {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::uninit_vec)]
|
||||
fn forward_available(&mut self) -> bool {
|
||||
if let Some((stderr, buffer)) = self.inner.as_mut() {
|
||||
loop {
|
||||
let old_data_end = buffer.len();
|
||||
|
||||
// For non-blocking we check to see if there is data available, so we should try to
|
||||
// read at least that much. For blocking, always read at least the minimum amount.
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
@@ -104,7 +130,7 @@ impl StderrForwarder {
|
||||
let to_reserve = if self.is_non_blocking && !self.bytes_available_failed {
|
||||
match crate::parallel::stderr::bytes_available(stderr) {
|
||||
#[cfg(windows)]
|
||||
Ok(0) => return false,
|
||||
Ok(0) => break false,
|
||||
#[cfg(unix)]
|
||||
Ok(0) => {
|
||||
// On Unix, depending on the implementation, we may sometimes get 0 in a
|
||||
@@ -120,7 +146,7 @@ impl StderrForwarder {
|
||||
write_warning(&buffer[..]);
|
||||
}
|
||||
self.inner = None;
|
||||
return true;
|
||||
break true;
|
||||
}
|
||||
#[cfg(unix)]
|
||||
Err(_) => {
|
||||
@@ -130,48 +156,54 @@ impl StderrForwarder {
|
||||
self.bytes_available_failed = true;
|
||||
MIN_BUFFER_CAPACITY
|
||||
}
|
||||
#[cfg(target_family = "wasm")]
|
||||
Err(_) => panic!("bytes_available should always succeed on wasm"),
|
||||
Ok(bytes_available) => MIN_BUFFER_CAPACITY.max(bytes_available),
|
||||
}
|
||||
} else {
|
||||
MIN_BUFFER_CAPACITY
|
||||
};
|
||||
buffer.reserve(to_reserve);
|
||||
|
||||
// SAFETY: 1) the length is set to the capacity, so we are never using memory beyond
|
||||
// the underlying buffer and 2) we always call `truncate` below to set the len back
|
||||
// to the initialized data.
|
||||
unsafe {
|
||||
buffer.set_len(buffer.capacity());
|
||||
if self.bytes_buffered + to_reserve > buffer.len() {
|
||||
buffer.resize(self.bytes_buffered + to_reserve, 0);
|
||||
}
|
||||
match stderr.read(&mut buffer[old_data_end..]) {
|
||||
|
||||
match stderr.read(&mut buffer[self.bytes_buffered..]) {
|
||||
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => {
|
||||
// No data currently, yield back.
|
||||
buffer.truncate(old_data_end);
|
||||
return false;
|
||||
break false;
|
||||
}
|
||||
Err(err) if err.kind() == std::io::ErrorKind::Interrupted => {
|
||||
// Interrupted, try again.
|
||||
buffer.truncate(old_data_end);
|
||||
continue;
|
||||
}
|
||||
Ok(0) | Err(_) => {
|
||||
// End of stream: flush remaining data and bail.
|
||||
if old_data_end > 0 {
|
||||
write_warning(&buffer[..old_data_end]);
|
||||
}
|
||||
self.inner = None;
|
||||
return true;
|
||||
}
|
||||
Ok(bytes_read) => {
|
||||
buffer.truncate(old_data_end + bytes_read);
|
||||
Ok(bytes_read) if bytes_read != 0 => {
|
||||
self.bytes_buffered += bytes_read;
|
||||
let mut consumed = 0;
|
||||
for line in buffer.split_inclusive(|&b| b == b'\n') {
|
||||
for line in buffer[..self.bytes_buffered].split_inclusive(|&b| b == b'\n') {
|
||||
// Only forward complete lines, leave the rest in the buffer.
|
||||
if let Some((b'\n', line)) = line.split_last() {
|
||||
consumed += line.len() + 1;
|
||||
write_warning(line);
|
||||
}
|
||||
}
|
||||
buffer.drain(..consumed);
|
||||
if consumed > 0 && consumed < self.bytes_buffered {
|
||||
// Remove the consumed bytes from buffer
|
||||
buffer.copy_within(consumed.., 0);
|
||||
}
|
||||
self.bytes_buffered -= consumed;
|
||||
}
|
||||
res => {
|
||||
// End of stream: flush remaining data and bail.
|
||||
if self.bytes_buffered > 0 {
|
||||
write_warning(&buffer[..self.bytes_buffered]);
|
||||
}
|
||||
if let Err(err) = res {
|
||||
write_warning(
|
||||
format!("Failed to read from child stderr: {err}").as_bytes(),
|
||||
);
|
||||
}
|
||||
self.inner.take();
|
||||
break true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,7 +247,7 @@ fn write_warning(line: &[u8]) {
|
||||
|
||||
fn wait_on_child(
|
||||
cmd: &Command,
|
||||
program: &str,
|
||||
program: &Path,
|
||||
child: &mut Child,
|
||||
cargo_output: &CargoOutput,
|
||||
) -> Result<(), Error> {
|
||||
@@ -227,8 +259,10 @@ fn wait_on_child(
|
||||
return Err(Error::new(
|
||||
ErrorKind::ToolExecError,
|
||||
format!(
|
||||
"Failed to wait on spawned child process, command {:?} with args {:?}: {}.",
|
||||
cmd, program, e
|
||||
"Failed to wait on spawned child process, command {:?} with args {}: {}.",
|
||||
cmd,
|
||||
program.display(),
|
||||
e
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -242,8 +276,10 @@ fn wait_on_child(
|
||||
Err(Error::new(
|
||||
ErrorKind::ToolExecError,
|
||||
format!(
|
||||
"Command {:?} with args {:?} did not execute successfully (status code {}).",
|
||||
cmd, program, status
|
||||
"Command {:?} with args {} did not execute successfully (status code {}).",
|
||||
cmd,
|
||||
program.display(),
|
||||
status
|
||||
),
|
||||
))
|
||||
}
|
||||
@@ -276,7 +312,24 @@ pub(crate) fn objects_from_files(files: &[Arc<Path>], dst: &Path) -> Result<Vec<
|
||||
// Hash the dirname. This should prevent conflicts if we have multiple
|
||||
// object files with the same filename in different subfolders.
|
||||
let mut hasher = hash_map::DefaultHasher::new();
|
||||
hasher.write(dirname.to_string().as_bytes());
|
||||
|
||||
// Make the dirname relative (if possible) to avoid full system paths influencing the sha
|
||||
// and making the output system-dependent
|
||||
//
|
||||
// NOTE: Here we allow using std::env::var (instead of Build::getenv) because
|
||||
// CARGO_* variables always trigger a rebuild when changed
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
let dirname = if let Some(root) = std::env::var_os("CARGO_MANIFEST_DIR") {
|
||||
let root = root.to_string_lossy();
|
||||
Cow::Borrowed(dirname.strip_prefix(&*root).unwrap_or(&dirname))
|
||||
} else {
|
||||
dirname
|
||||
};
|
||||
|
||||
hasher.write(dirname.as_bytes());
|
||||
if let Some(extension) = file.extension() {
|
||||
hasher.write(extension.to_string_lossy().as_bytes());
|
||||
}
|
||||
let obj = dst
|
||||
.join(format!("{:016x}-{}", hasher.finish(), basename))
|
||||
.with_extension("o");
|
||||
@@ -299,21 +352,26 @@ pub(crate) fn objects_from_files(files: &[Arc<Path>], dst: &Path) -> Result<Vec<
|
||||
|
||||
pub(crate) fn run(
|
||||
cmd: &mut Command,
|
||||
program: &str,
|
||||
program: impl AsRef<Path>,
|
||||
cargo_output: &CargoOutput,
|
||||
) -> Result<(), Error> {
|
||||
let program = program.as_ref();
|
||||
|
||||
let mut child = spawn(cmd, program, cargo_output)?;
|
||||
wait_on_child(cmd, program, &mut child, cargo_output)
|
||||
}
|
||||
|
||||
pub(crate) fn run_output(
|
||||
cmd: &mut Command,
|
||||
program: &str,
|
||||
program: impl AsRef<Path>,
|
||||
cargo_output: &CargoOutput,
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
cmd.stdout(Stdio::piped());
|
||||
let program = program.as_ref();
|
||||
|
||||
let mut child = spawn(cmd, program, cargo_output)?;
|
||||
// We specifically need the output to be captured, so override default
|
||||
let mut captured_cargo_output = cargo_output.clone();
|
||||
captured_cargo_output.output = OutputKind::Capture;
|
||||
let mut child = spawn(cmd, program, &captured_cargo_output)?;
|
||||
|
||||
let mut stdout = vec![];
|
||||
child
|
||||
@@ -323,6 +381,7 @@ pub(crate) fn run_output(
|
||||
.read_to_end(&mut stdout)
|
||||
.unwrap();
|
||||
|
||||
// Don't care about this output, use the normal settings
|
||||
wait_on_child(cmd, program, &mut child, cargo_output)?;
|
||||
|
||||
Ok(stdout)
|
||||
@@ -330,7 +389,7 @@ pub(crate) fn run_output(
|
||||
|
||||
pub(crate) fn spawn(
|
||||
cmd: &mut Command,
|
||||
program: &str,
|
||||
program: &Path,
|
||||
cargo_output: &CargoOutput,
|
||||
) -> Result<Child, Error> {
|
||||
struct ResetStderr<'cmd>(&'cmd mut Command);
|
||||
@@ -346,42 +405,55 @@ pub(crate) fn spawn(
|
||||
cargo_output.print_debug(&format_args!("running: {:?}", cmd));
|
||||
|
||||
let cmd = ResetStderr(cmd);
|
||||
let child = cmd.0.stderr(cargo_output.stdio_for_warnings()).spawn();
|
||||
let child = cmd
|
||||
.0
|
||||
.stderr(cargo_output.stdio_for_warnings())
|
||||
.stdout(cargo_output.stdio_for_output())
|
||||
.spawn();
|
||||
match child {
|
||||
Ok(child) => Ok(child),
|
||||
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
|
||||
let extra = if cfg!(windows) {
|
||||
" (see https://github.com/rust-lang/cc-rs#compile-time-requirements \
|
||||
" (see https://docs.rs/cc/latest/cc/#compile-time-requirements \
|
||||
for help)"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
Err(Error::new(
|
||||
ErrorKind::ToolNotFound,
|
||||
format!("Failed to find tool. Is `{}` installed?{}", program, extra),
|
||||
format!(
|
||||
"Failed to find tool. Is `{}` installed?{}",
|
||||
program.display(),
|
||||
extra
|
||||
),
|
||||
))
|
||||
}
|
||||
Err(e) => Err(Error::new(
|
||||
ErrorKind::ToolExecError,
|
||||
format!(
|
||||
"Command {:?} with args {:?} failed to start: {:?}",
|
||||
cmd.0, program, e
|
||||
"Command {:?} with args {} failed to start: {:?}",
|
||||
cmd.0,
|
||||
program.display(),
|
||||
e
|
||||
),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn command_add_output_file(
|
||||
cmd: &mut Command,
|
||||
dst: &Path,
|
||||
cuda: bool,
|
||||
msvc: bool,
|
||||
clang: bool,
|
||||
gnu: bool,
|
||||
is_asm: bool,
|
||||
is_arm: bool,
|
||||
) {
|
||||
if msvc && !clang && !gnu && !cuda && !(is_asm && is_arm) {
|
||||
pub(crate) struct CmdAddOutputFileArgs {
|
||||
pub(crate) cuda: bool,
|
||||
pub(crate) is_assembler_msvc: bool,
|
||||
pub(crate) msvc: bool,
|
||||
pub(crate) clang: bool,
|
||||
pub(crate) gnu: bool,
|
||||
pub(crate) is_asm: bool,
|
||||
pub(crate) is_arm: bool,
|
||||
}
|
||||
|
||||
pub(crate) fn command_add_output_file(cmd: &mut Command, dst: &Path, args: CmdAddOutputFileArgs) {
|
||||
if args.is_assembler_msvc
|
||||
|| !(!args.msvc || args.clang || args.gnu || args.cuda || (args.is_asm && args.is_arm))
|
||||
{
|
||||
let mut s = OsString::from("-Fo");
|
||||
s.push(dst);
|
||||
cmd.arg(s);
|
||||
@@ -393,7 +465,7 @@ pub(crate) fn command_add_output_file(
|
||||
#[cfg(feature = "parallel")]
|
||||
pub(crate) fn try_wait_on_child(
|
||||
cmd: &Command,
|
||||
program: &str,
|
||||
program: &Path,
|
||||
child: &mut Child,
|
||||
stdout: &mut dyn io::Write,
|
||||
stderr_forwarder: &mut StderrForwarder,
|
||||
@@ -412,8 +484,10 @@ pub(crate) fn try_wait_on_child(
|
||||
Err(Error::new(
|
||||
ErrorKind::ToolExecError,
|
||||
format!(
|
||||
"Command {:?} with args {:?} did not execute successfully (status code {}).",
|
||||
cmd, program, status
|
||||
"Command {:?} with args {} did not execute successfully (status code {}).",
|
||||
cmd,
|
||||
program.display(),
|
||||
status
|
||||
),
|
||||
))
|
||||
}
|
||||
@@ -424,8 +498,10 @@ pub(crate) fn try_wait_on_child(
|
||||
Err(Error::new(
|
||||
ErrorKind::ToolExecError,
|
||||
format!(
|
||||
"Failed to wait on spawned child process, command {:?} with args {:?}: {}.",
|
||||
cmd, program, e
|
||||
"Failed to wait on spawned child process, command {:?} with args {}: {}.",
|
||||
cmd,
|
||||
program.display(),
|
||||
e
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
15
third_party/rust/cc/src/detect_compiler_family.c
vendored
Normal file
15
third_party/rust/cc/src/detect_compiler_family.c
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifdef __clang__
|
||||
#pragma message "clang"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma message "gcc"
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#pragma message "emscripten"
|
||||
#endif
|
||||
|
||||
#ifdef __VXWORKS__
|
||||
#pragma message "VxWorks"
|
||||
#endif
|
||||
492
third_party/rust/cc/src/flags.rs
vendored
Normal file
492
third_party/rust/cc/src/flags.rs
vendored
Normal file
@@ -0,0 +1,492 @@
|
||||
use crate::target::TargetInfo;
|
||||
use crate::{Build, Error, ErrorKind, Tool, ToolFamily};
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::OsString;
|
||||
|
||||
#[derive(Debug, PartialEq, Default)]
|
||||
pub(crate) struct RustcCodegenFlags<'a> {
|
||||
branch_protection: Option<&'a str>,
|
||||
code_model: Option<&'a str>,
|
||||
no_vectorize_loops: bool,
|
||||
no_vectorize_slp: bool,
|
||||
profile_generate: Option<&'a str>,
|
||||
profile_use: Option<&'a str>,
|
||||
control_flow_guard: Option<&'a str>,
|
||||
lto: Option<&'a str>,
|
||||
relocation_model: Option<&'a str>,
|
||||
embed_bitcode: Option<bool>,
|
||||
force_frame_pointers: Option<bool>,
|
||||
link_dead_code: Option<bool>,
|
||||
no_redzone: Option<bool>,
|
||||
soft_float: Option<bool>,
|
||||
}
|
||||
|
||||
impl<'this> RustcCodegenFlags<'this> {
|
||||
// Parse flags obtained from CARGO_ENCODED_RUSTFLAGS
|
||||
pub(crate) fn parse(rustflags_env: &'this str) -> Result<Self, Error> {
|
||||
fn is_flag_prefix(flag: &str) -> bool {
|
||||
[
|
||||
"-Z",
|
||||
"-C",
|
||||
"--codegen",
|
||||
"-L",
|
||||
"-l",
|
||||
"-o",
|
||||
"-W",
|
||||
"--warn",
|
||||
"-A",
|
||||
"--allow",
|
||||
"-D",
|
||||
"--deny",
|
||||
"-F",
|
||||
"--forbid",
|
||||
]
|
||||
.contains(&flag)
|
||||
}
|
||||
|
||||
fn handle_flag_prefix<'a>(prev: &'a str, curr: &'a str) -> (&'a str, &'a str) {
|
||||
match prev {
|
||||
"--codegen" | "-C" => ("-C", curr),
|
||||
// Handle flags passed like --codegen=code-model=small
|
||||
_ if curr.starts_with("--codegen=") => ("-C", &curr[10..]),
|
||||
"-Z" => ("-Z", curr),
|
||||
"-L" | "-l" | "-o" => (prev, curr),
|
||||
// Handle lint flags
|
||||
"-W" | "--warn" => ("-W", curr),
|
||||
"-A" | "--allow" => ("-A", curr),
|
||||
"-D" | "--deny" => ("-D", curr),
|
||||
"-F" | "--forbid" => ("-F", curr),
|
||||
_ => ("", curr),
|
||||
}
|
||||
}
|
||||
|
||||
let mut codegen_flags = Self::default();
|
||||
|
||||
let mut prev_prefix = None;
|
||||
for curr in rustflags_env.split("\u{1f}") {
|
||||
let prev = prev_prefix.take().unwrap_or("");
|
||||
if prev.is_empty() && is_flag_prefix(curr) {
|
||||
prev_prefix = Some(curr);
|
||||
continue;
|
||||
}
|
||||
|
||||
let (prefix, rustc_flag) = handle_flag_prefix(prev, curr);
|
||||
codegen_flags.set_rustc_flag(prefix, rustc_flag)?;
|
||||
}
|
||||
|
||||
Ok(codegen_flags)
|
||||
}
|
||||
|
||||
fn set_rustc_flag(&mut self, prefix: &str, flag: &'this str) -> Result<(), Error> {
|
||||
// Convert a textual representation of a bool-like rustc flag argument into an actual bool
|
||||
fn arg_to_bool(arg: impl AsRef<str>) -> Option<bool> {
|
||||
match arg.as_ref() {
|
||||
"y" | "yes" | "on" | "true" => Some(true),
|
||||
"n" | "no" | "off" | "false" => Some(false),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
let (flag, value) = if let Some((flag, value)) = flag.split_once('=') {
|
||||
(flag, Some(value))
|
||||
} else {
|
||||
(flag, None)
|
||||
};
|
||||
let flag = if prefix.is_empty() {
|
||||
Cow::Borrowed(flag)
|
||||
} else {
|
||||
Cow::Owned(format!("{prefix}{flag}"))
|
||||
};
|
||||
|
||||
fn flag_ok_or<'flag>(
|
||||
flag: Option<&'flag str>,
|
||||
msg: &'static str,
|
||||
) -> Result<&'flag str, Error> {
|
||||
flag.ok_or(Error::new(ErrorKind::InvalidFlag, msg))
|
||||
}
|
||||
|
||||
match flag.as_ref() {
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#code-model
|
||||
"-Ccode-model" => {
|
||||
self.code_model = Some(flag_ok_or(value, "-Ccode-model must have a value")?);
|
||||
}
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#no-vectorize-loops
|
||||
"-Cno-vectorize-loops" => self.no_vectorize_loops = true,
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#no-vectorize-slp
|
||||
"-Cno-vectorize-slp" => self.no_vectorize_slp = true,
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#profile-generate
|
||||
"-Cprofile-generate" => {
|
||||
self.profile_generate =
|
||||
Some(flag_ok_or(value, "-Cprofile-generate must have a value")?);
|
||||
}
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#profile-use
|
||||
"-Cprofile-use" => {
|
||||
self.profile_use = Some(flag_ok_or(value, "-Cprofile-use must have a value")?);
|
||||
}
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#control-flow-guard
|
||||
"-Ccontrol-flow-guard" => self.control_flow_guard = value.or(Some("true")),
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#lto
|
||||
"-Clto" => self.lto = value.or(Some("true")),
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model
|
||||
"-Crelocation-model" => {
|
||||
self.relocation_model =
|
||||
Some(flag_ok_or(value, "-Crelocation-model must have a value")?);
|
||||
}
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#embed-bitcode
|
||||
"-Cembed-bitcode" => self.embed_bitcode = value.map_or(Some(true), arg_to_bool),
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#force-frame-pointers
|
||||
"-Cforce-frame-pointers" => {
|
||||
self.force_frame_pointers = value.map_or(Some(true), arg_to_bool)
|
||||
}
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#link-dead-code
|
||||
"-Clink-dead-code" => self.link_dead_code = value.map_or(Some(true), arg_to_bool),
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#no-redzone
|
||||
"-Cno-redzone" => self.no_redzone = value.map_or(Some(true), arg_to_bool),
|
||||
// https://doc.rust-lang.org/rustc/codegen-options/index.html#soft-float
|
||||
// Note: This flag is now deprecated in rustc.
|
||||
"-Csoft-float" => self.soft_float = value.map_or(Some(true), arg_to_bool),
|
||||
// https://doc.rust-lang.org/beta/unstable-book/compiler-flags/branch-protection.html
|
||||
// FIXME: Drop the -Z variant and update the doc link once the option is stabilised
|
||||
"-Zbranch-protection" | "-Cbranch-protection" => {
|
||||
self.branch_protection =
|
||||
Some(flag_ok_or(value, "-Zbranch-protection must have a value")?);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Rust and clang/cc don't agree on what equivalent flags should look like.
|
||||
pub(crate) fn cc_flags(&self, build: &Build, tool: &mut Tool, target: &TargetInfo<'_>) {
|
||||
let family = tool.family;
|
||||
// Push `flag` to `flags` if it is supported by the currently used CC
|
||||
let mut push_if_supported = |flag: OsString| {
|
||||
if build
|
||||
.is_flag_supported_inner(&flag, tool, target)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
tool.args.push(flag);
|
||||
} else {
|
||||
build.cargo_output.print_warning(&format!(
|
||||
"Inherited flag {:?} is not supported by the currently used CC",
|
||||
flag
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let clang_or_gnu =
|
||||
matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu { .. });
|
||||
|
||||
// Flags shared between clang and gnu
|
||||
if clang_or_gnu {
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbranch-protection
|
||||
if let Some(value) = self.branch_protection {
|
||||
push_if_supported(
|
||||
format!("-mbranch-protection={}", value.replace(",", "+")).into(),
|
||||
);
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mcmodel
|
||||
if let Some(value) = self.code_model {
|
||||
push_if_supported(format!("-mcmodel={value}").into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-vectorize
|
||||
if self.no_vectorize_loops {
|
||||
push_if_supported("-fno-vectorize".into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-slp-vectorize
|
||||
if self.no_vectorize_slp {
|
||||
push_if_supported("-fno-slp-vectorize".into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
|
||||
if let Some(value) = self.control_flow_guard {
|
||||
let cc_val = match value {
|
||||
"y" | "yes" | "on" | "true" | "checks" => Some("cf"),
|
||||
"nochecks" => Some("cf-nochecks"),
|
||||
"n" | "no" | "off" | "false" => Some("none"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(cc_val) = cc_val {
|
||||
push_if_supported(format!("-mguard={cc_val}").into());
|
||||
}
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
|
||||
if let Some(value) = self.lto {
|
||||
let cc_val = match value {
|
||||
"y" | "yes" | "on" | "true" | "fat" => Some("full"),
|
||||
"thin" => Some("thin"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(cc_val) = cc_val {
|
||||
push_if_supported(format!("-flto={cc_val}").into());
|
||||
}
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic
|
||||
if let Some(value) = self.relocation_model {
|
||||
let cc_flag = match value {
|
||||
"pic" => Some("-fPIC"),
|
||||
"pie" => Some("-fPIE"),
|
||||
"dynamic-no-pic" => Some("-mdynamic-no-pic"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(cc_flag) = cc_flag {
|
||||
push_if_supported(cc_flag.into());
|
||||
}
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode
|
||||
if let Some(value) = self.embed_bitcode {
|
||||
let cc_val = if value { "all" } else { "off" };
|
||||
push_if_supported(format!("-fembed-bitcode={cc_val}").into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-omit-frame-pointer
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
|
||||
if let Some(value) = self.force_frame_pointers {
|
||||
let cc_flag = if value {
|
||||
"-fno-omit-frame-pointer"
|
||||
} else {
|
||||
"-fomit-frame-pointer"
|
||||
};
|
||||
push_if_supported(cc_flag.into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-dead_strip
|
||||
if let Some(false) = self.link_dead_code {
|
||||
push_if_supported("-dead_strip".into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mno-red-zone
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mred-zone
|
||||
if let Some(value) = self.no_redzone {
|
||||
let cc_flag = if value { "-mno-red-zone" } else { "-mred-zone" };
|
||||
push_if_supported(cc_flag.into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-msoft-float
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mno-soft-float
|
||||
if let Some(value) = self.soft_float {
|
||||
let cc_flag = if value {
|
||||
"-msoft-float"
|
||||
} else {
|
||||
"-mno-soft-float"
|
||||
};
|
||||
push_if_supported(cc_flag.into());
|
||||
}
|
||||
}
|
||||
|
||||
// Compiler-exclusive flags
|
||||
match family {
|
||||
ToolFamily::Clang { .. } => {
|
||||
// GNU and Clang compilers both support the same PGO flags, but they use different libraries and
|
||||
// different formats for the profile files which are not compatible.
|
||||
// clang and rustc both internally use llvm, so we want to inherit the PGO flags only for clang.
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-generate
|
||||
if let Some(value) = self.profile_generate {
|
||||
push_if_supported(format!("-fprofile-generate={value}").into());
|
||||
}
|
||||
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-use
|
||||
if let Some(value) = self.profile_use {
|
||||
push_if_supported(format!("-fprofile-use={value}").into());
|
||||
}
|
||||
}
|
||||
ToolFamily::Gnu { .. } => {}
|
||||
ToolFamily::Msvc { .. } => {
|
||||
// https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard
|
||||
if let Some(value) = self.control_flow_guard {
|
||||
let cc_val = match value {
|
||||
"y" | "yes" | "on" | "true" | "checks" => Some("cf"),
|
||||
"n" | "no" | "off" | "false" => Some("cf-"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(cc_val) = cc_val {
|
||||
push_if_supported(format!("/guard:{cc_val}").into());
|
||||
}
|
||||
}
|
||||
// https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission
|
||||
if let Some(value) = self.force_frame_pointers {
|
||||
// Flag is unsupported on 64-bit arches
|
||||
if !target.arch.contains("64") {
|
||||
let cc_flag = if value { "/Oy-" } else { "/Oy" };
|
||||
push_if_supported(cc_flag.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[track_caller]
|
||||
fn check(env: &str, expected: &RustcCodegenFlags) {
|
||||
let actual = RustcCodegenFlags::parse(env).unwrap();
|
||||
assert_eq!(actual, *expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codegen_type() {
|
||||
let expected = RustcCodegenFlags {
|
||||
code_model: Some("tiny"),
|
||||
..RustcCodegenFlags::default()
|
||||
};
|
||||
check("-Ccode-model=tiny", &expected);
|
||||
check("-C\u{1f}code-model=tiny", &expected);
|
||||
check("--codegen\u{1f}code-model=tiny", &expected);
|
||||
check("--codegen=code-model=tiny", &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn precedence() {
|
||||
check(
|
||||
"-ccode-model=tiny\u{1f}-Ccode-model=small",
|
||||
&RustcCodegenFlags {
|
||||
code_model: Some("small"),
|
||||
..RustcCodegenFlags::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_valid_prefixes() {
|
||||
let expected = RustcCodegenFlags::default();
|
||||
check("-L\u{1f}-Clto", &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn three_valid_prefixes() {
|
||||
let expected = RustcCodegenFlags {
|
||||
lto: Some("true"),
|
||||
..RustcCodegenFlags::default()
|
||||
};
|
||||
check("-L\u{1f}-L\u{1f}-Clto", &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_rustc_flags() {
|
||||
// Throw all possible flags at the parser to catch false positives
|
||||
let flags = [
|
||||
// Set all the flags we recognise first
|
||||
"-Ccode-model=tiny",
|
||||
"-Ccontrol-flow-guard=yes",
|
||||
"-Cembed-bitcode=no",
|
||||
"-Cforce-frame-pointers=yes",
|
||||
"-Clto=false",
|
||||
"-Clink-dead-code=yes",
|
||||
"-Cno-redzone=yes",
|
||||
"-Cno-vectorize-loops",
|
||||
"-Cno-vectorize-slp",
|
||||
"-Cprofile-generate=fooprofile",
|
||||
"-Cprofile-use=fooprofile",
|
||||
"-Crelocation-model=pic",
|
||||
"-Csoft-float=yes",
|
||||
"-Zbranch-protection=bti,pac-ret,leaf",
|
||||
// Set flags we don't recognise but rustc supports next
|
||||
// rustc flags
|
||||
"--cfg",
|
||||
"a",
|
||||
"--check-cfg 'cfg(verbose)",
|
||||
"-L",
|
||||
"/usr/lib/foo",
|
||||
"-l",
|
||||
"static:+whole-archive=mylib",
|
||||
"--crate-type=dylib",
|
||||
"--crate-name=foo",
|
||||
"--edition=2021",
|
||||
"--emit=asm",
|
||||
"--print=crate-name",
|
||||
"-g",
|
||||
"-O",
|
||||
"-o",
|
||||
"foooutput",
|
||||
"--out-dir",
|
||||
"foooutdir",
|
||||
"--target",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"-W",
|
||||
"missing-docs",
|
||||
"-D",
|
||||
"unused-variables",
|
||||
"--force-warn",
|
||||
"dead-code",
|
||||
"-A",
|
||||
"unused",
|
||||
"-F",
|
||||
"unused",
|
||||
"--cap-lints",
|
||||
"warn",
|
||||
"--version",
|
||||
"--verbose",
|
||||
"-v",
|
||||
"--extern",
|
||||
"foocrate",
|
||||
"--sysroot",
|
||||
"fooroot",
|
||||
"--error-format",
|
||||
"human",
|
||||
"--color",
|
||||
"auto",
|
||||
"--diagnostic-width",
|
||||
"80",
|
||||
"--remap-path-prefix",
|
||||
"foo=bar",
|
||||
"--json=artifact",
|
||||
// Codegen flags
|
||||
"-Car",
|
||||
"-Ccodegen-units=1",
|
||||
"-Ccollapse-macro-debuginfo=yes",
|
||||
"-Cdebug-assertions=yes",
|
||||
"-Cdebuginfo=1",
|
||||
"-Cdefault-linker-libraries=yes",
|
||||
"-Cdlltool=foo",
|
||||
"-Cextra-filename=foo",
|
||||
"-Cforce-unwind-tables=yes",
|
||||
"-Cincremental=foodir",
|
||||
"-Cinline-threshold=6",
|
||||
"-Cinstrument-coverage",
|
||||
"-Clink-arg=-foo",
|
||||
"-Clink-args=-foo",
|
||||
"-Clink-self-contained=yes",
|
||||
"-Clinker=lld",
|
||||
"-Clinker-flavor=ld.lld",
|
||||
"-Clinker-plugin-lto=yes",
|
||||
"-Cllvm-args=foo",
|
||||
"-Cmetadata=foo",
|
||||
"-Cno-prepopulate-passes",
|
||||
"-Cno-stack-check",
|
||||
"-Copt-level=3",
|
||||
"-Coverflow-checks=yes",
|
||||
"-Cpanic=abort",
|
||||
"-Cpasses=foopass",
|
||||
"-Cprefer-dynamic=yes",
|
||||
"-Crelro-level=partial",
|
||||
"-Cremark=all",
|
||||
"-Crpath=yes",
|
||||
"-Csave-temps=yes",
|
||||
"-Csplit-debuginfo=packed",
|
||||
"-Cstrip=symbols",
|
||||
"-Csymbol-mangling-version=v0",
|
||||
"-Ctarget-cpu=native",
|
||||
"-Ctarget-feature=+sve",
|
||||
// Unstable options
|
||||
"-Ztune-cpu=machine",
|
||||
];
|
||||
check(
|
||||
&flags.join("\u{1f}"),
|
||||
&RustcCodegenFlags {
|
||||
code_model: Some("tiny"),
|
||||
control_flow_guard: Some("yes"),
|
||||
embed_bitcode: Some(false),
|
||||
force_frame_pointers: Some(true),
|
||||
link_dead_code: Some(true),
|
||||
lto: Some("false"),
|
||||
no_redzone: Some(true),
|
||||
no_vectorize_loops: true,
|
||||
no_vectorize_slp: true,
|
||||
profile_generate: Some("fooprofile"),
|
||||
profile_use: Some("fooprofile"),
|
||||
relocation_model: Some("pic"),
|
||||
soft_float: Some(true),
|
||||
branch_protection: Some("bti,pac-ret,leaf"),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
2452
third_party/rust/cc/src/lib.rs
vendored
2452
third_party/rust/cc/src/lib.rs
vendored
File diff suppressed because it is too large
Load Diff
124
third_party/rust/cc/src/parallel/job_token.rs
vendored
124
third_party/rust/cc/src/parallel/job_token.rs
vendored
@@ -1,6 +1,6 @@
|
||||
use std::{marker::PhantomData, mem::MaybeUninit, sync::Once};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::Error;
|
||||
use crate::{utilities::OnceLock, Error};
|
||||
|
||||
pub(crate) struct JobToken(PhantomData<()>);
|
||||
|
||||
@@ -34,19 +34,14 @@ impl JobTokenServer {
|
||||
/// that has to be static so that it will be shared by all cc
|
||||
/// compilation.
|
||||
fn new() -> &'static Self {
|
||||
static INIT: Once = Once::new();
|
||||
static mut JOBSERVER: MaybeUninit<JobTokenServer> = MaybeUninit::uninit();
|
||||
// TODO: Replace with a OnceLock once MSRV is 1.70
|
||||
static JOBSERVER: OnceLock<JobTokenServer> = OnceLock::new();
|
||||
|
||||
unsafe {
|
||||
INIT.call_once(|| {
|
||||
let server = inherited_jobserver::JobServer::from_env()
|
||||
.map(Self::Inherited)
|
||||
.unwrap_or_else(|| Self::InProcess(inprocess_jobserver::JobServer::new()));
|
||||
JOBSERVER = MaybeUninit::new(server);
|
||||
});
|
||||
// TODO: Poor man's assume_init_ref, as that'd require a MSRV of 1.55.
|
||||
&*JOBSERVER.as_ptr()
|
||||
}
|
||||
JOBSERVER.get_or_init(|| {
|
||||
unsafe { inherited_jobserver::JobServer::from_env() }
|
||||
.map(Self::Inherited)
|
||||
.unwrap_or_else(|| Self::InProcess(inprocess_jobserver::JobServer::new()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,19 +51,17 @@ pub(crate) enum ActiveJobTokenServer {
|
||||
}
|
||||
|
||||
impl ActiveJobTokenServer {
|
||||
pub(crate) fn new() -> Result<Self, Error> {
|
||||
pub(crate) fn new() -> Self {
|
||||
match JobTokenServer::new() {
|
||||
JobTokenServer::Inherited(inherited_jobserver) => {
|
||||
inherited_jobserver.enter_active().map(Self::Inherited)
|
||||
}
|
||||
JobTokenServer::InProcess(inprocess_jobserver) => {
|
||||
Ok(Self::InProcess(inprocess_jobserver))
|
||||
Self::Inherited(inherited_jobserver.enter_active())
|
||||
}
|
||||
JobTokenServer::InProcess(inprocess_jobserver) => Self::InProcess(inprocess_jobserver),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn acquire(&self) -> Result<JobToken, Error> {
|
||||
match &self {
|
||||
pub(crate) async fn acquire(&mut self) -> Result<JobToken, Error> {
|
||||
match self {
|
||||
Self::Inherited(jobserver) => jobserver.acquire().await,
|
||||
Self::InProcess(jobserver) => Ok(jobserver.acquire().await),
|
||||
}
|
||||
@@ -139,32 +132,40 @@ mod inherited_jobserver {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn enter_active(&self) -> Result<ActiveJobServer<'_>, Error> {
|
||||
ActiveJobServer::new(self)
|
||||
pub(super) fn enter_active(&self) -> ActiveJobServer<'_> {
|
||||
ActiveJobServer {
|
||||
jobserver: self,
|
||||
helper_thread: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HelperThread {
|
||||
inner: jobserver::HelperThread,
|
||||
/// When rx is dropped, all the token stored within it will be dropped.
|
||||
rx: mpsc::Receiver<io::Result<jobserver::Acquired>>,
|
||||
}
|
||||
|
||||
impl HelperThread {
|
||||
fn new(jobserver: &JobServer) -> Result<Self, Error> {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
Ok(Self {
|
||||
rx,
|
||||
inner: jobserver.inner.clone().into_helper_thread(move |res| {
|
||||
let _ = tx.send(res);
|
||||
})?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ActiveJobServer<'a> {
|
||||
jobserver: &'a JobServer,
|
||||
helper_thread: jobserver::HelperThread,
|
||||
/// When rx is dropped, all the token stored within it will be dropped.
|
||||
rx: mpsc::Receiver<io::Result<jobserver::Acquired>>,
|
||||
helper_thread: Option<HelperThread>,
|
||||
}
|
||||
|
||||
impl<'a> ActiveJobServer<'a> {
|
||||
fn new(jobserver: &'a JobServer) -> Result<Self, Error> {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
Ok(Self {
|
||||
rx,
|
||||
helper_thread: jobserver.inner.clone().into_helper_thread(move |res| {
|
||||
let _ = tx.send(res);
|
||||
})?,
|
||||
jobserver,
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn acquire(&self) -> Result<JobToken, Error> {
|
||||
pub(super) async fn acquire(&mut self) -> Result<JobToken, Error> {
|
||||
let mut has_requested_token = false;
|
||||
|
||||
loop {
|
||||
@@ -173,26 +174,41 @@ mod inherited_jobserver {
|
||||
break Ok(JobToken::new());
|
||||
}
|
||||
|
||||
// Cold path, no global implicit token, obtain one
|
||||
match self.rx.try_recv() {
|
||||
Ok(res) => {
|
||||
let acquired = res?;
|
||||
match self.jobserver.inner.try_acquire() {
|
||||
Ok(Some(acquired)) => {
|
||||
acquired.drop_without_releasing();
|
||||
break Ok(JobToken::new());
|
||||
}
|
||||
Err(mpsc::TryRecvError::Disconnected) => {
|
||||
break Err(Error::new(
|
||||
ErrorKind::JobserverHelpThreadError,
|
||||
"jobserver help thread has returned before ActiveJobServer is dropped",
|
||||
))
|
||||
}
|
||||
Err(mpsc::TryRecvError::Empty) => {
|
||||
if !has_requested_token {
|
||||
self.helper_thread.request_token();
|
||||
has_requested_token = true;
|
||||
Ok(None) => YieldOnce::default().await,
|
||||
Err(err) if err.kind() == io::ErrorKind::Unsupported => {
|
||||
// Fallback to creating a help thread with blocking acquire
|
||||
let helper_thread = if let Some(thread) = self.helper_thread.as_ref() {
|
||||
thread
|
||||
} else {
|
||||
self.helper_thread
|
||||
.insert(HelperThread::new(self.jobserver)?)
|
||||
};
|
||||
|
||||
match helper_thread.rx.try_recv() {
|
||||
Ok(res) => {
|
||||
let acquired = res?;
|
||||
acquired.drop_without_releasing();
|
||||
break Ok(JobToken::new());
|
||||
}
|
||||
Err(mpsc::TryRecvError::Disconnected) => break Err(Error::new(
|
||||
ErrorKind::JobserverHelpThreadError,
|
||||
"jobserver help thread has returned before ActiveJobServer is dropped",
|
||||
)),
|
||||
Err(mpsc::TryRecvError::Empty) => {
|
||||
if !has_requested_token {
|
||||
helper_thread.inner.request_token();
|
||||
has_requested_token = true;
|
||||
}
|
||||
YieldOnce::default().await
|
||||
}
|
||||
}
|
||||
YieldOnce::default().await
|
||||
}
|
||||
Err(err) => break Err(err.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
third_party/rust/cc/src/parallel/mod.rs
vendored
17
third_party/rust/cc/src/parallel/mod.rs
vendored
@@ -1,20 +1,3 @@
|
||||
pub(crate) mod async_executor;
|
||||
pub(crate) mod job_token;
|
||||
pub(crate) mod stderr;
|
||||
|
||||
/// Remove all element in `vec` which `f(element)` returns `false`.
|
||||
///
|
||||
/// TODO: Remove this once the MSRV is bumped to v1.61
|
||||
pub(crate) fn retain_unordered_mut<T, F>(vec: &mut Vec<T>, mut f: F)
|
||||
where
|
||||
F: FnMut(&mut T) -> bool,
|
||||
{
|
||||
let mut i = 0;
|
||||
while i < vec.len() {
|
||||
if f(&mut vec[i]) {
|
||||
i += 1;
|
||||
} else {
|
||||
vec.swap_remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
third_party/rust/cc/src/parallel/stderr.rs
vendored
3
third_party/rust/cc/src/parallel/stderr.rs
vendored
@@ -1,9 +1,10 @@
|
||||
#![cfg_attr(target_family = "wasm", allow(unused))]
|
||||
/// Helpers functions for [ChildStderr].
|
||||
use std::{convert::TryInto, process::ChildStderr};
|
||||
|
||||
use crate::{Error, ErrorKind};
|
||||
|
||||
#[cfg(all(not(unix), not(windows)))]
|
||||
#[cfg(all(not(unix), not(windows), not(target_family = "wasm")))]
|
||||
compile_error!("Only unix and windows support non-blocking pipes! For other OSes, disable the parallel feature.");
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
129
third_party/rust/cc/src/target.rs
vendored
Normal file
129
third_party/rust/cc/src/target.rs
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
//! Very basic parsing of `rustc` target triples.
|
||||
//!
|
||||
//! See the `target-lexicon` crate for a more principled approach to this.
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{Error, ErrorKind};
|
||||
|
||||
mod apple;
|
||||
mod generated;
|
||||
mod llvm;
|
||||
mod parser;
|
||||
|
||||
pub(crate) use parser::TargetInfoParser;
|
||||
|
||||
/// Information specific to a `rustc` target.
|
||||
///
|
||||
/// See <https://doc.rust-lang.org/cargo/appendix/glossary.html#target>.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub(crate) struct TargetInfo<'a> {
|
||||
/// The full architecture, including the subarchitecture.
|
||||
///
|
||||
/// This differs from `cfg!(target_arch)`, which only specifies the
|
||||
/// overall architecture, which is too coarse for certain cases.
|
||||
pub full_arch: &'a str,
|
||||
/// The overall target architecture.
|
||||
///
|
||||
/// This is the same as the value of `cfg!(target_arch)`.
|
||||
pub arch: &'a str,
|
||||
/// The target vendor.
|
||||
///
|
||||
/// This is the same as the value of `cfg!(target_vendor)`.
|
||||
pub vendor: &'a str,
|
||||
/// The operating system, or `none` on bare-metal targets.
|
||||
///
|
||||
/// This is the same as the value of `cfg!(target_os)`.
|
||||
pub os: &'a str,
|
||||
/// The environment on top of the operating system.
|
||||
///
|
||||
/// This is the same as the value of `cfg!(target_env)`.
|
||||
pub env: &'a str,
|
||||
/// The ABI on top of the operating system.
|
||||
///
|
||||
/// This is the same as the value of `cfg!(target_abi)`.
|
||||
pub abi: &'a str,
|
||||
/// The unversioned LLVM/Clang target triple.
|
||||
unversioned_llvm_target: &'a str,
|
||||
}
|
||||
|
||||
impl FromStr for TargetInfo<'_> {
|
||||
type Err = Error;
|
||||
|
||||
/// This will fail when using a custom target triple unknown to `rustc`.
|
||||
fn from_str(target_triple: &str) -> Result<Self, Error> {
|
||||
if let Ok(index) =
|
||||
generated::LIST.binary_search_by_key(&target_triple, |(target_triple, _)| target_triple)
|
||||
{
|
||||
let (_, info) = &generated::LIST[index];
|
||||
Ok(info.clone())
|
||||
} else {
|
||||
Err(Error::new(
|
||||
ErrorKind::UnknownTarget,
|
||||
format!(
|
||||
"unknown target `{target_triple}`.
|
||||
|
||||
NOTE: `cc-rs` only supports a fixed set of targets when not in a build script.
|
||||
- If adding a new target, you will need to fork of `cc-rs` until the target
|
||||
has landed on nightly and the auto-generated list has been updated. See also
|
||||
the `rustc` dev guide on adding a new target:
|
||||
https://rustc-dev-guide.rust-lang.org/building/new-target.html
|
||||
- If using a custom target, prefer to upstream it to `rustc` if possible,
|
||||
otherwise open an issue with `cc-rs`:
|
||||
https://github.com/rust-lang/cc-rs/issues/new
|
||||
"
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::TargetInfo;
|
||||
|
||||
// Test tier 1 targets
|
||||
#[test]
|
||||
fn tier1() {
|
||||
let targets = [
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-apple-darwin",
|
||||
"i686-pc-windows-gnu",
|
||||
"i686-pc-windows-msvc",
|
||||
"i686-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-pc-windows-gnu",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
];
|
||||
|
||||
for target in targets {
|
||||
// Check that it parses
|
||||
let _ = TargetInfo::from_str(target).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// Various custom target triples not (or no longer) known by `rustc`
|
||||
#[test]
|
||||
fn cannot_parse_extra() {
|
||||
let targets = [
|
||||
"aarch64-unknown-none-gnu",
|
||||
"aarch64-uwp-windows-gnu",
|
||||
"arm-frc-linux-gnueabi",
|
||||
"arm-unknown-netbsd-eabi",
|
||||
"armv7neon-unknown-linux-gnueabihf",
|
||||
"armv7neon-unknown-linux-musleabihf",
|
||||
"thumbv7-unknown-linux-gnueabihf",
|
||||
"thumbv7-unknown-linux-musleabihf",
|
||||
"x86_64-rumprun-netbsd",
|
||||
"x86_64-unknown-linux",
|
||||
];
|
||||
|
||||
for target in targets {
|
||||
// Check that it does not parse
|
||||
let _ = TargetInfo::from_str(target).unwrap_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
third_party/rust/cc/src/target/apple.rs
vendored
Normal file
37
third_party/rust/cc/src/target/apple.rs
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
use super::TargetInfo;
|
||||
|
||||
impl TargetInfo<'_> {
|
||||
pub(crate) fn apple_sdk_name(&self) -> &'static str {
|
||||
match (self.os, self.abi) {
|
||||
("macos", "") => "macosx",
|
||||
("ios", "") => "iphoneos",
|
||||
("ios", "sim") => "iphonesimulator",
|
||||
("ios", "macabi") => "macosx",
|
||||
("tvos", "") => "appletvos",
|
||||
("tvos", "sim") => "appletvsimulator",
|
||||
("watchos", "") => "watchos",
|
||||
("watchos", "sim") => "watchsimulator",
|
||||
("visionos", "") => "xros",
|
||||
("visionos", "sim") => "xrsimulator",
|
||||
(os, _) => panic!("invalid Apple target OS {}", os),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn apple_version_flag(&self, min_version: &str) -> String {
|
||||
match (self.os, self.abi) {
|
||||
("macos", "") => format!("-mmacosx-version-min={min_version}"),
|
||||
("ios", "") => format!("-miphoneos-version-min={min_version}"),
|
||||
("ios", "sim") => format!("-mios-simulator-version-min={min_version}"),
|
||||
("ios", "macabi") => format!("-mtargetos=ios{min_version}-macabi"),
|
||||
("tvos", "") => format!("-mappletvos-version-min={min_version}"),
|
||||
("tvos", "sim") => format!("-mappletvsimulator-version-min={min_version}"),
|
||||
("watchos", "") => format!("-mwatchos-version-min={min_version}"),
|
||||
("watchos", "sim") => format!("-mwatchsimulator-version-min={min_version}"),
|
||||
// `-mxros-version-min` does not exist
|
||||
// https://github.com/llvm/llvm-project/issues/88271
|
||||
("visionos", "") => format!("-mtargetos=xros{min_version}"),
|
||||
("visionos", "sim") => format!("-mtargetos=xros{min_version}-simulator"),
|
||||
(os, _) => panic!("invalid Apple target OS {}", os),
|
||||
}
|
||||
}
|
||||
}
|
||||
3403
third_party/rust/cc/src/target/generated.rs
vendored
Normal file
3403
third_party/rust/cc/src/target/generated.rs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
89
third_party/rust/cc/src/target/llvm.rs
vendored
Normal file
89
third_party/rust/cc/src/target/llvm.rs
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use super::TargetInfo;
|
||||
|
||||
impl<'a> TargetInfo<'a> {
|
||||
/// The versioned LLVM/Clang target triple.
|
||||
pub(crate) fn versioned_llvm_target(&self, version: Option<&str>) -> Cow<'a, str> {
|
||||
if let Some(version) = version {
|
||||
// Only support versioned Apple targets for now.
|
||||
assert_eq!(self.vendor, "apple");
|
||||
|
||||
let mut components = self.unversioned_llvm_target.split("-");
|
||||
let arch = components.next().expect("llvm_target should have arch");
|
||||
let vendor = components.next().expect("llvm_target should have vendor");
|
||||
let os = components.next().expect("LLVM target should have os");
|
||||
let environment = components.next();
|
||||
assert_eq!(components.next(), None, "too many LLVM target components");
|
||||
|
||||
Cow::Owned(if let Some(env) = environment {
|
||||
format!("{arch}-{vendor}-{os}{version}-{env}")
|
||||
} else {
|
||||
format!("{arch}-{vendor}-{os}{version}")
|
||||
})
|
||||
} else {
|
||||
Cow::Borrowed(self.unversioned_llvm_target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Rust and Clang don't really agree on naming, so do a best-effort
|
||||
/// conversion to support out-of-tree / custom target-spec targets.
|
||||
pub(crate) fn guess_llvm_target_triple(
|
||||
full_arch: &str,
|
||||
vendor: &str,
|
||||
os: &str,
|
||||
env: &str,
|
||||
abi: &str,
|
||||
) -> String {
|
||||
let arch = match full_arch {
|
||||
riscv32 if riscv32.starts_with("riscv32") => "riscv32",
|
||||
riscv64 if riscv64.starts_with("riscv64") => "riscv64",
|
||||
arch => arch,
|
||||
};
|
||||
let os = match os {
|
||||
"darwin" => "macosx",
|
||||
"visionos" => "xros",
|
||||
"uefi" => "windows",
|
||||
os => os,
|
||||
};
|
||||
let env = match env {
|
||||
"newlib" | "nto70" | "nto71" | "ohos" | "p1" | "p2" | "relibc" | "sgx" | "uclibc" => "",
|
||||
env => env,
|
||||
};
|
||||
let abi = match abi {
|
||||
"sim" => "simulator",
|
||||
"llvm" | "softfloat" | "uwp" | "vec-extabi" => "",
|
||||
"ilp32" => "_ilp32",
|
||||
abi => abi,
|
||||
};
|
||||
match (env, abi) {
|
||||
("", "") => format!("{arch}-{vendor}-{os}"),
|
||||
(env, abi) => format!("{arch}-{vendor}-{os}-{env}{abi}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_basic_llvm_triple_guessing() {
|
||||
assert_eq!(
|
||||
guess_llvm_target_triple("aarch64", "unknown", "linux", "", ""),
|
||||
"aarch64-unknown-linux"
|
||||
);
|
||||
assert_eq!(
|
||||
guess_llvm_target_triple("x86_64", "unknown", "linux", "gnu", ""),
|
||||
"x86_64-unknown-linux-gnu"
|
||||
);
|
||||
assert_eq!(
|
||||
guess_llvm_target_triple("x86_64", "unknown", "linux", "gnu", "eabi"),
|
||||
"x86_64-unknown-linux-gnueabi"
|
||||
);
|
||||
assert_eq!(
|
||||
guess_llvm_target_triple("x86_64", "apple", "darwin", "", ""),
|
||||
"x86_64-apple-macosx"
|
||||
);
|
||||
}
|
||||
}
|
||||
130
third_party/rust/cc/src/target/parser.rs
vendored
Normal file
130
third_party/rust/cc/src/target/parser.rs
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
use std::{env, str::FromStr};
|
||||
|
||||
use crate::{
|
||||
target::{llvm, TargetInfo},
|
||||
utilities::OnceLock,
|
||||
Error, ErrorKind,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TargetInfoParserInner {
|
||||
full_arch: Box<str>,
|
||||
arch: Box<str>,
|
||||
vendor: Box<str>,
|
||||
os: Box<str>,
|
||||
env: Box<str>,
|
||||
abi: Box<str>,
|
||||
unversioned_llvm_target: Box<str>,
|
||||
}
|
||||
|
||||
impl TargetInfoParserInner {
|
||||
fn from_cargo_environment_variables() -> Result<Self, Error> {
|
||||
// `TARGET` must be present.
|
||||
//
|
||||
// No need to emit `rerun-if-env-changed` for this,
|
||||
// as it is controlled by Cargo itself.
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
let target_triple = env::var("TARGET").map_err(|err| {
|
||||
Error::new(
|
||||
ErrorKind::EnvVarNotFound,
|
||||
format!("failed reading TARGET: {err}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
// Parse the full architecture name from the target triple.
|
||||
let (full_arch, _rest) = target_triple.split_once('-').ok_or(Error::new(
|
||||
ErrorKind::InvalidTarget,
|
||||
format!("target `{target_triple}` had an unknown architecture"),
|
||||
))?;
|
||||
|
||||
let cargo_env = |name, fallback: Option<&str>| -> Result<Box<str>, Error> {
|
||||
// No need to emit `rerun-if-env-changed` for these,
|
||||
// as they are controlled by Cargo itself.
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
match env::var(name) {
|
||||
Ok(var) => Ok(var.into_boxed_str()),
|
||||
Err(err) => match fallback {
|
||||
Some(fallback) => Ok(fallback.into()),
|
||||
None => Err(Error::new(
|
||||
ErrorKind::EnvVarNotFound,
|
||||
format!("did not find fallback information for target `{target_triple}`, and failed reading {name}: {err}"),
|
||||
)),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// Prefer to use `CARGO_ENV_*` if set, since these contain the most
|
||||
// correct information relative to the current `rustc`, and makes it
|
||||
// possible to support custom target JSON specs unknown to `rustc`.
|
||||
//
|
||||
// NOTE: If the user is using an older `rustc`, that data may be older
|
||||
// than our pre-generated data, but we still prefer Cargo's view of
|
||||
// the world, since at least `cc` won't differ from `rustc` in that
|
||||
// case.
|
||||
//
|
||||
// These may not be set in case the user depended on being able to
|
||||
// just set `TARGET` outside of build scripts; in those cases, fall
|
||||
// back back to data from the known set of target triples instead.
|
||||
//
|
||||
// See discussion in #1225 for further details.
|
||||
let fallback_target = TargetInfo::from_str(&target_triple).ok();
|
||||
let ft = fallback_target.as_ref();
|
||||
let arch = cargo_env("CARGO_CFG_TARGET_ARCH", ft.map(|t| t.arch))?;
|
||||
let vendor = cargo_env("CARGO_CFG_TARGET_VENDOR", ft.map(|t| t.vendor))?;
|
||||
let os = cargo_env("CARGO_CFG_TARGET_OS", ft.map(|t| t.os))?;
|
||||
let env = cargo_env("CARGO_CFG_TARGET_ENV", ft.map(|t| t.env))?;
|
||||
// `target_abi` was stabilized in Rust 1.78, which is higher than our
|
||||
// MSRV, so it may not always be available; In that case, fall back to
|
||||
// `""`, which is _probably_ correct for unknown target triples.
|
||||
let abi = cargo_env("CARGO_CFG_TARGET_ABI", ft.map(|t| t.abi))
|
||||
.unwrap_or_else(|_| String::default().into_boxed_str());
|
||||
|
||||
// Prefer `rustc`'s LLVM target triple information.
|
||||
let unversioned_llvm_target = match fallback_target {
|
||||
Some(ft) => ft.unversioned_llvm_target.to_string(),
|
||||
None => llvm::guess_llvm_target_triple(full_arch, &vendor, &os, &env, &abi),
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
full_arch: full_arch.to_string().into_boxed_str(),
|
||||
arch,
|
||||
vendor,
|
||||
os,
|
||||
env,
|
||||
abi,
|
||||
unversioned_llvm_target: unversioned_llvm_target.into_boxed_str(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Parser for [`TargetInfo`], contains cached information.
|
||||
#[derive(Default, Debug)]
|
||||
pub(crate) struct TargetInfoParser(OnceLock<Result<TargetInfoParserInner, Error>>);
|
||||
|
||||
impl TargetInfoParser {
|
||||
pub fn parse_from_cargo_environment_variables(&self) -> Result<TargetInfo<'_>, Error> {
|
||||
match self
|
||||
.0
|
||||
.get_or_init(TargetInfoParserInner::from_cargo_environment_variables)
|
||||
{
|
||||
Ok(TargetInfoParserInner {
|
||||
full_arch,
|
||||
arch,
|
||||
vendor,
|
||||
os,
|
||||
env,
|
||||
abi,
|
||||
unversioned_llvm_target,
|
||||
}) => Ok(TargetInfo {
|
||||
full_arch,
|
||||
arch,
|
||||
vendor,
|
||||
os,
|
||||
env,
|
||||
abi,
|
||||
unversioned_llvm_target,
|
||||
}),
|
||||
Err(e) => Err(e.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
86
third_party/rust/cc/src/tempfile.rs
vendored
Normal file
86
third_party/rust/cc/src/tempfile.rs
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
#![cfg_attr(target_family = "wasm", allow(unused))]
|
||||
|
||||
use std::{
|
||||
collections::hash_map::RandomState,
|
||||
fs::{remove_file, File, OpenOptions},
|
||||
hash::{BuildHasher, Hasher},
|
||||
io, os,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[cfg(not(any(unix, target_family = "wasm", windows)))]
|
||||
compile_error!("Your system is not supported since cc cannot create named tempfile");
|
||||
|
||||
fn rand() -> u64 {
|
||||
RandomState::new().build_hasher().finish()
|
||||
}
|
||||
|
||||
fn tmpname(suffix: &str) -> String {
|
||||
format!("{}{}", rand(), suffix)
|
||||
}
|
||||
|
||||
fn create_named(path: &Path) -> io::Result<File> {
|
||||
let mut open_options = OpenOptions::new();
|
||||
|
||||
open_options.read(true).write(true).create_new(true);
|
||||
|
||||
#[cfg(all(unix, not(target_os = "wasi")))]
|
||||
<OpenOptions as os::unix::fs::OpenOptionsExt>::mode(&mut open_options, 0o600);
|
||||
|
||||
#[cfg(windows)]
|
||||
<OpenOptions as os::windows::fs::OpenOptionsExt>::custom_flags(
|
||||
&mut open_options,
|
||||
crate::windows::windows_sys::FILE_ATTRIBUTE_TEMPORARY,
|
||||
);
|
||||
|
||||
open_options.open(path)
|
||||
}
|
||||
|
||||
pub(super) struct NamedTempfile {
|
||||
path: PathBuf,
|
||||
file: Option<File>,
|
||||
}
|
||||
|
||||
impl NamedTempfile {
|
||||
pub(super) fn new(base: &Path, suffix: &str) -> io::Result<Self> {
|
||||
for _ in 0..10 {
|
||||
let path = base.join(tmpname(suffix));
|
||||
match create_named(&path) {
|
||||
Ok(file) => {
|
||||
return Ok(Self {
|
||||
file: Some(file),
|
||||
path,
|
||||
})
|
||||
}
|
||||
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => continue,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
}
|
||||
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::AlreadyExists,
|
||||
format!(
|
||||
"too many temporary files exist in base `{}` with suffix `{}`",
|
||||
base.display(),
|
||||
suffix
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
pub(super) fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub(super) fn take_file(&mut self) -> Option<File> {
|
||||
self.file.take()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for NamedTempfile {
|
||||
fn drop(&mut self) {
|
||||
// On Windows you have to close all handle to it before
|
||||
// removing the file.
|
||||
self.file.take();
|
||||
let _ = remove_file(&self.path);
|
||||
}
|
||||
}
|
||||
259
third_party/rust/cc/src/tool.rs
vendored
259
third_party/rust/cc/src/tool.rs
vendored
@@ -1,12 +1,20 @@
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
ffi::OsString,
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
sync::Mutex,
|
||||
process::{Command, Stdio},
|
||||
sync::RwLock,
|
||||
};
|
||||
|
||||
use crate::command_helpers::{run_output, CargoOutput};
|
||||
use crate::{
|
||||
command_helpers::{run_output, CargoOutput},
|
||||
run,
|
||||
tempfile::NamedTempfile,
|
||||
Error, ErrorKind, OutputKind,
|
||||
};
|
||||
|
||||
/// Configuration used to represent an invocation of a C compiler.
|
||||
///
|
||||
@@ -32,17 +40,26 @@ pub struct Tool {
|
||||
impl Tool {
|
||||
pub(crate) fn new(
|
||||
path: PathBuf,
|
||||
cached_compiler_family: &Mutex<HashMap<Box<Path>, ToolFamily>>,
|
||||
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
|
||||
cargo_output: &CargoOutput,
|
||||
out_dir: Option<&Path>,
|
||||
) -> Self {
|
||||
Self::with_features(path, None, false, cached_compiler_family, cargo_output)
|
||||
Self::with_features(
|
||||
path,
|
||||
None,
|
||||
false,
|
||||
cached_compiler_family,
|
||||
cargo_output,
|
||||
out_dir,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn with_clang_driver(
|
||||
path: PathBuf,
|
||||
clang_driver: Option<&str>,
|
||||
cached_compiler_family: &Mutex<HashMap<Box<Path>, ToolFamily>>,
|
||||
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
|
||||
cargo_output: &CargoOutput,
|
||||
out_dir: Option<&Path>,
|
||||
) -> Self {
|
||||
Self::with_features(
|
||||
path,
|
||||
@@ -50,6 +67,7 @@ impl Tool {
|
||||
false,
|
||||
cached_compiler_family,
|
||||
cargo_output,
|
||||
out_dir,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -72,72 +90,161 @@ impl Tool {
|
||||
path: PathBuf,
|
||||
clang_driver: Option<&str>,
|
||||
cuda: bool,
|
||||
cached_compiler_family: &Mutex<HashMap<Box<Path>, ToolFamily>>,
|
||||
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
|
||||
cargo_output: &CargoOutput,
|
||||
out_dir: Option<&Path>,
|
||||
) -> Self {
|
||||
fn detect_family_inner(path: &Path, cargo_output: &CargoOutput) -> ToolFamily {
|
||||
let mut cmd = Command::new(path);
|
||||
cmd.arg("--version");
|
||||
|
||||
let stdout = match run_output(
|
||||
&mut cmd,
|
||||
&path.to_string_lossy(),
|
||||
fn is_zig_cc(path: &Path, cargo_output: &CargoOutput) -> bool {
|
||||
run_output(
|
||||
Command::new(path).arg("--version"),
|
||||
path,
|
||||
// tool detection issues should always be shown as warnings
|
||||
cargo_output,
|
||||
)
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o).ok())
|
||||
{
|
||||
Some(s) => s,
|
||||
None => {
|
||||
// --version failed. fallback to gnu
|
||||
cargo_output.print_warning(&format_args!("Failed to run: {:?}", cmd));
|
||||
return ToolFamily::Gnu;
|
||||
.map(|o| String::from_utf8_lossy(&o).contains("ziglang"))
|
||||
.unwrap_or_default()
|
||||
|| {
|
||||
match path.file_name().map(OsStr::to_string_lossy) {
|
||||
Some(fname) => fname.contains("zig"),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn guess_family_from_stdout(
|
||||
stdout: &str,
|
||||
path: &Path,
|
||||
cargo_output: &CargoOutput,
|
||||
) -> Result<ToolFamily, Error> {
|
||||
cargo_output.print_debug(&stdout);
|
||||
|
||||
// https://gitlab.kitware.com/cmake/cmake/-/blob/69a2eeb9dff5b60f2f1e5b425002a0fd45b7cadb/Modules/CMakeDetermineCompilerId.cmake#L267-271
|
||||
// stdin is set to null to ensure that the help output is never paginated.
|
||||
let accepts_cl_style_flags =
|
||||
run(Command::new(path).arg("-?").stdin(Stdio::null()), path, &{
|
||||
// the errors are not errors!
|
||||
let mut cargo_output = cargo_output.clone();
|
||||
cargo_output.warnings = cargo_output.debug;
|
||||
cargo_output.output = OutputKind::Discard;
|
||||
cargo_output
|
||||
})
|
||||
.is_ok();
|
||||
|
||||
let clang = stdout.contains(r#""clang""#);
|
||||
let gcc = stdout.contains(r#""gcc""#);
|
||||
let emscripten = stdout.contains(r#""emscripten""#);
|
||||
let vxworks = stdout.contains(r#""VxWorks""#);
|
||||
|
||||
match (clang, accepts_cl_style_flags, gcc, emscripten, vxworks) {
|
||||
(clang_cl, true, _, false, false) => Ok(ToolFamily::Msvc { clang_cl }),
|
||||
(true, _, _, _, false) | (_, _, _, true, false) => Ok(ToolFamily::Clang {
|
||||
zig_cc: is_zig_cc(path, cargo_output),
|
||||
}),
|
||||
(false, false, true, _, false) | (_, _, _, _, true) => Ok(ToolFamily::Gnu),
|
||||
(false, false, false, false, false) => {
|
||||
cargo_output.print_warning(&"Compiler family detection failed since it does not define `__clang__`, `__GNUC__`, `__EMSCRIPTEN__` or `__VXWORKS__`, also does not accept cl style flag `-?`, fallback to treating it as GNU");
|
||||
Err(Error::new(
|
||||
ErrorKind::ToolFamilyMacroNotFound,
|
||||
"Expects macro `__clang__`, `__GNUC__` or `__EMSCRIPTEN__`, `__VXWORKS__` or accepts cl style flag `-?`, but found none",
|
||||
))
|
||||
}
|
||||
};
|
||||
if stdout.contains("clang") {
|
||||
ToolFamily::Clang
|
||||
} else if stdout.contains("GCC") {
|
||||
ToolFamily::Gnu
|
||||
} else {
|
||||
// --version doesn't include clang for GCC
|
||||
cargo_output.print_warning(&format_args!(
|
||||
"Compiler version doesn't include clang or GCC: {:?}",
|
||||
cmd
|
||||
));
|
||||
ToolFamily::Gnu
|
||||
}
|
||||
}
|
||||
let detect_family = |path: &Path| -> ToolFamily {
|
||||
if let Some(family) = cached_compiler_family.lock().unwrap().get(path) {
|
||||
return *family;
|
||||
|
||||
fn detect_family_inner(
|
||||
path: &Path,
|
||||
cargo_output: &CargoOutput,
|
||||
out_dir: Option<&Path>,
|
||||
) -> Result<ToolFamily, Error> {
|
||||
let out_dir = out_dir
|
||||
.map(Cow::Borrowed)
|
||||
.unwrap_or_else(|| Cow::Owned(env::temp_dir()));
|
||||
|
||||
// Ensure all the parent directories exist otherwise temp file creation
|
||||
// will fail
|
||||
std::fs::create_dir_all(&out_dir).map_err(|err| Error {
|
||||
kind: ErrorKind::IOError,
|
||||
message: format!("failed to create OUT_DIR '{}': {}", out_dir.display(), err)
|
||||
.into(),
|
||||
})?;
|
||||
|
||||
let mut tmp =
|
||||
NamedTempfile::new(&out_dir, "detect_compiler_family.c").map_err(|err| Error {
|
||||
kind: ErrorKind::IOError,
|
||||
message: format!(
|
||||
"failed to create detect_compiler_family.c temp file in '{}': {}",
|
||||
out_dir.display(),
|
||||
err
|
||||
)
|
||||
.into(),
|
||||
})?;
|
||||
let mut tmp_file = tmp.take_file().unwrap();
|
||||
tmp_file.write_all(include_bytes!("detect_compiler_family.c"))?;
|
||||
// Close the file handle *now*, otherwise the compiler may fail to open it on Windows
|
||||
// (#1082). The file stays on disk and its path remains valid until `tmp` is dropped.
|
||||
tmp_file.flush()?;
|
||||
tmp_file.sync_data()?;
|
||||
drop(tmp_file);
|
||||
|
||||
// When expanding the file, the compiler prints a lot of information to stderr
|
||||
// that it is not an error, but related to expanding itself.
|
||||
//
|
||||
// cc would have to disable warning here to prevent generation of too many warnings.
|
||||
let mut compiler_detect_output = cargo_output.clone();
|
||||
compiler_detect_output.warnings = compiler_detect_output.debug;
|
||||
|
||||
let stdout = run_output(
|
||||
Command::new(path).arg("-E").arg(tmp.path()),
|
||||
path,
|
||||
&compiler_detect_output,
|
||||
)?;
|
||||
let stdout = String::from_utf8_lossy(&stdout);
|
||||
|
||||
if stdout.contains("-Wslash-u-filename") {
|
||||
let stdout = run_output(
|
||||
Command::new(path).arg("-E").arg("--").arg(tmp.path()),
|
||||
path,
|
||||
&compiler_detect_output,
|
||||
)?;
|
||||
let stdout = String::from_utf8_lossy(&stdout);
|
||||
guess_family_from_stdout(&stdout, path, cargo_output)
|
||||
} else {
|
||||
guess_family_from_stdout(&stdout, path, cargo_output)
|
||||
}
|
||||
}
|
||||
let detect_family = |path: &Path| -> Result<ToolFamily, Error> {
|
||||
if let Some(family) = cached_compiler_family.read().unwrap().get(path) {
|
||||
return Ok(*family);
|
||||
}
|
||||
|
||||
let family = detect_family_inner(path, cargo_output);
|
||||
let family = detect_family_inner(path, cargo_output, out_dir)?;
|
||||
cached_compiler_family
|
||||
.lock()
|
||||
.write()
|
||||
.unwrap()
|
||||
.insert(path.into(), family);
|
||||
family
|
||||
Ok(family)
|
||||
};
|
||||
|
||||
// Try to detect family of the tool from its name, falling back to Gnu.
|
||||
let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) {
|
||||
if fname.contains("clang-cl") {
|
||||
ToolFamily::Msvc { clang_cl: true }
|
||||
} else if fname.ends_with("cl") || fname == "cl.exe" {
|
||||
ToolFamily::Msvc { clang_cl: false }
|
||||
} else if fname.contains("clang") {
|
||||
match clang_driver {
|
||||
Some("cl") => ToolFamily::Msvc { clang_cl: true },
|
||||
_ => ToolFamily::Clang,
|
||||
let family = detect_family(&path).unwrap_or_else(|e| {
|
||||
cargo_output.print_warning(&format_args!(
|
||||
"Compiler family detection failed due to error: {}",
|
||||
e
|
||||
));
|
||||
match path.file_name().map(OsStr::to_string_lossy) {
|
||||
Some(fname) if fname.contains("clang-cl") => ToolFamily::Msvc { clang_cl: true },
|
||||
Some(fname) if fname.ends_with("cl") || fname == "cl.exe" => {
|
||||
ToolFamily::Msvc { clang_cl: false }
|
||||
}
|
||||
} else {
|
||||
detect_family(&path)
|
||||
Some(fname) if fname.contains("clang") => match clang_driver {
|
||||
Some("cl") => ToolFamily::Msvc { clang_cl: true },
|
||||
_ => ToolFamily::Clang {
|
||||
zig_cc: is_zig_cc(&path, cargo_output),
|
||||
},
|
||||
},
|
||||
Some(fname) if fname.contains("zig") => ToolFamily::Clang { zig_cc: true },
|
||||
_ => ToolFamily::Gnu,
|
||||
}
|
||||
} else {
|
||||
detect_family(&path)
|
||||
};
|
||||
});
|
||||
|
||||
Tool {
|
||||
path,
|
||||
@@ -184,10 +291,8 @@ impl Tool {
|
||||
if chars.next() != Some('/') {
|
||||
return false;
|
||||
}
|
||||
} else if self.is_like_gnu() || self.is_like_clang() {
|
||||
if chars.next() != Some('-') {
|
||||
return false;
|
||||
}
|
||||
} else if (self.is_like_gnu() || self.is_like_clang()) && chars.next() != Some('-') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for existing optimization flags (-O, /O)
|
||||
@@ -205,7 +310,7 @@ impl Tool {
|
||||
/// Don't push optimization arg if it conflicts with existing args.
|
||||
pub(crate) fn push_opt_unless_duplicate(&mut self, flag: OsString) {
|
||||
if self.is_duplicate_opt_arg(&flag) {
|
||||
println!("Info: Ignoring duplicate arg {:?}", &flag);
|
||||
eprintln!("Info: Ignoring duplicate arg {:?}", &flag);
|
||||
} else {
|
||||
self.push_cc_arg(flag);
|
||||
}
|
||||
@@ -303,7 +408,7 @@ impl Tool {
|
||||
|
||||
/// Whether the tool is Clang-like.
|
||||
pub fn is_like_clang(&self) -> bool {
|
||||
self.family == ToolFamily::Clang
|
||||
matches!(self.family, ToolFamily::Clang { .. })
|
||||
}
|
||||
|
||||
/// Whether the tool is AppleClang under .xctoolchain
|
||||
@@ -319,10 +424,18 @@ impl Tool {
|
||||
|
||||
/// Whether the tool is MSVC-like.
|
||||
pub fn is_like_msvc(&self) -> bool {
|
||||
match self.family {
|
||||
ToolFamily::Msvc { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.family, ToolFamily::Msvc { .. })
|
||||
}
|
||||
|
||||
/// Whether the tool is `clang-cl`-based MSVC-like.
|
||||
pub fn is_like_clang_cl(&self) -> bool {
|
||||
matches!(self.family, ToolFamily::Msvc { clang_cl: true })
|
||||
}
|
||||
|
||||
/// Supports using `--` delimiter to separate arguments and path to source files.
|
||||
pub(crate) fn supports_path_delimiter(&self) -> bool {
|
||||
// homebrew clang and zig-cc does not support this while stock version does
|
||||
matches!(self.family, ToolFamily::Msvc { clang_cl: true }) && !self.cuda
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +450,7 @@ pub enum ToolFamily {
|
||||
Gnu,
|
||||
/// Tool is Clang-like. It differs from the GCC in a sense that it accepts superset of flags
|
||||
/// and its cross-compilation approach is different.
|
||||
Clang,
|
||||
Clang { zig_cc: bool },
|
||||
/// Tool is the MSVC cl.exe.
|
||||
Msvc { clang_cl: bool },
|
||||
}
|
||||
@@ -349,7 +462,7 @@ impl ToolFamily {
|
||||
ToolFamily::Msvc { .. } => {
|
||||
cmd.push_cc_arg("-Z7".into());
|
||||
}
|
||||
ToolFamily::Gnu | ToolFamily::Clang => {
|
||||
ToolFamily::Gnu | ToolFamily::Clang { .. } => {
|
||||
cmd.push_cc_arg(
|
||||
dwarf_version
|
||||
.map_or_else(|| "-g".into(), |v| format!("-gdwarf-{}", v))
|
||||
@@ -362,7 +475,7 @@ impl ToolFamily {
|
||||
/// What the flag to force frame pointers.
|
||||
pub(crate) fn add_force_frame_pointer(&self, cmd: &mut Tool) {
|
||||
match *self {
|
||||
ToolFamily::Gnu | ToolFamily::Clang => {
|
||||
ToolFamily::Gnu | ToolFamily::Clang { .. } => {
|
||||
cmd.push_cc_arg("-fno-omit-frame-pointer".into());
|
||||
}
|
||||
_ => (),
|
||||
@@ -373,7 +486,7 @@ impl ToolFamily {
|
||||
pub(crate) fn warnings_flags(&self) -> &'static str {
|
||||
match *self {
|
||||
ToolFamily::Msvc { .. } => "-W4",
|
||||
ToolFamily::Gnu | ToolFamily::Clang => "-Wall",
|
||||
ToolFamily::Gnu | ToolFamily::Clang { .. } => "-Wall",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +494,7 @@ impl ToolFamily {
|
||||
pub(crate) fn extra_warnings_flags(&self) -> Option<&'static str> {
|
||||
match *self {
|
||||
ToolFamily::Msvc { .. } => None,
|
||||
ToolFamily::Gnu | ToolFamily::Clang => Some("-Wextra"),
|
||||
ToolFamily::Gnu | ToolFamily::Clang { .. } => Some("-Wextra"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,11 +502,11 @@ impl ToolFamily {
|
||||
pub(crate) fn warnings_to_errors_flag(&self) -> &'static str {
|
||||
match *self {
|
||||
ToolFamily::Msvc { .. } => "-WX",
|
||||
ToolFamily::Gnu | ToolFamily::Clang => "-Werror",
|
||||
ToolFamily::Gnu | ToolFamily::Clang { .. } => "-Werror",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn verbose_stderr(&self) -> bool {
|
||||
*self == ToolFamily::Clang
|
||||
matches!(*self, ToolFamily::Clang { .. })
|
||||
}
|
||||
}
|
||||
|
||||
130
third_party/rust/cc/src/utilities.rs
vendored
Normal file
130
third_party/rust/cc/src/utilities.rs
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
use std::{
|
||||
cell::UnsafeCell,
|
||||
ffi::OsStr,
|
||||
fmt::{self, Write},
|
||||
marker::PhantomData,
|
||||
mem::MaybeUninit,
|
||||
panic::{RefUnwindSafe, UnwindSafe},
|
||||
path::Path,
|
||||
sync::Once,
|
||||
};
|
||||
|
||||
pub(super) struct JoinOsStrs<'a, T> {
|
||||
pub(super) slice: &'a [T],
|
||||
pub(super) delimiter: char,
|
||||
}
|
||||
|
||||
impl<T> fmt::Display for JoinOsStrs<'_, T>
|
||||
where
|
||||
T: AsRef<OsStr>,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let len = self.slice.len();
|
||||
for (index, os_str) in self.slice.iter().enumerate() {
|
||||
// TODO: Use OsStr::display once it is stablised,
|
||||
// Path and OsStr has the same `Display` impl
|
||||
write!(f, "{}", Path::new(os_str).display())?;
|
||||
if index + 1 < len {
|
||||
f.write_char(self.delimiter)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct OptionOsStrDisplay<T>(pub(super) Option<T>);
|
||||
|
||||
impl<T> fmt::Display for OptionOsStrDisplay<T>
|
||||
where
|
||||
T: AsRef<OsStr>,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// TODO: Use OsStr::display once it is stablised
|
||||
// Path and OsStr has the same `Display` impl
|
||||
if let Some(os_str) = self.0.as_ref() {
|
||||
write!(f, "Some({})", Path::new(os_str).display())
|
||||
} else {
|
||||
f.write_str("None")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct OnceLock<T> {
|
||||
once: Once,
|
||||
value: UnsafeCell<MaybeUninit<T>>,
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Default for OnceLock<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> OnceLock<T> {
|
||||
pub(crate) const fn new() -> Self {
|
||||
Self {
|
||||
once: Once::new(),
|
||||
value: UnsafeCell::new(MaybeUninit::uninit()),
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_initialized(&self) -> bool {
|
||||
self.once.is_completed()
|
||||
}
|
||||
|
||||
unsafe fn get_unchecked(&self) -> &T {
|
||||
debug_assert!(self.is_initialized());
|
||||
#[allow(clippy::needless_borrow)]
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe {
|
||||
(&*self.value.get()).assume_init_ref()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_or_init(&self, f: impl FnOnce() -> T) -> &T {
|
||||
self.once.call_once(|| {
|
||||
unsafe { &mut *self.value.get() }.write(f());
|
||||
});
|
||||
unsafe { self.get_unchecked() }
|
||||
}
|
||||
|
||||
pub(crate) fn get(&self) -> Option<&T> {
|
||||
if self.is_initialized() {
|
||||
// Safe b/c checked is_initialized
|
||||
Some(unsafe { self.get_unchecked() })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for OnceLock<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut d = f.debug_tuple("OnceLock");
|
||||
match self.get() {
|
||||
Some(v) => d.field(v),
|
||||
None => d.field(&format_args!("<uninit>")),
|
||||
};
|
||||
d.finish()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: Sync + Send> Sync for OnceLock<T> {}
|
||||
unsafe impl<T: Send> Send for OnceLock<T> {}
|
||||
|
||||
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T> {}
|
||||
impl<T: UnwindSafe> UnwindSafe for OnceLock<T> {}
|
||||
|
||||
impl<T> Drop for OnceLock<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
if self.once.is_completed() {
|
||||
// SAFETY: The cell is initialized and being dropped, so it can't
|
||||
// be accessed again.
|
||||
unsafe { self.value.get_mut().assume_init_drop() };
|
||||
}
|
||||
}
|
||||
}
|
||||
51
third_party/rust/cc/src/windows/com.rs
vendored
51
third_party/rust/cc/src/windows/com.rs
vendored
@@ -5,8 +5,6 @@
|
||||
// All files in the project carrying such notice may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
use crate::windows::{
|
||||
winapi::{IUnknown, Interface},
|
||||
windows_sys::{
|
||||
@@ -16,10 +14,9 @@ use crate::windows::{
|
||||
};
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
ffi::{OsStr, OsString},
|
||||
mem::ManuallyDrop,
|
||||
ffi::OsString,
|
||||
ops::Deref,
|
||||
os::windows::ffi::{OsStrExt, OsStringExt},
|
||||
os::windows::ffi::OsStringExt,
|
||||
ptr::{null, null_mut},
|
||||
slice::from_raw_parts,
|
||||
};
|
||||
@@ -48,19 +45,6 @@ where
|
||||
assert!(!ptr.is_null());
|
||||
ComPtr(ptr)
|
||||
}
|
||||
/// Casts up the inheritance chain
|
||||
pub fn up<U>(self) -> ComPtr<U>
|
||||
where
|
||||
T: Deref<Target = U>,
|
||||
U: Interface,
|
||||
{
|
||||
ComPtr(self.into_raw() as *mut U)
|
||||
}
|
||||
/// Extracts the raw pointer.
|
||||
/// You are now responsible for releasing it yourself.
|
||||
pub fn into_raw(self) -> *mut T {
|
||||
ManuallyDrop::new(self).0
|
||||
}
|
||||
/// For internal use only.
|
||||
fn as_unknown(&self) -> &IUnknown {
|
||||
unsafe { &*(self.0 as *mut IUnknown) }
|
||||
@@ -124,34 +108,3 @@ impl Drop for BStr {
|
||||
unsafe { SysFreeString(self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ToWide {
|
||||
fn to_wide(&self) -> Vec<u16>;
|
||||
fn to_wide_null(&self) -> Vec<u16>;
|
||||
}
|
||||
impl<T> ToWide for T
|
||||
where
|
||||
T: AsRef<OsStr>,
|
||||
{
|
||||
fn to_wide(&self) -> Vec<u16> {
|
||||
self.as_ref().encode_wide().collect()
|
||||
}
|
||||
fn to_wide_null(&self) -> Vec<u16> {
|
||||
self.as_ref().encode_wide().chain(Some(0)).collect()
|
||||
}
|
||||
}
|
||||
pub trait FromWide
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
fn from_wide(wide: &[u16]) -> Self;
|
||||
fn from_wide_null(wide: &[u16]) -> Self {
|
||||
let len = wide.iter().take_while(|&&c| c != 0).count();
|
||||
Self::from_wide(&wide[..len])
|
||||
}
|
||||
}
|
||||
impl FromWide for OsString {
|
||||
fn from_wide(wide: &[u16]) -> OsString {
|
||||
OsStringExt::from_wide(wide)
|
||||
}
|
||||
}
|
||||
|
||||
656
third_party/rust/cc/src/windows/find_tools.rs
vendored
656
third_party/rust/cc/src/windows/find_tools.rs
vendored
File diff suppressed because it is too large
Load Diff
2
third_party/rust/cc/src/windows/mod.rs
vendored
2
third_party/rust/cc/src/windows/mod.rs
vendored
@@ -6,6 +6,8 @@ pub mod find_tools;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) mod windows_sys;
|
||||
#[cfg(windows)]
|
||||
mod windows_targets;
|
||||
|
||||
#[cfg(windows)]
|
||||
mod registry;
|
||||
|
||||
@@ -73,7 +73,7 @@ impl TryFrom<&Vec<u8>> for VswhereInstance {
|
||||
fn try_from(output: &Vec<u8>) -> Result<Self, Self::Error> {
|
||||
let map: HashMap<_, _> = output
|
||||
.lines()
|
||||
.filter_map(Result::ok)
|
||||
.map_while(Result::ok)
|
||||
.filter_map(|s| {
|
||||
let mut splitn = s.splitn(2, ": ");
|
||||
Some((splitn.next()?.to_owned(), splitn.next()?.to_owned()))
|
||||
|
||||
183
third_party/rust/cc/src/windows/windows_sys.rs
vendored
183
third_party/rust/cc/src/windows/windows_sys.rs
vendored
@@ -6,7 +6,7 @@
|
||||
// cd generate-windows-sys/
|
||||
// cargo run
|
||||
// ```
|
||||
// Bindings generated by `windows-bindgen` 0.53.0
|
||||
// Bindings generated by `windows-bindgen` 0.59.0
|
||||
|
||||
#![allow(
|
||||
non_snake_case,
|
||||
@@ -15,112 +15,23 @@
|
||||
dead_code,
|
||||
clippy::all
|
||||
)]
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
pub fn RegCloseKey(hkey: HKEY) -> WIN32_ERROR;
|
||||
}
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
pub fn RegEnumKeyExW(
|
||||
hkey: HKEY,
|
||||
dwindex: u32,
|
||||
lpname: PWSTR,
|
||||
lpcchname: *mut u32,
|
||||
lpreserved: *const u32,
|
||||
lpclass: PWSTR,
|
||||
lpcchclass: *mut u32,
|
||||
lpftlastwritetime: *mut FILETIME,
|
||||
) -> WIN32_ERROR;
|
||||
}
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
pub fn RegOpenKeyExW(
|
||||
hkey: HKEY,
|
||||
lpsubkey: PCWSTR,
|
||||
uloptions: u32,
|
||||
samdesired: REG_SAM_FLAGS,
|
||||
phkresult: *mut HKEY,
|
||||
) -> WIN32_ERROR;
|
||||
}
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
pub fn RegQueryValueExW(
|
||||
hkey: HKEY,
|
||||
lpvaluename: PCWSTR,
|
||||
lpreserved: *const u32,
|
||||
lptype: *mut REG_VALUE_TYPE,
|
||||
lpdata: *mut u8,
|
||||
lpcbdata: *mut u32,
|
||||
) -> WIN32_ERROR;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn FreeLibrary(hlibmodule: HMODULE) -> BOOL;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn GetMachineTypeAttributes(
|
||||
machine: u16,
|
||||
machinetypeattributes: *mut MACHINE_ATTRIBUTES,
|
||||
) -> HRESULT;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn GetProcAddress(hmodule: HMODULE, lpprocname: PCSTR) -> FARPROC;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn LoadLibraryA(lplibfilename: PCSTR) -> HMODULE;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn OpenSemaphoreA(dwdesiredaccess: u32, binherithandle: BOOL, lpname: PCSTR) -> HANDLE;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn PeekNamedPipe(
|
||||
hnamedpipe: HANDLE,
|
||||
lpbuffer: *mut ::core::ffi::c_void,
|
||||
nbuffersize: u32,
|
||||
lpbytesread: *mut u32,
|
||||
lptotalbytesavail: *mut u32,
|
||||
lpbytesleftthismessage: *mut u32,
|
||||
) -> BOOL;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn ReleaseSemaphore(
|
||||
hsemaphore: HANDLE,
|
||||
lreleasecount: i32,
|
||||
lppreviouscount: *mut i32,
|
||||
) -> BOOL;
|
||||
}
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
pub fn WaitForSingleObject(hhandle: HANDLE, dwmilliseconds: u32) -> WAIT_EVENT;
|
||||
}
|
||||
#[link(name = "ole32")]
|
||||
extern "system" {
|
||||
pub fn CoCreateInstance(
|
||||
rclsid: *const GUID,
|
||||
punkouter: *mut ::core::ffi::c_void,
|
||||
dwclscontext: CLSCTX,
|
||||
riid: *const GUID,
|
||||
ppv: *mut *mut ::core::ffi::c_void,
|
||||
) -> HRESULT;
|
||||
}
|
||||
#[link(name = "ole32")]
|
||||
extern "system" {
|
||||
pub fn CoInitializeEx(pvreserved: *const ::core::ffi::c_void, dwcoinit: u32) -> HRESULT;
|
||||
}
|
||||
#[link(name = "oleaut32")]
|
||||
extern "system" {
|
||||
pub fn SysFreeString(bstrstring: BSTR);
|
||||
}
|
||||
#[link(name = "oleaut32")]
|
||||
extern "system" {
|
||||
pub fn SysStringLen(pbstr: BSTR) -> u32;
|
||||
}
|
||||
|
||||
windows_targets::link!("ole32.dll" "system" fn CoCreateInstance(rclsid : *const GUID, punkouter : * mut core::ffi::c_void, dwclscontext : CLSCTX, riid : *const GUID, ppv : *mut *mut core::ffi::c_void) -> HRESULT);
|
||||
windows_targets::link!("ole32.dll" "system" fn CoInitializeEx(pvreserved : *const core::ffi::c_void, dwcoinit : u32) -> HRESULT);
|
||||
windows_targets::link!("kernel32.dll" "system" fn FreeLibrary(hlibmodule : HMODULE) -> BOOL);
|
||||
windows_targets::link!("kernel32.dll" "system" fn GetMachineTypeAttributes(machine : u16, machinetypeattributes : *mut MACHINE_ATTRIBUTES) -> HRESULT);
|
||||
windows_targets::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC);
|
||||
windows_targets::link!("kernel32.dll" "system" fn LoadLibraryA(lplibfilename : PCSTR) -> HMODULE);
|
||||
windows_targets::link!("kernel32.dll" "system" fn OpenSemaphoreA(dwdesiredaccess : u32, binherithandle : BOOL, lpname : PCSTR) -> HANDLE);
|
||||
windows_targets::link!("kernel32.dll" "system" fn PeekNamedPipe(hnamedpipe : HANDLE, lpbuffer : *mut core::ffi::c_void, nbuffersize : u32, lpbytesread : *mut u32, lptotalbytesavail : *mut u32, lpbytesleftthismessage : *mut u32) -> BOOL);
|
||||
windows_targets::link!("advapi32.dll" "system" fn RegCloseKey(hkey : HKEY) -> WIN32_ERROR);
|
||||
windows_targets::link!("advapi32.dll" "system" fn RegEnumKeyExW(hkey : HKEY, dwindex : u32, lpname : PWSTR, lpcchname : *mut u32, lpreserved : *const u32, lpclass : PWSTR, lpcchclass : *mut u32, lpftlastwritetime : *mut FILETIME) -> WIN32_ERROR);
|
||||
windows_targets::link!("advapi32.dll" "system" fn RegOpenKeyExW(hkey : HKEY, lpsubkey : PCWSTR, uloptions : u32, samdesired : REG_SAM_FLAGS, phkresult : *mut HKEY) -> WIN32_ERROR);
|
||||
windows_targets::link!("advapi32.dll" "system" fn RegQueryValueExW(hkey : HKEY, lpvaluename : PCWSTR, lpreserved : *const u32, lptype : *mut REG_VALUE_TYPE, lpdata : *mut u8, lpcbdata : *mut u32) -> WIN32_ERROR);
|
||||
windows_targets::link!("kernel32.dll" "system" fn ReleaseSemaphore(hsemaphore : HANDLE, lreleasecount : i32, lppreviouscount : *mut i32) -> BOOL);
|
||||
windows_targets::link!("oleaut32.dll" "system" fn SysFreeString(bstrstring : BSTR));
|
||||
windows_targets::link!("oleaut32.dll" "system" fn SysStringLen(pbstr : BSTR) -> u32);
|
||||
windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
|
||||
pub type ADVANCED_FEATURE_FLAGS = u16;
|
||||
pub type BOOL = i32;
|
||||
pub type BSTR = *const u16;
|
||||
@@ -131,31 +42,23 @@ pub const COINIT_MULTITHREADED: COINIT = 0i32;
|
||||
pub const ERROR_NO_MORE_ITEMS: WIN32_ERROR = 259u32;
|
||||
pub const ERROR_SUCCESS: WIN32_ERROR = 0u32;
|
||||
pub const FALSE: BOOL = 0i32;
|
||||
pub type FARPROC = ::core::option::Option<unsafe extern "system" fn() -> isize>;
|
||||
pub type FARPROC = Option<unsafe extern "system" fn() -> isize>;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct FILETIME {
|
||||
pub dwLowDateTime: u32,
|
||||
pub dwHighDateTime: u32,
|
||||
}
|
||||
impl ::core::marker::Copy for FILETIME {}
|
||||
impl ::core::clone::Clone for FILETIME {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
pub const FILE_ATTRIBUTE_TEMPORARY: FILE_FLAGS_AND_ATTRIBUTES = 256u32;
|
||||
pub type FILE_FLAGS_AND_ATTRIBUTES = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct GUID {
|
||||
pub data1: u32,
|
||||
pub data2: u16,
|
||||
pub data3: u16,
|
||||
pub data4: [u8; 8],
|
||||
}
|
||||
impl ::core::marker::Copy for GUID {}
|
||||
impl ::core::clone::Clone for GUID {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
impl GUID {
|
||||
pub const fn from_u128(uuid: u128) -> Self {
|
||||
Self {
|
||||
@@ -166,13 +69,25 @@ impl GUID {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type HANDLE = *mut ::core::ffi::c_void;
|
||||
pub type HKEY = *mut ::core::ffi::c_void;
|
||||
pub type HANDLE = *mut core::ffi::c_void;
|
||||
pub type HINSTANCE = *mut core::ffi::c_void;
|
||||
pub type HKEY = *mut core::ffi::c_void;
|
||||
pub const HKEY_LOCAL_MACHINE: HKEY = -2147483646i32 as _;
|
||||
pub type HMODULE = *mut ::core::ffi::c_void;
|
||||
pub type HMODULE = *mut core::ffi::c_void;
|
||||
pub type HRESULT = i32;
|
||||
pub type IMAGE_FILE_MACHINE = u16;
|
||||
pub const IMAGE_FILE_MACHINE_AMD64: IMAGE_FILE_MACHINE = 34404u16;
|
||||
pub const IID_IUnknown: GUID = GUID::from_u128(0x00000000_0000_0000_c000_000000000046);
|
||||
#[repr(C)]
|
||||
pub struct IUnknown_Vtbl {
|
||||
pub QueryInterface: unsafe extern "system" fn(
|
||||
this: *mut core::ffi::c_void,
|
||||
iid: *const GUID,
|
||||
interface: *mut *mut core::ffi::c_void,
|
||||
) -> HRESULT,
|
||||
pub AddRef: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
|
||||
pub Release: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
|
||||
}
|
||||
pub const KEY_READ: REG_SAM_FLAGS = 131097u32;
|
||||
pub const KEY_WOW64_32KEY: REG_SAM_FLAGS = 512u32;
|
||||
pub type MACHINE_ATTRIBUTES = i32;
|
||||
@@ -183,31 +98,21 @@ pub type REG_SAM_FLAGS = u32;
|
||||
pub const REG_SZ: REG_VALUE_TYPE = 1u32;
|
||||
pub type REG_VALUE_TYPE = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SAFEARRAY {
|
||||
pub cDims: u16,
|
||||
pub fFeatures: ADVANCED_FEATURE_FLAGS,
|
||||
pub cbElements: u32,
|
||||
pub cLocks: u32,
|
||||
pub pvData: *mut ::core::ffi::c_void,
|
||||
pub pvData: *mut core::ffi::c_void,
|
||||
pub rgsabound: [SAFEARRAYBOUND; 1],
|
||||
}
|
||||
impl ::core::marker::Copy for SAFEARRAY {}
|
||||
impl ::core::clone::Clone for SAFEARRAY {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SAFEARRAYBOUND {
|
||||
pub cElements: u32,
|
||||
pub lLbound: i32,
|
||||
}
|
||||
impl ::core::marker::Copy for SAFEARRAYBOUND {}
|
||||
impl ::core::clone::Clone for SAFEARRAYBOUND {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
pub const SEMAPHORE_MODIFY_STATE: SYNCHRONIZATION_ACCESS_RIGHTS = 2u32;
|
||||
pub type SYNCHRONIZATION_ACCESS_RIGHTS = u32;
|
||||
pub const S_FALSE: HRESULT = 0x1_u32 as _;
|
||||
@@ -221,3 +126,9 @@ pub const WAIT_FAILED: WAIT_EVENT = 4294967295u32;
|
||||
pub const WAIT_OBJECT_0: WAIT_EVENT = 0u32;
|
||||
pub const WAIT_TIMEOUT: WAIT_EVENT = 258u32;
|
||||
pub type WIN32_ERROR = u32;
|
||||
|
||||
#[link(name = "advapi32")]
|
||||
#[link(name = "ole32")]
|
||||
#[link(name = "oleaut32")]
|
||||
extern "C" {}
|
||||
use super::windows_targets;
|
||||
|
||||
19
third_party/rust/cc/src/windows/windows_targets.rs
vendored
Normal file
19
third_party/rust/cc/src/windows/windows_targets.rs
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
//! Provides the `link!` macro used by the generated windows bindings.
|
||||
//!
|
||||
//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
|
||||
//! It's very roughly equivalent to the windows-targets crate.
|
||||
|
||||
macro_rules! link_macro {
|
||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
||||
// Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't
|
||||
// have in this repo. So instead we always link kernel32.lib and add the rest of the import
|
||||
// libraries below by using an empty extern block. This works because extern blocks are not
|
||||
// connected to the library given in the #[link] attribute.
|
||||
#[link(name = "kernel32")]
|
||||
extern $abi {
|
||||
$(#[link_name=$link_name])?
|
||||
pub fn $($function)*;
|
||||
}
|
||||
)
|
||||
}
|
||||
pub(crate) use link_macro as link;
|
||||
Reference in New Issue
Block a user