Update the bootstrap compiler

Now that we've got a beta build, let's use it!
This commit is contained in:
Alex Crichton 2016-11-16 09:19:02 -08:00
parent 8e373b4787
commit 2186660b51
52 changed files with 30 additions and 559 deletions

View File

@ -65,7 +65,7 @@ HOST_CRATES := syntax syntax_ext proc_macro_tokens proc_macro_plugin syntax_pos
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
DEPS_core :=
DEPS_compiler_builtins := core
DEPS_compiler_builtins := core native:compiler-rt
DEPS_alloc := core libc alloc_system
DEPS_alloc_system := core libc
DEPS_alloc_jemalloc := core libc native:jemalloc
@ -79,11 +79,7 @@ DEPS_panic_unwind := libc alloc unwind
DEPS_unwind := libc
RUSTFLAGS_compiler_builtins := -lstatic=compiler-rt
# FIXME(stage0): change this to just `RUSTFLAGS_panic_abort := ...`
RUSTFLAGS1_panic_abort := -C panic=abort
RUSTFLAGS2_panic_abort := -C panic=abort
RUSTFLAGS3_panic_abort := -C panic=abort
RUSTFLAGS_panic_abort := -C panic=abort
DEPS_std := core libc rand alloc collections compiler_builtins rustc_unicode \
native:backtrace \

View File

@ -372,15 +372,12 @@ CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATUR
# Turn on feature-staging
export CFG_DISABLE_UNSTABLE_FEATURES
# Subvert unstable feature lints to do the self-build
export RUSTC_BOOTSTRAP=1
endif
ifdef CFG_MUSL_ROOT
export CFG_MUSL_ROOT
endif
# FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
# Remove this once the bootstrap compiler uses the new login in Issue #36548.
export RUSTC_BOOTSTRAP_KEY=62b3e239
export RUSTC_BOOTSTRAP := 1
######################################################################
# Per-stage targets and runner
@ -443,10 +440,7 @@ endif
TSREQ$(1)_T_$(2)_H_$(3) = \
$$(HSREQ$(1)_H_$(3)) \
$$(foreach obj,$$(REQUIRED_OBJECTS_$(2)),\
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj)) \
$$(TLIB0_T_$(2)_H_$(3))/$$(call CFG_STATIC_LIB_NAME_$(2),compiler-rt)
# ^ This copies `libcompiler-rt.a` to the stage0 sysroot
# ^ TODO(stage0) update this to not copy `libcompiler-rt.a` to stage0
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj))
# Prerequisites for a working stageN compiler and libraries, for a specific
# target

7
src/Cargo.lock generated
View File

@ -45,7 +45,6 @@ dependencies = [
"gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
@ -172,11 +171,6 @@ name = "log"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "md5"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num_cpus"
version = "0.2.13"
@ -686,7 +680,6 @@ dependencies = [
"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
"checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8"
"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"
"checksum md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5539a8dee9b4ae308c9c406a379838b435a8f2c84cf9fedc6d5a576be9888db"
"checksum num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3"
"checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b"
"checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796"

View File

@ -11,3 +11,20 @@ members = [
"tools/rustbook",
"tools/tidy",
]
# Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit
# MSVC when running the compile-fail test suite when a should-fail test panics.
# But hey if this is removed and it gets past the bots, sounds good to me.
[profile.release]
opt-level = 2
[profile.bench]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
[profile.test]
debug = false
debug-assertions = false

View File

@ -29,4 +29,3 @@ getopts = "0.2"
rustc-serialize = "0.3"
gcc = "0.3.38"
libc = "0.2"
md5 = "0.1"

View File

@ -20,7 +20,6 @@ use std::io::prelude::*;
use std::process::Command;
use build_helper::output;
use md5;
use Build;
@ -91,20 +90,4 @@ pub fn collect(build: &mut Build) {
build.ver_hash = Some(ver_hash);
build.short_ver_hash = Some(short_ver_hash);
}
// Calculate this compiler's bootstrap key, which is currently defined as
// the first 8 characters of the md5 of the release string.
let key = md5::compute(build.release.as_bytes());
build.bootstrap_key = format!("{:02x}{:02x}{:02x}{:02x}",
key[0], key[1], key[2], key[3]);
// Slurp up the stage0 bootstrap key as we're bootstrapping from an
// otherwise stable compiler.
let mut s = String::new();
t!(t!(File::open(build.src.join("src/stage0.txt"))).read_to_string(&mut s));
if let Some(line) = s.lines().find(|l| l.starts_with("rustc_key")) {
if let Some(key) = line.split(": ").nth(1) {
build.bootstrap_key_stage0 = key.to_string();
}
}
}

View File

@ -220,7 +220,7 @@ pub fn compiletest(build: &Build,
}
}
}
build.add_bootstrap_key(&mut cmd);
cmd.env("RUSTC_BOOTSTRAP", "1");
cmd.arg("--adb-path").arg("adb");
cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);

View File

@ -120,8 +120,8 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
let file = t!(file);
let mut cmd = Command::new(&compiler_path);
build.add_bootstrap_key(&mut cmd);
build.run(cmd.arg("--target").arg(target)
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
.arg("--target").arg(target)
.arg("--emit=obj")
.arg("--out-dir").arg(into)
.arg(file.path()));

View File

@ -22,7 +22,6 @@ extern crate cmake;
extern crate filetime;
extern crate gcc;
extern crate getopts;
extern crate md5;
extern crate num_cpus;
extern crate rustc_serialize;
extern crate toml;
@ -120,8 +119,6 @@ pub struct Build {
version: String,
package_vers: String,
local_rebuild: bool,
bootstrap_key: String,
bootstrap_key_stage0: String,
// Probed tools at runtime
lldb_version: Option<String>,
@ -205,8 +202,6 @@ impl Build {
ver_date: None,
version: String::new(),
local_rebuild: local_rebuild,
bootstrap_key: String::new(),
bootstrap_key_stage0: String::new(),
package_vers: String::new(),
cc: HashMap::new(),
cxx: HashMap::new(),
@ -438,7 +433,8 @@ impl Build {
.env("RUSTDOC_REAL", self.rustdoc(compiler))
.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
self.add_bootstrap_key(&mut cargo);
// Enable usage of unstable features
cargo.env("RUSTC_BOOTSTRAP", "1");
// Specify some various options for build scripts used throughout
// the build.
@ -655,14 +651,6 @@ impl Build {
add_lib_path(vec![self.rustc_libdir(compiler)], cmd);
}
/// Adds the compiler's bootstrap key to the environment of `cmd`.
fn add_bootstrap_key(&self, cmd: &mut Command) {
cmd.env("RUSTC_BOOTSTRAP", "1");
// FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
// Remove this once the bootstrap compiler uses the new login in Issue #36548.
cmd.env("RUSTC_BOOTSTRAP_KEY", "62b3e239");
}
/// Returns the compiler's libdir where it stores the dynamic libraries that
/// it itself links against.
///

View File

@ -89,7 +89,6 @@
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(never_type)]
#![feature(prelude_import)]

View File

@ -295,7 +295,6 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(str_escape)]
#![cfg_attr(stage0, feature(question_mark))]
use self::LabelText::*;

View File

@ -31,7 +31,6 @@
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![cfg_attr(stage0, feature(item_like_imports))]
#![feature(libc)]
#![feature(nonzero)]
@ -41,7 +40,6 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
extern crate arena;

View File

@ -36,7 +36,6 @@
#![feature(rand)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(rand))]
extern crate syntax;

View File

@ -19,14 +19,12 @@
#![allow(non_camel_case_types)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(associated_consts)]
#![feature(nonzero)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;

View File

@ -22,12 +22,10 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(box_patterns)]
#![feature(box_syntax)]

View File

@ -25,7 +25,6 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -24,14 +24,12 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(box_syntax)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(libc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate flate;

View File

@ -21,7 +21,6 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(range_contains)]
#![feature(libc)]
#![feature(unicode)]

View File

@ -19,8 +19,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), deny(warnings))]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(rand)]

View File

@ -31,7 +31,6 @@
#![cfg_attr(test, feature(test))]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -24,11 +24,11 @@
#![feature(associated_consts)]
#![feature(box_syntax)]
#![feature(concat_idents)]
#![feature(libc)]
#![feature(link_args)]
#![feature(staged_api)]
#![feature(linked_from)]
#![feature(concat_idents)]
#![feature(staged_api)]
extern crate libc;

