Skip to content

Commit 79358aa

Browse files
committed
Merge branch 'master' into issue-30961
2 parents 5c4d621 + 8052f73 commit 79358aa

Some content is hidden

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

80 files changed

+2158
-2550
lines changed

configure

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ opt debug-assertions 0 "build with debugging assertions"
600600
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
601601
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
602602
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
603-
opt local-rebuild 0 "use an installed rustc matching the current version, for rebuilds"
603+
opt local-rebuild 0 "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version"
604604
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
605605
opt rpath 1 "build rpaths into rustc itself"
606606
opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0"
@@ -612,6 +612,7 @@ opt rustbuild 0 "use the rust and cargo based build system"
612612
opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"
613613
opt codegen-tests 1 "run the src/test/codegen tests"
614614
opt option-checking 1 "complain about unrecognized options in this configure script"
615+
opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
615616

616617
# Optimization and debugging options. These may be overridden by the release channel, etc.
617618
opt_nosave optimize 1 "build optimized rust code"
@@ -785,6 +786,17 @@ probe CFG_BISON bison
785786
probe CFG_GDB gdb
786787
probe CFG_LLDB lldb
787788

789+
if [ -n "$CFG_ENABLE_NINJA" ]
790+
then
791+
probe CFG_NINJA ninja
792+
if [ -z "$CFG_NINJA" ]
793+
then
794+
# On Debian and Fedora, the `ninja` binary is an IRC bot, so the build tool was
795+
# renamed. Handle this case.
796+
probe CFG_NINJA ninja-build
797+
fi
798+
fi
799+
788800
# For building LLVM
789801
probe_need CFG_CMAKE cmake
790802

@@ -1534,7 +1546,10 @@ do
15341546
fi
15351547

15361548
# We need the generator later on for compiler-rt even if LLVM's not built
1537-
if [ ${is_msvc} -ne 0 ]
1549+
if [ -n "$CFG_NINJA" ]
1550+
then
1551+
generator="Ninja"
1552+
elif [ ${is_msvc} -ne 0 ]
15381553
then
15391554
case "$CFG_MSVC_ROOT" in
15401555
*14.0*)

mk/cfg/mips-unknown-linux-gnu.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
77
CFG_STATIC_LIB_NAME_mips-unknown-linux-gnu=lib$(1).a
88
CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
99
CFG_LIB_DSYM_GLOB_mips-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
10-
CFG_JEMALLOC_CFLAGS_mips-unknown-linux-gnu := -mips32r2 -msoft-float -mabi=32 $(CFLAGS)
11-
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32 $(CFLAGS)
10+
CFG_JEMALLOC_CFLAGS_mips-unknown-linux-gnu := -mips32r2 -mabi=32 $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -mabi=32 $(CFLAGS)
1212
CFG_GCCISH_CXXFLAGS_mips-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
13-
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32
13+
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -mabi=32
1414
CFG_GCCISH_DEF_FLAG_mips-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
1515
CFG_LLC_FLAGS_mips-unknown-linux-gnu :=
1616
CFG_INSTALL_NAME_mips-unknown-linux-gnu =

mk/llvm.mk

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,26 @@ $$(LLVM_CONFIG_$(1)): $$(LLVM_DONE_$(1))
4343

4444
$$(LLVM_DONE_$(1)): $$(LLVM_DEPS_TARGET_$(1)) $$(LLVM_STAMP_$(1))
4545
@$$(call E, cmake: llvm)
46-
ifeq ($$(findstring msvc,$(1)),msvc)
46+
ifneq ($$(CFG_NINJA),)
47+
$$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1))
48+
else ifeq ($$(findstring msvc,$(1)),msvc)
4749
$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
4850
--config $$(LLVM_BUILD_CONFIG_MODE)
4951
else
5052
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
5153
endif
5254
$$(Q)touch $$@
5355

54-
ifeq ($$(findstring msvc,$(1)),msvc)
56+
ifneq ($$(CFG_NINJA),)
5557
clean-llvm$(1):
58+
@$$(call E, clean: llvm)
59+
$$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1)) -t clean
60+
else ifeq ($$(findstring msvc,$(1)),msvc)
61+
clean-llvm$(1):
62+
@$$(call E, clean: llvm)
63+
$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
64+
--config $$(LLVM_BUILD_CONFIG_MODE) \
65+
--target clean
5666
else
5767
clean-llvm$(1):
5868
@$$(call E, clean: llvm)

