diff --git a/.gitignore b/.gitignore index cf9a415a10..1e236c10b5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.log # ignore rust build dirs everywhere **/target/ +**/instrument.target/ **/tests/ /build *.pyc diff --git a/Cargo.lock b/Cargo.lock index e2e4cb5906..02d2e5edf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,21 +37,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "c91f1f46651137be86f3a2b9a8359f9ab421d04d941c62b5982e1ca21113adf9" [[package]] name = "arc-swap" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164" [[package]] name = "atty" @@ -72,9 +66,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", @@ -103,7 +97,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap 3.2.8", + "clap 3.2.16", "env_logger", "lazy_static", "lazycell", @@ -123,77 +117,26 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitmaps" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" -dependencies = [ - "typenum", -] - [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] [[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", -] - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" - -[[package]] -name = "bytesize" -version = "1.1.0" +name = "bumpalo" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "c2rust" version = "0.16.0" dependencies = [ "anyhow", - "c2rust-dynamic-instrumentation", "c2rust-transpile", "clap 2.34.0", "env_logger", @@ -280,14 +223,16 @@ dependencies = [ ] [[package]] -name = "c2rust-dynamic-instrumentation" +name = "c2rust-instrument" version = "0.1.0" dependencies = [ "anyhow", "bincode", "c2rust-analysis-rt", - "cargo", - "cargo-util", + "camino", + "cargo_metadata", + "clap 3.2.16", + "fs-err", "indexmap", "itertools", "lazy_static", @@ -301,7 +246,7 @@ version = "0.1.0" dependencies = [ "bincode", "c2rust-analysis-rt", - "clap 3.2.8", + "clap 3.2.16", "color-eyre", "env_logger", "fs-err", @@ -347,61 +292,12 @@ dependencies = [ ] [[package]] -name = "cargo" -version = "0.62.0" +name = "camino" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79bc435c2de37f164b5c36420d9e1dd65cd5acbd41b2df10fdc02dbf75ed9efc" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" dependencies = [ - "anyhow", - "atty", - "bytesize", - "cargo-platform", - "cargo-util", - "clap 3.2.8", - "crates-io", - "crossbeam-utils", - "curl", - "curl-sys", - "env_logger", - "filetime", - "flate2", - "fwdansi", - "git2", - "git2-curl", - "glob", - "hex 0.4.3", - "home", - "humantime", - "ignore", - "im-rc", - "itertools", - "jobserver", - "lazy_static", - "lazycell", - "libc", - "libgit2-sys", - "log", - "memchr", - "opener", - "os_info", - "percent-encoding", - "rustc-workspace-hack", - "rustfix", - "semver", "serde", - "serde_ignored", - "serde_json", - "shell-escape", - "strip-ansi-escapes", - "tar", - "tempfile", - "termcolor", - "toml_edit", - "unicode-width", - "unicode-xid", - "url", - "walkdir", - "winapi", ] [[package]] @@ -414,25 +310,16 @@ dependencies = [ ] [[package]] -name = "cargo-util" -version = "0.1.2" +name = "cargo_metadata" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51c783163bdf4549820b80968d386c94ed45ed23819c93f59cca7ebd97fe0eb" +checksum = "3abb7553d5b9b8421c6de7cb02606ff15e0c6eea7d8eadd75ef013fd636bec36" dependencies = [ - "anyhow", - "core-foundation", - "crypto-hash", - "filetime", - "hex 0.4.3", - "jobserver", - "libc", - "log", - "miow", - "same-file", - "shell-escape", - "tempfile", - "walkdir", - "winapi", + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", ] [[package]] @@ -440,9 +327,6 @@ name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" -dependencies = [ - "jobserver", -] [[package]] name = "cexpr" @@ -488,9 +372,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.8" +version = "3.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" +checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9" dependencies = [ "atty", "bitflags", @@ -505,9 +389,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.2.7" +version = "3.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" +checksum = "9ba52acd3b0a5c33aeada5cdaa3267cdc7c594a98731d4268cdc1532f4264cb4" dependencies = [ "heck", "proc-macro-error", @@ -536,9 +420,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" +checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" dependencies = [ "backtrace", "color-spantrace", @@ -583,39 +467,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "combine" -version = "4.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a604e93b79d1808327a6fca85a6f2d69de66461e7620f5a4cbf5fb4d1d7c948" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] -name = "commoncrypto" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" -dependencies = [ - "commoncrypto-sys", -] - -[[package]] -name = "commoncrypto-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -dependencies = [ - "libc", -] - [[package]] name = "console" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" +checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847" dependencies = [ "encode_unicode", "libc", @@ -625,95 +481,22 @@ dependencies = [ ] [[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "crates-io" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4a87459133b2e708195eaab34be55039bc30e0d120658bd40794bb00b6328d" -dependencies = [ - "anyhow", - "curl", - "percent-encoding", - "serde", - "serde_json", - "url", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[package]] -name = "crypto-hash" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a77162240fd97248d19a564a565eb563a3f592b386e4136fb300909e67dddca" -dependencies = [ - "commoncrypto", - "hex 0.3.2", - "openssl", - "winapi", -] - -[[package]] -name = "curl" -version = "0.4.43" +name = "cpufeatures" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ - "curl-sys", "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2", - "winapi", ] [[package]] -name = "curl-sys" -version = "0.4.55+curl-7.83.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23734ec77368ec583c2e61dd3f0b0e5c98b93abe6d2a004ca06b91dd7e3e2762" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "cc", - "libc", - "libnghttp2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi", + "generic-array", + "typenum", ] [[package]] @@ -724,11 +507,12 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69" [[package]] name = "digest" -version = "0.8.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -739,9 +523,9 @@ checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" [[package]] name = "either" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "encode_unicode" @@ -806,21 +590,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fastrand" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" -dependencies = [ - "instant", -] - [[package]] name = "fern" version = "0.6.1" @@ -831,90 +600,27 @@ dependencies = [ "log", ] -[[package]] -name = "filetime" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi", -] - -[[package]] -name = "flate2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" -dependencies = [ - "crc32fast", - "libz-sys", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" -dependencies = [ - "matches", - "percent-encoding", -] - [[package]] name = "fs-err" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bd79fa345a495d3ae89fb7165fec01c0e72f41821d642dda363a1e97975652e" -[[package]] -name = "fwdansi" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c1f5787fe85505d1f7777268db5103d80a7a374d2316a7ce262e57baf8f208" -dependencies = [ - "memchr", - "termcolor", -] - [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", + "version_check", ] [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "git-testament" @@ -939,52 +645,12 @@ dependencies = [ "time", ] -[[package]] -name = "git2" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" -dependencies = [ - "bitflags", - "libc", - "libgit2-sys", - "log", - "openssl-probe", - "openssl-sys", - "url", -] - -[[package]] -name = "git2-curl" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13" -dependencies = [ - "curl", - "git2", - "log", - "url", -] - [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "globset" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - [[package]] name = "half" version = "1.8.2" @@ -993,9 +659,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.3.1" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66d0c1b6e3abfd1e72818798925e16e02ed77e1b47f6c25a95a23b377ee4299" +checksum = "360d9740069b2f6cbb63ce2dbaa71a20d3185350cbb990d7bebeb9318415eb17" dependencies = [ "log", "pest", @@ -1007,9 +673,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" @@ -1026,76 +692,12 @@ dependencies = [ "libc", ] -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "home" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" -dependencies = [ - "winapi", -] - [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "ignore" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" -dependencies = [ - "crossbeam-utils", - "globset", - "lazy_static", - "log", - "memchr", - "regex", - "same-file", - "thread_local", - "walkdir", - "winapi-util", -] - -[[package]] -name = "im-rc" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe" -dependencies = [ - "bitmaps", - "rand_core", - "rand_xoshiro", - "sized-chunks", - "typenum", - "version_check", -] - [[package]] name = "indenter" version = "0.3.3" @@ -1113,9 +715,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -1124,9 +726,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.15.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4126dd76ebfe2561486a1bd6738a33d2029ffb068a99ac446b7f8c77b2e58dbc" +checksum = "1585a0f4924236ca3c8dac97bc6a3efaacc08b1ed9264ff2155ec7ab2906a8ea" dependencies = [ "console", "once_cell", @@ -1136,15 +738,6 @@ dependencies = [ "similar", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "itertools" version = "0.10.3" @@ -1161,26 +754,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] -name = "jobserver" -version = "0.1.24" +name = "js-sys" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" dependencies = [ - "libc", + "wasm-bindgen", ] [[package]] -name = "kstring" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b310ccceade8121d7d77fee406160e457c2f4e7c7982d589da3499bc7ea4526" -dependencies = [ - "serde", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" +name = "lazy_static" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" @@ -1196,20 +780,6 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" -[[package]] -name = "libgit2-sys" -version = "0.13.4+1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" -dependencies = [ - "cc", - "libc", - "libssh2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", -] - [[package]] name = "libloading" version = "0.7.3" @@ -1220,42 +790,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libnghttp2-sys" -version = "0.1.7+1.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "libssh2-sys" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "libz-sys" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1291,18 +825,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - [[package]] name = "memchr" version = "2.5.0" @@ -1324,15 +846,6 @@ dependencies = [ "adler", ] -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - [[package]] name = "no-std-compat" version = "0.4.1" @@ -1360,96 +873,24 @@ dependencies = [ [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opener" -version = "0.5.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952" -dependencies = [ - "bstr", - "winapi", -] - -[[package]] -name = "openssl" -version = "0.10.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "os_info" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eca3ecae1481e12c3d9379ec541b238a16f0b75c9a409942daa8ec20dbfdb62" -dependencies = [ - "log", - "serde", - "winapi", -] +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "os_str_bytes" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "owo-colors" @@ -1469,26 +910,21 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - [[package]] name = "pest" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "69486e2b8c2d2aeb9762db7b4e00b0331156393555cff467f4163ff06821eef8" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "b13570633aff33c6d22ce47dd566b10a3b9122c2fe9d8e7501895905be532b91" dependencies = [ "pest", "pest_generator", @@ -1496,9 +932,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "b3c567e5702efdc79fb18859ea74c3eb36e14c43da7b8c1f098a4ed6514ec7a0" dependencies = [ "pest", "pest_meta", @@ -1509,11 +945,11 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "5eb32be5ee3bbdafa8c7a18b0a8a8d962b66cfa2ceee4037f49267a50ee821fe" dependencies = [ - "maplit", + "once_cell", "pest", "sha-1", ] @@ -1524,12 +960,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" -[[package]] -name = "pkg-config" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" - [[package]] name = "polonius-engine" version = "0.13.0" @@ -1543,9 +973,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.11" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" +checksum = "fffbe84bf1905c007253d1f10ffb85fbc8ca8624a40cff8f2ded6f36920e38e0" dependencies = [ "proc-macro2", "syn", @@ -1586,77 +1016,38 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" - -[[package]] -name = "rand_xoshiro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rustc-demangle" @@ -1677,29 +1068,11 @@ dependencies = [ "print_bytes", ] -[[package]] -name = "rustc-workspace-hack" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc71d2faa173b74b232dedc235e3ee1696581bb132fc116fa3626d6151a1a8fb" - -[[package]] -name = "rustfix" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd2853d9e26988467753bd9912c3a126f642d05d229a4b53f5752ee36c56481" -dependencies = [ - "anyhow", - "log", - "serde", - "serde_json", -] - [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8" [[package]] name = "ryu" @@ -1707,39 +1080,20 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" -dependencies = [ - "lazy_static", - "windows-sys", -] - [[package]] name = "semver" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.137" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500" dependencies = [ "serde_derive", ] @@ -1775,29 +1129,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "serde_ignored" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1940036ca2411651a40012009d062087dfe62817b2191a03750fb569e11fa633" -dependencies = [ - "serde", -] - [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" dependencies = [ "itoa", "ryu", @@ -1806,9 +1151,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec0091e1f5aa338283ce049bd9dfefd55e1f168ac233e85c1ffe0038fb48cbe" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ "indexmap", "ryu", @@ -1818,14 +1163,13 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.8.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "block-buffer", + "cfg-if", + "cpufeatures", "digest", - "fake-simd", - "opaque-debug", ] [[package]] @@ -1837,12 +1181,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shell-escape" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" - [[package]] name = "shlex" version = "1.1.0" @@ -1851,44 +1189,15 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "similar" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3" - -[[package]] -name = "sized-chunks" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" -dependencies = [ - "bitmaps", - "typenum", -] +checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" [[package]] name = "smallvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" - -[[package]] -name = "socket2" -version = "0.4.4" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "strip-ansi-escapes" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8" -dependencies = [ - "vte", -] +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "strsim" @@ -1904,15 +1213,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum_macros" -version = "0.24.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" +checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b" dependencies = [ "heck", "proc-macro2", @@ -1923,9 +1232,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.96" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", @@ -1944,30 +1253,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "tar" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" -dependencies = [ - "filetime", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - [[package]] name = "termcolor" version = "1.1.3" @@ -2033,11 +1318,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.9" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" +checksum = "74b7cc93fc23ba97fde84f7eea56c55d1ba183f495c6715defdfc7b9cb8c870f" dependencies = [ "itoa", + "js-sys", "libc", "num_threads", "time-macros", @@ -2049,39 +1335,11 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "toml_edit" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744e9ed5b352340aa47ce033716991b5589e23781acb97cad37d4ea70560f55b" -dependencies = [ - "combine", - "indexmap", - "itertools", - "kstring", - "serde", -] - [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" dependencies = [ "cfg-if", "pin-project-lite", @@ -2090,9 +1348,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" dependencies = [ "once_cell", "valuable", @@ -2110,9 +1368,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.11" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" +checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" dependencies = [ "sharded-slab", "thread_local", @@ -2127,30 +1385,15 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unicode-bidi" -version = "0.3.8" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unicode-ident" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" - -[[package]] -name = "unicode-normalization" -version = "0.1.19" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" -dependencies = [ - "tinyvec", -] +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "unicode-width" @@ -2164,36 +1407,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" -[[package]] -name = "url" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "utf8parse" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" - [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "vec_map" version = "0.8.2" @@ -2207,37 +1426,59 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "vte" -version = "0.10.1" +name = "wasm-bindgen" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ - "arrayvec", - "utf8parse", - "vte_generate_state_changes", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] -name = "vte_generate_state_changes" -version = "0.1.1" +name = "wasm-bindgen-backend" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" dependencies = [ + "bumpalo", + "log", + "once_cell", "proc-macro2", "quote", + "syn", + "wasm-bindgen-shared", ] [[package]] -name = "walkdir" -version = "2.3.2" +name = "wasm-bindgen-macro" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" dependencies = [ - "same-file", - "winapi", - "winapi-util", + "quote", + "wasm-bindgen-macro-support", ] +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" + [[package]] name = "which" version = "4.2.5" diff --git a/analysis/test/Cargo.toml b/analysis/test/Cargo.toml index 5edf6636dd..838e8ce06e 100644 --- a/analysis/test/Cargo.toml +++ b/analysis/test/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] libc = "0.2" +c2rust-analysis-rt = { path = "../../analysis/runtime", optional = true } diff --git a/c2rust/Cargo.toml b/c2rust/Cargo.toml index def1cd26e2..891f991d74 100644 --- a/c2rust/Cargo.toml +++ b/c2rust/Cargo.toml @@ -25,16 +25,10 @@ git-testament = "0.2.1" regex = "1.3" shlex = "1.1" c2rust-transpile = { version = "0.16.0", path = "../c2rust-transpile" } -c2rust-dynamic-instrumentation = { version = "0.1.0", path = "../dynamic_instrumentation", optional = true } [build-dependencies] rustc-private-link = { path = "../rustc-private-link" } -[[bin]] -name = "c2rust-instrument" -required-features = ["dynamic-instrumentation"] - [features] # Force static linking of LLVM llvm-static = ["c2rust-transpile/llvm-static"] -dynamic-instrumentation = ["dep:c2rust-dynamic-instrumentation"] diff --git a/c2rust/build.rs b/c2rust/build.rs deleted file mode 100644 index 3d93932b5e..0000000000 --- a/c2rust/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -use rustc_private_link::SysRoot; - -fn main() { - let sysroot = SysRoot::resolve(); - sysroot.link_rustc_private(); -} diff --git a/c2rust/src/bin/c2rust-instrument.rs b/c2rust/src/bin/c2rust-instrument.rs deleted file mode 100644 index c88dfcbc51..0000000000 --- a/c2rust/src/bin/c2rust-instrument.rs +++ /dev/null @@ -1,21 +0,0 @@ -use std::fs; -use std::path::Path; - -use c2rust_dynamic_instrumentation::instrument; -use clap::{load_yaml, App}; - -fn main() -> anyhow::Result<()> { - env_logger::init(); - let yaml = load_yaml!("../instrument.yaml"); - let matches = App::from_yaml(yaml).get_matches(); - - let extra_args: Vec<&str> = match matches.values_of("extra-cargo-args") { - Some(args) => args.collect(), - None => Vec::new(), - }; - let extra_args: Vec = extra_args.into_iter().map(|x| x.to_owned()).collect(); - - let metadata_file_path = Path::new(matches.value_of_os("METADATA_FILE").unwrap()); - let runtime_path = fs::canonicalize(matches.value_of_os("RUNTIME_PATH").unwrap()).unwrap(); - instrument(metadata_file_path, &runtime_path, &extra_args) -} diff --git a/c2rust/src/instrument.yaml b/c2rust/src/instrument.yaml deleted file mode 100644 index 68d739f3a7..0000000000 --- a/c2rust/src/instrument.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: instrument -version: 0.16.0 -author: | - - The C2Rust Project Developers -about: Instrument memory accesses for dynamic analysis -settings: - - TrailingVarArg -args: - - METADATA_FILE: - help: Path to the metadata output file storing instrumentation locations - required: true - index: 1 - - RUNTIME_PATH: - help: Path to the c2rust-analysis-runtime crate - required: true - index: 2 - - extra-cargo-args: - help: Extra arguments to pass to cargo after `build` - takes_value: true - multiple: true \ No newline at end of file diff --git a/c2rust/src/main.rs b/c2rust/src/main.rs index 89bd421d9b..a58220c931 100644 --- a/c2rust/src/main.rs +++ b/c2rust/src/main.rs @@ -7,7 +7,7 @@ use std::process::{exit, Command}; git_testament!(TESTAMENT); fn main() { - let subcommand_yamls = [load_yaml!("transpile.yaml"), load_yaml!("instrument.yaml")]; + let subcommand_yamls = [load_yaml!("transpile.yaml")]; let matches = App::new("C2Rust") .version(&*render_testament!(TESTAMENT)) .author(crate_authors!(", ")) diff --git a/dynamic_instrumentation/Cargo.toml b/dynamic_instrumentation/Cargo.toml index 323f93ad79..ffeae2414d 100644 --- a/dynamic_instrumentation/Cargo.toml +++ b/dynamic_instrumentation/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "c2rust-dynamic-instrumentation" +name = "c2rust-instrument" version = "0.1.0" edition = "2021" @@ -7,12 +7,14 @@ edition = "2021" anyhow = "1.0" bincode = "1.0.1" c2rust-analysis-rt = { path = "../analysis/runtime"} -cargo = "0.62" -cargo-util = "0.1" indexmap = "1.8" itertools = "0.10" lazy_static = "1.4" log = "0.4" +fs-err = "2" +clap = { version = "3.2", features = ["derive"] } +cargo_metadata = "0.15" +camino = "1.0" [build-dependencies] rustc-private-link = { path = "../rustc-private-link" } diff --git a/dynamic_instrumentation/build.rs b/dynamic_instrumentation/build.rs index b873c077eb..9bbd6765ac 100644 --- a/dynamic_instrumentation/build.rs +++ b/dynamic_instrumentation/build.rs @@ -2,7 +2,6 @@ use rustc_private_link::SysRoot; fn main() { let sysroot = SysRoot::resolve(); - sysroot.set_env_rust_sysroot(); // Not strictly needed here since this is not used as this is a library crate (it's needed in `c2rust`), // but it doesn't hurt, and in case this ever adds a binary crate, it's useful. sysroot.link_rustc_private(); diff --git a/dynamic_instrumentation/src/callbacks.rs b/dynamic_instrumentation/src/callbacks.rs new file mode 100644 index 0000000000..b27542514d --- /dev/null +++ b/dynamic_instrumentation/src/callbacks.rs @@ -0,0 +1,82 @@ +use rustc_ast::ast::{Item, ItemKind, Visibility, VisibilityKind}; +use rustc_ast::node_id::NodeId; +use rustc_ast::ptr::P; +use rustc_const_eval::transform::validate::Validator; +use rustc_driver::Compilation; +use rustc_interface::interface::Compiler; +use rustc_interface::Queries; +use rustc_middle::mir::MirPass; +use rustc_middle::ty::query::{ExternProviders, Providers}; +use rustc_middle::ty::WithOptConstParam; +use rustc_session::Session; +use rustc_span::def_id::LocalDefId; +use rustc_span::symbol::Ident; +use rustc_span::DUMMY_SP; + +use lazy_static::lazy_static; + +use crate::instrument::Instrumenter; + +lazy_static! { + /// TODO(kkysen) can be made non-lazy when `Mutex::new` is `const` in rust 1.63 + pub static ref INSTRUMENTER: Instrumenter = Instrumenter::new(); +} + +pub struct MirTransformCallbacks; + +impl rustc_driver::Callbacks for MirTransformCallbacks { + fn config(&mut self, config: &mut rustc_interface::Config) { + config.override_queries = Some(override_queries); + } + + fn after_parsing<'tcx>( + &mut self, + _compiler: &Compiler, + queries: &'tcx Queries<'tcx>, + ) -> Compilation { + let parse = queries.parse().unwrap(); + let mut parse = parse.peek_mut(); + parse.items.push(P(Item { + attrs: Vec::new(), + id: NodeId::from_u32(0), + span: DUMMY_SP, + vis: Visibility { + kind: VisibilityKind::Inherited, + span: DUMMY_SP, + tokens: None, + }, + ident: Ident::from_str("c2rust_analysis_rt"), + kind: ItemKind::ExternCrate(None), + tokens: None, + })); + Compilation::Continue + } +} + +fn override_queries( + _sess: &Session, + providers: &mut Providers, + _extern_providers: &mut ExternProviders, +) { + providers.mir_built = |tcx, def: WithOptConstParam| { + let mut providers = Providers::default(); + rustc_mir_build::provide(&mut providers); + + let steal_mir = (providers.mir_built)(tcx, def); + let mut mir = steal_mir.steal(); + + let body_did = def.did.to_def_id(); + let fn_ty = tcx.type_of(body_did); + if fn_ty.is_fn() && !tcx.is_const_fn(body_did) && !tcx.is_static(body_did) { + INSTRUMENTER.instrument_fn(tcx, &mut mir, body_did); + + Validator { + when: "After dynamic instrumentation".to_string(), + mir_phase: mir.phase, + } + .run_pass(tcx, &mut mir); + } + + tcx.alloc_steal_mir(mir) + }; +} diff --git a/dynamic_instrumentation/src/lib.rs b/dynamic_instrumentation/src/lib.rs deleted file mode 100644 index e1e8134b7b..0000000000 --- a/dynamic_instrumentation/src/lib.rs +++ /dev/null @@ -1,223 +0,0 @@ -#![feature(rustc_private)] -extern crate rustc_ast; -extern crate rustc_const_eval; -extern crate rustc_data_structures; -extern crate rustc_driver; -extern crate rustc_index; -extern crate rustc_interface; -extern crate rustc_middle; -extern crate rustc_mir_build; -extern crate rustc_mir_transform; -extern crate rustc_session; -extern crate rustc_span; -extern crate rustc_target; - -mod arg; -mod hooks; -mod instrument; -mod into_operand; -mod mir_utils; -mod point; -mod runtime_conversions; -mod util; - -use instrument::Instrumenter; - -use cargo::core::compiler::{CompileMode, Context, DefaultExecutor, Executor, Unit}; -use cargo::core::{PackageId, Target, Verbosity, Workspace}; -use cargo::ops; -use cargo::ops::CompileOptions; -use cargo::util::important_paths::find_root_manifest_for_wd; -use cargo::util::CargoResult; -use cargo::Config; -use cargo_util::ProcessBuilder; - -use rustc_ast::ast::{Item, ItemKind, Visibility, VisibilityKind}; -use rustc_ast::node_id::NodeId; -use rustc_ast::ptr::P; -use rustc_const_eval::transform::validate; -use rustc_driver::Compilation; -use rustc_interface::interface::Compiler; -use rustc_interface::Queries; -use rustc_middle::mir::MirPass; -use rustc_middle::ty::query::{ExternProviders, Providers}; -use rustc_middle::ty::WithOptConstParam; -use rustc_session::Session; -use rustc_span::def_id::LocalDefId; -use rustc_span::symbol::Ident; -use rustc_span::DUMMY_SP; - -use anyhow::anyhow; -use lazy_static::lazy_static; -use std::env; -use std::ffi::OsString; -use std::path::Path; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; - -lazy_static! { - /// TODO(kkysen) can be made non-lazy when `Mutex::new` is `const` in rust 1.63 - static ref INSTRUMENTER: Instrumenter = Instrumenter::new(); -} - -struct NullCallbacks; - -impl rustc_driver::Callbacks for NullCallbacks {} - -struct MirTransformCallbacks; - -impl rustc_driver::Callbacks for MirTransformCallbacks { - fn config(&mut self, config: &mut rustc_interface::Config) { - config.override_queries = Some(override_queries); - } - - fn after_parsing<'tcx>( - &mut self, - _compiler: &Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - let parse = queries.parse().unwrap(); - let mut parse = parse.peek_mut(); - parse.items.push(P(Item { - attrs: Vec::new(), - id: NodeId::from_u32(0), - span: DUMMY_SP, - vis: Visibility { - kind: VisibilityKind::Inherited, - span: DUMMY_SP, - tokens: None, - }, - ident: Ident::from_str("c2rust_analysis_rt"), - kind: ItemKind::ExternCrate(None), - tokens: None, - })); - Compilation::Continue - } -} - -fn override_queries( - _sess: &Session, - providers: &mut Providers, - _extern_providers: &mut ExternProviders, -) { - providers.mir_built = |tcx, def: WithOptConstParam| { - let mut providers = Providers::default(); - rustc_mir_build::provide(&mut providers); - - let steal_mir = (providers.mir_built)(tcx, def); - let mut mir = steal_mir.steal(); - - let body_did = def.did.to_def_id(); - let fn_ty = tcx.type_of(body_did); - if fn_ty.is_fn() && !tcx.is_const_fn(body_did) && !tcx.is_static(body_did) { - INSTRUMENTER.instrument_fn(tcx, &mut mir, body_did); - - validate::Validator { - when: "After dynamic instrumentation".to_string(), - mir_phase: mir.phase, - } - .run_pass(tcx, &mut mir); - } - - tcx.alloc_steal_mir(mir) - }; -} - -pub fn instrument( - metadata_file_path: &Path, - rt_path: &Path, - _args: &[String], -) -> anyhow::Result<()> { - let config = Config::default().unwrap(); - config.shell().set_verbosity(Verbosity::Quiet); - let mode = CompileMode::Build; - let compile_opts = CompileOptions::new(&config, mode).unwrap(); - - let manifest_path = find_root_manifest_for_wd(config.cwd()).unwrap(); - let ws = Workspace::new(&manifest_path, &config).unwrap(); - - let rt_manifest_path = find_root_manifest_for_wd(rt_path).unwrap(); - let mut rt_ws = Workspace::new(&rt_manifest_path, &config).unwrap(); - rt_ws.set_target_dir(ws.target_dir()); - - let exec = Arc::new(InstrumentationExecutor { - default: DefaultExecutor, - target_pkg: ws.current().unwrap().package_id(), - rt_crate_path: Mutex::new(String::new()), - building_rt: AtomicBool::new(true), - }); - let exec_dyn: Arc = exec.clone(); - - let cwd = env::current_dir().unwrap(); - - env::set_current_dir(rt_ws.root()).unwrap(); - ops::compile_with_exec(&rt_ws, &compile_opts, &exec_dyn)?; - - exec.building_rt.store(false, Ordering::Relaxed); - env::set_current_dir(cwd).unwrap(); - ops::compile_with_exec(&ws, &compile_opts, &exec_dyn)?; - - INSTRUMENTER.finalize(metadata_file_path) -} -struct InstrumentationExecutor { - default: DefaultExecutor, - target_pkg: PackageId, - rt_crate_path: Mutex, - building_rt: AtomicBool, -} - -impl Executor for InstrumentationExecutor { - fn init(&self, cx: &Context<'_, '_>, unit: &Unit) { - if self.building_rt.load(Ordering::Relaxed) && cx.is_primary_package(unit) { - *self.rt_crate_path.lock().unwrap() = cx.outputs(unit).unwrap()[0] - .path - .to_str() - .unwrap() - .to_owned(); - } - self.default.init(cx, unit); - } - - fn exec( - &self, - cmd: &ProcessBuilder, - id: PackageId, - target: &Target, - _mode: CompileMode, - _on_stdout_line: &mut dyn FnMut(&str) -> CargoResult<()>, - _on_stderr_line: &mut dyn FnMut(&str) -> CargoResult<()>, - ) -> CargoResult<()> { - let mut args: Vec = cmd - .get_args() - .iter() - .map(|a| a.to_str().unwrap().to_string()) - .collect(); - args.insert(0, cmd.get_program().to_str().unwrap().to_string()); - // We need to point the rust compiler libraries to the corresponding sysroot - args.push(format!("--sysroot={}", env!("RUST_SYSROOT"))); - for (var, val) in cmd.get_envs() { - env::set_var(var, val.as_ref().unwrap_or(&OsString::new())); - } - if id == self.target_pkg && !target.for_host() { - args.push("--extern".to_string()); - args.push(format!( - "c2rust_analysis_rt={}", - self.rt_crate_path.lock().unwrap() - )); - let mut callbacks = MirTransformCallbacks; - // TODO: Capture stdout and pass it back to cargo - rustc_driver::RunCompiler::new(&args, &mut callbacks) - .run() - .map_err(|_| anyhow!("Compilation failed")) - } else { - let mut callbacks = NullCallbacks; - rustc_driver::RunCompiler::new(&args, &mut callbacks) - .run() - .map_err(|_| anyhow!("Compilation failed")) - } - } - - fn force_rebuild(&self, unit: &Unit) -> bool { - self.building_rt.load(Ordering::Relaxed) || self.default.force_rebuild(unit) - } -} diff --git a/dynamic_instrumentation/src/main.rs b/dynamic_instrumentation/src/main.rs new file mode 100644 index 0000000000..36be1a88b5 --- /dev/null +++ b/dynamic_instrumentation/src/main.rs @@ -0,0 +1,323 @@ +#![feature(rustc_private)] +extern crate rustc_ast; +extern crate rustc_const_eval; +extern crate rustc_data_structures; +extern crate rustc_driver; +extern crate rustc_index; +extern crate rustc_interface; +extern crate rustc_middle; +extern crate rustc_mir_build; +extern crate rustc_mir_transform; +extern crate rustc_session; +extern crate rustc_span; + +mod arg; +mod callbacks; +mod hooks; +mod instrument; +mod into_operand; +mod mir_utils; +mod point; +mod runtime_conversions; +mod util; + +use crate::callbacks::{MirTransformCallbacks, INSTRUMENTER}; + +use std::{ + env, + ffi::{OsStr, OsString}, + iter, + path::{Path, PathBuf}, + process::{self, Command, ExitStatus}, +}; + +use rustc_driver::{RunCompiler, TimePassesCallbacks}; +use rustc_session::config::CrateType; + +use anyhow::{anyhow, ensure, Context}; +use camino::Utf8Path; +use cargo_metadata::MetadataCommand; +use clap::Parser; + +/// Instrument memory accesses for dynamic analysis. +#[derive(Debug, Parser)] +#[clap(author, version, about, long_about = None)] +struct Args { + /// Path to the metadata output file storing instrumentation locations. + #[clap(long, value_parser)] + metadata: PathBuf, + + /// `cargo` args. + cargo_args: Vec, +} + +fn exit_with_status(status: ExitStatus) { + process::exit(status.code().unwrap_or(1)) +} + +/// Resolve the current `rustc` sysroot using `rustc --print sysroot`. +/// +/// Normally, `rustc` looks up the sysroot by the location of its own binary. +/// This works because the `rustc` on `$PATH` is actually `rustup`, +/// and `rustup` invokes the real `rustc`, which is in a location relative to the sysroot. +/// As we invoke `rustc_driver` directly here, we are `rustc`, +/// and thus we have to explicitly specify the sysroot that the real `rustc` would normally use. +/// +/// Note that the sysroot contains the toolchain and host target name, +/// but this has no effect on cross-compiling. +/// Every toolchain's `rustc` is able to itself cross-compile. +/// I'm not sure why the host target needs to be in the sysroot directory name, but it is. +/// +/// Also note that this sysroot lookup should be done at runtime, +/// not at compile-time in the `build.rs`, +/// as the toolchain locations could be different +/// from where this binary was compiled and where it is running +/// (it could be on a different machine with a different `$RUSTUP_HOME`). +/// +/// TODO(kkysen) deduplicate this with `rustc_private_link::SysRoot::resolve` +fn resolve_sysroot() -> anyhow::Result { + let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()); + let output = Command::new(rustc) + .args(&["--print", "sysroot"]) + .output() + .context("could not invoke `rustc` to find rust sysroot")?; + // trim, but `str::trim` doesn't exist on `[u8]` + let path = output + .stdout + .as_slice() + .split(|c| c.is_ascii_whitespace()) + .next() + .unwrap_or_default(); + let path = if cfg!(unix) { + use std::os::unix::ffi::OsStrExt; + + OsStr::from_bytes(path) + } else { + // Windows is hard, so just require UTF-8 + let path = std::str::from_utf8(path).context("`rustc --print sysroot` is not UTF-8")?; + OsStr::new(path) + }; + let path = Path::new(path).to_owned(); + // `rustc` reports a million errors if the sysroot is wrong, so try to check first. + ensure!( + path.is_dir(), + "invalid sysroot (not a dir): {}", + path.display() + ); + Ok(path) +} + +/// Insert feature flags as the first arguments following the `cargo` subcommand. +/// +/// We can't insert them at the end because they could come after a `--` and thus be ignored. +/// And we can't insert them at the beginning before the `cargo` subcommand argument, +/// as `--features` is an argument of the subcommands, not `cargo` itself. +/// +/// If there are no arguments, we don't insert the feature flags, as: +/// * it would panic on splicing/insertion +/// * we don't want to add the feature flags anyways, as `cargo` without arguments is already an error +/// * we don't want to obfuscate that error with an error about unexpected feature flags +fn add_feature(cargo_args: &mut Vec, features: &[&str]) { + let insertion_point = 1; + if cargo_args.len() >= insertion_point { + cargo_args.splice( + insertion_point..insertion_point, + iter::once(&"--features").chain(features).map(|s| s.into()), + ); + } +} + +struct Cargo { + path: PathBuf, +} + +impl Cargo { + pub fn new() -> Self { + let path = env::var_os("CARGO") + .unwrap_or_else(|| "cargo".into()) + .into(); + Self { path } + } + + pub fn metadata(&self) -> MetadataCommand { + let mut cmd = MetadataCommand::new(); + cmd.cargo_path(&self.path); + cmd + } + + pub fn command(&self) -> Command { + let mut cmd = Command::new(&self.path); + cmd.env("CARGO_TARGET_DIR", "instrument.target"); + cmd + } + + pub fn run(&self, f: impl FnOnce(&mut Command)) -> anyhow::Result<()> { + let mut cmd = self.command(); + f(&mut cmd); + let status = cmd.status()?; + if !status.success() { + eprintln!("error running: {cmd:?}"); + exit_with_status(status); + } + Ok(()) + } +} + +const RUSTC_WRAPPER_VAR: &str = "RUSTC_WRAPPER"; +const RUST_SYSROOT_VAR: &str = "RUST_SYSROOT"; +const METADATA_VAR: &str = "C2RUST_INSTRUMENT_METADATA_PATH"; + +/// Read a [`PathBuf`] from the [`mod@env`]ironment that should've been set by the [`cargo_wrapper`]. +fn env_path_from_wrapper(var: &str) -> anyhow::Result { + let path = env::var_os(var) + .ok_or_else(|| anyhow!("the `cargo` wrapper should've `${var}` for the `rustc` wrapper"))?; + Ok(path.into()) +} + +/// Check if the current [`rustc_wrapper`] invocation is for the primary `cargo` package, +/// as determined by `$CARGO_PRIMARY_PACKAGE`. +fn is_primary_package() -> bool { + env::var("CARGO_PRIMARY_PACKAGE").is_ok() +} + +/// Check if the current [`rustc_wrapper`] invocation is a binary crate, +/// i.e., if `--crate-type bin` was specified. +/// +/// This uses the [`rustc_driver`] and [`rustc_session`] APIs +/// to check this exactly as `rustc` would. +fn is_bin_crate(at_args: &[String]) -> anyhow::Result { + let args = rustc_driver::args::arg_expand_all(at_args); + let matches = rustc_driver::handle_options(&args) + .ok_or_else(|| anyhow!("failed to parse `rustc` args"))?; + let session_options = rustc_session::config::build_session_options(&matches); + let is_bin = session_options.crate_types.contains(&CrateType::Executable); + Ok(is_bin) +} + +/// Read the name of the current binary crate being compiled, if it is a binary crate ([`is_bin_crate`]). +/// +/// Note that despite setting `--crate-type bin` and [`is_bin_crate`] being true, +/// there is no name set for build scripts. +/// That's how we can detect them. +fn bin_crate_name() -> Option { + env::var_os("CARGO_BIN_NAME").map(PathBuf::from) +} + +/// Detect if the current [`rustc_wrapper`] is for compiling a build script. +/// +/// `c2rust-analysis-rt` is not yet built for the build script, +/// so trying to compile it will fail. +/// Plus, we don't need to and don't want to instrument the build script. +/// +/// We check if it is a build script by checking if it's a `--crate-type bin` +/// and yet has no `$CARGO_BIN_NAME`, which is set for normal binary crates. +/// +/// Another solution (that `miri` uses) is to always specify the `--target`, +/// even if it's the host target. Then `cargo` thinks it's cross-compiling, +/// and always forwards `--target` to `rustc` for native compilations, +/// but for host compilations like build scripts and proc-macros, +/// it doesn't specify `--target`. +/// +/// This would work more robustly if we were also instrumenting dependencies, +/// as our currently solution would no longer work, but we aren't. +/// +/// On the other hand, the `--target` solution has a drawback +/// in that there are many ways to specify the target: +/// * `--target` +/// * `$CARGO_BUILD_TARGET` +/// * `targets` in `rust-toolchain.toml` +/// * `targets` in `.cargo/config.toml` +/// * and maybe some other places as well +/// All the resolution is in `cargo`, but we have to decide +/// if we're going to supply `--target $HOST` before `cargo` runs, +/// so we have to check all of those places ourselves to make sure +/// that we're not overriding the true cross-compilation the user wants. +/// +/// Compared to the current solution, this seems harder, +/// so we're sticking with the current solution for now as long as it works. +fn is_build_script(at_args: &[String]) -> anyhow::Result { + Ok(bin_crate_name().is_none() && is_bin_crate(at_args)?) +} + +/// Run as a `rustc` wrapper (a la `$RUSTC_WRAPPER`/[`RUSTC_WRAPPER_VAR`]). +fn rustc_wrapper() -> anyhow::Result<()> { + let mut at_args = env::args().skip(1).collect::>(); + // We also want to avoid proc-macro crates, + // but those must be separate crates, so we should be okay. + let should_instrument = is_primary_package() && !is_build_script(&at_args)?; + let sysroot = env_path_from_wrapper(RUST_SYSROOT_VAR)?; + let sysroot: &Utf8Path = sysroot.as_path().try_into()?; + at_args.extend(["--sysroot".into(), sysroot.as_str().into()]); + let result = if should_instrument { + RunCompiler::new(&at_args, &mut MirTransformCallbacks).run() + } else { + // Always use the dynamically linked `librustc_driver-{hash}.so`, + // as it is guaranteed to be the same version as the instrumented version. + // Furthermore, we can't accidentally load the wrong `librustc_driver-{hash}.so`, + // as it contains its hash. + // This also avoids an extra `rustc` (and potentially `rustup` `rustc`) invocation. + RunCompiler::new(&at_args, &mut TimePassesCallbacks::default()).run() + }; + // `ErrorReported` means the error has already been reported to the user, + // so we just have to fail/exit with a failing exit code. + // There is no `impl Error for ErrorReported`. + result.map_err(|_| anyhow!("`rustc` failed"))?; + if should_instrument { + INSTRUMENTER.finalize(&env_path_from_wrapper(METADATA_VAR)?)?; + } + Ok(()) +} + +/// Run as a `cargo` wrapper/plugin, the default invocation. +fn cargo_wrapper(rustc_wrapper: &Path) -> anyhow::Result<()> { + let Args { + metadata, + mut cargo_args, + } = Args::parse(); + + // Ensure we use a toolchain compatible with the `rustc` private crates we linked to. + env::set_var("RUSTUP_TOOLCHAIN", include_str!("../rust-toolchain").trim()); + + // Resolve the sysroot once in the [`cargo_wrapper`] + // so that we don't need all of the [`rustc_wrapper`]s to have to do it. + let sysroot = resolve_sysroot()?; + + let cargo = Cargo::new(); + + let cargo_metadata = cargo.metadata().exec()?; + let root_package = cargo_metadata + .root_package() + .ok_or_else(|| anyhow!("no root package found by `cargo`"))?; + + cargo.run(|cmd| { + // Clean the primary package so that we always rebuild it + // and get up-to-date, complete instrumentation [`Metadata`]. + // Incremental instrumentation is very tricky, + // so don't try that yet, + // and if we only need to rebuild the primary package, + // it usually isn't that slow. + cmd.args(&["clean", "--package", root_package.name.as_str()]); + })?; + + cargo.run(|cmd| { + // Enable the runtime dependency. + add_feature(&mut cargo_args, &["c2rust-analysis-rt"]); + cmd.args(cargo_args) + .env(RUSTC_WRAPPER_VAR, rustc_wrapper) + .env(RUST_SYSROOT_VAR, &sysroot) + .env(METADATA_VAR, &metadata); + })?; + + Ok(()) +} + +fn main() -> anyhow::Result<()> { + let own_exe = env::current_exe()?; + + let wrapping_rustc = env::var_os(RUSTC_WRAPPER_VAR).as_deref() == Some(own_exe.as_os_str()); + if wrapping_rustc { + rustc_wrapper() + } else { + cargo_wrapper(&own_exe) + } +} diff --git a/pdg/src/main.rs b/pdg/src/main.rs index 260e5b5598..1fe581f99d 100644 --- a/pdg/src/main.rs +++ b/pdg/src/main.rs @@ -144,7 +144,7 @@ mod tests { let dir = Path::new("analysis/test"); let status = Command::new("scripts/pdg.sh") .arg(dir) - .env("BINARY", "c2rust-analysis-test") + .env("PROFILE", "debug") .status()?; assert!(status.success()); let pdg = fs_err::read_to_string(dir.join("pdg.log"))?; diff --git a/rustc-private-link/src/lib.rs b/rustc-private-link/src/lib.rs index 68a6192649..407cdde5da 100644 --- a/rustc-private-link/src/lib.rs +++ b/rustc-private-link/src/lib.rs @@ -65,10 +65,6 @@ impl SysRoot { .collect() } - pub fn set_env_rust_sysroot(&self) { - print_cargo_path("rustc-env=RUST_SYSROOT=", self.sysroot()); - } - pub fn link_rustc_private(&self) { let lib = self.lib(); print_cargo_path("rustc-link-search=native=", &lib); diff --git a/scripts/get-binary-names-from-cargo-metadata.mjs b/scripts/get-binary-names-from-cargo-metadata.mjs deleted file mode 100755 index e048b33d29..0000000000 --- a/scripts/get-binary-names-from-cargo-metadata.mjs +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env node - -/** - * Parse the output of `cargo metadata --format-version 1` (on stdin) - * and print all the names of all the binaries - * produced by the current crate or workspace. - * - * There's 1 optional argument. If it's "default", - * then use the `default-run` key in `Cargo.toml`s - * and only print default target binaries. - * - * Requires a `node` that at least supports `Array.prototype.flatMap`. - * `node` 12 works. - */ - -import * as fs from "fs"; -import process from "node:process"; - -const [_nodePath, _scriptPath, ...args] = process.argv; -if (args.length > 1) { - console.error("too many arguments provided") - process.exit(1) -} -const isDefault = args[0] === "default"; - -const cargoMetadataString = fs.readFileSync("/dev/stdin"); -const cargoMetadata = JSON.parse(cargoMetadataString); -const binaryNames = cargoMetadata - .workspace_members - .map(id => cargoMetadata.packages.find(e => e.id === id)) - .flatMap(package_ => { - const useDefault = isDefault && package_.default_run; - return package_ - .targets - .filter(target => target.kind.includes("bin")) - .filter(target => !useDefault ? true : target.name === package_.default_run) - ; - }) - .map(e => e.name) - ; -for (const binaryName of binaryNames) { - console.log(binaryName); -} diff --git a/scripts/pdg.sh b/scripts/pdg.sh index 1c146983e7..392ad97e13 100755 --- a/scripts/pdg.sh +++ b/scripts/pdg.sh @@ -6,58 +6,22 @@ CWD="${PWD}" SCRIPT_PATH="${0}" SCRIPT_DIR="${CWD}/$(dirname "${SCRIPT_PATH}")" -on-instrument-failure() { - local metadata="${1}" - - # delete so that we'll re-compile next time - # instead of thinking it's already done - rm -f "${metadata}" - "${SCRIPT_DIR}/pretty-instrument-err.mjs" < instrument.err.jsonl - return 1; -} - # Usage: `./pdg.sh ` # # Environment Variables: # * `PROFILE` (default `release`): # a `cargo` profile as in `target/$PROFILE` -# * `BINARY` (default calculated by `get-binary-names-from-cargo-metadata.mjs`, require node): -# the name of the binary produced by the test crate # # Instrument and run a test crate and create its PDG. # -# 1. Compile the whole `c2rust` workspace, including `c2rust instrument`. -# 2. If the `c2rust-instrument` binary has changed, -# re-instrument the test crate using `c2rust instrument`. -# The produced metadata is saved to `metadata.bc`. -# It always has to be `cargo clean`ed first, -# for not quite known reasons, which may be: -# * interactions between the default `cargo` run and the `cargo` invocation in `c2rust instrument` -# * and/or incremental compilation -# 3. Redirect `c2rust instrument` output to `instrument.out.log` and `instrument.err.jsonl`. -# These are in the test crate directory. -# If there is an error, `instrument.err.jsonl` is pretty-printed. +# 1. Compile `c2rust-dynamic-instrumentation`. +# 3. Redirect `c2rust-dynamic-instrumentation` stdout to `instrument.out.log` in the test crate directory, +# as it prints a lot of debugging info currently. # 4. Run the instrumented binary directly. -# Note that `cargo run` can't be used because -# that will recompile without instrumentation. # The `bincode`-encoded event log is written to `log.bc`. # 5. Using the `metadata.bc` metadata and the `log.bc` event log, # run `c2rust-pdg` to generate the pdg. -# The output is saved to `pdg.log` (relative to the test crate directory), -# This output is just a debug representation of the PDG. -# Except for the `=>`-containing lines, -# which are from the `latest_assignments` `HashMap`, -# we want this output to remain stable. -# -# A couple of other notes: -# * `c2rust instrument` can only run the default `cargo` profile and settings right now. -# See https://github.com/immunant/c2rust/issues/448 for why. -# Thus, the instrumented binary is always in `dev`/`debug`` mode. -# The other crates are compiled in `release` mode by default, -# though that can be overridden by setting `PROFILE=debug` or another `cargo` profile. -# -# Requirements: -# * A recent node for some scripts. `node@18.2.0` works. +# The output is saved to `pdg.log` (relative to the test crate directory). main() { local test_dir="${1}" local args=("${@:2}") @@ -71,48 +35,29 @@ main() { fi local profile_args=(--profile "${profile}") - cargo build "${profile_args[@]}" --features dynamic-instrumentation - - export RUST_BACKTRACE=1 - unset RUSTC_WRAPPER + local instrument="c2rust-instrument" + cargo build "${profile_args[@]}" --bin "${instrument}" local c2rust="${CWD}/${profile_dir}/c2rust" - local c2rust_instrument="${CWD}/${profile_dir}/c2rust-instrument" - local runtime="${CWD}/analysis/runtime/" + local c2rust_instrument="${CWD}/${profile_dir}/${instrument}" local metadata="${CWD}/${test_dir}/metadata.bc" (cd "${test_dir}" - local binary_name - if [[ "${BINARY:-}" != "" ]]; then - binary_name="${BINARY}" - else - binary_name="$(command cargo metadata --format-version 1 \ - | "${SCRIPT_DIR}/get-binary-names-from-cargo-metadata.mjs" default)" - fi - local profile_dir="target/debug" # always dev/debug for now - local binary_path="${profile_dir}/${binary_name}" - - if [[ "${c2rust_instrument}" -nt "${metadata}" ]]; then - cargo clean --profile dev # always dev/debug for now - - if ! "${c2rust}" instrument \ - "${metadata}" "${runtime}" \ - -- "${profile_args[@]}" \ - 1> instrument.out.log \ - 2> instrument.err.jsonl; then - on-instrument-failure "${metadata}" - fi - fi - + export RUST_BACKTRACE=1 export INSTRUMENT_BACKEND=log export INSTRUMENT_OUTPUT=log.bc export INSTRUMENT_OUTPUT_APPEND=false export METADATA_FILE="${metadata}" - "${binary_path}" "${args[@]}" + + time "${c2rust_instrument}" \ + --metadata "${metadata}" \ + -- run "${profile_args[@]}" \ + -- "${args[@]}" \ + 1> instrument.out.log ) (cd pdg export RUST_BACKTRACE=full # print sources w/ color-eyre - export RUST_LOG=info + export RUST_LOG=error cargo run \ "${profile_args[@]}" \ -- \ diff --git a/scripts/pretty-instrument-err.mjs b/scripts/pretty-instrument-err.mjs deleted file mode 100755 index 4ddfaadb58..0000000000 --- a/scripts/pretty-instrument-err.mjs +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env node - -/** - * Consume output from `c2rust instrument` (which invokes `cargo`) - * and pretty print it. - * - * For example, `cargo` prints lots of JSONL messages, - * so we parse those and print their `rendered` fields if they have them, - * which are colored and pretty-printed already. - * - * Stack traces we leave alone. - */ - -import * as fs from "fs"; - -const [_nodePath, _scriptPath, ...args] = process.argv; -let stderr = fs.readFileSync("/dev/stdin").toString(); // jsonl -stderr = stderr.split("\n") - .map(line => { - try { - return JSON.parse(line); - } catch { - // probably a stacktrace - return { - level: "error: internal compiler error", - message: line, - rendered: line, - }; - } - }) - .filter(e => (e.level || "").includes("error")) - .map(e => e.rendered ? e.rendered : e.message) // okay if `e.rendered === ""` - .join("\n") - ; -console.error(stderr);