View File

@ -20,10 +20,8 @@
#![feature(box_patterns)]
#![feature(conservative_impl_trait)]
#![feature(core_intrinsics)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(proc_macro_internals)]
#![feature(proc_macro_lib)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -22,12 +22,10 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(associated_consts)]
#![feature(box_patterns)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![cfg_attr(stage0, feature(item_like_imports))]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
extern crate graphviz as dot;

View File

@ -23,7 +23,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), deny(warnings))]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(rustc_diagnostic_macros)]
#![feature(staged_api)]
#![feature(rustc_private)]

View File

@ -17,7 +17,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), deny(warnings))]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]

View File

@ -19,7 +19,6 @@
#![feature(associated_consts)]
#![feature(borrow_state)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]

View File

@ -18,7 +18,6 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(custom_attribute)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]

View File

@ -29,7 +29,6 @@
#![feature(cell_extras)]
#![feature(const_fn)]
#![feature(custom_attribute)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![allow(unused_attributes)]
#![feature(libc)]
#![feature(quote)]
@ -38,7 +37,6 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unicode)]
#![cfg_attr(stage0, feature(question_mark))]
use rustc::dep_graph::WorkProduct;

View File

@ -77,12 +77,10 @@ This API is completely unstable and subject to change.
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -20,7 +20,6 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(libc)]
#![feature(rustc_private)]
#![feature(set_stdio)]
@ -28,7 +27,6 @@
#![feature(staged_api)]
#![feature(test)]
#![feature(unicode)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate getopts;

View File

@ -35,7 +35,6 @@ Core encoding and decoding interfaces.
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unicode)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
// test harness access

View File

@ -249,7 +249,6 @@
#![feature(const_fn)]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(dropck_parametricity)]
#![feature(float_extras)]
#![feature(float_from_str_radix)]
@ -276,7 +275,6 @@
#![feature(panic_unwind)]
#![feature(placement_in_syntax)]
#![feature(prelude_import)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rand)]
#![feature(raw)]
#![feature(repr_simd)]

View File

@ -32,10 +32,8 @@
#![feature(staged_api)]
#![feature(str_escape)]
#![feature(unicode)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_diagnostic_macros)]
#![feature(specialization)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
extern crate core;
extern crate serialize;

View File

@ -19,7 +19,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), deny(warnings))]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(proc_macro_lib)]
#![feature(proc_macro_internals)]
#![feature(rustc_private)]

View File

@ -27,7 +27,6 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(specialization)]
use std::cell::{Cell, RefCell};

View File

@ -59,7 +59,6 @@
#![cfg_attr(windows, feature(libc))]
// Handle rustfmt skips
#![feature(custom_attribute)]
#![cfg_attr(stage0, feature(question_mark))]
#![allow(unused_attributes)]
use std::io::prelude::*;

View File

@ -38,7 +38,6 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(panic_unwind)]
extern crate getopts;

View File

@ -11,17 +11,6 @@ path = "rustc.rs"
name = "rustdoc"
path = "rustdoc.rs"
[profile.release]
opt-level = 2
[profile.bench]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
# All optional dependencies so the features passed to this Cargo.toml select
# what should actually be built.
[dependencies]

View File

@ -28,17 +28,6 @@ authors = ["The Rust Project Developers"]
name = "std_shim"
path = "lib.rs"
[profile.release]
opt-level = 2
[profile.bench]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
[dependencies]
std = { path = "../../libstd" }
core = { path = "../../libcore" }

View File

@ -12,16 +12,5 @@ authors = ["The Rust Project Developers"]
name = "test_shim"
path = "lib.rs"
[profile.release]
opt-level = 2
[profile.bench]
opt-level = 2
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
[dependencies]
test = { path = "../../libtest" }

View File

@ -12,5 +12,5 @@
# tarball for a stable release you'll likely see `1.x.0-$date` where `1.x.0` was
# released on `$date`
rustc: beta-2016-09-28
cargo: nightly-2016-09-26
rustc: beta-2016-11-16
cargo: nightly-2016-11-16

View File

@ -4,12 +4,6 @@ name = "compiletest"
version = "0.0.0"
build = "build.rs"
# Curiously, this will segfault if compiled with opt-level=3 on 64-bit MSVC when
# running the compile-fail test suite when a should-fail test panics. But hey if
# this is removed and it gets past the bots, sounds good to me.
[profile.release]
opt-level = 2
[dependencies]
log = "0.3"
env_logger = { version = "0.3.5", default-features = false }

View File

@ -16,8 +16,6 @@
#![feature(test)]
#![feature(libc)]
#![cfg_attr(stage0, feature(question_mark))]
#![deny(warnings)]
extern crate libc;

View File

@ -1 +0,0 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"944bf600c6230664922a011cbca026699969f2f89f6c7ff689835836ccd7b1de",".travis.yml":"3d7b50e89ac6ecc0c3a31273c1785a905aa528ccf70503973bf34fa49537519f","Cargo.toml":"7ed65153877c1057bac21ad6483ae2f6feb7713da2516f788528c81c222e1686","LICENSE.txt":"2362080adc3f0fb1a071ffe7dc5557cbb420058f319e284d53213a1e05687242","README.md":"f96785f9a0782f425cde37f0e4ec577f1097f92c38af291509e3953c20e9b87f","benches/lib.rs":"7ae37fded40473821a1e0d898d3e978efddfd1a2d2efcd550b84089932c8db23","src/lib.rs":"208c67b843ebbc02be1649dd40235088bf87d00c1a336a162118b4f352a03cb0"},"package":"a5539a8dee9b4ae308c9c406a379838b435a8f2c84cf9fedc6d5a576be9888db"}

View File

View File

@ -1,2 +0,0 @@
Cargo.lock
target

View File

@ -1,11 +0,0 @@
language: rust
sudo: required
after_success: curl https://stainless-steel.github.io/travis/after_success.sh | bash
env:
global:
secure: wq8fhRMctnvAck7rhva9151pveqKYK9uER9Dytdz1UIzWGbtuS5vpGdgc7txW/xtdyuLGbioPvziCvFvoQbGd3NfWpRM1fo4AIwaOxFpKgPPywgFrlBtqp1XmBmJUaAxcwMtQCbY7f0Q48ycQZsmuXRQSkMEXlXURNh8us96MP5Rm9B4UndArVUe/tEXqy8SNKFMHqKja6okvDg03hRDtfQtk8lu1+QkguA5Zd0tpNBw9UjxoUn/FL0yCP0hq0VP6It680hRAJmhpJ8XRayGvbb+PX2VZNcgHpMxtsoY2zAR5j+I6mVwjC8VMIeUMQQbu6yUeFrDQYpBC9d4syRupluNLLzbxzl3Pb6yUYjT6deniRJA5H4Bs5V68a5/wTaapmqkAUIZKiPYpQr4L0MGSyHvLuWf1L3WdOmJkUvsPUIJExqEpNFRhEPIc7a5ZcyzeFFYRTa1VnMaNlLB0ZP5fF5Mgjmh0cvq88LnrSZI9t3obJMD4F0GKLuI2tJM57WWCHETWziAtQ2h2Cx8J/tivH/zT78yrkzl4tX5garFG4C2OWDdyhX/8zFG197RYKb9fI802um9FHXO6fpq1G3GUH8sZhDZYn3MeexGvbKI0Rb48toBl7EjbPaIuE/PE4O0UoK5WJqJCS2lBgZMs64phcRef7/sRHga4znBea75TTI=
notifications:
email: false

View File

@ -1,9 +0,0 @@
[package]
name = "md5"
version = "0.1.1"
authors = ["Ivan Ukhov <ivan.ukhov@gmail.com>"]
license = "MIT"
repository = "https://github.com/stainless-steel/md5"
homepage = "https://github.com/stainless-steel/md5"
documentation = "https://stainless-steel.github.io/md5"
description = "The package provides the MD5 hash function."

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright 2015 Ivan Ukhov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,19 +0,0 @@
# MD5 [![Version][version-img]][version-url] [![Status][status-img]][status-url]
The package provides the [MD5][1] hash function.
## [Documentation][doc]
## Contributing
1. Fork the project.
2. Implement your idea.
3. Open a pull request.
[1]: https://en.wikipedia.org/wiki/MD5
[version-img]: https://img.shields.io/crates/v/md5.svg
[version-url]: https://crates.io/crates/md5
[status-img]: https://travis-ci.org/stainless-steel/md5.svg?branch=master
[status-url]: https://travis-ci.org/stainless-steel/md5
[doc]: https://stainless-steel.github.io/md5