mk/main.mk

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,6 @@ CFG_RELEASE_NUM=1.12.0
2020
# versions (section 9)
2121
CFG_PRERELEASE_VERSION=.1
2222

23-
# Append a version-dependent hash to each library, so we can install different
24-
# versions in the same place
25-
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
26-
27-
# A magic value that allows the compiler to use unstable features during the
28-
# bootstrap even when doing so would normally be an error because of feature
29-
# staging or because the build turns on warnings-as-errors and unstable features
30-
# default to warnings. The build has to match this key in an env var.
31-
#
32-
# This value is keyed off the release to ensure that all compilers for one
33-
# particular release have the same bootstrap key. Note that this is
34-
# intentionally not "secure" by any definition, this is largely just a deterrent
35-
# from users enabling unstable features on the stable compiler.
36-
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
37-
38-
# The stage0 compiler needs to use the previous key recorded in src/stage0.txt,
39-
# except for local-rebuild when it just uses the same current key.
40-
ifdef CFG_ENABLE_LOCAL_REBUILD
41-
CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY)
42-
else
43-
CFG_BOOTSTRAP_KEY_STAGE0=$(shell grep 'rustc_key' $(S)src/stage0.txt | sed 's/rustc_key: '//)
44-
endif
45-
4623
ifeq ($(CFG_RELEASE_CHANNEL),stable)
4724
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
4825
CFG_RELEASE=$(CFG_RELEASE_NUM)
@@ -72,6 +49,38 @@ CFG_RELEASE=$(CFG_RELEASE_NUM)-dev
7249
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev
7350
endif
7451

52+
# Append a version-dependent hash to each library, so we can install different
53+
# versions in the same place
54+
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
55+
56+
# A magic value that allows the compiler to use unstable features during the
57+
# bootstrap even when doing so would normally be an error because of feature
58+
# staging or because the build turns on warnings-as-errors and unstable features
59+
# default to warnings. The build has to match this key in an env var.
60+
#
61+
# This value is keyed off the release to ensure that all compilers for one
62+
# particular release have the same bootstrap key. Note that this is
63+
# intentionally not "secure" by any definition, this is largely just a deterrent
64+
# from users enabling unstable features on the stable compiler.
65+
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
66+
67+
# If local-rust is the same as the current version, then force a local-rebuild
68+
ifdef CFG_ENABLE_LOCAL_RUST
69+
ifeq ($(CFG_RELEASE),\
70+
$(shell $(S)src/etc/local_stage0.sh --print-rustc-release $(CFG_LOCAL_RUST_ROOT)))
71+
CFG_INFO := $(info cfg: auto-detected local-rebuild $(CFG_RELEASE))
72+
CFG_ENABLE_LOCAL_REBUILD = 1
73+
endif
74+
endif
75+
76+
# The stage0 compiler needs to use the previous key recorded in src/stage0.txt,
77+
# except for local-rebuild when it just uses the same current key.
78+
ifdef CFG_ENABLE_LOCAL_REBUILD
79+
CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY)
80+
else
81+
CFG_BOOTSTRAP_KEY_STAGE0=$(shell sed -ne 's/^rustc_key: //p' $(S)src/stage0.txt)
82+
endif
83+
7584
# The name of the package to use for creating tarballs, installers etc.
7685
CFG_PACKAGE_NAME=rustc-$(CFG_PACKAGE_VERS)
7786

mk/rt.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,17 @@ $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD
350350
$$(COMPRT_DEFINES_$(1)) \
351351
$$(COMPRT_BUILD_CC_$(1)) \
352352
-G"$$(CFG_CMAKE_GENERATOR)"
353+
ifneq ($$(CFG_NINJA),)
354+
$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
355+
--target $$(COMPRT_BUILD_TARGET_$(1)) \
356+
--config $$(LLVM_BUILD_CONFIG_MODE) \
357+
-- $$(COMPRT_BUILD_ARGS_$(1))
358+
else
353359
$$(Q)$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
354360
--target $$(COMPRT_BUILD_TARGET_$(1)) \
355361
--config $$(LLVM_BUILD_CONFIG_MODE) \
356362
-- $$(COMPRT_BUILD_ARGS_$(1)) $$(MFLAGS)
363+
endif
357364
$$(Q)cp "$$(COMPRT_OUTPUT_$(1))" $$@
358365

