Auto merge of #42664 - alexcrichton:moar-crates, r=eddyb

Remove in-tree flate/getopts crates

Remove `src/libflate` in favor of `flate2` on crates.io and `src/libgetopts` in favor of `getopts` on crates.io. The replacements have slightly different APIs and the usage in the compiler has been updated to reflect this.

This uncovered an unfortunate limitation of the compiler today to deal with linking everything correctly, and the workaround can be found documented in `src/librustc/Cargo.toml`.
This commit is contained in:
bors 2017-06-21 06:27:36 +00:00
commit 37a991abc0
33 changed files with 389 additions and 2409 deletions

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, libc, compiler_builtins_lib)]
#![feature(lang_items, alloc_system, compiler_builtins_lib)]
#![crate_type = "dylib"]
#![no_std]
extern crate libc;
extern crate alloc_system;
extern crate compiler_builtins;
#[no_mangle]

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, libc, compiler_builtins_lib)]
#![feature(lang_items, alloc_system, compiler_builtins_lib)]
#![no_std]
#![crate_type = "dylib"]
extern crate libc;
extern crate alloc_system;
extern crate compiler_builtins;
#[no_mangle]

View file

@ -17,7 +17,6 @@ extern crate graphviz;
extern crate krate2;
extern crate krate2 as krate3;
extern crate flate as myflate;
use graphviz::RenderOption;
use std::collections::{HashMap,HashSet};
@ -51,7 +50,6 @@ fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) {
krate2::hello();
krate3::hello();
myflate::deflate_bytes(&[]);
let x = (3isize, 4usize);
let y = x.1;

View file

@ -18,7 +18,6 @@ extern crate graphviz;
extern crate krate2;
extern crate krate2 as krate3;
extern crate flate as myflate;
use graphviz::RenderOption;
use std::collections::{HashMap,HashSet};
@ -52,7 +51,6 @@ fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) {
krate2::hello();
krate3::hello();
myflate::deflate_bytes(&[]);
let x = (3isize, 4usize);
let y = x.1;

View file

@ -10,33 +10,40 @@
// no-prefer-dynamic
#![feature(allocator, core_intrinsics, libc)]
#![feature(allocator, core_intrinsics)]
#![allocator]
#![crate_type = "rlib"]
#![no_std]
extern crate libc;
pub static mut HITS: usize = 0;
type size_t = usize;
extern {
fn malloc(size: usize) -> *mut u8;
fn free(ptr: *mut u8);
fn calloc(size: usize, amt: usize) -> *mut u8;
fn realloc(ptr: *mut u8, size: usize) -> *mut u8;
}
#[no_mangle]
pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
unsafe {
HITS += 1;
libc::malloc(size as libc::size_t) as *mut u8
malloc(size as size_t) as *mut u8
}
}
#[no_mangle]
pub extern fn __rust_allocate_zeroed(size: usize, _align: usize) -> *mut u8 {
unsafe { libc::calloc(size as libc::size_t, 1) as *mut u8 }
unsafe { calloc(size as size_t, 1) as *mut u8 }
}
#[no_mangle]
pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
unsafe {
HITS += 1;
libc::free(ptr as *mut _)
free(ptr as *mut _)
}
}
@ -44,7 +51,7 @@ pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> *mut u8 {
unsafe {
libc::realloc(ptr as *mut _, size as libc::size_t) as *mut u8
realloc(ptr as *mut _, size as size_t) as *mut u8
}
}

View file

@ -1,28 +0,0 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_private)]
extern crate getopts;
use getopts::{optopt, getopts};
pub fn main() {
let args = Vec::new();
let opts = vec![optopt("b", "", "something", "SMTHNG")];
match getopts(&args, &opts) {
Ok(ref m) =>
assert!(!m.opt_present("b")),
Err(ref f) => panic!("{}", *f)
};
}

View file

@ -11,11 +11,12 @@
// Smallest "hello world" with a libc runtime
// pretty-expanded FIXME #23616
// ignore-windows
#![feature(intrinsics, lang_items, start, no_core, libc)]
#![feature(intrinsics, lang_items, start, no_core, alloc_system)]
#![no_core]
extern crate libc;
extern crate alloc_system;
extern { fn puts(s: *const u8); }
extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }