Skip to content

Commit 6aee7c5

Browse files
committed
Auto merge of #29546 - alexcrichton:new-libc, r=brson
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.
2 parents 2968dfa + 3d28b8b commit 6aee7c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1899
-9621
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@
1414
[submodule "src/rust-installer"]
1515
path = src/rust-installer
1616
url = https://github.com/rust-lang/rust-installer
17+
[submodule "src/liblibc"]
18+
path = src/liblibc
19+
url = https://github.com/rust-lang/libc

mk/crates.mk

+3
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,6 @@ $(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
174174
ifdef CFG_DISABLE_ELF_TLS
175175
RUSTFLAGS_std := --cfg no_elf_tls
176176
endif
177+
178+
CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
179+
RUSTFLAGS_libc := --cfg stdbuild

mk/tests.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $(eval $(call RUST_CRATE,coretest))
2222
DEPS_collectionstest :=
2323
$(eval $(call RUST_CRATE,collectionstest))
2424

25-
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system \
25+
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system libc \
2626
alloc_jemalloc,$(TARGET_CRATES)) \
2727
collectionstest coretest
2828
TEST_DOC_CRATES = $(DOC_CRATES)
@@ -283,6 +283,7 @@ tidy-binaries:
283283
| grep '^$(S)src/compiler-rt' -v \
284284
| grep '^$(S)src/libbacktrace' -v \
285285
| grep '^$(S)src/rust-installer' -v \
286+
| grep '^$(S)src/liblibc' -v \
286287
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
287288

288289
.PHONY: tidy-errors

src/etc/tidy.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def interesting_file(f):
108108
'src/rustllvm',
109109
'src/rt/valgrind',
110110
'src/rt/msvc',
111-
'src/rust-installer'
111+
'src/rust-installer',
112+
'src/liblibc',
112113
}
113114

114115
if any(d in dirpath for d in skippable_dirs):

src/liballoc_jemalloc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![staged_api]
1515
#![no_std]
1616
#![cfg_attr(not(stage0), allocator)]
17+
#![cfg_attr(stage0, allow(improper_ctypes))]
1718
#![unstable(feature = "alloc_jemalloc",
1819
reason = "this library is unlikely to be stabilized in its current \
1920
form or name",

src/liballoc_system/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![staged_api]
1515
#![no_std]
1616
#![cfg_attr(not(stage0), allocator)]
17+
#![cfg_attr(stage0, allow(improper_ctypes))]
1718
#![unstable(feature = "alloc_system",
1819
reason = "this library is unlikely to be stabilized in its current \
1920
form or name",
@@ -141,10 +142,16 @@ mod imp {
141142
}
142143

143144
#[cfg(windows)]
145+
#[allow(bad_style)]
144146
mod imp {
145-
use libc::{BOOL, DWORD, HANDLE, LPVOID, SIZE_T};
146147
use MIN_ALIGN;
147148

149+
type LPVOID = *mut u8;
150+
type HANDLE = LPVOID;
151+
type SIZE_T = usize;
152+
type DWORD = u32;
153+
type BOOL = i32;
154+
148155
extern "system" {
149156
fn GetProcessHeap() -> HANDLE;
150157
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;

src/libflate/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![feature(staged_api)]
3030
#![feature(unique)]
3131
#![cfg_attr(test, feature(rustc_private, rand, vec_push_all))]
32+
#![cfg_attr(stage0, allow(improper_ctypes))]
3233

3334
#[cfg(test)]
3435
#[macro_use]

src/liblibc

Submodule liblibc added at b1a043f

0 commit comments

Comments
 (0)