Skip to content

Commit

Permalink
Auto merge of #29546 - alexcrichton:new-libc, r=brson
Browse files Browse the repository at this point in the history
This commit replaces the in-tree liblibc with the [external clone](https://github.com/rust-lang-nursery/libc) which has no evolved beyond the in-tree version in light of its [recent redesign](rust-lang/rfcs#1291).

The primary changes here are:

* `src/liblibc/lib.rs` was deleted
* `src/liblibc` is now a submodule pointing at the external repository
* `src/libstd/sys/unix/{c.rs,sync.rs}` were both deleted having all bindings folded into the external liblibc.
* Many ad-hoc `extern` blocks in the standard library were removed in favor of bindings now being in the external liblibc.
* Many functions/types were added to `src/libstd/sys/windows/c.rs`, and the scattered definitions throughout the standard library were consolidated here.

At the API level this commit is **not a breaking change**, although it is only very lightly tested on the *BSD variants and is probably going to break almost all of their builds! Follow-up commits to liblibc should in theory be all that's necessary to get the build working on the *BSDs again.
  • Loading branch information
bors committed Nov 10, 2015
2 parents 2968dfa + 3d28b8b commit 6aee7c5
Show file tree
Hide file tree
Showing 65 changed files with 1,899 additions and 9,621 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -14,3 +14,6 @@
[submodule "src/rust-installer"]
path = src/rust-installer
url = https://github.com/rust-lang/rust-installer
[submodule "src/liblibc"]
path = src/liblibc
url = https://github.com/rust-lang/libc
3 changes: 3 additions & 0 deletions mk/crates.mk
Expand Up @@ -174,3 +174,6 @@ $(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
ifdef CFG_DISABLE_ELF_TLS
RUSTFLAGS_std := --cfg no_elf_tls
endif

CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
RUSTFLAGS_libc := --cfg stdbuild
3 changes: 2 additions & 1 deletion mk/tests.mk
Expand Up @@ -22,7 +22,7 @@ $(eval $(call RUST_CRATE,coretest))
DEPS_collectionstest :=
$(eval $(call RUST_CRATE,collectionstest))

TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system \
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system libc \
alloc_jemalloc,$(TARGET_CRATES)) \
collectionstest coretest
TEST_DOC_CRATES = $(DOC_CRATES)
Expand Down Expand Up @@ -283,6 +283,7 @@ tidy-binaries:
| grep '^$(S)src/compiler-rt' -v \
| grep '^$(S)src/libbacktrace' -v \
| grep '^$(S)src/rust-installer' -v \
| grep '^$(S)src/liblibc' -v \
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py

.PHONY: tidy-errors
Expand Down
3 changes: 2 additions & 1 deletion src/etc/tidy.py
Expand Up @@ -108,7 +108,8 @@ def interesting_file(f):
'src/rustllvm',
'src/rt/valgrind',
'src/rt/msvc',
'src/rust-installer'
'src/rust-installer',
'src/liblibc',
}

if any(d in dirpath for d in skippable_dirs):
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_jemalloc/lib.rs
Expand Up @@ -14,6 +14,7 @@
#![staged_api]
#![no_std]
#![cfg_attr(not(stage0), allocator)]
#![cfg_attr(stage0, allow(improper_ctypes))]
#![unstable(feature = "alloc_jemalloc",
reason = "this library is unlikely to be stabilized in its current \
form or name",
Expand Down
9 changes: 8 additions & 1 deletion src/liballoc_system/lib.rs
Expand Up @@ -14,6 +14,7 @@
#![staged_api]
#![no_std]
#![cfg_attr(not(stage0), allocator)]
#![cfg_attr(stage0, allow(improper_ctypes))]
#![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \
form or name",
Expand Down Expand Up @@ -141,10 +142,16 @@ mod imp {
}

#[cfg(windows)]
#[allow(bad_style)]
mod imp {
use libc::{BOOL, DWORD, HANDLE, LPVOID, SIZE_T};
use MIN_ALIGN;

type LPVOID = *mut u8;
type HANDLE = LPVOID;
type SIZE_T = usize;
type DWORD = u32;
type BOOL = i32;

extern "system" {
fn GetProcessHeap() -> HANDLE;
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
Expand Down
1 change: 1 addition & 0 deletions src/libflate/lib.rs
Expand Up @@ -29,6 +29,7 @@
#![feature(staged_api)]
#![feature(unique)]
#![cfg_attr(test, feature(rustc_private, rand, vec_push_all))]
#![cfg_attr(stage0, allow(improper_ctypes))]

#[cfg(test)]
#[macro_use]
Expand Down
1 change: 1 addition & 0 deletions src/liblibc
Submodule liblibc added at b1a043

0 comments on commit 6aee7c5

Please sign in to comment.