View File

@ -1,16 +0,0 @@
#![feature(test)]
extern crate md5;
extern crate test;
#[bench] fn compute_0001000(bencher: &mut test::Bencher) { compute( 1000, bencher); }
#[bench] fn compute_0010000(bencher: &mut test::Bencher) { compute( 10000, bencher); }
#[bench] fn compute_0100000(bencher: &mut test::Bencher) { compute( 100000, bencher); }
#[bench] fn compute_1000000(bencher: &mut test::Bencher) { compute(1_000000, bencher); }
fn compute(size: usize, bencher: &mut test::Bencher) {
let data = &vec![0xFFu8; size][..];
bencher.iter(|| {
test::black_box(md5::compute(data));
});
}

View File

@ -1,340 +0,0 @@
//! The [MD5][1] hash function.
//!
//! [1]: https://en.wikipedia.org/wiki/MD5
// The implementation is based on:
// http://people.csail.mit.edu/rivest/Md5.c
use std::convert::From;
use std::io::{Result, Write};
use std::mem;
/// A digest.
pub type Digest = [u8; 16];
/// A context.
#[derive(Copy)]
pub struct Context {
handled: [u32; 2],
buffer: [u32; 4],
input: [u8; 64],
}
impl Clone for Context {
#[inline]
fn clone(&self) -> Context { *self }
}
const PADDING: [u8; 64] = [
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
impl Context {
/// Create a context for computing a digest.
#[inline]
pub fn new() -> Context {
Context {
handled: [0, 0],
buffer: [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476],
input: unsafe { mem::uninitialized() },
}
}
/// Consume data.
pub fn consume(&mut self, data: &[u8]) {
let mut input: [u32; 16] = unsafe { mem::uninitialized() };
let mut k = ((self.handled[0] >> 3) & 0x3F) as usize;
let length = data.len() as u32;
if (self.handled[0] + (length << 3)) < self.handled[0] {
self.handled[1] += 1;
}
self.handled[0] += length << 3;
self.handled[1] += length >> 29;
for &value in data {
self.input[k] = value;
k += 1;
if k != 0x40 {
continue;
}
let mut j = 0;
for i in 0..16 {
input[i] = ((self.input[j + 3] as u32) << 24) |
((self.input[j + 2] as u32) << 16) |
((self.input[j + 1] as u32) << 8) |
((self.input[j ] as u32) );
j += 4;
}
transform(&mut self.buffer, &input);
k = 0;
}
}
/// Finalize and return the digest.
pub fn compute(mut self) -> Digest {
let mut input: [u32; 16] = unsafe { mem::uninitialized() };
let k = ((self.handled[0] >> 3) & 0x3F) as usize;
input[14] = self.handled[0];
input[15] = self.handled[1];
self.consume(&PADDING[..(if k < 56 { 56 - k } else { 120 - k })]);
let mut j = 0;
for i in 0..14 {
input[i] = ((self.input[j + 3] as u32) << 24) |
((self.input[j + 2] as u32) << 16) |
((self.input[j + 1] as u32) << 8) |
((self.input[j ] as u32) );
j += 4;
}
transform(&mut self.buffer, &input);
let mut digest: Digest = unsafe { mem::uninitialized() };
let mut j = 0;
for i in 0..4 {
digest[j ] = ((self.buffer[i] ) & 0xFF) as u8;
digest[j + 1] = ((self.buffer[i] >> 8) & 0xFF) as u8;
digest[j + 2] = ((self.buffer[i] >> 16) & 0xFF) as u8;
digest[j + 3] = ((self.buffer[i] >> 24) & 0xFF) as u8;
j += 4;
}
digest
}
}
impl Write for Context {
#[inline]
fn write(&mut self, data: &[u8]) -> Result<usize> {
self.consume(data);
Ok(data.len())
}
#[inline]
fn flush(&mut self) -> Result<()> {
Ok(())
}
}
impl From<Context> for Digest {
#[inline]
fn from(context: Context) -> Digest {
context.compute()
}
}
/// Compute the digest of data.
#[inline]
pub fn compute(data: &[u8]) -> Digest {
let mut context = Context::new();
context.consume(data);
context.compute()
}
fn transform(buffer: &mut [u32; 4], input: &[u32; 16]) {
let (mut a, mut b, mut c, mut d) = (buffer[0], buffer[1], buffer[2], buffer[3]);
macro_rules! add(
($a:expr, $b:expr) => ($a.wrapping_add($b));
);
macro_rules! rotate(
($x:expr, $n:expr) => (($x << $n) | ($x >> (32 - $n)));
);
{
macro_rules! F(
($x:expr, $y:expr, $z:expr) => (($x & $y) | (!$x & $z));
);
macro_rules! T(
($a:expr, $b:expr, $c:expr, $d:expr, $x:expr, $s:expr, $ac:expr) => ({
$a = add!(add!(add!($a, F!($b, $c, $d)), $x), $ac);
$a = rotate!($a, $s);
$a = add!($a, $b);
});
);
const S1: u32 = 7;
const S2: u32 = 12;
const S3: u32 = 17;
const S4: u32 = 22;
T!(a, b, c, d, input[ 0], S1, 3614090360);
T!(d, a, b, c, input[ 1], S2, 3905402710);
T!(c, d, a, b, input[ 2], S3, 606105819);
T!(b, c, d, a, input[ 3], S4, 3250441966);
T!(a, b, c, d, input[ 4], S1, 4118548399);
T!(d, a, b, c, input[ 5], S2, 1200080426);
T!(c, d, a, b, input[ 6], S3, 2821735955);
T!(b, c, d, a, input[ 7], S4, 4249261313);
T!(a, b, c, d, input[ 8], S1, 1770035416);
T!(d, a, b, c, input[ 9], S2, 2336552879);
T!(c, d, a, b, input[10], S3, 4294925233);
T!(b, c, d, a, input[11], S4, 2304563134);
T!(a, b, c, d, input[12], S1, 1804603682);
T!(d, a, b, c, input[13], S2, 4254626195);
T!(c, d, a, b, input[14], S3, 2792965006);
T!(b, c, d, a, input[15], S4, 1236535329);
}
{
macro_rules! F(
($x:expr, $y:expr, $z:expr) => (($x & $z) | ($y & !$z));
);
macro_rules! T(
($a:expr, $b:expr, $c:expr, $d:expr, $x:expr, $s:expr, $ac:expr) => ({
$a = add!(add!(add!($a, F!($b, $c, $d)), $x), $ac);
$a = rotate!($a, $s);
$a = add!($a, $b);
});
);
const S1: u32 = 5;
const S2: u32 = 9;
const S3: u32 = 14;
const S4: u32 = 20;
T!(a, b, c, d, input[ 1], S1, 4129170786);
T!(d, a, b, c, input[ 6], S2, 3225465664);
T!(c, d, a, b, input[11], S3, 643717713);
T!(b, c, d, a, input[ 0], S4, 3921069994);
T!(a, b, c, d, input[ 5], S1, 3593408605);
T!(d, a, b, c, input[10], S2, 38016083);
T!(c, d, a, b, input[15], S3, 3634488961);
T!(b, c, d, a, input[ 4], S4, 3889429448);
T!(a, b, c, d, input[ 9], S1, 568446438);
T!(d, a, b, c, input[14], S2, 3275163606);
T!(c, d, a, b, input[ 3], S3, 4107603335);
T!(b, c, d, a, input[ 8], S4, 1163531501);
T!(a, b, c, d, input[13], S1, 2850285829);
T!(d, a, b, c, input[ 2], S2, 4243563512);
T!(c, d, a, b, input[ 7], S3, 1735328473);
T!(b, c, d, a, input[12], S4, 2368359562);
}
{
macro_rules! F(
($x:expr, $y:expr, $z:expr) => ($x ^ $y ^ $z);
);
macro_rules! T(
($a:expr, $b:expr, $c:expr, $d:expr, $x:expr, $s:expr, $ac:expr) => ({
$a = add!(add!(add!($a, F!($b, $c, $d)), $x), $ac);
$a = rotate!($a, $s);
$a = add!($a, $b);
});
);
const S1: u32 = 4;
const S2: u32 = 11;
const S3: u32 = 16;
const S4: u32 = 23;
T!(a, b, c, d, input[ 5], S1, 4294588738);
T!(d, a, b, c, input[ 8], S2, 2272392833);
T!(c, d, a, b, input[11], S3, 1839030562);
T!(b, c, d, a, input[14], S4, 4259657740);
T!(a, b, c, d, input[ 1], S1, 2763975236);
T!(d, a, b, c, input[ 4], S2, 1272893353);
T!(c, d, a, b, input[ 7], S3, 4139469664);
T!(b, c, d, a, input[10], S4, 3200236656);
T!(a, b, c, d, input[13], S1, 681279174);
T!(d, a, b, c, input[ 0], S2, 3936430074);
T!(c, d, a, b, input[ 3], S3, 3572445317);
T!(b, c, d, a, input[ 6], S4, 76029189);
T!(a, b, c, d, input[ 9], S1, 3654602809);
T!(d, a, b, c, input[12], S2, 3873151461);
T!(c, d, a, b, input[15], S3, 530742520);
T!(b, c, d, a, input[ 2], S4, 3299628645);
}
{
macro_rules! F(
($x:expr, $y:expr, $z:expr) => ($y ^ ($x | !$z));
);
macro_rules! T(
($a:expr, $b:expr, $c:expr, $d:expr, $x:expr, $s:expr, $ac:expr) => ({
$a = add!(add!(add!($a, F!($b, $c, $d)), $x), $ac);
$a = rotate!($a, $s);
$a = add!($a, $b);
});
);
const S1: u32 = 6;
const S2: u32 = 10;
const S3: u32 = 15;
const S4: u32 = 21;
T!(a, b, c, d, input[ 0], S1, 4096336452);
T!(d, a, b, c, input[ 7], S2, 1126891415);
T!(c, d, a, b, input[14], S3, 2878612391);
T!(b, c, d, a, input[ 5], S4, 4237533241);
T!(a, b, c, d, input[12], S1, 1700485571);
T!(d, a, b, c, input[ 3], S2, 2399980690);
T!(c, d, a, b, input[10], S3, 4293915773);
T!(b, c, d, a, input[ 1], S4, 2240044497);
T!(a, b, c, d, input[ 8], S1, 1873313359);
T!(d, a, b, c, input[15], S2, 4264355552);
T!(c, d, a, b, input[ 6], S3, 2734768916);
T!(b, c, d, a, input[13], S4, 1309151649);
T!(a, b, c, d, input[ 4], S1, 4149444226);
T!(d, a, b, c, input[11], S2, 3174756917);
T!(c, d, a, b, input[ 2], S3, 718787259);
T!(b, c, d, a, input[ 9], S4, 3951481745);
}
buffer[0] = add!(buffer[0], a);
buffer[1] = add!(buffer[1], b);
buffer[2] = add!(buffer[2], c);
buffer[3] = add!(buffer[3], d);
}
#[cfg(test)]
mod tests {
macro_rules! digest(
($string:expr) => ({
let mut context = ::Context::new();
context.consume($string.as_bytes());
let mut digest = String::with_capacity(2 * 16);
for x in &context.compute()[..] {
digest.push_str(&format!("{:02x}", x));
}
digest
});
);
#[test]
fn compute() {
let inputs = [
"",
"a",
"abc",
"message digest",
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
];
let outputs = [
"d41d8cd98f00b204e9800998ecf8427e",
"0cc175b9c0f1b6a831c399e269772661",
"900150983cd24fb0d6963f7d28e17f72",
"f96b697d7cb7938d525a2f31aaf161d0",
"c3fcd3d76192e4007dfb496cca67e13b",
"d174ab98d277d9f5a5611c2c9f419d9f",
"57edf4a22be3c955ac49da2e2107b67a",
];
for (input, &output) in inputs.iter().zip(outputs.iter()) {
assert_eq!(&digest!(input)[..], output);
}
}
}