Skip to content

Use similar compression settings as before updating to use flate2 #43147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ use std::io::{self, Read};
use std::path::{Path, PathBuf};
use std::time::Instant;

use flate2::read::ZlibDecoder;
use flate2::read::DeflateDecoder;
use owning_ref::{ErasedBoxRef, OwningRef};

pub struct CrateMismatch {
Expand Down Expand Up @@ -862,7 +862,7 @@ fn get_metadata_section_imp(target: &Target,
let compressed_bytes = &buf[header_len..];
debug!("inflating {} bytes of compressed metadata", compressed_bytes.len());
let mut inflated = Vec::new();
match ZlibDecoder::new(compressed_bytes).read_to_end(&mut inflated) {
match DeflateDecoder::new(compressed_bytes).read_to_end(&mut inflated) {
Ok(_) => {
let buf = unsafe { OwningRef::new_assert_stable_address(inflated) };
buf.map_owner_box().erase_owner()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;
use flate2::Compression;
use flate2::write::ZlibEncoder;
use flate2::write::DeflateEncoder;
use syntax::ast;
use syntax::attr;
use syntax_pos::Span;
Expand Down Expand Up @@ -622,7 +622,7 @@ fn link_rlib<'a>(sess: &'a Session,
}

let mut bc_data_deflated = Vec::new();
ZlibEncoder::new(&mut bc_data_deflated, Compression::Default)
DeflateEncoder::new(&mut bc_data_deflated, Compression::Fast)
.write_all(&bc_data).unwrap();

let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc::hir::def_id::LOCAL_CRATE;
use back::write::{ModuleConfig, with_llvm_pmb, CodegenContext};

use libc;
use flate2::read::ZlibDecoder;
use flate2::read::DeflateDecoder;

use std::io::Read;
use std::ffi::CString;
Expand Down Expand Up @@ -111,7 +111,7 @@ pub fn run(cgcx: &CodegenContext,
(link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as usize)];

let mut inflated = Vec::new();
let res = ZlibDecoder::new(compressed_data)
let res = DeflateDecoder::new(compressed_data)
.read_to_end(&mut inflated);
if res.is_err() {
let msg = format!("failed to decompress bc of `{}`",
Expand All @@ -131,7 +131,7 @@ pub fn run(cgcx: &CodegenContext,
// simply inflate everything and let LLVM decide if it can
// make sense of it
let mut inflated = Vec::new();
let res = ZlibDecoder::new(bc_encoded)
let res = DeflateDecoder::new(bc_encoded)
.read_to_end(&mut inflated);
if res.is_err() {
let msg = format!("failed to decompress bc of `{}`",
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
-> (ContextRef, ModuleRef, EncodedMetadata) {
use std::io::Write;
use flate2::Compression;
use flate2::write::ZlibEncoder;
use flate2::write::DeflateEncoder;

let (metadata_llcx, metadata_llmod) = unsafe {
context::create_context_and_module(tcx.sess, "metadata")
Expand Down Expand Up @@ -770,7 +770,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,

assert!(kind == MetadataKind::Compressed);
let mut compressed = cstore.metadata_encoding_version().to_vec();
ZlibEncoder::new(&mut compressed, Compression::Default)
DeflateEncoder::new(&mut compressed, Compression::Fast)
.write_all(&metadata.raw_data).unwrap();

let llmeta = C_bytes_in_context(metadata_llcx, &compressed);
Expand Down