Skip to content

Commit a4024c5

Browse files
committed
Remove the in-tree flate crate
A long time coming this commit removes the `flate` crate in favor of the `flate2` crate on crates.io. The functionality in `flate2` originally flowered out of `flate` itself and is additionally the namesake for the crate. This will leave a gap in the naming (there's not `flate` crate), which will likely cause a particle collapse of some form somewhere.
1 parent 380100c commit a4024c5

File tree

21 files changed

+71
-2131
lines changed

21 files changed

+71
-2131
lines changed

COPYRIGHT

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ The Rust Project includes packages written by third parties.
2222
The following third party packages are included, and carry
2323
their own copyright notices and license terms:
2424

25-
* The src/rt/miniz.c file, carrying an implementation of
26-
RFC1950/RFC1951 DEFLATE, by Rich Geldreich
27-
<[email protected]>. All uses of this file are
28-
permitted by the embedded "unlicense" notice
29-
(effectively: public domain with warranty disclaimer).
30-
3125
* LLVM. Code for this package is found in src/llvm.
3226

3327
Copyright (c) 2003-2013 University of Illinois at

src/libflate/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/libflate/build.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/libflate/lib.rs

Lines changed: 0 additions & 166 deletions
This file was deleted.

src/librustc/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,32 @@ rustc_errors = { path = "../librustc_errors" }
2222
serialize = { path = "../libserialize" }
2323
syntax = { path = "../libsyntax" }
2424
syntax_pos = { path = "../libsyntax_pos" }
25+
26+
# Note that these dependencies are a lie, they're just here to get linkage to
27+
# work.
28+
#
29+
# We're creating a bunch of dylibs for the compiler but we're also compiling a
30+
# bunch of crates.io crates. Everything in the compiler is compiled as an
31+
# rlib/dylib pair but all crates.io crates tend to just be rlibs. This means
32+
# we've got a problem for dependency graphs that look like:
33+
#
34+
# foo - rustc_trans
35+
# / \
36+
# rustc ---- rustc_driver
37+
# \ /
38+
# foo - rustc_metadata
39+
#
40+
# Here the crate `foo` is linked into the `rustc_trans` and the
41+
# `rustc_metadata` dylibs, meaning we've got duplicate copies! When we then
42+
# go to link `rustc_driver` the compiler notices this and gives us a compiler
43+
# error.
44+
#
45+
# To work around this problem we just add these crates.io dependencies to the
46+
# `rustc` crate which is a shared dependency above. That way the crate `foo`
47+
# shows up in the dylib for the `rustc` crate, deduplicating it and allowing
48+
# crates like `rustc_trans` to use `foo` *through* the `rustc` crate.
49+
#
50+
# tl;dr; this is not needed to get `rustc` to compile, but if you remove it then
51+
# later crate stop compiling. If you can remove this and everything
52+
# compiles, then please feel free to do so!
53+
flate2 = "0.2"

src/librustc/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ extern crate syntax_pos;
6363

6464
extern crate serialize as rustc_serialize; // used by deriving
6565

66+
extern crate flate2;
67+
6668
#[macro_use]
6769
mod macros;
6870

src/librustc_metadata/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ path = "lib.rs"
99
crate-type = ["dylib"]
1010

1111
[dependencies]
12-
flate = { path = "../libflate" }
12+
flate2 = "0.2"
1313
log = "0.3"
1414
owning_ref = "0.3.3"
1515
proc_macro = { path = "../libproc_macro" }

src/librustc_metadata/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern crate log;
3333
#[macro_use]
3434
extern crate syntax;
3535
extern crate syntax_pos;
36-
extern crate flate;
36+
extern crate flate2;
3737
extern crate serialize as rustc_serialize; // used by deriving
3838
extern crate owning_ref;
3939
extern crate rustc_errors as errors;

src/librustc_metadata/locator.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ use std::io::{self, Read};
242242
use std::path::{Path, PathBuf};
243243
use std::time::Instant;
244244

245-
use flate;
245+
use flate2::read::ZlibDecoder;
246246
use owning_ref::{ErasedBoxRef, OwningRef};
247247

248248
pub struct CrateMismatch {
@@ -861,8 +861,9 @@ fn get_metadata_section_imp(target: &Target,
861861
// Header is okay -> inflate the actual metadata
862862
let compressed_bytes = &buf[header_len..];
863863
debug!("inflating {} bytes of compressed metadata", compressed_bytes.len());
864-
match flate::inflate_bytes(compressed_bytes) {
865-
Ok(inflated) => {
864+
let mut inflated = Vec::new();
865+
match ZlibDecoder::new(compressed_bytes).read_to_end(&mut inflated) {
866+
Ok(_) => {
866867
let buf = unsafe { OwningRef::new_assert_stable_address(inflated) };
867868
buf.map_owner_box().erase_owner()
868869
}

src/librustc_trans/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["dylib"]
1010
test = false
1111

1212
[dependencies]
13-
flate = { path = "../libflate" }
13+
flate2 = "0.2"
1414
log = "0.3"
1515
owning_ref = "0.3.3"
1616
rustc = { path = "../librustc" }

0 commit comments

Comments
 (0)