Skip to content

Commit da2ce22

Browse files
authored
Auto merge of #37670 - eddyb:rollup, r=eddyb
Rollup of 15 pull requests - Successful merges: #36868, #37134, #37229, #37250, #37370, #37428, #37432, #37472, #37524, #37614, #37622, #37627, #37636, #37644, #37654 - Failed merges: #37463, #37542, #37645
2 parents bca365e + 60c74b7 commit da2ce22

File tree

510 files changed

+42643
-1380
lines changed

Some content is hidden

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

510 files changed

+42643
-1380
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
src/etc/pkg/rust-logo.ico binary
88
src/etc/pkg/rust-logo.png binary
99
*.woff binary
10+
src/vendor/* binary

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ tmp.*.rs
9898
version.md
9999
version.ml
100100
version.texi
101+
.cargo

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before_install:
1515
script:
1616
- docker run -v `pwd`:/build rust
1717
sh -c "
18-
./configure --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 --enable-quiet-tests &&
18+
./configure --enable-vendor --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 --enable-quiet-tests &&
1919
make tidy &&
2020
make check -j4
2121
"

configure

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ opt rustbuild 0 "use the rust and cargo based build system"
634634
opt codegen-tests 1 "run the src/test/codegen tests"
635635
opt option-checking 1 "complain about unrecognized options in this configure script"
636636
opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
637+
opt vendor 0 "enable usage of vendored Rust crates"
637638

638639
# Optimization and debugging options. These may be overridden by the release channel, etc.
639640
opt_nosave optimize 1 "build optimized rust code"

mk/dist.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ PKG_FILES := \
6565
stage0.txt \
6666
rust-installer \
6767
tools \
68-
test) \
68+
test \
69+
vendor) \
6970
$(PKG_GITMODULES) \
7071
$(filter-out config.stamp, \
7172
$(MKFILES_FOR_TARBALL))

src/Cargo.lock

-69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ num_cpus = "0.2"
2727
toml = "0.1"
2828
getopts = "0.2"
2929
rustc-serialize = "0.3"
30-
gcc = "0.3.36"
30+
gcc = "0.3.38"
3131
libc = "0.2"
3232
md5 = "0.1"
33-
34-
[target.'cfg(windows)'.dependencies]
35-
winapi = "0.2"
36-
kernel32-sys = "0.2"

src/bootstrap/bootstrap.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ def build_bootstrap(self):
259259
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
260260
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
261261
os.pathsep + env["PATH"]
262-
self.run([self.cargo(), "build", "--manifest-path",
263-
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")],
264-
env)
262+
args = [self.cargo(), "build", "--manifest-path",
263+
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
264+
if self.use_vendored_sources:
265+
args.append("--frozen")
266+
self.run(args, env)
265267

266268
def run(self, args, env):
267269
proc = subprocess.Popen(args, env=env)
@@ -400,6 +402,25 @@ def main():
400402
except:
401403
pass
402404

405+
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
406+
'CFG_ENABLE_VENDOR' in rb.config_mk
407+
408+
if rb.use_vendored_sources:
409+
if not os.path.exists('.cargo'):
410+
os.makedirs('.cargo')
411+
f = open('.cargo/config','w')
412+
f.write("""
413+
[source.crates-io]
414+
replace-with = 'vendored-sources'
415+
registry = 'https://example.com'
416+
417+
[source.vendored-sources]
418+
directory = '{}/src/vendor'
419+
""".format(rb.rust_root))
420+
f.close()
421+
else:
422+
if os.path.exists('.cargo'):
423+
shutil.rmtree('.cargo')
403424
data = stage0_data(rb.rust_root)
404425
rb._rustc_channel, rb._rustc_date = data['rustc'].split('-', 1)
405426
rb._cargo_channel, rb._cargo_date = data['cargo'].split('-', 1)

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct Config {
4444
pub submodules: bool,
4545
pub compiler_docs: bool,
4646
pub docs: bool,
47+
pub vendor: bool,
4748
pub target_config: HashMap<String, Target>,
4849

4950
// llvm codegen options
@@ -126,6 +127,7 @@ struct Build {
126127
docs: Option<bool>,
127128
submodules: Option<bool>,
128129
gdb: Option<String>,
130+
vendor: Option<bool>,
129131
}
130132

131133
/// TOML representation of how the LLVM build is configured.
@@ -234,6 +236,7 @@ impl Config {
234236
set(&mut config.compiler_docs, build.compiler_docs);
235237
set(&mut config.docs, build.docs);
236238
set(&mut config.submodules, build.submodules);
239+
set(&mut config.vendor, build.vendor);
237240

238241
if let Some(ref llvm) = toml.llvm {
239242
set(&mut config.ccache, llvm.ccache);
@@ -347,6 +350,7 @@ impl Config {
347350
("LOCAL_REBUILD", self.local_rebuild),
348351
("NINJA", self.ninja),
349352
("CODEGEN_TESTS", self.codegen_tests),
353+
("VENDOR", self.vendor),
350354
}
351355

352356
match key {

src/bootstrap/config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
# The path to (or name of) the GDB executable to use
8383
#gdb = "gdb"
8484

85+
# Indicate whether the vendored sources are used for Rust dependencies or not
86+
#vendor = false
87+
8588
# =============================================================================
8689
# Options for compiling Rust code itself
8790
# =============================================================================

src/bootstrap/job.rs

+71-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,82 @@
3737
//! Note that this module has a #[cfg(windows)] above it as none of this logic
3838
//! is required on Unix.
3939
40-
extern crate kernel32;
41-
extern crate winapi;
40+
#![allow(bad_style, dead_code)]
4241

4342
use std::env;
4443
use std::io;
4544
use std::mem;
4645

47-
use self::winapi::*;
48-
use self::kernel32::*;
46+
type HANDLE = *mut u8;
47+
type BOOL = i32;
48+
type DWORD = u32;
49+
type LPHANDLE = *mut HANDLE;
50+
type LPVOID = *mut u8;
51+
type JOBOBJECTINFOCLASS = i32;
52+
type SIZE_T = usize;
53+
type LARGE_INTEGER = i64;
54+
type ULONG_PTR = usize;
55+
type ULONGLONG = u64;
56+
57+
const FALSE: BOOL = 0;
58+
const DUPLICATE_SAME_ACCESS: DWORD = 0x2;
59+
const PROCESS_DUP_HANDLE: DWORD = 0x40;
60+
const JobObjectExtendedLimitInformation: JOBOBJECTINFOCLASS = 9;
61+
const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: DWORD = 0x2000;
62+
63+
extern "system" {
64+
fn CreateJobObjectW(lpJobAttributes: *mut u8, lpName: *const u8) -> HANDLE;
65+
fn CloseHandle(hObject: HANDLE) -> BOOL;
66+
fn GetCurrentProcess() -> HANDLE;
67+
fn OpenProcess(dwDesiredAccess: DWORD,
68+
bInheritHandle: BOOL,
69+
dwProcessId: DWORD) -> HANDLE;
70+
fn DuplicateHandle(hSourceProcessHandle: HANDLE,
71+
hSourceHandle: HANDLE,
72+
hTargetProcessHandle: HANDLE,
73+
lpTargetHandle: LPHANDLE,
74+
dwDesiredAccess: DWORD,
75+
bInheritHandle: BOOL,
76+
dwOptions: DWORD) -> BOOL;
77+
fn AssignProcessToJobObject(hJob: HANDLE, hProcess: HANDLE) -> BOOL;
78+
fn SetInformationJobObject(hJob: HANDLE,
79+
JobObjectInformationClass: JOBOBJECTINFOCLASS,
80+
lpJobObjectInformation: LPVOID,
81+
cbJobObjectInformationLength: DWORD) -> BOOL;
82+
}
83+
84+
#[repr(C)]
85+
struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
86+
BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION,
87+
IoInfo: IO_COUNTERS,
88+
ProcessMemoryLimit: SIZE_T,
89+
JobMemoryLimit: SIZE_T,
90+
PeakProcessMemoryUsed: SIZE_T,
91+
PeakJobMemoryUsed: SIZE_T,
92+
}
93+
94+
#[repr(C)]
95+
struct IO_COUNTERS {
96+
ReadOperationCount: ULONGLONG,
97+
WriteOperationCount: ULONGLONG,
98+
OtherOperationCount: ULONGLONG,
99+
ReadTransferCount: ULONGLONG,
100+
WriteTransferCount: ULONGLONG,
101+
OtherTransferCount: ULONGLONG,
102+
}
103+
104+
#[repr(C)]
105+
struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
106+
PerProcessUserTimeLimit: LARGE_INTEGER,
107+
PerJobUserTimeLimit: LARGE_INTEGER,
108+
LimitFlags: DWORD,
109+
MinimumWorkingsetSize: SIZE_T,
110+
MaximumWorkingsetSize: SIZE_T,
111+
ActiveProcessLimit: DWORD,
112+
Affinity: ULONG_PTR,
113+
PriorityClass: DWORD,
114+
SchedulingClass: DWORD,
115+
}
49116

50117
pub unsafe fn setup() {
51118
// Create a new job object for us to use

src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ impl Build {
460460
if self.config.rust_optimize {
461461
cargo.arg("--release");
462462
}
463+
if self.config.vendor {
464+
cargo.arg("--frozen");
465+
}
463466
return cargo
464467
}
465468

0 commit comments

Comments
 (0)