From 5d1ced501cac04a0d89b641f1bfb94516316a93c Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sat, 29 Dec 2018 19:16:49 +0100 Subject: [PATCH 01/27] Rename legacy binaries --- Cargo.lock | 383 +++++++++++------- Cargo.toml | 53 ++- cli.yml | 68 ---- src/application/logging.rs | 42 -- src/bin/legacy-ptx-linker/cli.rs | 236 +++++++++++ .../legacy-ptx-linker}/main.rs | 34 +- .../legacy-rustc-dylib-wrapper}/iter.rs | 0 .../legacy-rustc-dylib-wrapper}/main.rs | 0 src/bin/rust-ptx-linker/main.rs | 1 + src/lib.rs | 8 +- src/session.rs | 57 --- targets/nvptx-nvidia-cuda.json | 4 +- targets/nvptx64-nvidia-cuda.json | 4 +- tests/cli.rs | 119 ------ tests/linker.rs | 2 +- 15 files changed, 543 insertions(+), 468 deletions(-) delete mode 100644 cli.yml delete mode 100644 src/application/logging.rs create mode 100644 src/bin/legacy-ptx-linker/cli.rs rename src/{application => bin/legacy-ptx-linker}/main.rs (55%) rename src/{rustc-dylib-wrapper => bin/legacy-rustc-dylib-wrapper}/iter.rs (100%) rename src/{rustc-dylib-wrapper => bin/legacy-rustc-dylib-wrapper}/main.rs (100%) create mode 100644 src/bin/rust-ptx-linker/main.rs delete mode 100644 tests/cli.rs diff --git a/Cargo.lock b/Cargo.lock index 9ca2fc1..48a5a97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -16,10 +16,10 @@ dependencies = [ [[package]] name = "ar" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -27,30 +27,36 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.24" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -60,24 +66,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cargo_metadata" -version = "0.6.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.25" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -97,7 +103,6 @@ dependencies = [ "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -110,7 +115,7 @@ dependencies = [ [[package]] name = "colored" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -121,15 +126,15 @@ name = "crate-compile-test" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -138,39 +143,43 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "error-chain" -version = "0.12.0" +name = "env_logger" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "failure" -version = "0.1.3" +name = "error-chain" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "failure_derive" -version = "0.1.3" +name = "failure" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.19 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fern" -version = "0.5.7" +name = "failure_derive" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -187,6 +196,14 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humantime" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.4.3" @@ -199,7 +216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.43" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -207,7 +224,7 @@ name = "libloading" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -216,9 +233,9 @@ name = "llvm-sys" version = "60.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -233,17 +250,16 @@ dependencies = [ [[package]] name = "memchr" -version = "2.1.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro2" -version = "0.4.21" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,46 +267,56 @@ dependencies = [ [[package]] name = "ptx-linker" -version = "0.8.3" +version = "0.9.0-alpha" dependencies = [ - "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "crate-compile-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fern 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" -version = "0.5.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" -version = "0.2.2" +name = "rand_chacha" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -299,9 +325,63 @@ name = "rand_core" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_os" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_pcg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redox_syscall" -version = "0.1.40" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -309,7 +389,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -318,7 +398,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -326,12 +406,12 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -341,15 +421,15 @@ name = "regex-syntax" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -362,7 +442,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.9" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -370,16 +450,24 @@ name = "rustc-llvm-proxy" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cargo_metadata 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ryu" version = "0.2.7" @@ -399,7 +487,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -409,27 +497,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.80" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.80" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -442,18 +530,18 @@ name = "syn" version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.19" +version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -462,32 +550,40 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tempfile" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -509,7 +605,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -532,14 +628,9 @@ name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "walkdir" -version = "2.2.6" +version = "2.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,78 +666,92 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "yaml-rust" -version = "0.3.5" +name = "wincolor" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [metadata] "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" +"checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" -"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" +"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" +"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" +"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cargo_metadata 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1aaa1a9856ae2d188340526d0986feb6899c9ad11c5dfd73453c784fed6e373d" -"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" +"checksum byteorder 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60f0b0d4c0a382d2734228fd12b5a6b5dac185c60e938026fd31b265b94f9bd2" +"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe" +"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc0a60679001b62fb628c4da80e574b9645ab4646056d7c9018885efffe45533" +"checksum colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e9a455e156a4271e12fd0246238c380b1e223e3736663c7a18ed8b6362028a9" "checksum crate-compile-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efa7bc09385a5adcf2af00aa28a6bae6bb98864004e3a2b246f2fa38dc480ce3" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" +"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" -"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" -"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" -"checksum fern 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b48af88aaf938b11baef948a5599e66e709cf92854aa2b87c71f1bcf20f80a01" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "936c5f19986bab65559133df74319ab1d8c15d9b54cff82a8403cf87b4107c20" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" -"checksum proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ab2fc21ba78ac73e4ff6b3818ece00be4e175ffbef4d0a717d978b48b24150c4" -"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" -"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" -"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" +"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" +"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" +"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" +"checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" +"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" +"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -"checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" +"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9e3ec23ded8fe4603e5290f327165255e9717c4939787da77a7f87a0e3fb73d1" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" -"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c" -"checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" +"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" +"checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" +"checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.19 (registry+https://github.com/rust-lang/crates.io-index)" = "39054bb43f2c5e4f3aef47718a391bf397c1b820fefc86f467d4d354f67bf7ef" +"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" +"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" +"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0f8bfa9ff0cadcd210129ad9d2c5f145c13e9ced3d3e5d948a6213487d52444" +"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum walkdir 2.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0ffb549f212c31e19f3667c55a7f515b983a84aef10fd0a4d1f9c125425115f3" +"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" +"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" diff --git a/Cargo.toml b/Cargo.toml index 1c91964..20d5246 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ptx-linker" -version = "0.8.3" +version = "0.9.0-alpha" authors = ["Denys Zariaiev "] license = "MIT" @@ -9,35 +9,55 @@ description = "NVPTX modules linker" repository = "https://github.com/denzp/rust-ptx-linker" categories = ["development-tools", "development-tools::build-utils", "external-ffi-bindings"] keywords = ["llvm", "cuda", "nvptx", "linker"] -autotests = true + +[badges] +appveyor = { repository = "denzp/rust-ptx-linker", branch = "master", service = "github" } +travis-ci = { repository = "denzp/rust-ptx-linker", branch = "master" } +maintenance = { status = "experimental" } + +[features] +default = ["llvm-proxy", "cli-legacy"] +cli-legacy = [] +cli-rustc = [] +llvm-proxy = ["rustc-llvm-proxy"] +llvm-external = [] [[bin]] -name = "ptx-linker" +name = "legacy-ptx-linker" doc = false -path = "src/application/main.rs" +path = "src/bin/legacy-ptx-linker/main.rs" +required-features = ["cli-legacy"] [[bin]] -name = "rustc-dylib-wrapper" +name = "legacy-rustc-dylib-wrapper" doc = false -path = "src/rustc-dylib-wrapper/main.rs" +path = "src/bin/legacy-rustc-dylib-wrapper/main.rs" +required-features = ["cli-legacy"] -[lib] -name = "ptx_linker" +[[bin]] +name = "rust-ptx-linker" +doc = false +path = "src/bin/rust-ptx-linker/main.rs" +required-features = ["cli-rustc"] [dependencies] -log = "0.4" -fern = "0.5" -colored = "1.5" -error-chain = "0.12" ar = "0.6" -clap = { version = "2.31", features = ["yaml", "suggestions", "color"] } -rustc-llvm-proxy = "0.1" either = "1.5" +env_logger = "0.6" +log = "0.4" +clap = "2.31" + +# TODO: get rid of me! +error-chain = "0.12" [dependencies.llvm-sys] version = "60" features = ["no-llvm-linking", "disable-alltargets-init"] +[dependencies.rustc-llvm-proxy] +version = "0.1" +optional = true + [dev-dependencies] failure = "0.1" crate-compile-test = "0.2" @@ -45,8 +65,3 @@ crate-compile-test = "0.2" [[test]] name = "linker" harness = false - -[badges] -appveyor = { repository = "denzp/rust-ptx-linker", branch = "master", service = "github" } -travis-ci = { repository = "denzp/rust-ptx-linker", branch = "master" } -maintenance = { status = "experimental" } diff --git a/cli.yml b/cli.yml deleted file mode 100644 index a2ba2b3..0000000 --- a/cli.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: "ptx-linker" -about: Performs linking of Rust NVPTX crates - -args: - - input: - help: Path to input rlib or bitcode - multiple: true - - - output: - short: o - help: Sets path for assembly output - takes_value: true - value_name: FILE.ptx - - - optimise: - short: O - help: Sets optimisation level - takes_value: true - value_name: level - - - __ignored_lib_start: - long: whole-archive - hidden: true - multiple: true - - - __ignored_lib_end: - long: no-whole-archive - hidden: true - multiple: true - - - __ignored_start_group: - long: start-group - hidden: true - multiple: true - - - __ignored_end_group: - long: end-group - hidden: true - multiple: true - - - __ignored_compiler_prefix: - short: B - takes_value: true - hidden: true - multiple: true - number_of_values: 1 - - - __ignored_shared_hack: - short: s - hidden: true - multiple: true - takes_value: true - - - __ignored_lib_path: - short: L - takes_value: true - hidden: true - multiple: true - number_of_values: 1 - -subcommands: - - print: - about: Prints NVPTX target definition JSON into stdout - args: - - TARGET: - help: Specifies the target name - required: true - possible_values: ["nvptx64-nvidia-cuda", "nvptx-nvidia-cuda"] diff --git a/src/application/logging.rs b/src/application/logging.rs deleted file mode 100644 index 35173da..0000000 --- a/src/application/logging.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::fmt::Arguments; -use std::io::stderr; - -use colored::*; -use fern::{Dispatch, FormatCallback}; -use log::{Level, LevelFilter, Record}; - -pub trait AlignedOutputString: ToString { - fn prefix_with_spaces(&self, spaces_count: usize) -> String { - let separator = String::from("\n") + &" ".repeat(spaces_count); - - self.to_string() - .split('\n') - .collect::>() - .join(&separator) - } -} - -impl AlignedOutputString for String {} - -pub fn setup_logging() { - Dispatch::new() - .format(logging_handler) - .level(LevelFilter::Info) - .chain(stderr()) - .apply() - .unwrap(); -} - -fn logging_handler(out: FormatCallback, message: &Arguments, record: &Record) { - let level = match record.level() { - Level::Trace => format!("{}{}{}", "[".bold(), "TRACE".cyan(), "]".bold()), - Level::Debug => format!("{}{}{}", "[".bold(), "DEBUG".blue(), "]".bold()), - Level::Info => format!(" {}{}{}", "[".bold(), "INFO".green().bold(), "]".bold()), - Level::Warn => format!(" {}{}{}", "[".bold(), "WARN".yellow().bold(), "]".bold()), - Level::Error => format!("{}{}{}", "[".bold(), "ERROR".red().bold(), "]".bold()), - }; - - let message = format!("{}", message); - - out.finish(format_args!("{} {}", level, message.prefix_with_spaces(8))); -} diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs new file mode 100644 index 0000000..0e2a66c --- /dev/null +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -0,0 +1,236 @@ +use std::path::Path; + +use clap::{App, Arg, ArgMatches}; +use ptx_linker::session::{Configuration, Session}; + +#[derive(Debug, PartialEq)] +pub enum CommandLineRequest { + Link(Session), + Print64BitTargetJson, + Print32BitTargetJson, +} + +pub fn get_cli_request() -> CommandLineRequest { + CommandLineRequest::from(get_app().get_matches()) +} + +fn get_app() -> App<'static, 'static> { + App::new("legacy-ptx-linker") + .version(crate_version!()) + .author(crate_authors!()) + .about("Performs linking of Rust NVPTX crates") + .args(&[ + Arg::with_name("input") + .help("Path to input rlib or bitcode") + .multiple(true), + Arg::with_name("output") + .short("o") + .help("Sets path for assembly output") + .takes_value(true) + .value_name("FILE.ptx"), + Arg::with_name("optimise") + .short("O") + .help("Sets optimisation level") + .takes_value(true) + .value_name("level"), + Arg::with_name("__ignored_lib_start") + .long("whole-archive") + .hidden(true) + .multiple(true), + Arg::with_name("__ignored_lib_end") + .long("no-whole-archive") + .hidden(true) + .multiple(true), + Arg::with_name("__ignored_start_group") + .long("start-group") + .hidden(true) + .multiple(true), + Arg::with_name("__ignored_end_group") + .long("end-group") + .hidden(true) + .multiple(true), + Arg::with_name("__ignored_compiler_prefix") + .short("B") + .takes_value(true) + .hidden(true) + .multiple(true) + .number_of_values(1), + Arg::with_name("__ignored_shared_hack") + .short("s") + .hidden(true) + .multiple(true) + .takes_value(true), + Arg::with_name("__ignored_lib_path") + .short("L") + .takes_value(true) + .hidden(true) + .multiple(true) + .number_of_values(1), + ]) + .subcommand({ + App::new("print") + .about("Prints NVPTX target definition JSON into stdout") + .arg( + &Arg::with_name("TARGET") + .help("Specifies the target name") + .required(true) + .possible_values(&["nvptx64-nvidia-cuda", "nvptx-nvidia-cuda"]), + ) + }) +} + +impl<'a> From> for CommandLineRequest { + fn from(matches: ArgMatches) -> CommandLineRequest { + match matches.subcommand_name() { + Some("print") => { + let target = matches + .subcommand_matches("print") + .unwrap() + .value_of("TARGET"); + + match target { + Some("nvptx64-nvidia-cuda") => CommandLineRequest::Print64BitTargetJson, + Some("nvptx-nvidia-cuda") => CommandLineRequest::Print32BitTargetJson, + + other => { + unreachable!("Unknown target: {:?}", other); + } + } + } + + _ => { + let mut session = Session::default(); + + if let Some(inputs) = matches.values_of("input") { + for input in inputs { + if input.ends_with(".o") { + session.link_bitcode(Path::new(input)); + } else if input.ends_with(".rlib") { + session.link_rlib(Path::new(input)); + } else { + warn!("Can't recognise input type: {:?}", input); + } + } + } + + if let Some(output) = matches.value_of("output") { + session.set_output(Path::new(output)); + } + + match matches.value_of("optimise") { + Some("0") | None => session.set_configuration(Configuration::Debug), + Some(_) => session.set_configuration(Configuration::Release), + }; + + CommandLineRequest::Link(session) + } + } + } +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use super::*; + use ptx_linker::session::Output; + + #[test] + fn it_should_parse_args() { + let matches = get_app().get_matches_from_safe(vec![ + "ptx-linker", + "-L", + "/rustlib/lib", + "/kernel/target/debug/deps/kernel.0.o", + "/kernel/target/debug/deps/kernel.crate.metadata.o", + "-o", + "/kernel/target/debug/deps/libkernel.ptx", + "-L", + "/kernel/target/debug/deps", + "-L", + "/kernel/target/debug/deps", + "-L", + "~/rustlib/nvptx64-nvidia-cuda/lib", + "-Bstatic", + "--whole-archive", + "/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib", + "--no-whole-archive", + "/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib", + ]); + + let expected_session = Session { + emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], + configuration: Configuration::Debug, + + output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), + + include_rlibs: vec![ + PathBuf::from("/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib"), + PathBuf::from("/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib"), + ], + + include_bitcode_modules: vec![PathBuf::from("/kernel/target/debug/deps/kernel.0.o")], + }; + + assert_eq!( + CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), + CommandLineRequest::Link(expected_session) + ); + } + + #[test] + fn it_should_parse_optimization() { + let matches = get_app().get_matches_from_safe(vec![ + "ptx-linker", + "-o", + "/kernel/target/debug/deps/libkernel.ptx", + "-O1", + ]); + + let expected_session = Session { + emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], + configuration: Configuration::Release, + + output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), + + include_rlibs: vec![], + include_bitcode_modules: vec![], + }; + + assert_eq!( + CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), + CommandLineRequest::Link(expected_session) + ); + } + + #[test] + fn it_should_not_print_unknown_target_json() { + let matches = + get_app().get_matches_from_safe(vec!["ptx-linker", "print", "another-target-triple"]); + + assert!(matches.is_err()); + } + + #[test] + fn it_should_print_64bit_target_json() { + let matches = + get_app().get_matches_from_safe(vec!["ptx-linker", "print", "nvptx64-nvidia-cuda"]); + + assert_eq!( + CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), + CommandLineRequest::Print64BitTargetJson + ); + } + + #[test] + fn it_should_print_32bit_target_json() { + let matches = + get_app().get_matches_from_safe(vec!["ptx-linker", "print", "nvptx-nvidia-cuda"]); + + assert_eq!( + CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), + CommandLineRequest::Print32BitTargetJson + ); + } + +} diff --git a/src/application/main.rs b/src/bin/legacy-ptx-linker/main.rs similarity index 55% rename from src/application/main.rs rename to src/bin/legacy-ptx-linker/main.rs index 0f9f0d1..1d2986b 100644 --- a/src/application/main.rs +++ b/src/bin/legacy-ptx-linker/main.rs @@ -1,8 +1,8 @@ #![deny(warnings)] +#![warn(clippy::all)] -extern crate colored; +extern crate env_logger; extern crate error_chain; -extern crate fern; extern crate ptx_linker; #[macro_use] @@ -11,22 +11,22 @@ extern crate clap; #[macro_use] extern crate log; -mod logging; -use logging::{setup_logging, AlignedOutputString}; +use env_logger::{Builder, Env}; -use clap::App; use ptx_linker::error::*; use ptx_linker::linker::Linker; -use ptx_linker::session::CommandLineRequest; + +mod cli; +use cli::{get_cli_request, CommandLineRequest}; fn main() { - setup_logging(); + Builder::from_env(Env::default().default_filter_or("warn")).init(); if let Err(ref e) = run() { error!("{}", e); for e in e.iter().skip(1) { - error!(" caused by: {}", e.to_string().prefix_with_spaces(13)); + error!(" caused by: {}", e.to_string()); } if let Some(backtrace) = e.backtrace() { @@ -38,13 +38,7 @@ fn main() { } fn run() -> Result<()> { - let yaml = load_yaml!("../../cli.yml"); - let matches = App::from_yaml(yaml) - .version(crate_version!()) - .author(crate_authors!()) - .get_matches(); - - match CommandLineRequest::from(matches) { + match get_cli_request() { CommandLineRequest::Link(session) => { Linker::new(session) .link() @@ -52,11 +46,17 @@ fn run() -> Result<()> { } CommandLineRequest::Print64BitTargetJson => { - println!("{}", include_str!("../../targets/nvptx64-nvidia-cuda.json")); + println!( + "{}", + include_str!("../../../targets/nvptx64-nvidia-cuda.json") + ); } CommandLineRequest::Print32BitTargetJson => { - println!("{}", include_str!("../../targets/nvptx-nvidia-cuda.json")); + println!( + "{}", + include_str!("../../../targets/nvptx-nvidia-cuda.json") + ); } }; diff --git a/src/rustc-dylib-wrapper/iter.rs b/src/bin/legacy-rustc-dylib-wrapper/iter.rs similarity index 100% rename from src/rustc-dylib-wrapper/iter.rs rename to src/bin/legacy-rustc-dylib-wrapper/iter.rs diff --git a/src/rustc-dylib-wrapper/main.rs b/src/bin/legacy-rustc-dylib-wrapper/main.rs similarity index 100% rename from src/rustc-dylib-wrapper/main.rs rename to src/bin/legacy-rustc-dylib-wrapper/main.rs diff --git a/src/bin/rust-ptx-linker/main.rs b/src/bin/rust-ptx-linker/main.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/src/bin/rust-ptx-linker/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/lib.rs b/src/lib.rs index 6cb078b..19daac5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,14 @@ -#![deny(warnings)] +// TODO: temp solution for `error-chain` #![allow(deprecated)] +#![deny(warnings)] +#![warn(clippy::all)] + +#[cfg(feature = "llvm-proxy")] +extern crate rustc_llvm_proxy; extern crate ar; extern crate clap; extern crate llvm_sys; -extern crate rustc_llvm_proxy; #[macro_use] extern crate error_chain; diff --git a/src/session.rs b/src/session.rs index ea3920e..a8e1f8c 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,4 +1,3 @@ -use clap::ArgMatches; use std::path::{Path, PathBuf}; #[derive(Debug, PartialEq)] @@ -14,13 +13,6 @@ pub enum Output { Bitcode, } -#[derive(Debug, PartialEq)] -pub enum CommandLineRequest { - Link(Session), - Print64BitTargetJson, - Print32BitTargetJson, -} - // TODO: make the fields private #[derive(Debug, PartialEq)] pub struct Session { @@ -82,52 +74,3 @@ impl Session { path.to_str().unwrap().ends_with(".crate.metadata.o") } } - -impl<'a> From> for CommandLineRequest { - fn from(matches: ArgMatches) -> CommandLineRequest { - match matches.subcommand_name() { - Some("print") => { - let target = matches - .subcommand_matches("print") - .unwrap() - .value_of("TARGET"); - - match target { - Some("nvptx64-nvidia-cuda") => CommandLineRequest::Print64BitTargetJson, - Some("nvptx-nvidia-cuda") => CommandLineRequest::Print32BitTargetJson, - - other => { - unreachable!("Unknown target: {:?}", other); - } - } - } - - _ => { - let mut session = Session::default(); - - if let Some(inputs) = matches.values_of("input") { - for input in inputs { - if input.ends_with(".o") { - session.link_bitcode(Path::new(input)); - } else if input.ends_with(".rlib") { - session.link_rlib(Path::new(input)); - } else { - warn!("Can't recognise input type: {:?}", input); - } - } - } - - if let Some(output) = matches.value_of("output") { - session.set_output(Path::new(output)); - } - - match matches.value_of("optimise") { - Some("0") | None => session.set_configuration(Configuration::Debug), - Some(_) => session.set_configuration(Configuration::Release), - }; - - CommandLineRequest::Link(session) - } - } - } -} diff --git a/targets/nvptx-nvidia-cuda.json b/targets/nvptx-nvidia-cuda.json index feefbcc..391e718 100644 --- a/targets/nvptx-nvidia-cuda.json +++ b/targets/nvptx-nvidia-cuda.json @@ -1,8 +1,8 @@ { "arch": "nvptx", "cpu": "sm_20", - "data-layout": "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64", - "linker": "ptx-linker", + "data-layout": "e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64", + "linker": "legacy-ptx-linker", "linker-flavor": "ld", "linker-is-gnu": true, "dll-prefix": "", diff --git a/targets/nvptx64-nvidia-cuda.json b/targets/nvptx64-nvidia-cuda.json index 78d421d..5c3f516 100644 --- a/targets/nvptx64-nvidia-cuda.json +++ b/targets/nvptx64-nvidia-cuda.json @@ -1,8 +1,8 @@ { "arch": "nvptx64", "cpu": "sm_20", - "data-layout": "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64", - "linker": "ptx-linker", + "data-layout": "e-i64:64-i128:128-v16:16-v32:32-n16:32:64", + "linker": "legacy-ptx-linker", "linker-flavor": "ld", "linker-is-gnu": true, "dll-prefix": "", diff --git a/tests/cli.rs b/tests/cli.rs deleted file mode 100644 index 7246bf7..0000000 --- a/tests/cli.rs +++ /dev/null @@ -1,119 +0,0 @@ -#[macro_use] -extern crate clap; -extern crate ptx_linker; - -use clap::App; -use ptx_linker::session::*; -use std::path::PathBuf; - -#[test] -fn it_should_parse_args() { - let yaml = load_yaml!("../cli.yml"); - let matches = App::from_yaml(yaml).get_matches_from_safe(vec![ - "ptx-linker", - "-L", - "/rustlib/lib", - "/kernel/target/debug/deps/kernel.0.o", - "/kernel/target/debug/deps/kernel.crate.metadata.o", - "-o", - "/kernel/target/debug/deps/libkernel.ptx", - "-L", - "/kernel/target/debug/deps", - "-L", - "/kernel/target/debug/deps", - "-L", - "~/rustlib/nvptx64-nvidia-cuda/lib", - "-Bstatic", - "--whole-archive", - "/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib", - "--no-whole-archive", - "/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib", - ]); - - let expected_session = Session { - emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], - configuration: Configuration::Debug, - - output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), - - include_rlibs: vec![ - PathBuf::from("/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib"), - PathBuf::from("/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib"), - ], - - include_bitcode_modules: vec![PathBuf::from("/kernel/target/debug/deps/kernel.0.o")], - }; - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Link(expected_session) - ); -} - -#[test] -fn it_should_parse_optimization() { - let yaml = load_yaml!("../cli.yml"); - let matches = App::from_yaml(yaml).get_matches_from_safe(vec![ - "ptx-linker", - "-o", - "/kernel/target/debug/deps/libkernel.ptx", - "-O1", - ]); - - let expected_session = Session { - emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], - configuration: Configuration::Release, - - output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), - - include_rlibs: vec![], - include_bitcode_modules: vec![], - }; - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Link(expected_session) - ); -} - -#[test] -fn it_should_not_print_unknown_target_json() { - let yaml = load_yaml!("../cli.yml"); - let matches = App::from_yaml(yaml).get_matches_from_safe(vec![ - "ptx-linker", - "print", - "another-target-triple", - ]); - - assert!(matches.is_err()); -} - -#[test] -fn it_should_print_64bit_target_json() { - let yaml = load_yaml!("../cli.yml"); - let matches = App::from_yaml(yaml).get_matches_from_safe(vec![ - "ptx-linker", - "print", - "nvptx64-nvidia-cuda", - ]); - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Print64BitTargetJson - ); -} - -#[test] -fn it_should_print_32bit_target_json() { - let yaml = load_yaml!("../cli.yml"); - let matches = App::from_yaml(yaml).get_matches_from_safe(vec![ - "ptx-linker", - "print", - "nvptx-nvidia-cuda", - ]); - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Print32BitTargetJson - ); -} diff --git a/tests/linker.rs b/tests/linker.rs index 47d7884..18ba02e 100644 --- a/tests/linker.rs +++ b/tests/linker.rs @@ -127,7 +127,7 @@ fn create_config(mode: Mode, profile: Profile) -> Config { .unwrap() .parent() .unwrap() - .join("ptx-linker") + .join("legacy-ptx-linker") .to_string_lossy(), ); From 86443453c0b6015a1c48f97d40966001af025c04 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Tue, 15 Jan 2019 00:02:13 +0100 Subject: [PATCH 02/27] Brand new `rust-ptx-linker` binary and several additional CLI options --- Cargo.lock | 51 +-- Cargo.toml | 20 +- src/bin/legacy-ptx-linker/cli.rs | 80 ++++- src/bin/legacy-ptx-linker/main.rs | 31 +- src/bin/rust-ptx-linker/cli.rs | 570 ++++++++++++++++++++++++++++++ src/bin/rust-ptx-linker/main.rs | 24 +- src/lib.rs | 30 ++ src/linker.rs | 37 +- src/session.rs | 62 ++-- 9 files changed, 775 insertions(+), 130 deletions(-) create mode 100644 src/bin/rust-ptx-linker/cli.rs diff --git a/Cargo.lock b/Cargo.lock index 48a5a97..82c071a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,13 +230,13 @@ dependencies = [ [[package]] name = "llvm-sys" -version = "60.3.0" +version = "70.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -276,9 +276,9 @@ dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-llvm-proxy 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -392,18 +392,6 @@ dependencies = [ "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" version = "1.1.0" @@ -416,14 +404,6 @@ dependencies = [ "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex-syntax" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex-syntax" version = "0.6.4" @@ -447,7 +427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-llvm-proxy" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -455,9 +435,9 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -525,16 +505,6 @@ name = "strsim" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "syn" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syn" version = "0.15.26" @@ -703,7 +673,7 @@ dependencies = [ "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum llvm-sys 60.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "936c5f19986bab65559133df74319ab1d8c15d9b54cff82a8403cf87b4107c20" +"checksum llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60a9ee82fe0fa72ae6ef6d018b407296085863836451c7a97384f84ed7e26b9f" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" @@ -720,13 +690,11 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" -"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9e3ec23ded8fe4603e5290f327165255e9717c4939787da77a7f87a0e3fb73d1" +"checksum rustc-llvm-proxy 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d2f278142275f9dd3729d65aefdab3b2db4f3f68a4487d9b23b342ec1ee216de" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" @@ -736,7 +704,6 @@ dependencies = [ "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" "checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" diff --git a/Cargo.toml b/Cargo.toml index 20d5246..4a6e681 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,14 @@ travis-ci = { repository = "denzp/rust-ptx-linker", branch = "master" } maintenance = { status = "experimental" } [features] -default = ["llvm-proxy", "cli-legacy"] +default = ["llvm-proxy", "cli-legacy", "cli-rustc"] cli-legacy = [] cli-rustc = [] -llvm-proxy = ["rustc-llvm-proxy"] -llvm-external = [] +llvm-proxy = [ + "rustc-llvm-proxy", + "llvm-sys/no-llvm-linking", + "llvm-sys/disable-alltargets-init" +] [[bin]] name = "legacy-ptx-linker" @@ -42,18 +45,15 @@ required-features = ["cli-rustc"] [dependencies] ar = "0.6" -either = "1.5" -env_logger = "0.6" log = "0.4" clap = "2.31" +either = "1.5" +llvm-sys = "70" +env_logger = "0.6" -# TODO: get rid of me! +# TODO(denzp): implement proper error handling! error-chain = "0.12" -[dependencies.llvm-sys] -version = "60" -features = ["no-llvm-linking", "disable-alltargets-init"] - [dependencies.rustc-llvm-proxy] version = "0.1" optional = true diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs index 0e2a66c..fd56544 100644 --- a/src/bin/legacy-ptx-linker/cli.rs +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -1,7 +1,7 @@ use std::path::Path; use clap::{App, Arg, ArgMatches}; -use ptx_linker::session::{Configuration, Session}; +use ptx_linker::session::{OptLevel, Output, Session}; #[derive(Debug, PartialEq)] pub enum CommandLineRequest { @@ -66,6 +66,24 @@ fn get_app() -> App<'static, 'static> { .hidden(true) .multiple(true) .number_of_values(1), + Arg::with_name("arch") + .long("arch") + .short("a") + .help("Target CUDA architectures") + .takes_value(true) + .multiple(true) + .number_of_values(1) + .use_delimiter(true), + Arg::with_name("emit") + .long("emit") + .short("e") + .help("Output type") + .takes_value(true) + .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc", "cubin"]) + .default_value("asm") + .multiple(true) + .number_of_values(1) + .use_delimiter(true), ]) .subcommand({ App::new("print") @@ -118,10 +136,27 @@ impl<'a> From> for CommandLineRequest { } match matches.value_of("optimise") { - Some("0") | None => session.set_configuration(Configuration::Debug), - Some(_) => session.set_configuration(Configuration::Release), + Some("0") | None => session.set_opt_level(OptLevel::None), + Some(_) => session.set_opt_level(OptLevel::Default), }; + if let Some(outputs) = matches.values_of("emit") { + for output in outputs { + session.add_output_type(match output { + "llvm-ir" => Output::IntermediateRepresentation, + "llvm-bc" => Output::Bitcode, + "cubin" => Output::Cubin, + _ => Output::PTXAssembly, + }); + } + } + + if let Some(archs) = matches.values_of("arch") { + for arch in archs { + session.add_output_arch(arch); + } + } + CommandLineRequest::Link(session) } } @@ -138,7 +173,7 @@ mod tests { #[test] fn it_should_parse_args() { let matches = get_app().get_matches_from_safe(vec![ - "ptx-linker", + "legacy-ptx-linker", "-L", "/rustlib/lib", "/kernel/target/debug/deps/kernel.0.o", @@ -159,8 +194,11 @@ mod tests { ]); let expected_session = Session { - emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], - configuration: Configuration::Debug, + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), @@ -181,15 +219,18 @@ mod tests { #[test] fn it_should_parse_optimization() { let matches = get_app().get_matches_from_safe(vec![ - "ptx-linker", + "legacy-ptx-linker", "-o", "/kernel/target/debug/deps/libkernel.ptx", "-O1", ]); let expected_session = Session { - emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], - configuration: Configuration::Release, + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::Default, + debug_info: false, output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), @@ -205,16 +246,22 @@ mod tests { #[test] fn it_should_not_print_unknown_target_json() { - let matches = - get_app().get_matches_from_safe(vec!["ptx-linker", "print", "another-target-triple"]); + let matches = get_app().get_matches_from_safe(vec![ + "legacy-ptx-linker", + "print", + "another-target-triple", + ]); assert!(matches.is_err()); } #[test] fn it_should_print_64bit_target_json() { - let matches = - get_app().get_matches_from_safe(vec!["ptx-linker", "print", "nvptx64-nvidia-cuda"]); + let matches = get_app().get_matches_from_safe(vec![ + "legacy-ptx-linker", + "print", + "nvptx64-nvidia-cuda", + ]); assert_eq!( CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), @@ -224,8 +271,11 @@ mod tests { #[test] fn it_should_print_32bit_target_json() { - let matches = - get_app().get_matches_from_safe(vec!["ptx-linker", "print", "nvptx-nvidia-cuda"]); + let matches = get_app().get_matches_from_safe(vec![ + "legacy-ptx-linker", + "print", + "nvptx-nvidia-cuda", + ]); assert_eq!( CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), diff --git a/src/bin/legacy-ptx-linker/main.rs b/src/bin/legacy-ptx-linker/main.rs index 1d2986b..1169b5f 100644 --- a/src/bin/legacy-ptx-linker/main.rs +++ b/src/bin/legacy-ptx-linker/main.rs @@ -2,7 +2,6 @@ #![warn(clippy::all)] extern crate env_logger; -extern crate error_chain; extern crate ptx_linker; #[macro_use] @@ -12,37 +11,17 @@ extern crate clap; extern crate log; use env_logger::{Builder, Env}; - -use ptx_linker::error::*; -use ptx_linker::linker::Linker; +use ptx_linker::linker_entrypoint; mod cli; use cli::{get_cli_request, CommandLineRequest}; fn main() { - Builder::from_env(Env::default().default_filter_or("warn")).init(); - - if let Err(ref e) = run() { - error!("{}", e); - - for e in e.iter().skip(1) { - error!(" caused by: {}", e.to_string()); - } - - if let Some(backtrace) = e.backtrace() { - error!("{:?}", backtrace); - } + Builder::from_env(Env::default().default_filter_or("info")).init(); - ::std::process::exit(1); - } -} - -fn run() -> Result<()> { match get_cli_request() { CommandLineRequest::Link(session) => { - Linker::new(session) - .link() - .chain_err(|| "Unable to link modules")?; + linker_entrypoint(session); } CommandLineRequest::Print64BitTargetJson => { @@ -58,7 +37,5 @@ fn run() -> Result<()> { include_str!("../../../targets/nvptx-nvidia-cuda.json") ); } - }; - - Ok(()) + } } diff --git a/src/bin/rust-ptx-linker/cli.rs b/src/bin/rust-ptx-linker/cli.rs new file mode 100644 index 0000000..648535f --- /dev/null +++ b/src/bin/rust-ptx-linker/cli.rs @@ -0,0 +1,570 @@ +use std::path::Path; + +use clap::{App, Arg, ArgMatches}; +use ptx_linker::session::{OptLevel, Output, Session}; + +pub fn current_session() -> Session { + parse_session(get_app().get_matches()) +} + +fn get_app() -> App<'static, 'static> { + App::new("rust-ptx-linker") + .version(crate_version!()) + .author(crate_authors!()) + .about("CUDA PTX linker for Rust crates.") + .args(&[ + { + Arg::with_name("bitcode") + .long("bitcode") + .help("Input LLVM bitcode file") + .display_order(0) + .takes_value(true) + .multiple(true) + .number_of_values(1) + }, + { + Arg::with_name("rlib") + .long("rlib") + .help("Input Rust rlib archive") + .display_order(1) + .takes_value(true) + .multiple(true) + .number_of_values(1) + }, + { + Arg::with_name("output") + .short("o") + .help("Output PTX assembly path") + .display_order(2) + .takes_value(true) + .value_name("PATH.ptx") + }, + { + Arg::with_name("input_dir") + .short("L") + .help("Input files directory") + .takes_value(true) + .value_name("PATH") + .multiple(true) + .number_of_values(1) + }, + { + Arg::with_name("optimisation") + .short("O") + .help("Optimisation level") + .takes_value(true) + .possible_values(&["0", "1", "2", "3", "s"]) + .value_name("level") + }, + { + Arg::with_name("debug") + .long("debug") + .help("Emit debug info") + }, + { + Arg::with_name("arch") + .short("a") + .long("arch") + .help("Target CUDA architectures") + .takes_value(true) + .multiple(true) + .number_of_values(1) + .use_delimiter(true) + }, + { + Arg::with_name("emit") + .short("e") + .long("emit") + .help("Output kind") + .takes_value(true) + .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc", "cubin"]) + .default_value("asm") + .multiple(true) + .number_of_values(1) + .use_delimiter(true) + }, + ]) +} + +fn parse_session(matches: ArgMatches<'static>) -> Session { + let mut session = Session::default(); + + if let Some(inputs) = matches.values_of("bitcode") { + for input in inputs { + session.link_bitcode(Path::new(input)); + } + } + + if let Some(inputs) = matches.values_of("rlib") { + for input in inputs { + session.link_rlib(Path::new(input)); + } + } + + if let Some(output) = matches.value_of("output") { + session.set_output(Path::new(output)); + } + + if matches.is_present("debug") { + session.set_debug_info(true); + } + + match matches.value_of("optimisation") { + Some("0") | None => session.set_opt_level(OptLevel::None), + Some("2") => session.set_opt_level(OptLevel::Default), + + Some("1") | Some("3") => { + info!("Using default optimisation level `-O2`."); + session.set_opt_level(OptLevel::Default); + } + + Some(_) => { + warn!("Not supported optimisation level! Falling back to `-O0`."); + } + }; + + if let Some(outputs) = matches.values_of("emit") { + for output in outputs { + session.add_output_type(match output { + "llvm-ir" => Output::IntermediateRepresentation, + "llvm-bc" => Output::Bitcode, + "cubin" => Output::Cubin, + + // CLI arg has `possible_values` anyway + _ => Output::PTXAssembly, + }); + } + } + + if let Some(archs) = matches.values_of("arch") { + for arch in archs { + session.add_output_arch(arch); + } + } + + session +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use super::*; + use ptx_linker::session::Output; + + #[test] + fn it_should_parse_bitcode_inputs() { + let matches = get_app().get_matches_from_safe(vec![ + "rust-ptx-linker", + "-L", + "/rustlib/lib", + "--bitcode", + "/kernel/target/debug/deps/kernel.0.o", + "--bitcode", + "/kernel/target/debug/deps/kernel.crate.metadata.o", + "--bitcode", + "/kernel/target/debug/deps/kernel.1.o", + ]); + + assert_eq!( + parse_session(matches.unwrap()), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_rlibs: vec![], + + include_bitcode_modules: vec![ + PathBuf::from("/kernel/target/debug/deps/kernel.0.o"), + PathBuf::from("/kernel/target/debug/deps/kernel.1.o"), + ], + } + ); + } + + #[test] + fn it_should_parse_rlib_inputs() { + let matches = get_app().get_matches_from_safe(vec![ + "rust-ptx-linker", + "-L", + "/rustlib/lib", + "--rlib", + "/kernel/target/debug/deps/kernel.0.rlib", + "--rlib", + "/kernel/target/debug/deps/kernel.1.rlib", + ]); + + assert_eq!( + parse_session(matches.unwrap()), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + + include_rlibs: vec![ + PathBuf::from("/kernel/target/debug/deps/kernel.0.rlib"), + PathBuf::from("/kernel/target/debug/deps/kernel.1.rlib"), + ], + } + ); + } + + #[test] + fn it_should_parse_output() { + let matches = get_app().get_matches_from_safe(vec![ + "rust-ptx-linker", + "-o", + "/kernel/target/debug/deps/kernel.ptx", + ]); + + assert_eq!( + parse_session(matches.unwrap()), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: Some(PathBuf::from("/kernel/target/debug/deps/kernel.ptx")), + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + } + + #[test] + fn it_should_parse_debug_flag() { + let matches = get_app().get_matches_from_safe(vec!["rust-ptx-linker", "--debug"]); + + assert_eq!( + parse_session(matches.unwrap()), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: true, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + } + + #[test] + fn it_should_parse_optimisations() { + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "-O0"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "-O1"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::Default, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "-O2"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::Default, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "-O3"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::Default, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "-Os"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + } + + #[test] + fn it_should_parse_emit() { + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "asm"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "ptx"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "llvm-ir"]) + .unwrap() + ), + Session { + emit: vec![Output::IntermediateRepresentation], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "llvm-bc"]) + .unwrap() + ), + Session { + emit: vec![Output::Bitcode], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "cubin"]) + .unwrap() + ), + Session { + emit: vec![Output::Cubin], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec![ + "rust-ptx-linker", + "--emit", + "asm", + "--emit", + "llvm-bc" + ]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly, Output::Bitcode], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "asm,llvm-bc"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly, Output::Bitcode], + achitectures: vec![], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + } + + #[test] + fn it_should_parse_arch() { + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--arch", "sm_60"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![String::from("sm_60")], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec![ + "rust-ptx-linker", + "--arch", + "sm_50", + "--arch", + "sm_60" + ]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![String::from("sm_50"), String::from("sm_60")], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--arch", "sm_50,sm_60"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + achitectures: vec![String::from("sm_50"), String::from("sm_60")], + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + } +} diff --git a/src/bin/rust-ptx-linker/main.rs b/src/bin/rust-ptx-linker/main.rs index f328e4d..c26844a 100644 --- a/src/bin/rust-ptx-linker/main.rs +++ b/src/bin/rust-ptx-linker/main.rs @@ -1 +1,23 @@ -fn main() {} +#![deny(warnings)] +#![warn(clippy::all)] + +extern crate env_logger; +extern crate ptx_linker; + +#[macro_use] +extern crate log; + +#[macro_use] +extern crate clap; + +use env_logger::{Builder, Env}; +use ptx_linker::linker_entrypoint; + +mod cli; +use cli::current_session; + +fn main() { + Builder::from_env(Env::default().default_filter_or("info")).init(); + + linker_entrypoint(current_session()) +} diff --git a/src/lib.rs b/src/lib.rs index 19daac5..2593e5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ extern crate llvm_sys; #[macro_use] extern crate error_chain; + #[macro_use] extern crate log; @@ -21,3 +22,32 @@ mod passes; pub mod error; pub mod linker; pub mod session; + +pub fn linker_entrypoint(session: session::Session) -> ! { + use error::*; + use linker::Linker; + + let result = { + Linker::new(session) + .link() + .chain_err(|| "Unable to link modules") + }; + + let exit_code = if let Err(ref e) = result { + error!("{}", e); + + for e in e.iter().skip(1) { + error!(" caused by: {}", e.to_string()); + } + + if let Some(backtrace) = e.backtrace() { + error!("{:?}", backtrace); + } + + 1 + } else { + 0 + }; + + ::std::process::exit(exit_code) +} diff --git a/src/linker.rs b/src/linker.rs index 741f575..ec335fa 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -19,7 +19,7 @@ use llvm_sys::transforms::{ipo::*, pass_manager_builder::*}; use error::*; use llvm::{Message, PassRunner}; use passes::{FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass}; -use session::{Configuration, Output, Session}; +use session::{OptLevel, Output, Session}; pub struct Linker { session: Session, @@ -41,7 +41,7 @@ impl Linker { pub fn link(self) -> Result<()> { info!( - "Going to link {} bitcode modules and {} rlibs...\n", + "Going to link {} bitcode modules and {} rlibs...", self.session.include_bitcode_modules.len(), self.session.include_rlibs.len() ); @@ -58,6 +58,7 @@ impl Linker { .emit_asm() .chain_err(|| "Unable to emit PTX assembly")?, + Output::Cubin => bail!("CUBIN output is not yet supported."), Output::Bitcode => self.emit_bc().chain_err(|| "Unable to emit LLVM bitcode")?, Output::IntermediateRepresentation => { self.emit_ir().chain_err(|| "Unable to emit LLVM IR code")? @@ -137,13 +138,13 @@ impl Linker { let builder = LLVMPassManagerBuilderCreate(); let pass_manager = LLVMCreatePassManager(); - match self.session.configuration { - Configuration::Debug => { + match self.session.opt_level { + OptLevel::None => { info!("Linking without optimisations"); LLVMPassManagerBuilderSetOptLevel(builder, 0); } - Configuration::Release => { + OptLevel::Default => { info!("Linking with Link Time Optimisation"); LLVMPassManagerBuilderSetOptLevel(builder, 3); LLVMPassManagerBuilderPopulateLTOPassManager(builder, pass_manager, 1, 1); @@ -157,8 +158,14 @@ impl Linker { LLVMRunPassManager(pass_manager, self.module); LLVMDisposePassManager(pass_manager); - // Temporary workaround until https://reviews.llvm.org/D46189 is ready - LLVMStripModuleDebugInfo(self.module); + if self.session.debug_info { + // Temporary workaround until https://reviews.llvm.org/D46189 is ready + warn!("Removing debug info because it's not yet supported."); + LLVMStripModuleDebugInfo(self.module); + } else { + LLVMStripModuleDebugInfo(self.module); + } + LLVMSetModuleInlineAsm(self.module, CString::new(vec![]).unwrap().as_ptr()); } } @@ -194,10 +201,18 @@ impl Linker { } fn emit_asm(&self) -> Result<()> { - let path = CString::new(self.get_output_path()?.to_str().unwrap()).unwrap(); + if self.session.achitectures.len() > 1 { + bail!("More than 1 CUDA architecture is not yet supported with PTX output."); + } + + // TOOD(denzp): is it possible to get architecture coming from Rust? + let arch = match self.session.achitectures.iter().next() { + Some(arch) => &arch, + None => "sm_20", + }; - // TODO: get `cpu` from current module - let cpu = CString::new("sm_20").unwrap(); + let path = CString::new(self.get_output_path()?.to_str().unwrap()).unwrap(); + let arch = CString::new(arch).unwrap(); let feature = CString::new("").unwrap(); unsafe { @@ -221,7 +236,7 @@ impl Linker { let target_machine = LLVMCreateTargetMachine( target, triple, - cpu.as_ptr(), + arch.as_ptr(), feature.as_ptr(), LLVMCodeGenOptLevel::LLVMCodeGenLevelAggressive, // TODO: investigate about right settings LLVMRelocMode::LLVMRelocDefault, diff --git a/src/session.rs b/src/session.rs index a8e1f8c..a97e387 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,9 +1,15 @@ use std::path::{Path, PathBuf}; #[derive(Debug, PartialEq)] -pub enum Configuration { - Release, - Debug, +pub enum OptLevel { + None, + Default, +} + +impl Default for OptLevel { + fn default() -> Self { + OptLevel::None + } } #[derive(Debug, PartialEq)] @@ -11,38 +17,31 @@ pub enum Output { PTXAssembly, IntermediateRepresentation, Bitcode, + Cubin, } // TODO: make the fields private -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Default)] pub struct Session { pub output: Option, pub include_rlibs: Vec, pub include_bitcode_modules: Vec, - pub configuration: Configuration, - pub emit: Vec, -} -impl Default for Session { - fn default() -> Self { - Session { - output: None, - include_rlibs: vec![], - include_bitcode_modules: vec![], - configuration: Configuration::Debug, - emit: vec![Output::PTXAssembly, Output::IntermediateRepresentation], - } - } + pub opt_level: OptLevel, + pub debug_info: bool, + + pub emit: Vec, + pub achitectures: Vec, } impl Session { - /// Sets the output path + /// Sets the output path. pub fn set_output(&mut self, path: &Path) { let extension = path.extension().unwrap_or_default(); if extension != "ptx" { warn!( - "The output extension is not '.ptx'. Please consider changing from '.{}' to '.ptx'", + "The output extension is not '.ptx'. Consider changing from '.{}' to '.ptx'", extension.to_str().unwrap() ); } @@ -50,12 +49,17 @@ impl Session { self.output = Some(path.to_path_buf()); } - /// Sets a optimisation - debug or release - pub fn set_configuration(&mut self, configuration: Configuration) { - self.configuration = configuration; + /// Sets an optimisation level. + pub fn set_opt_level(&mut self, level: OptLevel) { + self.opt_level = level; + } + + /// Emit debug information or not. + pub fn set_debug_info(&mut self, debug: bool) { + self.debug_info = debug; } - /// Adds a bitcode file to the linking session + /// Adds a bitcode file to the linking session. /// /// **Note**, for now `*.crate.metadata.o` modules are omitted. pub fn link_bitcode(&mut self, path: &Path) { @@ -65,11 +69,21 @@ impl Session { } } - /// Adds a rlib archive to the linking session + /// Adds a rlib archive to the linking session. pub fn link_rlib(&mut self, path: &Path) { self.include_rlibs.push(path.to_path_buf()); } + /// Emit artifacts of the type. + pub fn add_output_type(&mut self, output: Output) { + self.emit.push(output); + } + + /// Specify output architecture (e.g. `sm_60`). + pub fn add_output_arch(&mut self, arch: &str) { + self.achitectures.push(arch.into()); + } + fn is_metadata_bitcode(&self, path: &Path) -> bool { path.to_str().unwrap().ends_with(".crate.metadata.o") } From 9e3f374ec12588a497e1cf159a9731dcd0203e94 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sun, 20 Jan 2019 23:32:17 +0100 Subject: [PATCH 03/27] Emit IR during tests --- tests/linker.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/linker.rs b/tests/linker.rs index 18ba02e..0bd023c 100644 --- a/tests/linker.rs +++ b/tests/linker.rs @@ -131,6 +131,7 @@ fn create_config(mode: Mode, profile: Profile) -> Config { .to_string_lossy(), ); + config.add_cargo_env("RUSTFLAGS", "-Clink-arg=--emit=asm,llvm-ir"); config.add_cargo_env( "RUST_TARGET_PATH", ¤t_dir().unwrap().join("targets").to_string_lossy(), From c7efe7bd62f0e04f14ad444306f3ae56501aa378 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sun, 20 Jan 2019 23:48:11 +0100 Subject: [PATCH 04/27] Remove cubin output for now. It feels to be out of the scope for the linker. --- src/bin/legacy-ptx-linker/cli.rs | 3 +-- src/bin/rust-ptx-linker/cli.rs | 22 +--------------------- src/linker.rs | 1 - src/session.rs | 1 - 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs index fd56544..288ff8d 100644 --- a/src/bin/legacy-ptx-linker/cli.rs +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -79,7 +79,7 @@ fn get_app() -> App<'static, 'static> { .short("e") .help("Output type") .takes_value(true) - .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc", "cubin"]) + .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc"]) .default_value("asm") .multiple(true) .number_of_values(1) @@ -145,7 +145,6 @@ impl<'a> From> for CommandLineRequest { session.add_output_type(match output { "llvm-ir" => Output::IntermediateRepresentation, "llvm-bc" => Output::Bitcode, - "cubin" => Output::Cubin, _ => Output::PTXAssembly, }); } diff --git a/src/bin/rust-ptx-linker/cli.rs b/src/bin/rust-ptx-linker/cli.rs index 648535f..72e877f 100644 --- a/src/bin/rust-ptx-linker/cli.rs +++ b/src/bin/rust-ptx-linker/cli.rs @@ -77,7 +77,7 @@ fn get_app() -> App<'static, 'static> { .long("emit") .help("Output kind") .takes_value(true) - .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc", "cubin"]) + .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc"]) .default_value("asm") .multiple(true) .number_of_values(1) @@ -128,7 +128,6 @@ fn parse_session(matches: ArgMatches<'static>) -> Session { session.add_output_type(match output { "llvm-ir" => Output::IntermediateRepresentation, "llvm-bc" => Output::Bitcode, - "cubin" => Output::Cubin, // CLI arg has `possible_values` anyway _ => Output::PTXAssembly, @@ -438,25 +437,6 @@ mod tests { } ); - assert_eq!( - parse_session( - get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "--emit", "cubin"]) - .unwrap() - ), - Session { - emit: vec![Output::Cubin], - achitectures: vec![], - - opt_level: OptLevel::None, - debug_info: false, - - output: None, - include_bitcode_modules: vec![], - include_rlibs: vec![], - } - ); - assert_eq!( parse_session( get_app() diff --git a/src/linker.rs b/src/linker.rs index ec335fa..3f504c5 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -58,7 +58,6 @@ impl Linker { .emit_asm() .chain_err(|| "Unable to emit PTX assembly")?, - Output::Cubin => bail!("CUBIN output is not yet supported."), Output::Bitcode => self.emit_bc().chain_err(|| "Unable to emit LLVM bitcode")?, Output::IntermediateRepresentation => { self.emit_ir().chain_err(|| "Unable to emit LLVM IR code")? diff --git a/src/session.rs b/src/session.rs index a97e387..83163b0 100644 --- a/src/session.rs +++ b/src/session.rs @@ -17,7 +17,6 @@ pub enum Output { PTXAssembly, IntermediateRepresentation, Bitcode, - Cubin, } // TODO: make the fields private From 1efc02729b7745664689f706edf1f9bf091c55d6 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sun, 20 Jan 2019 23:56:04 +0100 Subject: [PATCH 05/27] Address clippy issues --- src/linker.rs | 7 ++++--- src/llvm/iter.rs | 21 ++++++++++----------- src/llvm/message.rs | 2 +- src/passes/rename.rs | 2 +- src/session.rs | 7 ++++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/linker.rs b/src/linker.rs index 3f504c5..37ef2c8 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -111,7 +111,7 @@ impl Linker { } fn run_passes(&self) -> Result<()> { - let runner = unsafe { PassRunner::new(::std::mem::transmute(self.module)) }; + let runner = PassRunner::new(self.module); let mut internalize_pass = InternalizePass::new(); runner.run_functions_visitor(&mut internalize_pass); @@ -165,7 +165,8 @@ impl Linker { LLVMStripModuleDebugInfo(self.module); } - LLVMSetModuleInlineAsm(self.module, CString::new(vec![]).unwrap().as_ptr()); + let inline_asm_contents = CString::new(vec![]).unwrap(); + LLVMSetModuleInlineAsm(self.module, inline_asm_contents.as_ptr()); } } @@ -249,7 +250,7 @@ impl Linker { LLVMTargetMachineEmitToFile( target_machine, self.module, - ::std::mem::transmute(path.as_ptr()), + path.as_ptr() as *mut _, LLVMCodeGenFileType::LLVMAssemblyFile, message.as_mut_ptr(), ); diff --git a/src/llvm/iter.rs b/src/llvm/iter.rs index 20641e5..aa4ccf0 100644 --- a/src/llvm/iter.rs +++ b/src/llvm/iter.rs @@ -1,23 +1,22 @@ use std::marker::PhantomData; -use std::ptr::null_mut; use llvm_sys::core::*; use llvm_sys::prelude::*; pub trait FunctionsIterableModule { - fn functions_iter<'a>(&'a self) -> FunctionIter<'a>; + fn functions_iter(&self) -> FunctionIter; } pub trait GlobalsIterableModule { - fn globals_iter<'a>(&'a self) -> GlobalIter<'a>; + fn globals_iter(&self) -> GlobalIter; } pub trait BlocksIterableFunction { - fn blocks_iter<'a>(&'a self) -> BlockIter<'a>; + fn blocks_iter(&self) -> BlockIter; } pub trait InstructionsIterableBlock { - fn instructions_iter<'a>(&'a self) -> InstructionIter<'a>; + fn instructions_iter(&self) -> InstructionIter; } pub struct FunctionIter<'a> { @@ -41,7 +40,7 @@ pub struct InstructionIter<'a> { } impl FunctionsIterableModule for LLVMModuleRef { - fn functions_iter<'a>(&'a self) -> FunctionIter<'a> { + fn functions_iter(&self) -> FunctionIter { FunctionIter::new(self) } } @@ -71,7 +70,7 @@ impl<'a> Iterator for FunctionIter<'a> { } impl GlobalsIterableModule for LLVMModuleRef { - fn globals_iter<'a>(&'a self) -> GlobalIter<'a> { + fn globals_iter(&self) -> GlobalIter { GlobalIter::new(self) } } @@ -101,7 +100,7 @@ impl<'a> Iterator for GlobalIter<'a> { } impl BlocksIterableFunction for LLVMValueRef { - fn blocks_iter<'a>(&'a self) -> BlockIter<'a> { + fn blocks_iter(&self) -> BlockIter { BlockIter::new(self) } } @@ -131,7 +130,7 @@ impl<'a> Iterator for BlockIter<'a> { } impl InstructionsIterableBlock for LLVMBasicBlockRef { - fn instructions_iter<'a>(&'a self) -> InstructionIter<'a> { + fn instructions_iter(&self) -> InstructionIter { InstructionIter::new(self) } } @@ -166,7 +165,7 @@ trait FromPtr { impl FromPtr for Option { fn from_ptr(ptr: LLVMValueRef) -> Self { - if ptr == null_mut() { + if ptr.is_null() { None } else { Some(ptr) @@ -176,7 +175,7 @@ impl FromPtr for Option { impl FromPtr for Option { fn from_ptr(ptr: LLVMBasicBlockRef) -> Self { - if ptr == null_mut() { + if ptr.is_null() { None } else { Some(ptr) diff --git a/src/llvm/message.rs b/src/llvm/message.rs index 9b1f0eb..299f092 100644 --- a/src/llvm/message.rs +++ b/src/llvm/message.rs @@ -19,7 +19,7 @@ impl Message { } pub fn is_empty(&self) -> bool { - self.ptr == ptr::null_mut() + self.ptr.is_null() } pub fn as_mut_ptr(&mut self) -> *mut *mut i8 { diff --git a/src/passes/rename.rs b/src/passes/rename.rs index 88b3dbf..2c9e55b 100644 --- a/src/passes/rename.rs +++ b/src/passes/rename.rs @@ -23,7 +23,7 @@ impl GlobalValueVisitor for RenameGlobalsPass { fn visit_global_value(&mut self, value: LLVMValueRef) -> bool { let current_name = unsafe { CStr::from_ptr(LLVMGetValueName(value)).to_string_lossy() }; - if current_name.contains(".") { + if current_name.contains('.') { let updated_name = unsafe { CString::from_vec_unchecked(current_name.replace(".", "_").into()) }; diff --git a/src/session.rs b/src/session.rs index 83163b0..2e7698d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -62,9 +62,10 @@ impl Session { /// /// **Note**, for now `*.crate.metadata.o` modules are omitted. pub fn link_bitcode(&mut self, path: &Path) { - match self.is_metadata_bitcode(path) { - true => info!("Ignoring metadata bitcode: {:?}", path), - false => self.include_bitcode_modules.push(path.to_path_buf()), + if self.is_metadata_bitcode(path) { + info!("Ignoring metadata bitcode: {:?}", path) + } else { + self.include_bitcode_modules.push(path.to_path_buf()); } } From fe0da5bede9d0daaf2eed342a4020201c8a6933a Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Mon, 21 Jan 2019 00:00:20 +0100 Subject: [PATCH 06/27] Switch to 2018 Rust edition --- Cargo.toml | 1 + src/bin/legacy-ptx-linker/main.rs | 2 +- src/bin/legacy-rustc-dylib-wrapper/main.rs | 2 +- src/bin/rust-ptx-linker/main.rs | 2 +- src/lib.rs | 4 ++-- src/linker.rs | 8 ++++---- src/passes/external_references.rs | 2 +- src/passes/internalize.rs | 2 +- src/passes/rename.rs | 2 +- tests/linker.rs | 2 +- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4a6e681..896ae9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ description = "NVPTX modules linker" repository = "https://github.com/denzp/rust-ptx-linker" categories = ["development-tools", "development-tools::build-utils", "external-ffi-bindings"] keywords = ["llvm", "cuda", "nvptx", "linker"] +edition = "2018" [badges] appveyor = { repository = "denzp/rust-ptx-linker", branch = "master", service = "github" } diff --git a/src/bin/legacy-ptx-linker/main.rs b/src/bin/legacy-ptx-linker/main.rs index 1169b5f..1531896 100644 --- a/src/bin/legacy-ptx-linker/main.rs +++ b/src/bin/legacy-ptx-linker/main.rs @@ -14,7 +14,7 @@ use env_logger::{Builder, Env}; use ptx_linker::linker_entrypoint; mod cli; -use cli::{get_cli_request, CommandLineRequest}; +use crate::cli::{get_cli_request, CommandLineRequest}; fn main() { Builder::from_env(Env::default().default_filter_or("info")).init(); diff --git a/src/bin/legacy-rustc-dylib-wrapper/main.rs b/src/bin/legacy-rustc-dylib-wrapper/main.rs index a70c40a..6d63e06 100644 --- a/src/bin/legacy-rustc-dylib-wrapper/main.rs +++ b/src/bin/legacy-rustc-dylib-wrapper/main.rs @@ -5,7 +5,7 @@ use std::env::args; use std::process::{exit, Command, Stdio}; mod iter; -use iter::IteratorExt; +use crate::iter::IteratorExt; fn main() { let mut command = Command::new("rustc"); diff --git a/src/bin/rust-ptx-linker/main.rs b/src/bin/rust-ptx-linker/main.rs index c26844a..f0973a5 100644 --- a/src/bin/rust-ptx-linker/main.rs +++ b/src/bin/rust-ptx-linker/main.rs @@ -14,7 +14,7 @@ use env_logger::{Builder, Env}; use ptx_linker::linker_entrypoint; mod cli; -use cli::current_session; +use crate::cli::current_session; fn main() { Builder::from_env(Env::default().default_filter_or("info")).init(); diff --git a/src/lib.rs b/src/lib.rs index 2593e5b..37b7b8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,8 @@ pub mod linker; pub mod session; pub fn linker_entrypoint(session: session::Session) -> ! { - use error::*; - use linker::Linker; + use crate::error::*; + use crate::linker::Linker; let result = { Linker::new(session) diff --git a/src/linker.rs b/src/linker.rs index 37ef2c8..42351ad 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -16,10 +16,10 @@ use llvm_sys::target::*; use llvm_sys::target_machine::*; use llvm_sys::transforms::{ipo::*, pass_manager_builder::*}; -use error::*; -use llvm::{Message, PassRunner}; -use passes::{FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass}; -use session::{OptLevel, Output, Session}; +use crate::error::*; +use crate::llvm::{Message, PassRunner}; +use crate::passes::{FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass}; +use crate::session::{OptLevel, Output, Session}; pub struct Linker { session: Session, diff --git a/src/passes/external_references.rs b/src/passes/external_references.rs index 56e4e69..487c91e 100644 --- a/src/passes/external_references.rs +++ b/src/passes/external_references.rs @@ -3,7 +3,7 @@ use llvm_sys::prelude::*; use std::collections::BTreeSet; use std::ffi::CStr; -use llvm::CallVisitor; +use crate::llvm::CallVisitor; pub const SYSCALLS: &[&str] = &["vprintf", "__assertfail", "malloc", "free"]; diff --git a/src/passes/internalize.rs b/src/passes/internalize.rs index 22c18b9..955c128 100644 --- a/src/passes/internalize.rs +++ b/src/passes/internalize.rs @@ -4,7 +4,7 @@ use llvm_sys::*; use std::ffi::CStr; use super::external_references::SYSCALLS; -use llvm::{FunctionVisitor, GlobalValueVisitor}; +use crate::llvm::{FunctionVisitor, GlobalValueVisitor}; const PTX_KERNEL_CALL_CONV: u32 = 71; diff --git a/src/passes/rename.rs b/src/passes/rename.rs index 2c9e55b..9b73995 100644 --- a/src/passes/rename.rs +++ b/src/passes/rename.rs @@ -2,7 +2,7 @@ use llvm_sys::core::*; use llvm_sys::prelude::*; use std::ffi::{CStr, CString}; -use llvm::{FunctionVisitor, GlobalValueVisitor}; +use crate::llvm::{FunctionVisitor, GlobalValueVisitor}; pub struct RenameGlobalsPass; pub struct RenameFunctionsPass; diff --git a/tests/linker.rs b/tests/linker.rs index 0bd023c..ad4a261 100644 --- a/tests/linker.rs +++ b/tests/linker.rs @@ -9,7 +9,7 @@ use std::env::{current_dir, current_exe}; use std::path::Path; mod steps; -use steps::{ +use crate::steps::{ assembly::StepFactory as AssemblyTestStepFactory, ir::StepFactory as IRTestStepFactory, verification::StepFactory as VerificationTestStepFactory, }; From 8fb249c7490933ea1873a277b549437e4c1c9eef Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Mon, 21 Jan 2019 00:22:30 +0100 Subject: [PATCH 07/27] Handle LLVM deprecations --- src/linker.rs | 6 ++++-- src/passes/external_references.rs | 6 +++++- src/passes/internalize.rs | 6 +++++- src/passes/rename.rs | 36 ++++++++++++++++++++++++------- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/linker.rs b/src/linker.rs index 42351ad..6564ea9 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -18,7 +18,9 @@ use llvm_sys::transforms::{ipo::*, pass_manager_builder::*}; use crate::error::*; use crate::llvm::{Message, PassRunner}; -use crate::passes::{FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass}; +use crate::passes::{ + FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass, +}; use crate::session::{OptLevel, Output, Session}; pub struct Linker { @@ -166,7 +168,7 @@ impl Linker { } let inline_asm_contents = CString::new(vec![]).unwrap(); - LLVMSetModuleInlineAsm(self.module, inline_asm_contents.as_ptr()); + LLVMSetModuleInlineAsm2(self.module, inline_asm_contents.as_ptr(), 0); } } diff --git a/src/passes/external_references.rs b/src/passes/external_references.rs index 487c91e..404487f 100644 --- a/src/passes/external_references.rs +++ b/src/passes/external_references.rs @@ -29,7 +29,11 @@ impl FindExternalReferencesPass { impl CallVisitor for FindExternalReferencesPass { fn visit_call(&mut self, _caller: LLVMValueRef, callee: LLVMValueRef) -> bool { - let callee_name = unsafe { CStr::from_ptr(LLVMGetValueName(callee)).to_string_lossy() }; + let callee_name = unsafe { + let mut callee_name_len = 0; + + CStr::from_ptr(LLVMGetValueName2(callee, &mut callee_name_len)).to_string_lossy() + }; let is_declaration = unsafe { LLVMIsDeclaration(callee) == 1 }; let is_intrinsic = callee_name.starts_with("llvm."); diff --git a/src/passes/internalize.rs b/src/passes/internalize.rs index 955c128..69c30b1 100644 --- a/src/passes/internalize.rs +++ b/src/passes/internalize.rs @@ -18,7 +18,11 @@ impl InternalizePass { impl FunctionVisitor for InternalizePass { fn visit_function(&mut self, function: LLVMValueRef) -> bool { - let function_name = unsafe { CStr::from_ptr(LLVMGetValueName(function)).to_string_lossy() }; + let function_name = unsafe { + let mut function_name_len = 0; + + CStr::from_ptr(LLVMGetValueName2(function, &mut function_name_len)).to_string_lossy() + }; let is_kernel = unsafe { LLVMGetFunctionCallConv(function) == PTX_KERNEL_CALL_CONV }; let is_intrinsic = function_name.starts_with("llvm."); diff --git a/src/passes/rename.rs b/src/passes/rename.rs index 9b73995..6a864a9 100644 --- a/src/passes/rename.rs +++ b/src/passes/rename.rs @@ -21,14 +21,24 @@ impl RenameFunctionsPass { impl GlobalValueVisitor for RenameGlobalsPass { fn visit_global_value(&mut self, value: LLVMValueRef) -> bool { - let current_name = unsafe { CStr::from_ptr(LLVMGetValueName(value)).to_string_lossy() }; + let current_name = unsafe { + let mut current_name_len = 0; + + CStr::from_ptr(LLVMGetValueName2(value, &mut current_name_len)).to_string_lossy() + }; if current_name.contains('.') { - let updated_name = - unsafe { CString::from_vec_unchecked(current_name.replace(".", "_").into()) }; + let updated_name = current_name.replace(".", "_"); + + let updated_name_len = updated_name.len(); + let updated_name_ffi = unsafe { CString::from_vec_unchecked(updated_name.into()) }; unsafe { - LLVMSetValueName(value, updated_name.as_ptr() as *const i8); + LLVMSetValueName2( + value, + updated_name_ffi.as_ptr() as *const i8, + updated_name_len, + ); } } @@ -38,14 +48,24 @@ impl GlobalValueVisitor for RenameGlobalsPass { impl FunctionVisitor for RenameFunctionsPass { fn visit_function(&mut self, value: LLVMValueRef) -> bool { - let current_name = unsafe { CStr::from_ptr(LLVMGetValueName(value)).to_string_lossy() }; + let current_name = unsafe { + let mut current_name_len = 0; + + CStr::from_ptr(LLVMGetValueName2(value, &mut current_name_len)).to_string_lossy() + }; if current_name.contains("..") { - let updated_name = - unsafe { CString::from_vec_unchecked(current_name.replace(".", "_").into()) }; + let updated_name = current_name.replace(".", "_"); + + let updated_name_len = updated_name.len(); + let updated_name_ffi = unsafe { CString::from_vec_unchecked(updated_name.into()) }; unsafe { - LLVMSetValueName(value, updated_name.as_ptr() as *const i8); + LLVMSetValueName2( + value, + updated_name_ffi.as_ptr() as *const i8, + updated_name_len, + ); } } From edcca245830f9d6a8b814ccab82c740078d962ab Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Mon, 21 Jan 2019 00:59:27 +0100 Subject: [PATCH 08/27] Migrate from error-chain to failure --- Cargo.lock | 1 - Cargo.toml | 9 +++----- src/error.rs | 25 ++++++++-------------- src/lib.rs | 42 +++++++++---------------------------- src/linker.rs | 41 ++++++++++++++++++------------------ src/passes/internalize.rs | 4 +++- src/session.rs | 2 ++ tests/linker.rs | 10 +++------ tests/steps/mod.rs | 1 + tests/steps/verification.rs | 1 + 10 files changed, 53 insertions(+), 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82c071a..6e7e836 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,7 +274,6 @@ dependencies = [ "crate-compile-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 896ae9d..7beedd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,21 +46,18 @@ required-features = ["cli-rustc"] [dependencies] ar = "0.6" -log = "0.4" clap = "2.31" either = "1.5" -llvm-sys = "70" env_logger = "0.6" - -# TODO(denzp): implement proper error handling! -error-chain = "0.12" +failure = "0.1" +llvm-sys = "70" +log = "0.4" [dependencies.rustc-llvm-proxy] version = "0.1" optional = true [dev-dependencies] -failure = "0.1" crate-compile-test = "0.2" [[test]] diff --git a/src/error.rs b/src/error.rs index 52c2a6d..140609d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,20 +1,13 @@ -error_chain! { - errors { - PathArgumentError(argument: String) { - description("Expected path") - display("Expected path, got `{}`", argument) - } +use failure::Fail; - NoOutputPathError { - display("No output path is specified") - } +#[derive(Debug, Fail)] +pub enum LinkerError { + #[fail(display = "No output path is specified")] + NoOutputPathError, - UndefinedReferences(references: Vec) { - display("Undefined references: {:?}", references) - } - } + #[fail(display = "Expected path, got `{}`", _0)] + PathArgumentError(String), - foreign_links { - Io(::std::io::Error); - } + #[fail(display = "Undefined references: {:?}", _0)] + UndefinedReferences(Vec), } diff --git a/src/lib.rs b/src/lib.rs index 37b7b8d..5056be4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,21 +1,9 @@ -// TODO: temp solution for `error-chain` -#![allow(deprecated)] #![deny(warnings)] #![warn(clippy::all)] #[cfg(feature = "llvm-proxy")] extern crate rustc_llvm_proxy; -extern crate ar; -extern crate clap; -extern crate llvm_sys; - -#[macro_use] -extern crate error_chain; - -#[macro_use] -extern crate log; - mod llvm; mod passes; @@ -24,30 +12,20 @@ pub mod linker; pub mod session; pub fn linker_entrypoint(session: session::Session) -> ! { - use crate::error::*; use crate::linker::Linker; + use log::error; - let result = { - Linker::new(session) - .link() - .chain_err(|| "Unable to link modules") - }; + std::process::exit(match Linker::new(session).link() { + Ok(_) => 0, - let exit_code = if let Err(ref e) = result { - error!("{}", e); + Err(error) => { + error!("Unable to link modules"); - for e in e.iter().skip(1) { - error!(" caused by: {}", e.to_string()); - } + for cause in error.iter_chain() { + error!(" caused by: {}", cause.to_string()); + } - if let Some(backtrace) = e.backtrace() { - error!("{:?}", backtrace); + 1 } - - 1 - } else { - 0 - }; - - ::std::process::exit(exit_code) + }) } diff --git a/src/linker.rs b/src/linker.rs index 6564ea9..bc0d1e2 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -5,7 +5,6 @@ use std::path::{Path, PathBuf}; use std::ptr; use std::str; -use ar::Archive; use llvm_sys::bit_reader::*; use llvm_sys::bit_writer::*; use llvm_sys::core::*; @@ -16,6 +15,10 @@ use llvm_sys::target::*; use llvm_sys::target_machine::*; use llvm_sys::transforms::{ipo::*, pass_manager_builder::*}; +use ar::Archive; +use failure::{bail, Error, ResultExt}; +use log::*; + use crate::error::*; use crate::llvm::{Message, PassRunner}; use crate::passes::{ @@ -41,7 +44,7 @@ impl Linker { } } - pub fn link(self) -> Result<()> { + pub fn link(self) -> Result<(), Error> { info!( "Going to link {} bitcode modules and {} rlibs...", self.session.include_bitcode_modules.len(), @@ -56,13 +59,11 @@ impl Linker { for output in &self.session.emit { match *output { - Output::PTXAssembly => self - .emit_asm() - .chain_err(|| "Unable to emit PTX assembly")?, + Output::PTXAssembly => self.emit_asm().context("Unable to emit PTX assembly")?, + Output::Bitcode => self.emit_bc().context("Unable to emit LLVM bitcode")?, - Output::Bitcode => self.emit_bc().chain_err(|| "Unable to emit LLVM bitcode")?, Output::IntermediateRepresentation => { - self.emit_ir().chain_err(|| "Unable to emit LLVM IR code")? + self.emit_ir().context("Unable to emit LLVM IR code")? } } } @@ -70,7 +71,7 @@ impl Linker { Ok(()) } - fn link_bitcode(&self) -> Result<()> { + fn link_bitcode(&self) -> Result<(), Error> { for module_path in &self.session.include_bitcode_modules { debug!("Linking bitcode: {:?}", module_path); @@ -84,7 +85,7 @@ impl Linker { Ok(()) } - fn link_rlibs(&self) -> Result<()> { + fn link_rlibs(&self) -> Result<(), Error> { for rlib_path in &self.session.include_rlibs { debug!("Linking rlib: {:?}", rlib_path); @@ -112,7 +113,7 @@ impl Linker { name.extension().unwrap() == "o" } - fn run_passes(&self) -> Result<()> { + fn run_passes(&self) -> Result<(), Error> { let runner = PassRunner::new(self.module); let mut internalize_pass = InternalizePass::new(); @@ -123,9 +124,9 @@ impl Linker { runner.run_calls_visitor(&mut external_references_pass); if external_references_pass.count() > 0 { - return Err( - ErrorKind::UndefinedReferences(external_references_pass.references()).into(), - ); + bail!(LinkerError::UndefinedReferences( + external_references_pass.references() + )); } runner.run_globals_visitor(&mut RenameGlobalsPass::new()); @@ -172,7 +173,7 @@ impl Linker { } } - fn emit_ir(&self) -> Result<()> { + fn emit_ir(&self) -> Result<(), Error> { let path = CString::new(self.get_output_path_with_ext("ll")?.to_str().unwrap()).unwrap(); unsafe { @@ -190,7 +191,7 @@ impl Linker { Ok(()) } - fn emit_bc(&self) -> Result<()> { + fn emit_bc(&self) -> Result<(), Error> { let path = CString::new(self.get_output_path_with_ext("bc")?.to_str().unwrap()).unwrap(); unsafe { @@ -202,7 +203,7 @@ impl Linker { Ok(()) } - fn emit_asm(&self) -> Result<()> { + fn emit_asm(&self) -> Result<(), Error> { if self.session.achitectures.len() > 1 { bail!("More than 1 CUDA architecture is not yet supported with PTX output."); } @@ -265,21 +266,21 @@ impl Linker { Ok(()) } - fn get_output_path(&self) -> Result { + fn get_output_path(&self) -> Result { match self.session.output.as_ref() { Some(path) => Ok(path.clone()), - None => Err(ErrorKind::NoOutputPathError.into()), + None => bail!(LinkerError::NoOutputPathError), } } - fn get_output_path_with_ext(&self, extension: &str) -> Result { + fn get_output_path_with_ext(&self, extension: &str) -> Result { let mut output_path = self.get_output_path()?; output_path.set_extension(extension); Ok(output_path) } - fn link_bitcode_contents(&self, module: LLVMModuleRef, buffer: Vec) -> Result<()> { + fn link_bitcode_contents(&self, module: LLVMModuleRef, buffer: Vec) -> Result<(), Error> { unsafe { let buffer_name = CString::new("sm_20").unwrap(); let buffer = LLVMCreateMemoryBufferWithMemoryRange( diff --git a/src/passes/internalize.rs b/src/passes/internalize.rs index 69c30b1..31afc38 100644 --- a/src/passes/internalize.rs +++ b/src/passes/internalize.rs @@ -1,7 +1,9 @@ +use std::ffi::CStr; + use llvm_sys::core::*; use llvm_sys::prelude::*; use llvm_sys::*; -use std::ffi::CStr; +use log::*; use super::external_references::SYSCALLS; use crate::llvm::{FunctionVisitor, GlobalValueVisitor}; diff --git a/src/session.rs b/src/session.rs index 2e7698d..36f7d7d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,5 +1,7 @@ use std::path::{Path, PathBuf}; +use log::*; + #[derive(Debug, PartialEq)] pub enum OptLevel { None, diff --git a/tests/linker.rs b/tests/linker.rs index ad4a261..a064659 100644 --- a/tests/linker.rs +++ b/tests/linker.rs @@ -1,13 +1,9 @@ -#[macro_use] -extern crate failure; - -#[macro_use] -extern crate crate_compile_test; - -use crate_compile_test::prelude::*; use std::env::{current_dir, current_exe}; use std::path::Path; +use crate_compile_test::bootstrap_compilation_tests; +use crate_compile_test::prelude::*; + mod steps; use crate::steps::{ assembly::StepFactory as AssemblyTestStepFactory, ir::StepFactory as IRTestStepFactory, diff --git a/tests/steps/mod.rs b/tests/steps/mod.rs index 8eb3d0b..c5a97f6 100644 --- a/tests/steps/mod.rs +++ b/tests/steps/mod.rs @@ -3,6 +3,7 @@ use std::io::{BufReader, Read}; use std::path::Path; use crate_compile_test::prelude::*; +use failure::bail; pub mod assembly; pub mod ir; diff --git a/tests/steps/verification.rs b/tests/steps/verification.rs index 2555536..bdfd40b 100644 --- a/tests/steps/verification.rs +++ b/tests/steps/verification.rs @@ -3,6 +3,7 @@ use std::process::Command; use crate_compile_test::prelude::*; use crate_compile_test::steps::{TestStep, TestStepFactory}; +use failure::bail; pub struct StepFactory; pub struct Step; From fc73589eda4bfa51f5ca6f62f6bd70e9cc136a69 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Mon, 21 Jan 2019 20:46:41 +0100 Subject: [PATCH 09/27] Bump `rustc-llvm-proxy` version --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e7e836..d46000d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -277,7 +277,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-llvm-proxy 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-llvm-proxy 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -426,7 +426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-llvm-proxy" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -693,7 +693,7 @@ dependencies = [ "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum rustc-llvm-proxy 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d2f278142275f9dd3729d65aefdab3b2db4f3f68a4487d9b23b342ec1ee216de" +"checksum rustc-llvm-proxy 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "78722422c290493fc9e06453648d587a1483fb19070cbb5f13217bed7e4d56d2" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" From b0b48a1e8ffe6d8669cb3d518f5f2a2012f98ec5 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Thu, 24 Jan 2019 00:52:22 +0100 Subject: [PATCH 10/27] Fix FindExternalReferencesPass with enabled debug-assetions --- src/linker.rs | 2 ++ src/passes/external_references.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/linker.rs b/src/linker.rs index bc0d1e2..1e8ef4e 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -129,6 +129,7 @@ impl Linker { )); } + // TODO(denzp): the two passes will become obsolete with built-in target. runner.run_globals_visitor(&mut RenameGlobalsPass::new()); runner.run_functions_visitor(&mut RenameFunctionsPass::new()); @@ -168,6 +169,7 @@ impl Linker { LLVMStripModuleDebugInfo(self.module); } + // TODO(denzp): this will become obsolete with built-in target. let inline_asm_contents = CString::new(vec![]).unwrap(); LLVMSetModuleInlineAsm2(self.module, inline_asm_contents.as_ptr(), 0); } diff --git a/src/passes/external_references.rs b/src/passes/external_references.rs index 404487f..316f857 100644 --- a/src/passes/external_references.rs +++ b/src/passes/external_references.rs @@ -1,8 +1,10 @@ -use llvm_sys::core::*; -use llvm_sys::prelude::*; use std::collections::BTreeSet; use std::ffi::CStr; +use llvm_sys::core::*; +use llvm_sys::prelude::*; +use llvm_sys::LLVMValueKind; + use crate::llvm::CallVisitor; pub const SYSCALLS: &[&str] = &["vprintf", "__assertfail", "malloc", "free"]; @@ -35,7 +37,11 @@ impl CallVisitor for FindExternalReferencesPass { CStr::from_ptr(LLVMGetValueName2(callee, &mut callee_name_len)).to_string_lossy() }; - let is_declaration = unsafe { LLVMIsDeclaration(callee) == 1 }; + let is_declaration = unsafe { + LLVMGetValueKind(callee) == LLVMValueKind::LLVMFunctionValueKind + && LLVMIsDeclaration(callee) == 1 + }; + let is_intrinsic = callee_name.starts_with("llvm."); let is_syscall = SYSCALLS.contains(&callee_name.as_ref()); From 1b6e71b8d19abd35aa5081cdbd46ef857ebabf05 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sat, 26 Jan 2019 01:05:17 +0100 Subject: [PATCH 11/27] Update README --- README.md | 122 ++++++++++++------------------ examples/depenencies/Cargo.toml | 4 +- examples/intrinsics/Cargo.toml | 2 +- examples/undefined-ref/Cargo.toml | 2 +- 4 files changed, 53 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index aaa051d..e9656b3 100644 --- a/README.md +++ b/README.md @@ -3,102 +3,78 @@ [![Build status](https://ci.appveyor.com/api/projects/status/fjhq7mdp1skpjfqu/branch/master?svg=true)](https://ci.appveyor.com/project/denzp/rust-ptx-linker/branch/master) [![Current Version](https://img.shields.io/crates/v/ptx-linker.svg)](https://crates.io/crates/ptx-linker) -LLVM NVPTX bitcode linker for Rust 🔥 **without any external dependencies** 🔥! +LLVM NVPTX bitcode linker for Rust 🔥 **without external system dependencies** 🔥! -## Purpose -It is definitely [possible to create](https://github.com/japaric/nvptx) CUDA (PTX) kernels written with Rust even without the linker. - -You could emit PTX code with `--emit asm` flag. -Unfortunately, `--emit asm` can't link couple modules into a single PTX. -Problems comes up when you need to write more or less complex kernels, which use functions from external crates. - -From [discussion](https://github.com/nagisa/math.rs/pull/3#issuecomment-304737732) another solution revealed: use of LLVM api. +## What's going on in v0.9? +The release is important for the linker and existing users. +Linker binaries are now split into *legacy* and *modern*. -The linker does the magic without any external dependency installed though. -*How could it be?* you may ask. -Thanks to [rustc-llvm-proxy](https://crates.io/crates/rustc-llvm-proxy) we avoid dependency on external LLVM lib and use rustc own one. +* *Legacy* can be used with any Rust version and provides json target specification. +Basically, it has the same behaviour as prior versions. +* *Modern* uses a special CLI calling convention and requires support from Rust. +Eventually, it will become the only supported usage approach. -### Windows users! -Unfortunately, due to [rustc-llvm-proxy#1](/denzp/rustc-llvm-proxy/issues/1) **MSVS** targets are not supported yet. - -You might face similar errors: -``` -Unable to find symbol 'LLVMContextCreate' in the LLVM shared lib -``` - -For now the only solution is to use **GNU** targets. - -## Issues -According to Rust [NVPTX metabug](https://github.com/rust-lang/rust/issues/38789) it's quite realistic to solve part of bugs within this repo: +## Purpose +The linker solves several of issues mentioned in the [NVPTX metabug](https://github.com/rust-lang/rust/issues/38789): - [x] Non-inlined functions can't be used cross crate - [rust#38787](https://github.com/rust-lang/rust/issues/38787) - [x] No "undefined reference" error is raised when it should be - [rust#38786](https://github.com/rust-lang/rust/issues/38786) -## Approach -The trick is to **build a kernels crate as "dylib"** and let the linker handle "linking". +## Convenient usage +The linker is rather an under-the-hood tool normally being used by Rust itself. +You just need to install it, make sure Rust is told to use the linker, and build a `cdylib` device crate. +The easiest way would be to stick with [ptx-builder](https://crates.io/crates/ptx-builder) or other device crate builder. -For that, you need a special target definition json and to specify crate type in `Cargo.toml`: -``` toml -[lib] -crate_type = ["dylib"] -``` +~~You can also refer to [a tutorial](https://github.com/denzp/rust-inline-cuda-tutorial/tree/master/chapter-1) about using CUDA kernels written in Rust.~~ *(Sorry, the tutorial is pretty outdated at the moment)*. -## Convinient usage -The easiest would be to rely on [ptx-builder](https://crates.io/crates/ptx-builder) to handle device crate building. -It will run `xargo` (which will invoke the linker after) and set all needed environment variables for comfortable development flow. +## Advanced usage +Alternatively, the linker can be used alone. +The modern approach uses Rust built-in target specification and a special CLI between Rust and the linker. -You can also refer to [a tutorial](https://github.com/denzp/rust-inline-cuda-tutorial/tree/master/chapter-1) about using CUDA kernels written in Rust. +*Heads up! More details are coming soon!* + +### Legacy approach +The approach is similar to the one was used prior `v0.9` release. +It involves `xargo` to automatically compile `libcore` for the CUDA target. -## Advanced usage -Alternatively, you can use the linker solo. First you need to install tools: ``` $ cargo install ptx-linker $ cargo install xargo ``` -Then, create a `nvptx64-nvidia-cuda` definition: +Then, create a `nvptx64-nvidia-cuda` target specification: ``` -$ cd /path/to/kernels/crate -$ ptx-linker --print-target-json nvptx64-nvidia-cuda > nvptx64-nvidia-cuda.json +$ export RUST_TARGET_PATH="/tmp" +$ legacy-ptx-linker --print-target-json nvptx64-nvidia-cuda > $RUST_TARGET_PATH/nvptx64-nvidia-cuda.json +``` + +Make sure you are using a `cdylib` crate type (the step is needed to perform "linking"). +Add to your `Cargo.toml`: +``` toml +[lib] +crate_type = ["cdylib"] ``` -And finally, run a build with proper environment vars: +And finally, run a build with `xargo`: ``` -$ export RUST_TARGET_PATH="/path/to/kernels/crate" +$ cd /path/to/kernels/crate $ xargo build --target nvptx64-nvidia-cuda --release ``` -Eventually the linker will be used to produce a PTX assembly, that can be usually found at `target/nvptx64-nvidia-cuda/release/KERNELS_CRATE_NAME.ptx`. - -### Target definition -The common definition for `nvptx64-nvidia-cuda` looks like: -``` json -{ - "arch": "nvptx64", - "cpu": "sm_20", - "data-layout": "e-i64:64-v16:16-v32:32-n16:32:64", - "linker": "ptx-linker", - "linker-flavor": "ld", - "linker-is-gnu": true, - "dll-prefix": "", - "dll-suffix": ".ptx", - "dynamic-linking": true, - "llvm-target": "nvptx64-nvidia-cuda", - "max-atomic-width": 0, - "os": "cuda", - "obj-is-bitcode": true, - "panic-strategy": "abort", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32" -} +Eventually, the linker will produce a PTX assembly, that can be usually found at `target/nvptx64-nvidia-cuda/release/KERNELS_CRATE_NAME.ptx`. + +## How does it work? +The linker does the magic without external system dependencies (mainly, LLVM libs) installed. +Thanks to the [rustc-llvm-proxy](https://crates.io/crates/rustc-llvm-proxy) the correct LLVM symbols are being loaded at runtime. +The approach also ensures that the linker uses same libraries versions as Rust. + +### Windows users! +Unfortunately, due to [rustc-llvm-proxy#1](/denzp/rustc-llvm-proxy/issues/1) **MSVS** targets are not supported yet. + +You might face similar errors: +``` +Unable to find symbol 'LLVMContextCreate' in the LLVM shared lib ``` -Especially, the most important for the linker are the properties: -* `"linker"` - the linker executable name in `PATH`. -* `"linker-flavor"` - currently the linker supports parsing of `ld`-style arguments. -* `"linker-is-gnu"` - needed to be `true` for Rust to pass optimisation flags. -* `"dll-suffix"` - specifies a correct assembly file extension. -* `"dynamic-linking"` - allows Rust to create **dylib** for the target. -* `"obj-is-bitcode"` - store bitcode instead of object files, it's significantly easier to work with them. +For now, the only solution on Windows is to use **GNU** host binaries. diff --git a/examples/depenencies/Cargo.toml b/examples/depenencies/Cargo.toml index 03e1d5b..8b1fc5b 100644 --- a/examples/depenencies/Cargo.toml +++ b/examples/depenencies/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Denys "] [lib] -crate_type = ["dylib"] +crate_type = ["cdylib"] [dependencies] -dummy_math = { path = "dependencies/dummy_math" } \ No newline at end of file +dummy_math = { path = "dependencies/dummy_math" } diff --git a/examples/intrinsics/Cargo.toml b/examples/intrinsics/Cargo.toml index e9e46cd..d5611b2 100644 --- a/examples/intrinsics/Cargo.toml +++ b/examples/intrinsics/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" authors = ["Denys "] [lib] -crate_type = ["dylib"] +crate_type = ["cdylib"] diff --git a/examples/undefined-ref/Cargo.toml b/examples/undefined-ref/Cargo.toml index c328455..63ef6e8 100644 --- a/examples/undefined-ref/Cargo.toml +++ b/examples/undefined-ref/Cargo.toml @@ -4,5 +4,5 @@ version = "0.1.0" authors = ["Denys "] [lib] -crate_type = ["dylib"] +crate_type = ["cdylib"] From 44179cbe5799178e285ee5719cbe67bf0e5556a1 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sat, 26 Jan 2019 01:09:30 +0100 Subject: [PATCH 12/27] Legacy: support additional flags when linking `cdylib` --- src/bin/legacy-ptx-linker/cli.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs index 288ff8d..c8e8d5d 100644 --- a/src/bin/legacy-ptx-linker/cli.rs +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -66,6 +66,14 @@ fn get_app() -> App<'static, 'static> { .hidden(true) .multiple(true) .number_of_values(1), + Arg::with_name("__ignored_version_script") + .long("version-script") + .hidden(true) + .multiple(true), + Arg::with_name("__ignored_gc_sections") + .long("gc-sections") + .hidden(true) + .multiple(true), Arg::with_name("arch") .long("arch") .short("a") From 9805429b5394a6dad340be1c6667dce9ea7f11cc Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sat, 26 Jan 2019 01:12:28 +0100 Subject: [PATCH 13/27] README: change wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9656b3..bf7c97d 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,4 @@ You might face similar errors: Unable to find symbol 'LLVMContextCreate' in the LLVM shared lib ``` -For now, the only solution on Windows is to use **GNU** host binaries. +For now, the only solution on Windows is to use **GNU** toolchain. From faba7c0a83cd55d2a3f9f2d7326ddcdbe1e32bc4 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Mon, 28 Jan 2019 22:29:44 +0100 Subject: [PATCH 14/27] Change CLI regarding optimisation level --- Cargo.lock | 2 + src/bin/legacy-ptx-linker/cli.rs | 4 +- src/bin/rust-ptx-linker/cli.rs | 93 +++----------------------------- src/linker.rs | 37 +++++++------ src/session.rs | 2 +- 5 files changed, 33 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d46000d..25153cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "aho-corasick" version = "0.6.9" diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs index c8e8d5d..d3b510c 100644 --- a/src/bin/legacy-ptx-linker/cli.rs +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -145,7 +145,7 @@ impl<'a> From> for CommandLineRequest { match matches.value_of("optimise") { Some("0") | None => session.set_opt_level(OptLevel::None), - Some(_) => session.set_opt_level(OptLevel::Default), + Some(_) => session.set_opt_level(OptLevel::LTO), }; if let Some(outputs) = matches.values_of("emit") { @@ -236,7 +236,7 @@ mod tests { emit: vec![Output::PTXAssembly], achitectures: vec![], - opt_level: OptLevel::Default, + opt_level: OptLevel::LTO, debug_info: false, output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), diff --git a/src/bin/rust-ptx-linker/cli.rs b/src/bin/rust-ptx-linker/cli.rs index 72e877f..1aacb1c 100644 --- a/src/bin/rust-ptx-linker/cli.rs +++ b/src/bin/rust-ptx-linker/cli.rs @@ -53,7 +53,7 @@ fn get_app() -> App<'static, 'static> { .short("O") .help("Optimisation level") .takes_value(true) - .possible_values(&["0", "1", "2", "3", "s"]) + .possible_values(&["lto"]) .value_name("level") }, { @@ -110,16 +110,11 @@ fn parse_session(matches: ArgMatches<'static>) -> Session { } match matches.value_of("optimisation") { - Some("0") | None => session.set_opt_level(OptLevel::None), - Some("2") => session.set_opt_level(OptLevel::Default), - - Some("1") | Some("3") => { - info!("Using default optimisation level `-O2`."); - session.set_opt_level(OptLevel::Default); - } + Some("lto") => session.set_opt_level(OptLevel::LTO), + None => session.set_opt_level(OptLevel::None), Some(_) => { - warn!("Not supported optimisation level! Falling back to `-O0`."); + warn!("Not supported optimisation level! Ignoring..."); } }; @@ -266,90 +261,14 @@ mod tests { assert_eq!( parse_session( get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "-O0"]) - .unwrap() - ), - Session { - emit: vec![Output::PTXAssembly], - achitectures: vec![], - - opt_level: OptLevel::None, - debug_info: false, - - output: None, - include_bitcode_modules: vec![], - include_rlibs: vec![], - } - ); - - assert_eq!( - parse_session( - get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "-O1"]) - .unwrap() - ), - Session { - emit: vec![Output::PTXAssembly], - achitectures: vec![], - - opt_level: OptLevel::Default, - debug_info: false, - - output: None, - include_bitcode_modules: vec![], - include_rlibs: vec![], - } - ); - - assert_eq!( - parse_session( - get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "-O2"]) - .unwrap() - ), - Session { - emit: vec![Output::PTXAssembly], - achitectures: vec![], - - opt_level: OptLevel::Default, - debug_info: false, - - output: None, - include_bitcode_modules: vec![], - include_rlibs: vec![], - } - ); - - assert_eq!( - parse_session( - get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "-O3"]) + .get_matches_from_safe(vec!["rust-ptx-linker", "-Olto"]) .unwrap() ), Session { emit: vec![Output::PTXAssembly], achitectures: vec![], - opt_level: OptLevel::Default, - debug_info: false, - - output: None, - include_bitcode_modules: vec![], - include_rlibs: vec![], - } - ); - - assert_eq!( - parse_session( - get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "-Os"]) - .unwrap() - ), - Session { - emit: vec![Output::PTXAssembly], - achitectures: vec![], - - opt_level: OptLevel::None, + opt_level: OptLevel::LTO, debug_info: false, output: None, diff --git a/src/linker.rs b/src/linker.rs index 1e8ef4e..76891ff 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -138,26 +138,33 @@ impl Linker { fn run_llvm_passes(&self) { unsafe { - let builder = LLVMPassManagerBuilderCreate(); let pass_manager = LLVMCreatePassManager(); match self.session.opt_level { OptLevel::None => { - info!("Linking without optimisations"); - LLVMPassManagerBuilderSetOptLevel(builder, 0); + info!("Linking without Link Time Optimisation"); } - OptLevel::Default => { + OptLevel::LTO => { info!("Linking with Link Time Optimisation"); - LLVMPassManagerBuilderSetOptLevel(builder, 3); - LLVMPassManagerBuilderPopulateLTOPassManager(builder, pass_manager, 1, 1); + let pass_manager_builder = LLVMPassManagerBuilderCreate(); + + LLVMPassManagerBuilderSetOptLevel(pass_manager_builder, 3); + LLVMPassManagerBuilderPopulateLTOPassManager( + pass_manager_builder, + pass_manager, + 1, + 1, + ); + + LLVMPassManagerBuilderDispose(pass_manager_builder); } } - LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager); - LLVMPassManagerBuilderDispose(builder); - + // The pass is needed to perform cleanup after our internaliser. LLVMAddGlobalDCEPass(pass_manager); + + // TODO(denzp): check the result LLVMRunPassManager(pass_manager, self.module); LLVMDisposePassManager(pass_manager); @@ -179,12 +186,12 @@ impl Linker { let path = CString::new(self.get_output_path_with_ext("ll")?.to_str().unwrap()).unwrap(); unsafe { - // TODO: check result + // TODO(denzp): check result let mut message = Message::new(); LLVMPrintModuleToFile(self.module, path.as_ptr(), message.as_mut_ptr()); if !message.is_empty() { - // TODO: stderr? + // TODO(denzp): stderr? println!("{}", message); } } @@ -197,7 +204,7 @@ impl Linker { let path = CString::new(self.get_output_path_with_ext("bc")?.to_str().unwrap()).unwrap(); unsafe { - // TODO: check result + // TODO(denzp): check result LLVMWriteBitcodeToFile(self.module, path.as_ptr()); } @@ -251,7 +258,7 @@ impl Linker { { let mut message = Message::new(); - // TODO: check result + // TODO(denzp): check result LLVMTargetMachineEmitToFile( target_machine, self.module, @@ -294,10 +301,10 @@ impl Linker { let mut temp_module = ptr::null_mut(); - // TODO: check result + // TODO(denzp): check result LLVMParseBitcodeInContext2(self.context, buffer, &mut temp_module); - // TODO: check result + // TODO(denzp): check result LLVMLinkModules2(module, temp_module); LLVMDisposeMemoryBuffer(buffer); } diff --git a/src/session.rs b/src/session.rs index 36f7d7d..75f468f 100644 --- a/src/session.rs +++ b/src/session.rs @@ -5,7 +5,7 @@ use log::*; #[derive(Debug, PartialEq)] pub enum OptLevel { None, - Default, + LTO, } impl Default for OptLevel { From 367d5f6dc10afb3ae96ff347f2e62ba31b43e7fb Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Tue, 29 Jan 2019 20:42:36 +0100 Subject: [PATCH 15/27] Support fallback arch specified by Rust with `target-cpu` --- src/bin/legacy-ptx-linker/cli.rs | 10 ++++- src/bin/rust-ptx-linker/cli.rs | 75 +++++++++++++++++++++++++------- src/linker.rs | 9 ++-- src/session.rs | 10 ++++- 4 files changed, 80 insertions(+), 24 deletions(-) diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs index d3b510c..9a2c411 100644 --- a/src/bin/legacy-ptx-linker/cli.rs +++ b/src/bin/legacy-ptx-linker/cli.rs @@ -164,6 +164,10 @@ impl<'a> From> for CommandLineRequest { } } + // Unfortunately, there is no way to get the fallback arch from Rust + // with the legacy approach. + session.set_fallback_arch("sm_30"); + CommandLineRequest::Link(session) } } @@ -202,7 +206,8 @@ mod tests { let expected_session = Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -234,7 +239,8 @@ mod tests { let expected_session = Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::LTO, debug_info: false, diff --git a/src/bin/rust-ptx-linker/cli.rs b/src/bin/rust-ptx-linker/cli.rs index 1aacb1c..623beeb 100644 --- a/src/bin/rust-ptx-linker/cli.rs +++ b/src/bin/rust-ptx-linker/cli.rs @@ -61,6 +61,13 @@ fn get_app() -> App<'static, 'static> { .long("debug") .help("Emit debug info") }, + { + Arg::with_name("fallback_arch") + .long("fallback-arch") + .help("Rust own target architecture") + .takes_value(true) + .default_value("sm_30") + }, { Arg::with_name("arch") .short("a") @@ -136,6 +143,10 @@ fn parse_session(matches: ArgMatches<'static>) -> Session { } } + if let Some(arch) = matches.value_of("fallback_arch") { + session.set_fallback_arch(arch); + } + session } @@ -164,7 +175,8 @@ mod tests { parse_session(matches.unwrap()), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -196,7 +208,8 @@ mod tests { parse_session(matches.unwrap()), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -224,7 +237,8 @@ mod tests { parse_session(matches.unwrap()), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -244,7 +258,8 @@ mod tests { parse_session(matches.unwrap()), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: true, @@ -266,7 +281,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::LTO, debug_info: false, @@ -288,7 +304,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -307,7 +324,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -326,7 +344,8 @@ mod tests { ), Session { emit: vec![Output::IntermediateRepresentation], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -345,7 +364,8 @@ mod tests { ), Session { emit: vec![Output::Bitcode], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -370,7 +390,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly, Output::Bitcode], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -389,7 +410,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly, Output::Bitcode], - achitectures: vec![], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -406,12 +428,13 @@ mod tests { assert_eq!( parse_session( get_app() - .get_matches_from_safe(vec!["rust-ptx-linker", "--arch", "sm_60"]) + .get_matches_from_safe(vec!["rust-ptx-linker", "--arch", "sm_70"]) .unwrap() ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![String::from("sm_60")], + ptx_archs: vec![String::from("sm_70")], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -436,7 +459,8 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![String::from("sm_50"), String::from("sm_60")], + ptx_archs: vec![String::from("sm_50"), String::from("sm_60")], + ptx_fallback_arch: String::from("sm_30"), opt_level: OptLevel::None, debug_info: false, @@ -455,7 +479,28 @@ mod tests { ), Session { emit: vec![Output::PTXAssembly], - achitectures: vec![String::from("sm_50"), String::from("sm_60")], + ptx_archs: vec![String::from("sm_50"), String::from("sm_60")], + ptx_fallback_arch: String::from("sm_30"), + + opt_level: OptLevel::None, + debug_info: false, + + output: None, + include_bitcode_modules: vec![], + include_rlibs: vec![], + } + ); + + assert_eq!( + parse_session( + get_app() + .get_matches_from_safe(vec!["rust-ptx-linker", "--fallback-arch", "sm_40"]) + .unwrap() + ), + Session { + emit: vec![Output::PTXAssembly], + ptx_archs: vec![], + ptx_fallback_arch: String::from("sm_40"), opt_level: OptLevel::None, debug_info: false, diff --git a/src/linker.rs b/src/linker.rs index 76891ff..2d68c2c 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -213,14 +213,13 @@ impl Linker { } fn emit_asm(&self) -> Result<(), Error> { - if self.session.achitectures.len() > 1 { + if self.session.ptx_archs.len() > 1 { bail!("More than 1 CUDA architecture is not yet supported with PTX output."); } - // TOOD(denzp): is it possible to get architecture coming from Rust? - let arch = match self.session.achitectures.iter().next() { - Some(arch) => &arch, - None => "sm_20", + let arch = match self.session.ptx_archs.iter().next() { + Some(arch) => arch.as_str(), + None => self.session.ptx_fallback_arch.as_str(), }; let path = CString::new(self.get_output_path()?.to_str().unwrap()).unwrap(); diff --git a/src/session.rs b/src/session.rs index 75f468f..d469ffa 100644 --- a/src/session.rs +++ b/src/session.rs @@ -32,7 +32,8 @@ pub struct Session { pub debug_info: bool, pub emit: Vec, - pub achitectures: Vec, + pub ptx_archs: Vec, + pub ptx_fallback_arch: String, } impl Session { @@ -83,7 +84,12 @@ impl Session { /// Specify output architecture (e.g. `sm_60`). pub fn add_output_arch(&mut self, arch: &str) { - self.achitectures.push(arch.into()); + self.ptx_archs.push(arch.into()); + } + + /// Specify the fallback architecture if no other explicitly set. + pub fn set_fallback_arch(&mut self, arch: &str) { + self.ptx_fallback_arch = arch.into(); } fn is_metadata_bitcode(&self, path: &Path) -> bool { From c3b1f92513c47b9ed9ab074e3624fb303898583a Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 16:48:04 +0100 Subject: [PATCH 16/27] Use `cargo` instead of `xargo` for tests --- .travis.yml | 4 +--- appveyor.yml | 6 ++---- examples/depenencies/Xargo.toml | 6 ------ examples/intrinsics/Xargo.toml | 6 ------ examples/undefined-ref/Xargo.toml | 6 ------ tests/linker.rs | 10 ++-------- tests/steps/assembly.rs | 4 ++-- tests/steps/ir.rs | 6 +++--- 8 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 examples/depenencies/Xargo.toml delete mode 100644 examples/intrinsics/Xargo.toml delete mode 100644 examples/undefined-ref/Xargo.toml diff --git a/.travis.yml b/.travis.yml index 22d3b5c..686597f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,7 @@ matrix: rust: nightly script: - - rustup component add rust-src - - cargo install -f xargo - - cargo check + - rustup target add nvptx64-nvidia-cuda - cargo test notifications: diff --git a/appveyor.yml b/appveyor.yml index 86fd469..2d21fd3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,13 +11,11 @@ install: - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - rustc -V - cargo -V - - rustup component add rust-src - - cargo install -f xargo + - rustup target add nvptx64-nvidia-cuda -build: off +build: "off" test_script: - - cargo check - cargo test branches: diff --git a/examples/depenencies/Xargo.toml b/examples/depenencies/Xargo.toml deleted file mode 100644 index 43b05a5..0000000 --- a/examples/depenencies/Xargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[dependencies.core] -stage = 0 - -[dependencies.alloc] -features = ["compiler-builtins-mem"] -stage = 1 diff --git a/examples/intrinsics/Xargo.toml b/examples/intrinsics/Xargo.toml deleted file mode 100644 index 43b05a5..0000000 --- a/examples/intrinsics/Xargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[dependencies.core] -stage = 0 - -[dependencies.alloc] -features = ["compiler-builtins-mem"] -stage = 1 diff --git a/examples/undefined-ref/Xargo.toml b/examples/undefined-ref/Xargo.toml deleted file mode 100644 index 43b05a5..0000000 --- a/examples/undefined-ref/Xargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[dependencies.core] -stage = 0 - -[dependencies.alloc] -features = ["compiler-builtins-mem"] -stage = 1 diff --git a/tests/linker.rs b/tests/linker.rs index a064659..ef1132c 100644 --- a/tests/linker.rs +++ b/tests/linker.rs @@ -1,4 +1,4 @@ -use std::env::{current_dir, current_exe}; +use std::env::current_exe; use std::path::Path; use crate_compile_test::bootstrap_compilation_tests; @@ -99,7 +99,6 @@ bootstrap_compilation_tests![ptx_assembly_tests, ir_tests, failure_tests]; fn create_config(mode: Mode, profile: Profile) -> Config { let mut config = Config::new(mode, "examples"); - config.cargo_command = "xargo".into(); config.profile = profile; config.target = Some("nvptx64-nvidia-cuda".into()); @@ -123,15 +122,10 @@ fn create_config(mode: Mode, profile: Profile) -> Config { .unwrap() .parent() .unwrap() - .join("legacy-ptx-linker") + .join("rust-ptx-linker") .to_string_lossy(), ); config.add_cargo_env("RUSTFLAGS", "-Clink-arg=--emit=asm,llvm-ir"); - config.add_cargo_env( - "RUST_TARGET_PATH", - ¤t_dir().unwrap().join("targets").to_string_lossy(), - ); - config } diff --git a/tests/steps/assembly.rs b/tests/steps/assembly.rs index a8fa139..42492c2 100644 --- a/tests/steps/assembly.rs +++ b/tests/steps/assembly.rs @@ -40,7 +40,7 @@ impl LinkOutputCheckStep for Step { "%ctaid.x;", "%tid.x;", ], - &["example__Image"], + &["example$$Image", "example..image"], )), (Profile::Debug, "examples/intrinsics") => Some(( &[ @@ -50,7 +50,7 @@ impl LinkOutputCheckStep for Step { "%ntid.x;", "%ctaid.x;", "%tid.x;", - "example__image__Image", + "example$$image$$Image", ], &["example..image..Image"], )), diff --git a/tests/steps/ir.rs b/tests/steps/ir.rs index f6d7fb6..25db8d9 100644 --- a/tests/steps/ir.rs +++ b/tests/steps/ir.rs @@ -41,7 +41,7 @@ impl LinkOutputCheckStep for Step { "tail call signext i32 @llvm.nvvm.read.ptx.sreg.tid.x()", "declare signext i32 @vprintf(i8* nocapture readonly, i8*)", ], - &["example__image__Image"], + &["example$$image", "example..image"], )), (Profile::Debug, "examples/intrinsics") => Some(( &[ @@ -51,12 +51,12 @@ impl LinkOutputCheckStep for Step { "call signext i32 @llvm.nvvm.read.ptx.sreg.ntid.x()", "call signext i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()", "call signext i32 @llvm.nvvm.read.ptx.sreg.tid.x()", - "example__image__Image", + "example$$image$$Image", "declare signext i32 @vprintf(i8*, i8*)", "declare i8* @malloc(i64)", "declare void @free(i8*)", ], - &[], + &["example..image"], )), (Profile::Release, "examples/depenencies") => Some(( From 08a25f209d80c1f4668139f15f66395c18cf0d03 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 16:49:11 +0100 Subject: [PATCH 17/27] Get rid of legacy binary --- src/bin/legacy-ptx-linker/cli.rs | 299 ------------------------------ src/bin/legacy-ptx-linker/main.rs | 41 ---- targets/nvptx-nvidia-cuda.json | 23 --- targets/nvptx64-nvidia-cuda.json | 23 --- 4 files changed, 386 deletions(-) delete mode 100644 src/bin/legacy-ptx-linker/cli.rs delete mode 100644 src/bin/legacy-ptx-linker/main.rs delete mode 100644 targets/nvptx-nvidia-cuda.json delete mode 100644 targets/nvptx64-nvidia-cuda.json diff --git a/src/bin/legacy-ptx-linker/cli.rs b/src/bin/legacy-ptx-linker/cli.rs deleted file mode 100644 index 9a2c411..0000000 --- a/src/bin/legacy-ptx-linker/cli.rs +++ /dev/null @@ -1,299 +0,0 @@ -use std::path::Path; - -use clap::{App, Arg, ArgMatches}; -use ptx_linker::session::{OptLevel, Output, Session}; - -#[derive(Debug, PartialEq)] -pub enum CommandLineRequest { - Link(Session), - Print64BitTargetJson, - Print32BitTargetJson, -} - -pub fn get_cli_request() -> CommandLineRequest { - CommandLineRequest::from(get_app().get_matches()) -} - -fn get_app() -> App<'static, 'static> { - App::new("legacy-ptx-linker") - .version(crate_version!()) - .author(crate_authors!()) - .about("Performs linking of Rust NVPTX crates") - .args(&[ - Arg::with_name("input") - .help("Path to input rlib or bitcode") - .multiple(true), - Arg::with_name("output") - .short("o") - .help("Sets path for assembly output") - .takes_value(true) - .value_name("FILE.ptx"), - Arg::with_name("optimise") - .short("O") - .help("Sets optimisation level") - .takes_value(true) - .value_name("level"), - Arg::with_name("__ignored_lib_start") - .long("whole-archive") - .hidden(true) - .multiple(true), - Arg::with_name("__ignored_lib_end") - .long("no-whole-archive") - .hidden(true) - .multiple(true), - Arg::with_name("__ignored_start_group") - .long("start-group") - .hidden(true) - .multiple(true), - Arg::with_name("__ignored_end_group") - .long("end-group") - .hidden(true) - .multiple(true), - Arg::with_name("__ignored_compiler_prefix") - .short("B") - .takes_value(true) - .hidden(true) - .multiple(true) - .number_of_values(1), - Arg::with_name("__ignored_shared_hack") - .short("s") - .hidden(true) - .multiple(true) - .takes_value(true), - Arg::with_name("__ignored_lib_path") - .short("L") - .takes_value(true) - .hidden(true) - .multiple(true) - .number_of_values(1), - Arg::with_name("__ignored_version_script") - .long("version-script") - .hidden(true) - .multiple(true), - Arg::with_name("__ignored_gc_sections") - .long("gc-sections") - .hidden(true) - .multiple(true), - Arg::with_name("arch") - .long("arch") - .short("a") - .help("Target CUDA architectures") - .takes_value(true) - .multiple(true) - .number_of_values(1) - .use_delimiter(true), - Arg::with_name("emit") - .long("emit") - .short("e") - .help("Output type") - .takes_value(true) - .possible_values(&["asm", "ptx", "llvm-ir", "llvm-bc"]) - .default_value("asm") - .multiple(true) - .number_of_values(1) - .use_delimiter(true), - ]) - .subcommand({ - App::new("print") - .about("Prints NVPTX target definition JSON into stdout") - .arg( - &Arg::with_name("TARGET") - .help("Specifies the target name") - .required(true) - .possible_values(&["nvptx64-nvidia-cuda", "nvptx-nvidia-cuda"]), - ) - }) -} - -impl<'a> From> for CommandLineRequest { - fn from(matches: ArgMatches) -> CommandLineRequest { - match matches.subcommand_name() { - Some("print") => { - let target = matches - .subcommand_matches("print") - .unwrap() - .value_of("TARGET"); - - match target { - Some("nvptx64-nvidia-cuda") => CommandLineRequest::Print64BitTargetJson, - Some("nvptx-nvidia-cuda") => CommandLineRequest::Print32BitTargetJson, - - other => { - unreachable!("Unknown target: {:?}", other); - } - } - } - - _ => { - let mut session = Session::default(); - - if let Some(inputs) = matches.values_of("input") { - for input in inputs { - if input.ends_with(".o") { - session.link_bitcode(Path::new(input)); - } else if input.ends_with(".rlib") { - session.link_rlib(Path::new(input)); - } else { - warn!("Can't recognise input type: {:?}", input); - } - } - } - - if let Some(output) = matches.value_of("output") { - session.set_output(Path::new(output)); - } - - match matches.value_of("optimise") { - Some("0") | None => session.set_opt_level(OptLevel::None), - Some(_) => session.set_opt_level(OptLevel::LTO), - }; - - if let Some(outputs) = matches.values_of("emit") { - for output in outputs { - session.add_output_type(match output { - "llvm-ir" => Output::IntermediateRepresentation, - "llvm-bc" => Output::Bitcode, - _ => Output::PTXAssembly, - }); - } - } - - if let Some(archs) = matches.values_of("arch") { - for arch in archs { - session.add_output_arch(arch); - } - } - - // Unfortunately, there is no way to get the fallback arch from Rust - // with the legacy approach. - session.set_fallback_arch("sm_30"); - - CommandLineRequest::Link(session) - } - } - } -} - -#[cfg(test)] -mod tests { - use std::path::PathBuf; - - use super::*; - use ptx_linker::session::Output; - - #[test] - fn it_should_parse_args() { - let matches = get_app().get_matches_from_safe(vec![ - "legacy-ptx-linker", - "-L", - "/rustlib/lib", - "/kernel/target/debug/deps/kernel.0.o", - "/kernel/target/debug/deps/kernel.crate.metadata.o", - "-o", - "/kernel/target/debug/deps/libkernel.ptx", - "-L", - "/kernel/target/debug/deps", - "-L", - "/kernel/target/debug/deps", - "-L", - "~/rustlib/nvptx64-nvidia-cuda/lib", - "-Bstatic", - "--whole-archive", - "/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib", - "--no-whole-archive", - "/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib", - ]); - - let expected_session = Session { - emit: vec![Output::PTXAssembly], - ptx_archs: vec![], - ptx_fallback_arch: String::from("sm_30"), - - opt_level: OptLevel::None, - debug_info: false, - - output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), - - include_rlibs: vec![ - PathBuf::from("/tmp/rustc.Ew934MzC8cj0/liblib-f0faab0dbaa9f7ef.rlib"), - PathBuf::from("/tmp/rustc.Ew934MzC8cj0/libother-6b4931ba2f43f84b.rlib"), - ], - - include_bitcode_modules: vec![PathBuf::from("/kernel/target/debug/deps/kernel.0.o")], - }; - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Link(expected_session) - ); - } - - #[test] - fn it_should_parse_optimization() { - let matches = get_app().get_matches_from_safe(vec![ - "legacy-ptx-linker", - "-o", - "/kernel/target/debug/deps/libkernel.ptx", - "-O1", - ]); - - let expected_session = Session { - emit: vec![Output::PTXAssembly], - ptx_archs: vec![], - ptx_fallback_arch: String::from("sm_30"), - - opt_level: OptLevel::LTO, - debug_info: false, - - output: Some(PathBuf::from("/kernel/target/debug/deps/libkernel.ptx")), - - include_rlibs: vec![], - include_bitcode_modules: vec![], - }; - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Link(expected_session) - ); - } - - #[test] - fn it_should_not_print_unknown_target_json() { - let matches = get_app().get_matches_from_safe(vec![ - "legacy-ptx-linker", - "print", - "another-target-triple", - ]); - - assert!(matches.is_err()); - } - - #[test] - fn it_should_print_64bit_target_json() { - let matches = get_app().get_matches_from_safe(vec![ - "legacy-ptx-linker", - "print", - "nvptx64-nvidia-cuda", - ]); - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Print64BitTargetJson - ); - } - - #[test] - fn it_should_print_32bit_target_json() { - let matches = get_app().get_matches_from_safe(vec![ - "legacy-ptx-linker", - "print", - "nvptx-nvidia-cuda", - ]); - - assert_eq!( - CommandLineRequest::from(matches.expect("Unable to parse CLI arguments")), - CommandLineRequest::Print32BitTargetJson - ); - } - -} diff --git a/src/bin/legacy-ptx-linker/main.rs b/src/bin/legacy-ptx-linker/main.rs deleted file mode 100644 index 1531896..0000000 --- a/src/bin/legacy-ptx-linker/main.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![deny(warnings)] -#![warn(clippy::all)] - -extern crate env_logger; -extern crate ptx_linker; - -#[macro_use] -extern crate clap; - -#[macro_use] -extern crate log; - -use env_logger::{Builder, Env}; -use ptx_linker::linker_entrypoint; - -mod cli; -use crate::cli::{get_cli_request, CommandLineRequest}; - -fn main() { - Builder::from_env(Env::default().default_filter_or("info")).init(); - - match get_cli_request() { - CommandLineRequest::Link(session) => { - linker_entrypoint(session); - } - - CommandLineRequest::Print64BitTargetJson => { - println!( - "{}", - include_str!("../../../targets/nvptx64-nvidia-cuda.json") - ); - } - - CommandLineRequest::Print32BitTargetJson => { - println!( - "{}", - include_str!("../../../targets/nvptx-nvidia-cuda.json") - ); - } - } -} diff --git a/targets/nvptx-nvidia-cuda.json b/targets/nvptx-nvidia-cuda.json deleted file mode 100644 index 391e718..0000000 --- a/targets/nvptx-nvidia-cuda.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "arch": "nvptx", - "cpu": "sm_20", - "data-layout": "e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64", - "linker": "legacy-ptx-linker", - "linker-flavor": "ld", - "linker-is-gnu": true, - "dll-prefix": "", - "dll-suffix": ".ptx", - "exe-prefix": "", - "exe-suffix": ".ptx", - "executables": true, - "dynamic-linking": true, - "llvm-target": "nvptx-nvidia-cuda", - "max-atomic-width": 0, - "os": "cuda", - "obj-is-bitcode": true, - "panic-strategy": "abort", - "target-endian": "little", - "target-pointer-width": "32", - "target-c-int-width": "32", - "merge-functions": "disabled" -} diff --git a/targets/nvptx64-nvidia-cuda.json b/targets/nvptx64-nvidia-cuda.json deleted file mode 100644 index 5c3f516..0000000 --- a/targets/nvptx64-nvidia-cuda.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "arch": "nvptx64", - "cpu": "sm_20", - "data-layout": "e-i64:64-i128:128-v16:16-v32:32-n16:32:64", - "linker": "legacy-ptx-linker", - "linker-flavor": "ld", - "linker-is-gnu": true, - "dll-prefix": "", - "dll-suffix": ".ptx", - "exe-prefix": "", - "exe-suffix": ".ptx", - "executables": true, - "dynamic-linking": true, - "llvm-target": "nvptx64-nvidia-cuda", - "max-atomic-width": 0, - "os": "cuda", - "obj-is-bitcode": true, - "panic-strategy": "abort", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "merge-functions": "disabled" -} From 3803921f6c1e9314d2615156de067c610930dfcc Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 16:49:37 +0100 Subject: [PATCH 18/27] Get rid of obsolete passes --- src/linker.rs | 12 +------ src/passes/mod.rs | 3 -- src/passes/rename.rs | 74 -------------------------------------------- 3 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 src/passes/rename.rs diff --git a/src/linker.rs b/src/linker.rs index 2d68c2c..26eac49 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -21,9 +21,7 @@ use log::*; use crate::error::*; use crate::llvm::{Message, PassRunner}; -use crate::passes::{ - FindExternalReferencesPass, InternalizePass, RenameFunctionsPass, RenameGlobalsPass, -}; +use crate::passes::{FindExternalReferencesPass, InternalizePass}; use crate::session::{OptLevel, Output, Session}; pub struct Linker { @@ -129,10 +127,6 @@ impl Linker { )); } - // TODO(denzp): the two passes will become obsolete with built-in target. - runner.run_globals_visitor(&mut RenameGlobalsPass::new()); - runner.run_functions_visitor(&mut RenameFunctionsPass::new()); - Ok(()) } @@ -175,10 +169,6 @@ impl Linker { } else { LLVMStripModuleDebugInfo(self.module); } - - // TODO(denzp): this will become obsolete with built-in target. - let inline_asm_contents = CString::new(vec![]).unwrap(); - LLVMSetModuleInlineAsm2(self.module, inline_asm_contents.as_ptr(), 0); } } diff --git a/src/passes/mod.rs b/src/passes/mod.rs index 44d3ce3..ed7a48c 100644 --- a/src/passes/mod.rs +++ b/src/passes/mod.rs @@ -1,6 +1,3 @@ -mod rename; -pub use self::rename::{RenameFunctionsPass, RenameGlobalsPass}; - mod external_references; pub use self::external_references::FindExternalReferencesPass; diff --git a/src/passes/rename.rs b/src/passes/rename.rs deleted file mode 100644 index 6a864a9..0000000 --- a/src/passes/rename.rs +++ /dev/null @@ -1,74 +0,0 @@ -use llvm_sys::core::*; -use llvm_sys::prelude::*; -use std::ffi::{CStr, CString}; - -use crate::llvm::{FunctionVisitor, GlobalValueVisitor}; - -pub struct RenameGlobalsPass; -pub struct RenameFunctionsPass; - -impl RenameGlobalsPass { - pub fn new() -> Self { - RenameGlobalsPass {} - } -} - -impl RenameFunctionsPass { - pub fn new() -> Self { - RenameFunctionsPass {} - } -} - -impl GlobalValueVisitor for RenameGlobalsPass { - fn visit_global_value(&mut self, value: LLVMValueRef) -> bool { - let current_name = unsafe { - let mut current_name_len = 0; - - CStr::from_ptr(LLVMGetValueName2(value, &mut current_name_len)).to_string_lossy() - }; - - if current_name.contains('.') { - let updated_name = current_name.replace(".", "_"); - - let updated_name_len = updated_name.len(); - let updated_name_ffi = unsafe { CString::from_vec_unchecked(updated_name.into()) }; - - unsafe { - LLVMSetValueName2( - value, - updated_name_ffi.as_ptr() as *const i8, - updated_name_len, - ); - } - } - - false - } -} - -impl FunctionVisitor for RenameFunctionsPass { - fn visit_function(&mut self, value: LLVMValueRef) -> bool { - let current_name = unsafe { - let mut current_name_len = 0; - - CStr::from_ptr(LLVMGetValueName2(value, &mut current_name_len)).to_string_lossy() - }; - - if current_name.contains("..") { - let updated_name = current_name.replace(".", "_"); - - let updated_name_len = updated_name.len(); - let updated_name_ffi = unsafe { CString::from_vec_unchecked(updated_name.into()) }; - - unsafe { - LLVMSetValueName2( - value, - updated_name_ffi.as_ptr() as *const i8, - updated_name_len, - ); - } - } - - false - } -} From d19e48ce5434f7398e48b8a09a760d25fa1d5c17 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 16:50:09 +0100 Subject: [PATCH 19/27] Bump version --- Cargo.lock | 2 +- Cargo.toml | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25153cf..5cee20e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "ptx-linker" -version = "0.9.0-alpha" +version = "0.9.0" dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 7beedd2..84f5314 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ptx-linker" -version = "0.9.0-alpha" +version = "0.9.0" authors = ["Denys Zariaiev "] license = "MIT" @@ -17,33 +17,20 @@ travis-ci = { repository = "denzp/rust-ptx-linker", branch = "master" } maintenance = { status = "experimental" } [features] -default = ["llvm-proxy", "cli-legacy", "cli-rustc"] +default = ["llvm-proxy", "cli-legacy"] cli-legacy = [] -cli-rustc = [] llvm-proxy = [ "rustc-llvm-proxy", "llvm-sys/no-llvm-linking", "llvm-sys/disable-alltargets-init" ] -[[bin]] -name = "legacy-ptx-linker" -doc = false -path = "src/bin/legacy-ptx-linker/main.rs" -required-features = ["cli-legacy"] - [[bin]] name = "legacy-rustc-dylib-wrapper" doc = false path = "src/bin/legacy-rustc-dylib-wrapper/main.rs" required-features = ["cli-legacy"] -[[bin]] -name = "rust-ptx-linker" -doc = false -path = "src/bin/rust-ptx-linker/main.rs" -required-features = ["cli-rustc"] - [dependencies] ar = "0.6" clap = "2.31" From 2ed113924915e3e7792655ceebb1166a570f886f Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 16:52:26 +0100 Subject: [PATCH 20/27] Get rid of legacy `crate-type` helper binary --- Cargo.toml | 9 +-- src/bin/legacy-rustc-dylib-wrapper/iter.rs | 66 --------------- src/bin/legacy-rustc-dylib-wrapper/main.rs | 94 ---------------------- 3 files changed, 1 insertion(+), 168 deletions(-) delete mode 100644 src/bin/legacy-rustc-dylib-wrapper/iter.rs delete mode 100644 src/bin/legacy-rustc-dylib-wrapper/main.rs diff --git a/Cargo.toml b/Cargo.toml index 84f5314..c026309 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,20 +17,13 @@ travis-ci = { repository = "denzp/rust-ptx-linker", branch = "master" } maintenance = { status = "experimental" } [features] -default = ["llvm-proxy", "cli-legacy"] -cli-legacy = [] +default = ["llvm-proxy"] llvm-proxy = [ "rustc-llvm-proxy", "llvm-sys/no-llvm-linking", "llvm-sys/disable-alltargets-init" ] -[[bin]] -name = "legacy-rustc-dylib-wrapper" -doc = false -path = "src/bin/legacy-rustc-dylib-wrapper/main.rs" -required-features = ["cli-legacy"] - [dependencies] ar = "0.6" clap = "2.31" diff --git a/src/bin/legacy-rustc-dylib-wrapper/iter.rs b/src/bin/legacy-rustc-dylib-wrapper/iter.rs deleted file mode 100644 index 9c38326..0000000 --- a/src/bin/legacy-rustc-dylib-wrapper/iter.rs +++ /dev/null @@ -1,66 +0,0 @@ -use std::mem::replace; - -pub trait IteratorExt: Sized + Iterator { - fn keep_last_pair(self, needle: Self::Item) -> KeepLastPairIter { - KeepLastPairIter { - needle, - last: PairState::None, - iter: self, - } - } -} - -impl IteratorExt for T where T: Iterator {} - -enum PairState { - None, - Complete(T, T), - Partial(T), -} - -pub struct KeepLastPairIter { - needle: I::Item, - last: PairState, - iter: I, -} - -impl Iterator for KeepLastPairIter -where - I: Iterator, - I::Item: Clone + PartialEq, -{ - type Item = I::Item; - - fn next(&mut self) -> Option { - match self.iter.next() { - Some(head) => { - if head == self.needle { - match self.iter.next() { - Some(next) => { - self.last = PairState::Complete(head, next); - self.iter.next() - } - - None => Some(head), - } - } else { - Some(head) - } - } - - None => match replace(&mut self.last, PairState::None) { - PairState::Complete(first, second) => { - self.last = PairState::Partial(second); - Some(first) - } - - PairState::Partial(second) => { - self.last = PairState::None; - Some(second) - } - - PairState::None => None, - }, - } - } -} diff --git a/src/bin/legacy-rustc-dylib-wrapper/main.rs b/src/bin/legacy-rustc-dylib-wrapper/main.rs deleted file mode 100644 index 6d63e06..0000000 --- a/src/bin/legacy-rustc-dylib-wrapper/main.rs +++ /dev/null @@ -1,94 +0,0 @@ -extern crate either; - -use either::Either; -use std::env::args; -use std::process::{exit, Command, Stdio}; - -mod iter; -use crate::iter::IteratorExt; - -fn main() { - let mut command = Command::new("rustc"); - - let status = command - .args(transform_args(args())) - .stdin(Stdio::inherit()) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .status(); - - match status.unwrap().code() { - Some(code) => exit(code), - None => exit(0), - } -} - -fn transform_args(args: impl Iterator) -> impl Iterator { - let args = args.skip(1).collect::>(); - - if args.iter().find(|item| *item == "___").is_some() { - Either::Left(args.into_iter()) - } else { - Either::Right(args.into_iter().keep_last_pair("--crate-type".to_string())) - } -} - -#[test] -fn test_multiple_crate_types() { - let input = &[ - "wrapper", - "--crate-type", - "lib", - "--crate-name", - "sample_crate", - "--crate-type", - "dylib", - "--sysroot", - "/tmp", - ]; - - let output = vec![ - "--crate-name".to_string(), - "sample_crate".to_string(), - "--sysroot".to_string(), - "/tmp".to_string(), - "--crate-type".to_string(), - "dylib".to_string(), - ]; - - assert_eq!( - transform_args(input.iter().map(|item| item.to_string())).collect::>(), - output - ); -} - -#[test] -fn test_internal_discovery() { - let input = &[ - "wrapper", - "--crate-type", - "lib", - "--crate-name", - "___", - "--crate-type", - "dylib", - "--sysroot", - "/tmp", - ]; - - let output = vec![ - "--crate-type".to_string(), - "lib".to_string(), - "--crate-name".to_string(), - "___".to_string(), - "--crate-type".to_string(), - "dylib".to_string(), - "--sysroot".to_string(), - "/tmp".to_string(), - ]; - - assert_eq!( - transform_args(input.iter().map(|item| item.to_string())).collect::>(), - output - ); -} From 687823ae18e7f14740374807f035f213784f3b85 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 19:54:58 +0100 Subject: [PATCH 21/27] Update CI configs --- .travis.yml | 27 +++++++++++++++++++++++---- appveyor.yml | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 686597f..6c6410e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,40 @@ language: rust cache: cargo +rust: nightly matrix: + fast_finish: true include: + - name: "Check with Clippy" + install: + - rustup component add clippy + script: + - cargo clippy -- --verbose + + - name: "Check with Rustfmt" + install: + - rustup component add rustfmt + script: + - cargo fmt -- --check + - name: "x86_64-unknown-linux-gnu" os: linux - rust: nightly - name: "x86_64-apple-darwin" os: osx osx_image: xcode10 - rust: nightly -script: +before_install: - rustup target add nvptx64-nvidia-cuda - - cargo test + +script: + - cargo test --verbose notifications: email: on_success: never + +branches: + only: + - master + - /^v\d+\.\d+\.\d+.*$/ diff --git a/appveyor.yml b/appveyor.yml index 2d21fd3..cebd219 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,8 +16,9 @@ install: build: "off" test_script: - - cargo test + - cargo test --verbose branches: only: - master + - /^v\d+\.\d+\.\d+.*$/ From dcb7261b8d8196aaca47a6f163f6e93726f68c24 Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Wed, 6 Feb 2019 21:39:23 +0100 Subject: [PATCH 22/27] Update README to reflect recent changes --- README.md | 61 +++++++++++++++++++++------------------------- examples/README.md | 12 +++++---- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index bf7c97d..40fef66 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,21 @@ LLVM NVPTX bitcode linker for Rust 🔥 **without external system dependencies** ## What's going on in v0.9? The release is important for the linker and existing users. -Linker binaries are now split into *legacy* and *modern*. +The former approach was using an external `nvptx64-nvidia-cuda` json target specification and `xargo` to automatically compile `libcore`. -* *Legacy* can be used with any Rust version and provides json target specification. -Basically, it has the same behaviour as prior versions. -* *Modern* uses a special CLI calling convention and requires support from Rust. -Eventually, it will become the only supported usage approach. +As of *2019-02-06* Rust [received built-in support](https://github.com/rust-lang/rust/pull/57937) for building the CUDA kernels, and which evolved from the experience gained with `ptx-linker` prior `v0.9`. + +Currently, it's possible to jump into a CUDA development with Nightly Rust: + +``` bash +# Install the minimal required version of the linker. +$ cargo install ptx-linker -f --version ">= 0.9" + +# Install `libcore` for the CUDA target. +$ rustup target add nvptx64-nvidia-cuda +``` + +More details about further usage can be found below ([**Advanced usage**](#advanced-usage) section). ## Purpose The linker solves several of issues mentioned in the [NVPTX metabug](https://github.com/rust-lang/rust/issues/38789): @@ -21,48 +30,34 @@ The linker solves several of issues mentioned in the [NVPTX metabug](https://git - [x] No "undefined reference" error is raised when it should be - [rust#38786](https://github.com/rust-lang/rust/issues/38786) ## Convenient usage -The linker is rather an under-the-hood tool normally being used by Rust itself. -You just need to install it, make sure Rust is told to use the linker, and build a `cdylib` device crate. -The easiest way would be to stick with [ptx-builder](https://crates.io/crates/ptx-builder) or other device crate builder. - -~~You can also refer to [a tutorial](https://github.com/denzp/rust-inline-cuda-tutorial/tree/master/chapter-1) about using CUDA kernels written in Rust.~~ *(Sorry, the tutorial is pretty outdated at the moment)*. - -## Advanced usage -Alternatively, the linker can be used alone. -The modern approach uses Rust built-in target specification and a special CLI between Rust and the linker. - *Heads up! More details are coming soon!* -### Legacy approach -The approach is similar to the one was used prior `v0.9` release. -It involves `xargo` to automatically compile `libcore` for the CUDA target. +At the moment [ptx-builder](https://crates.io/crates/ptx-builder) is still using a legacy approach with `xargo`, but the situation will change very soon! -First you need to install tools: -``` -$ cargo install ptx-linker -$ cargo install xargo -``` + -Then, create a `nvptx64-nvidia-cuda` target specification: -``` -$ export RUST_TARGET_PATH="/tmp" -$ legacy-ptx-linker --print-target-json nvptx64-nvidia-cuda > $RUST_TARGET_PATH/nvptx64-nvidia-cuda.json -``` +## Advanced usage +Alternatively, the linker can be used alone. -Make sure you are using a `cdylib` crate type (the step is needed to perform "linking"). +Make sure you are using a `cdylib` crate type (the step is needed to perform the actual "linking"). Add to your `Cargo.toml`: ``` toml [lib] crate_type = ["cdylib"] ``` -And finally, run a build with `xargo`: -``` +And finally, build the PTX assembly file: +``` bash $ cd /path/to/kernels/crate -$ xargo build --target nvptx64-nvidia-cuda --release +$ cargo build --target nvptx64-nvidia-cuda --release ``` -Eventually, the linker will produce a PTX assembly, that can be usually found at `target/nvptx64-nvidia-cuda/release/KERNELS_CRATE_NAME.ptx`. +Rust will involve `ptx-linker` under-the-hood and the latter will write the assembly at: +``` +target/nvptx64-nvidia-cuda/release/KERNELS_CRATE_NAME.ptx +``` ## How does it work? The linker does the magic without external system dependencies (mainly, LLVM libs) installed. diff --git a/examples/README.md b/examples/README.md index 1174651..fd0196b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,9 +1,11 @@ # Examples To build the examples: -``` -export RUST_TARGET_PATH="$(pwd)/../../targets" -xargo build --target nvptx64-nvidia-cuda --release +``` bash +# Make sure `rust-ptx-linker` is in the $PATH +$ which `rust-ptx-linker` +$ cd example_dir +$ cargo build --target nvptx64-nvidia-cuda --release ``` ## Deep Dependencies Example: `depenencies` @@ -25,8 +27,8 @@ This example shows that the linker can find unresoved external references and re When you try to run the example the linker should fail with error message: ``` -[ERROR] Unable to link modules -[ERROR] caused by: Undefined references: ["bar"] +[ERROR ptx_linker] Unable to link modules +[ERROR ptx_linker] caused by: Undefined references: ["bar"] ``` ## Intrinsics Example: `intrinsics` From b0f71a784d2b36b7b1fd8491dc724307b253704b Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Thu, 21 Nov 2019 20:00:14 +0100 Subject: [PATCH 23/27] Fix tests with the recent nightly --- Cargo.lock | 59 ++++++++++++++++--------------------- Cargo.toml | 6 ++-- tests/steps/assembly.rs | 6 ++-- tests/steps/ir.rs | 6 ++-- tests/steps/verification.rs | 2 +- 5 files changed, 35 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cee20e..13359bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,11 +18,8 @@ dependencies = [ [[package]] name = "ar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "atty" @@ -66,11 +63,6 @@ name = "bitflags" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "byteorder" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cargo_metadata" version = "0.6.4" @@ -95,14 +87,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.32.0" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -146,12 +138,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -200,7 +192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "humantime" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -244,7 +236,7 @@ dependencies = [ [[package]] name = "log" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -271,15 +263,15 @@ dependencies = [ name = "ptx-linker" version = "0.9.0" dependencies = [ - "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "crate-compile-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-llvm-proxy 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-llvm-proxy 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -428,7 +420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-llvm-proxy" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -503,7 +495,7 @@ dependencies = [ [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -560,7 +552,7 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -648,34 +640,33 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" +"checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60f0b0d4c0a382d2734228fd12b5a6b5dac185c60e938026fd31b265b94f9bd2" "checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe" "checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e9a455e156a4271e12fd0246238c380b1e223e3736663c7a18ed8b6362028a9" "checksum crate-compile-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efa7bc09385a5adcf2af00aa28a6bae6bb98864004e3a2b246f2fa38dc480ce3" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" +"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60a9ee82fe0fa72ae6ef6d018b407296085863836451c7a97384f84ed7e26b9f" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -695,7 +686,7 @@ dependencies = [ "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum rustc-llvm-proxy 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "78722422c290493fc9e06453648d587a1483fb19070cbb5f13217bed7e4d56d2" +"checksum rustc-llvm-proxy 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd81d364e5ac962be1fae5eafbcbb845b997fa92fdf7616421c435eac0562137" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" @@ -704,13 +695,13 @@ dependencies = [ "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" "checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" diff --git a/Cargo.toml b/Cargo.toml index c026309..2424824 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,10 +25,10 @@ llvm-proxy = [ ] [dependencies] -ar = "0.6" -clap = "2.31" +ar = "0.8" +clap = "2.33" either = "1.5" -env_logger = "0.6" +env_logger = "0.7" failure = "0.1" llvm-sys = "70" log = "0.4" diff --git a/tests/steps/assembly.rs b/tests/steps/assembly.rs index 42492c2..093d337 100644 --- a/tests/steps/assembly.rs +++ b/tests/steps/assembly.rs @@ -17,7 +17,7 @@ impl StepFactory { } impl TestStepFactory for StepFactory { - fn initialize(&self, _config: &Config, crate_path: &Path) -> Result> { + fn initialize(&self, _config: &Config, crate_path: &Path) -> Result> { Ok(Box::new(Step { crate_path: crate_path.into(), })) @@ -40,7 +40,7 @@ impl LinkOutputCheckStep for Step { "%ctaid.x;", "%tid.x;", ], - &["example$$Image", "example..image"], + &["_ZN7example5image", "example..image"], )), (Profile::Debug, "examples/intrinsics") => Some(( &[ @@ -50,7 +50,7 @@ impl LinkOutputCheckStep for Step { "%ntid.x;", "%ctaid.x;", "%tid.x;", - "example$$image$$Image", + "_ZN7example5image14Image", ], &["example..image..Image"], )), diff --git a/tests/steps/ir.rs b/tests/steps/ir.rs index 25db8d9..89d7cb9 100644 --- a/tests/steps/ir.rs +++ b/tests/steps/ir.rs @@ -17,7 +17,7 @@ impl StepFactory { } impl TestStepFactory for StepFactory { - fn initialize(&self, _config: &Config, crate_path: &Path) -> Result> { + fn initialize(&self, _config: &Config, crate_path: &Path) -> Result> { Ok(Box::new(Step { crate_path: crate_path.into(), })) @@ -41,7 +41,7 @@ impl LinkOutputCheckStep for Step { "tail call signext i32 @llvm.nvvm.read.ptx.sreg.tid.x()", "declare signext i32 @vprintf(i8* nocapture readonly, i8*)", ], - &["example$$image", "example..image"], + &["_ZN7example5image", "example..image"], )), (Profile::Debug, "examples/intrinsics") => Some(( &[ @@ -51,7 +51,7 @@ impl LinkOutputCheckStep for Step { "call signext i32 @llvm.nvvm.read.ptx.sreg.ntid.x()", "call signext i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()", "call signext i32 @llvm.nvvm.read.ptx.sreg.tid.x()", - "example$$image$$Image", + "_ZN7example5image14Image", "declare signext i32 @vprintf(i8*, i8*)", "declare i8* @malloc(i64)", "declare void @free(i8*)", diff --git a/tests/steps/verification.rs b/tests/steps/verification.rs index bdfd40b..aabafd0 100644 --- a/tests/steps/verification.rs +++ b/tests/steps/verification.rs @@ -23,7 +23,7 @@ impl StepFactory { } impl TestStepFactory for StepFactory { - fn initialize(&self, _config: &Config, _crate_path: &Path) -> Result> { + fn initialize(&self, _config: &Config, _crate_path: &Path) -> Result> { Ok(Box::new(Step {})) } } From 6a7b45572e9b31dc825b3cfc8258f8ea49663086 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Fri, 3 Jan 2020 00:13:23 +0900 Subject: [PATCH 24/27] Use LLVM6 --- Cargo.lock | 51 ++++++++++++++++++++++++++++++++++++++++++--------- Cargo.toml | 2 +- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13359bf..ac08239 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,13 +224,13 @@ dependencies = [ [[package]] name = "llvm-sys" -version = "70.1.0" +version = "60.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -269,9 +269,9 @@ dependencies = [ "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "llvm-sys 60.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-llvm-proxy 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -385,6 +385,18 @@ dependencies = [ "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex" version = "1.1.0" @@ -397,6 +409,14 @@ dependencies = [ "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex-syntax" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" version = "0.6.4" @@ -420,7 +440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-llvm-proxy" -version = "0.1.9" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -428,9 +448,9 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "llvm-sys 60.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -498,6 +518,16 @@ name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "syn" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "0.15.26" @@ -665,7 +695,7 @@ dependencies = [ "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60a9ee82fe0fa72ae6ef6d018b407296085863836451c7a97384f84ed7e26b9f" +"checksum llvm-sys 60.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6408460c3a65414ed87f2b2ab6ebe9a2fa94d954f3b5eeaacb998218ecb42442" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" @@ -682,11 +712,13 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" +"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum rustc-llvm-proxy 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cd81d364e5ac962be1fae5eafbcbb845b997fa92fdf7616421c435eac0562137" +"checksum rustc-llvm-proxy 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9e3ec23ded8fe4603e5290f327165255e9717c4939787da77a7f87a0e3fb73d1" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" @@ -696,6 +728,7 @@ dependencies = [ "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" "checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" diff --git a/Cargo.toml b/Cargo.toml index 2424824..d6f5db6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ clap = "2.33" either = "1.5" env_logger = "0.7" failure = "0.1" -llvm-sys = "70" +llvm-sys = "60" log = "0.4" [dependencies.rustc-llvm-proxy] From bd66dc90f4636d3f674ff7265ae77cc1195217c9 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Fri, 3 Jan 2020 00:15:32 +0900 Subject: [PATCH 25/27] Revert changes about LLVMGetValueName2 --- src/passes/external_references.rs | 6 +----- src/passes/internalize.rs | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/passes/external_references.rs b/src/passes/external_references.rs index 316f857..50505fb 100644 --- a/src/passes/external_references.rs +++ b/src/passes/external_references.rs @@ -31,11 +31,7 @@ impl FindExternalReferencesPass { impl CallVisitor for FindExternalReferencesPass { fn visit_call(&mut self, _caller: LLVMValueRef, callee: LLVMValueRef) -> bool { - let callee_name = unsafe { - let mut callee_name_len = 0; - - CStr::from_ptr(LLVMGetValueName2(callee, &mut callee_name_len)).to_string_lossy() - }; + let callee_name = unsafe { CStr::from_ptr(LLVMGetValueName(callee)).to_string_lossy() }; let is_declaration = unsafe { LLVMGetValueKind(callee) == LLVMValueKind::LLVMFunctionValueKind diff --git a/src/passes/internalize.rs b/src/passes/internalize.rs index 31afc38..3b8e9b6 100644 --- a/src/passes/internalize.rs +++ b/src/passes/internalize.rs @@ -20,11 +20,7 @@ impl InternalizePass { impl FunctionVisitor for InternalizePass { fn visit_function(&mut self, function: LLVMValueRef) -> bool { - let function_name = unsafe { - let mut function_name_len = 0; - - CStr::from_ptr(LLVMGetValueName2(function, &mut function_name_len)).to_string_lossy() - }; + let function_name = unsafe { CStr::from_ptr(LLVMGetValueName(function)).to_string_lossy() }; let is_kernel = unsafe { LLVMGetFunctionCallConv(function) == PTX_KERNEL_CALL_CONV }; let is_intrinsic = function_name.starts_with("llvm."); From 9b703b337b4fe7478fb57c370c7cfa565d28f8bd Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Fri, 3 Jan 2020 00:27:56 +0900 Subject: [PATCH 26/27] Fix cargo version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d6f5db6..5840cc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ptx-linker" -version = "0.9.0" +version = "0.8.0" authors = ["Denys Zariaiev "] license = "MIT" From 8aa56d738f24f48353b7d06da91afae74947b365 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Fri, 3 Jan 2020 00:29:21 +0900 Subject: [PATCH 27/27] Fix to 0.8.3 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5840cc3..a6c235f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ptx-linker" -version = "0.8.0" +version = "0.8.3" authors = ["Denys Zariaiev "] license = "MIT"