359366
endif

mk/stage0.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ endif
1111

1212
$(SNAPSHOT_RUSTC_POST_CLEANUP): \
1313
$(S)src/stage0.txt \
14+
$(S)src/etc/local_stage0.sh \
1415
$(S)src/etc/get-stage0.py $(MKFILE_DEPS) \
1516
| $(HBIN0_H_$(CFG_BUILD))/
1617
@$(call E, fetch: $@)

src/bootstrap/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ impl Config {
317317
("OPTIMIZE_TESTS", self.rust_optimize_tests),
318318
("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
319319
("LOCAL_REBUILD", self.local_rebuild),
320+
("NINJA", self.ninja),
320321
}
321322

322323
match key {

src/bootstrap/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub struct Build {
118118
ver_date: Option<String>,
119119
version: String,
120120
package_vers: String,
121+
local_rebuild: bool,
121122
bootstrap_key: String,
122123
bootstrap_key_stage0: String,
123124

@@ -174,6 +175,7 @@ impl Build {
174175
Some(ref s) => PathBuf::from(s),
175176
None => stage0_root.join(exe("cargo", &config.build)),
176177
};
178+
let local_rebuild = config.local_rebuild;
177179

178180
Build {
179181
flags: flags,
@@ -189,6 +191,7 @@ impl Build {
189191
short_ver_hash: None,
190192
ver_date: None,
191193
version: String::new(),
194+
local_rebuild: local_rebuild,
192195
bootstrap_key: String::new(),
193196
bootstrap_key_stage0: String::new(),
194197
package_vers: String::new(),
@@ -219,6 +222,16 @@ impl Build {
219222
sanity::check(self);
220223
self.verbose("collecting channel variables");
221224
channel::collect(self);
225+
// If local-rust is the same as the current version, then force a local-rebuild
226+
let local_version_verbose = output(
227+
Command::new(&self.rustc).arg("--version").arg("--verbose"));
228+
let local_release = local_version_verbose
229+
.lines().filter(|x| x.starts_with("release:"))
230+
.next().unwrap().trim_left_matches("release:").trim();
231+
if local_release == self.release {
232+
self.verbose(&format!("auto-detected local-rebuild {}", self.release));
233+
self.local_rebuild = true;
234+
}
222235
self.verbose("updating submodules");
223236
self.update_submodules();
224237

@@ -525,7 +538,7 @@ impl Build {
525538
.arg("--target").arg(target);
526539

527540
let stage;
528-
if compiler.stage == 0 && self.config.local_rebuild {
541+
if compiler.stage == 0 && self.local_rebuild {
529542
// Assume the local-rebuild rustc already has stage1 features.
530543
stage = 1;
531544
} else {
@@ -766,7 +779,7 @@ impl Build {
766779
// In stage0 we're using a previously released stable compiler, so we
767780
// use the stage0 bootstrap key. Otherwise we use our own build's
768781
// bootstrap key.
769-
let bootstrap_key = if compiler.is_snapshot(self) && !self.config.local_rebuild {
782+
let bootstrap_key = if compiler.is_snapshot(self) && !self.local_rebuild {
770783
&self.bootstrap_key_stage0
771784
} else {
772785
&self.bootstrap_key

src/doc/book/no-stdlib.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ this using our `Cargo.toml` file:
2121

2222
```toml
2323
[dependencies]
24-
libc = { version = "0.2.11", default-features = false }
24+
libc = { version = "0.2.14", default-features = false }
2525
```
2626

2727
Note that the default features have been disabled. This is a critical step -
@@ -36,8 +36,7 @@ or overriding the default shim for the C `main` function with your own.
3636
The function marked `#[start]` is passed the command line parameters
3737
in the same format as C:
3838

39-
```rust
40-
# #![feature(libc)]
39+
```rust,ignore
4140
#![feature(lang_items)]
4241
#![feature(start)]
4342
#![no_std]
@@ -51,53 +50,77 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
5150
0
5251
}
5352
54-
// These functions and traits are used by the compiler, but not
53+
// These functions are used by the compiler, but not
5554
// for a bare-bones hello world. These are normally
5655
// provided by libstd.
57-
#[lang = "eh_personality"] extern fn eh_personality() {}
58-
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} }
59-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
60-
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
61-
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
62-
# // fn main() {} tricked you, rustdoc!
56+
#[lang = "eh_personality"]
57+
#[no_mangle]
58+
pub extern fn eh_personality() {
59+
}
60+
61+
#[lang = "panic_fmt"]
62+
#[no_mangle]
63+
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
64+
_file: &'static str,
65+
_line: u32) -> ! {
66+
loop {}
67+
}
6368
```
6469

6570
To override the compiler-inserted `main` shim, one has to disable it
6671
with `#![no_main]` and then create the appropriate symbol with the
6772
correct ABI and the correct name, which requires overriding the
6873
compiler's name mangling too:
6974

70-
```rust
71-
# #![feature(libc)]
75+
```rust,ignore
7276
#![feature(lang_items)]
7377
#![feature(start)]
7478
#![no_std]
7579
#![no_main]
7680
81+
// Pull in the system libc library for what crt0.o likely requires
7782
extern crate libc;
7883
84+
// Entry point for this program
7985
#[no_mangle] // ensure that this symbol is called `main` in the output
80-
pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
86+
pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
8187
0
8288
}
8389
84-
#[lang = "eh_personality"] extern fn eh_personality() {}
85-
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} }
86-
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
87-
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
88-
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
89-
# // fn main() {} tricked you, rustdoc!
90+
// These functions and traits are used by the compiler, but not
91+
// for a bare-bones hello world. These are normally
92+
// provided by libstd.
93+
#[lang = "eh_personality"]
94+
#[no_mangle]
95+
pub extern fn eh_personality() {
96+
}
97+
98+
#[lang = "panic_fmt"]
99+
#[no_mangle]
100+
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
101+
_file: &'static str,
102+
_line: u32) -> ! {
103+
loop {}
104+
}
90105
```
91106

92-
The compiler currently makes a few assumptions about symbols which are available
93-
in the executable to call. Normally these functions are provided by the standard
94-
library, but without it you must define your own.
107+
## More about the langauge items
108+
109+
The compiler currently makes a few assumptions about symbols which are
110+
available in the executable to call. Normally these functions are provided by
111+
the standard library, but without it you must define your own. These symbols
112+
are called "language items", and they each have an internal name, and then a
113+
signature that an implementation must conform to.
95114

96115
The first of these two functions, `eh_personality`, is used by the failure
97116
mechanisms of the compiler. This is often mapped to GCC's personality function
98117
(see the [libstd implementation][unwind] for more information), but crates
99118
which do not trigger a panic can be assured that this function is never
100-
called. The second function, `panic_fmt`, is also used by the failure
101-
mechanisms of the compiler.
102-
119+
called. Both the language item and the symbol name are `eh_personality`.
120+
103121
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
122+
123+
The second function, `panic_fmt`, is also used by the failure mechanisms of the
124+
compiler. When a panic happens, this controls the message that's displayed on
125+
the screen. While the language item's name is `panic_fmt`, the symbol name is
126+
`rust_begin_panic`.

src/doc/nomicon/phantom-data.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ struct Vec<T> {
5151
```
5252

5353
Unlike the previous example it *appears* that everything is exactly as we
54-
want. Every generic argument to Vec shows up in the at least one field.
54+
want. Every generic argument to Vec shows up in at least one field.
5555
Good to go!
5656

5757
Nope.
5858

59-
The drop checker will generously determine that Vec<T> does not own any values
59+
The drop checker will generously determine that `Vec<T>` does not own any values
6060
of type T. This will in turn make it conclude that it doesn't need to worry
6161
about Vec dropping any T's in its destructor for determining drop check
6262
soundness. This will in turn allow people to create unsoundness using
@@ -81,7 +81,7 @@ Raw pointers that own an allocation is such a pervasive pattern that the
8181
standard library made a utility for itself called `Unique<T>` which:
8282

8383
* wraps a `*const T` for variance
84-
* includes a `PhantomData<T>`,
84+
* includes a `PhantomData<T>`
8585
* auto-derives Send/Sync as if T was contained
8686
* marks the pointer as NonZero for the null-pointer optimization
8787

0 commit comments

Comments
 (0)