Skip to content

Commit df9dc34

Browse files
committed
---
yaml --- r: 274367 b: refs/heads/stable c: 7a0e490 h: refs/heads/master i: 274365: 9274294 274363: 4038865 274359: 60b1862 274351: 4e85cf3 274335: 9b8d8c2 274303: f7c60b7
1 parent 83bedbb commit df9dc34

Some content is hidden

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

62 files changed

+3519
-146
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: ba97b06609a9f7b503ed0a83cc76d8fa89519752
32+
refs/heads/stable: 7a0e490bdd9a9c41a1293836e8bd826ddad90fd0
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ do
14091409
make_dir $h/test/debuginfo-gdb
14101410
make_dir $h/test/debuginfo-lldb
14111411
make_dir $h/test/codegen
1412+
make_dir $h/test/codegen-units
14121413
make_dir $h/test/rustdoc
14131414
done
14141415

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# armv7-unknown-linux-gnueabihf configuration
2+
CROSS_PREFIX_armv7-unknown-linux-gnueabihf=armv7-unknown-linux-gnueabihf-
3+
CC_armv7-unknown-linux-gnueabihf=gcc
4+
CXX_armv7-unknown-linux-gnueabihf=g++
5+
CPP_armv7-unknown-linux-gnueabihf=gcc -E
6+
AR_armv7-unknown-linux-gnueabihf=ar
7+
CFG_LIB_NAME_armv7-unknown-linux-gnueabihf=lib$(1).so
8+
CFG_STATIC_LIB_NAME_armv7-unknown-linux-gnueabihf=lib$(1).a
9+
CFG_LIB_GLOB_armv7-unknown-linux-gnueabihf=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_armv7-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
11+
CFG_JEMALLOC_CFLAGS_armv7-unknown-linux-gnueabihf := -D__arm__ $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_armv7-unknown-linux-gnueabihf := -Wall -g -fPIC -D__arm__ $(CFLAGS)
13+
CFG_GCCISH_CXXFLAGS_armv7-unknown-linux-gnueabihf := -fno-rtti $(CXXFLAGS)
14+
CFG_GCCISH_LINK_FLAGS_armv7-unknown-linux-gnueabihf := -shared -fPIC -g
15+
CFG_GCCISH_DEF_FLAG_armv7-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
16+
CFG_LLC_FLAGS_armv7-unknown-linux-gnueabihf :=
17+
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf =
18+
CFG_EXE_SUFFIX_armv7-unknown-linux-gnueabihf :=
19+
CFG_WINDOWSY_armv7-unknown-linux-gnueabihf :=
20+
CFG_UNIXY_armv7-unknown-linux-gnueabihf := 1
21+
CFG_LDPATH_armv7-unknown-linux-gnueabihf :=
22+
CFG_RUN_armv7-unknown-linux-gnueabihf=$(2)
23+
CFG_RUN_TARG_armv7-unknown-linux-gnueabihf=$(call CFG_RUN_armv7-unknown-linux-gnueabihf,,$(2))
24+
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf := -C target-feature=+v7,+vfp2,+neon
25+
RUSTC_CROSS_FLAGS_armv7-unknown-linux-gnueabihf :=
26+
CFG_GNU_TRIPLE_armv7-unknown-linux-gnueabihf := armv7-unknown-linux-gnueabihf

branches/stable/mk/cfg/armv7s-apple-ios.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ CFG_LIB_GLOB_armv7s-apple-ios = lib$(1)-*.a
1414
CFG_INSTALL_ONLY_RLIB_armv7s-apple-ios = 1
1515
CFG_STATIC_LIB_NAME_armv7s-apple-ios=lib$(1).a
1616
CFG_LIB_DSYM_GLOB_armv7s-apple-ios = lib$(1)-*.a.dSYM
17-
CFG_JEMALLOC_CFLAGS_armv7s-apple-ios := -arch armv7s -mfpu=vfp4 $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios)
18-
CFG_GCCISH_CFLAGS_armv7s-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -mfpu=vfp4 -arch armv7s
17+
CFG_JEMALLOC_CFLAGS_armv7s-apple-ios := -arch armv7s $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios)
18+
CFG_GCCISH_CFLAGS_armv7s-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -arch armv7s
1919
CFG_GCCISH_CXXFLAGS_armv7s-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -I$(CFG_IOS_SDK_armv7s-apple-ios)/usr/include/c++/4.2.1
2020
CFG_GCCISH_LINK_FLAGS_armv7s-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_armv7s-apple-ios) -Wl,-no_compact_unwind
2121
CFG_GCCISH_DEF_FLAG_armv7s-apple-ios := -Wl,-exported_symbols_list,

branches/stable/mk/tests.mk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ check-stage$(1)-T-$(2)-H-$(3)-exec: \
310310
check-stage$(1)-T-$(2)-H-$(3)-debuginfo-gdb-exec \
311311
check-stage$(1)-T-$(2)-H-$(3)-debuginfo-lldb-exec \
312312
check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
313+
check-stage$(1)-T-$(2)-H-$(3)-codegen-units-exec \
313314
check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
314315
check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
315316

@@ -473,6 +474,7 @@ DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
473474
DEBUGINFO_LLDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
474475
CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
475476
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
477+
CODEGEN_UNITS_RS := $(wildcard $(S)src/test/codegen-units/*.rs)
476478
RUSTDOCCK_RS := $(wildcard $(S)src/test/rustdoc/*.rs)
477479

478480
RPASS_TESTS := $(RPASS_RS)
@@ -488,6 +490,7 @@ PRETTY_TESTS := $(PRETTY_RS)
488490
DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
489491
DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
490492
CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
493+
CODEGEN_UNITS_TESTS := $(CODEGEN_UNITS_RS)
491494
RUSTDOCCK_TESTS := $(RUSTDOCCK_RS)
492495

493496
CTEST_SRC_BASE_rpass = run-pass
@@ -550,6 +553,11 @@ CTEST_BUILD_BASE_codegen = codegen
550553
CTEST_MODE_codegen = codegen
551554
CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
552555

556+
CTEST_SRC_BASE_codegen-units = codegen-units
557+
CTEST_BUILD_BASE_codegen-units = codegen-units
558+
CTEST_MODE_codegen-units = codegen-units
559+
CTEST_RUNTOOL_codegen-units = $(CTEST_RUNTOOL)
560+
553561
CTEST_SRC_BASE_rustdocck = rustdoc
554562
CTEST_BUILD_BASE_rustdocck = rustdoc
555563
CTEST_MODE_rustdocck = rustdoc
@@ -673,6 +681,7 @@ CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
673681
$(S)src/etc/lldb_batchmode.py \
674682
$(S)src/etc/lldb_rust_formatters.py
675683
CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
684+
CTEST_DEPS_codegen-units_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_UNITS_TESTS)
676685
CTEST_DEPS_rustdocck_$(1)-T-$(2)-H-$(3) = $$(RUSTDOCCK_TESTS) \
677686
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
678687
$(S)src/etc/htmldocck.py
@@ -739,7 +748,7 @@ endif
739748
endef
740749

741750
CTEST_NAMES = rpass rpass-valgrind rpass-full rfail-full cfail-full rfail cfail pfail \
742-
bench debuginfo-gdb debuginfo-lldb codegen rustdocck
751+
bench debuginfo-gdb debuginfo-lldb codegen codegen-units rustdocck
743752

744753
$(foreach host,$(CFG_HOST), \
745754
$(eval $(foreach target,$(CFG_TARGET), \
@@ -917,6 +926,7 @@ TEST_GROUPS = \
917926
debuginfo-gdb \
918927
debuginfo-lldb \
919928
codegen \
929+
codegen-units \
920930
doc \
921931
$(foreach docname,$(DOC_NAMES),doc-$(docname)) \
922932
pretty \

branches/stable/src/compiletest/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum Mode {
2525
DebugInfoLldb,
2626
Codegen,
2727
Rustdoc,
28+
CodegenUnits
2829
}
2930

3031
impl FromStr for Mode {
@@ -41,6 +42,7 @@ impl FromStr for Mode {
4142
"debuginfo-gdb" => Ok(DebugInfoGdb),
4243
"codegen" => Ok(Codegen),
4344
"rustdoc" => Ok(Rustdoc),
45+
"codegen-units" => Ok(CodegenUnits),
4446
_ => Err(()),
4547
}
4648
}
@@ -59,6 +61,7 @@ impl fmt::Display for Mode {
5961
DebugInfoLldb => "debuginfo-lldb",
6062
Codegen => "codegen",
6163
Rustdoc => "rustdoc",
64+
CodegenUnits => "codegen-units",
6265
}, f)
6366
}
6467
}

branches/stable/src/compiletest/runtest.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010

1111
use common::Config;
1212
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
13-
use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc};
13+
use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits};
1414
use errors;
1515
use header::TestProps;
1616
use header;
1717
use procsrv;
1818
use util::logv;
1919

2020
use std::env;
21+
use std::collections::HashSet;
2122
use std::fmt;
2223
use std::fs::{self, File};
2324
use std::io::BufReader;
@@ -56,6 +57,7 @@ pub fn run(config: Config, testfile: &Path) {
5657
DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile),
5758
Codegen => run_codegen_test(&config, &props, &testfile),
5859
Rustdoc => run_rustdoc_test(&config, &props, &testfile),
60+
CodegenUnits => run_codegen_units_test(&config, &props, &testfile),
5961
}
6062
}
6163

@@ -1747,3 +1749,44 @@ fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) {
17471749
fatal_proc_rec("htmldocck failed!", &res);
17481750
}
17491751
}
1752+
1753+
fn run_codegen_units_test(config: &Config, props: &TestProps, testfile: &Path) {
1754+
let proc_res = compile_test(config, props, testfile);
1755+
1756+
if !proc_res.status.success() {
1757+
fatal_proc_rec("compilation failed!", &proc_res);
1758+
}
1759+
1760+
check_no_compiler_crash(&proc_res);
1761+
1762+
let prefix = "TRANS_ITEM ";
1763+
1764+
let actual: HashSet<String> = proc_res
1765+
.stdout
1766+
.lines()
1767+
.filter(|line| line.starts_with(prefix))
1768+
.map(|s| (&s[prefix.len()..]).to_string())
1769+
.collect();
1770+
1771+
let expected: HashSet<String> = errors::load_errors(testfile)
1772+
.iter()
1773+
.map(|e| e.msg.trim().to_string())
1774+
.collect();
1775+
1776+
if actual != expected {
1777+
let mut missing: Vec<_> = expected.difference(&actual).collect();
1778+
missing.sort();
1779+
1780+
let mut too_much: Vec<_> = actual.difference(&expected).collect();
1781+
too_much.sort();
1782+
1783+
println!("Expected and actual sets of codegen-items differ.\n\
1784+
These items should have been contained but were not:\n\n\
1785+
{}\n\n\
1786+
These items were contained but should not have been:\n\n\
1787+
{}\n\n",
1788+
missing.iter().fold("".to_string(), |s1, s2| s1 + "\n" + s2),
1789+
too_much.iter().fold("".to_string(), |s1, s2| s1 + "\n" + s2));
1790+
panic!();
1791+
}
1792+
}

branches/stable/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ comments (`/** ... */`), are interpreted as a special syntax for `doc`
104104
`#[doc="..."]` around the body of the comment, i.e., `/// Foo` turns into
105105
`#[doc="Foo"]`.
106106

107-
Line comments beginning with `//!` and block comments `/*! ... !*/` are
107+
Line comments beginning with `//!` and block comments `/*! ... */` are
108108
doc comments that apply to the parent of the comment, rather than the item
109109
that follows. That is, they are equivalent to writing `#![doc="..."]` around
110110
the body of the comment. `//!` comments are usually used to document

branches/stable/src/libcollections/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl String {
641641
Cow::Owned(res)
642642
}
643643

644-
/// Decode a UTF-16 encoded vector `v` into a `String`, returning `None`
644+
/// Decode a UTF-16 encoded vector `v` into a `String`, returning `Err`
645645
/// if `v` contains any invalid data.
646646
///
647647
/// # Examples

branches/stable/src/liblibc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit af77843345ec6fc7e51113bfd692138d89024bc0
1+
Subproject commit 91ff43c736de664f8d3cd351e148c09cdea6731e

branches/stable/src/librustc/README.md

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Rustc consists of a number of crates, including `libsyntax`,
2121
(the names and divisions are not set in stone and may change;
2222
in general, a finer-grained division of crates is preferable):
2323

24-
- `libsyntax` contains those things concerned purely with syntax –
24+
- [`libsyntax`][libsyntax] contains those things concerned purely with syntax –
2525
that is, the AST, parser, pretty-printer, lexer, macro expander, and
2626
utilities for traversing ASTs – are in a separate crate called
2727
"syntax", whose files are in `./../libsyntax`, where `.` is the
@@ -32,32 +32,92 @@ in general, a finer-grained division of crates is preferable):
3232
passes, such as the type checker, borrow checker, and so forth.
3333
It is the heart of the compiler.
3434

35-
- `librustc_back` contains some very low-level details that are
35+
- [`librustc_back`][back] contains some very low-level details that are
3636
specific to different LLVM targets and so forth.
3737

38-
- `librustc_trans` contains the code to convert from Rust IR into LLVM
38+
- [`librustc_trans`][trans] contains the code to convert from Rust IR into LLVM
3939
IR, and then from LLVM IR into machine code, as well as the main
4040
driver that orchestrates all the other passes and various other bits
4141
of miscellany. In general it contains code that runs towards the
4242
end of the compilation process.
4343

44-
- `librustc_driver` invokes the compiler from `libsyntax`, then the
45-
analysis phases from `librustc`, and finally the lowering and
46-
codegen passes from `librustc_trans`.
44+
- [`librustc_driver`][driver] invokes the compiler from
45+
[`libsyntax`][libsyntax], then the analysis phases from `librustc`, and
46+
finally the lowering and codegen passes from [`librustc_trans`][trans].
4747

4848
Roughly speaking the "order" of the three crates is as follows:
4949

50-
libsyntax -> librustc -> librustc_trans
51-
| |
52-
+-----------------+-------------------+
53-
|
5450
librustc_driver
51+
|
52+
+-----------------+-------------------+
53+
| |
54+
libsyntax -> librustc -> librustc_trans
5555

5656

57-
Modules in the rustc crate
58-
==========================
59-
60-
The rustc crate itself consists of the following submodules
57+
The compiler process:
58+
=====================
59+
60+
The Rust compiler is comprised of six main compilation phases.
61+
62+
1. Parsing input
63+
2. Configuration & expanding (cfg rules & syntax extension expansion)
64+
3. Running analysis passes
65+
4. Translation to LLVM
66+
5. LLVM passes
67+
6. Linking
68+
69+
Phase one is responsible for parsing & lexing the input to the compiler. The
70+
output of this phase is an abstract syntax tree (AST). The AST at this point
71+
includes all macro uses & attributes. This means code which will be later
72+
expanded and/or removed due to `cfg` attributes is still present in this
73+
version of the AST. Parsing abstracts away details about individual files which
74+
have been read into the AST.
75+
76+
Phase two handles configuration and macro expansion. You can think of this
77+
phase as a function acting on the AST from the previous phase. The input for
78+
this phase is the unexpanded AST from phase one, and the output is an expanded
79+
version of the same AST. This phase will expand all macros & syntax
80+
extensions and will evaluate all `cfg` attributes, potentially removing some
81+
code. The resulting AST will not contain any macros or `macro_use` statements.
82+
83+
The code for these first two phases is in [`libsyntax`][libsyntax].
84+
85+
After this phase, the compiler allocates IDs to each node in the AST
86+
(technically not every node, but most of them). If we are writing out
87+
dependencies, that happens now.
88+
89+
The third phase is analysis. This is the most complex phase in the compiler,
90+
and makes up much of the code. This phase included name resolution, type
91+
checking, borrow checking, type & lifetime inference, trait selection, method
92+
selection, linting and so on. Most of the error detection in the compiler comes
93+
from this phase (with the exception of parse errors which arise during
94+
parsing). The "output" of this phase is a set of side tables containing
95+
semantic information about the source program. The analysis code is in
96+
[`librustc`][rustc] and some other crates with the `librustc_` prefix.
97+
98+
The fourth phase is translation. This phase translates the AST (and the side
99+
tables from the previous phase) into LLVM IR (intermediate representation).
100+
This is achieved by calling into the LLVM libraries. The code for this is in
101+
[`librustc_trans`][trans].
102+
103+
Phase five runs the LLVM backend. This runs LLVM's optimization passes on the
104+
generated IR and generates machine code resulting in object files. This phase
105+
is not really part of the Rust compiler, as LLVM carries out all the work.
106+
The interface between LLVM and Rust is in [`librustc_llvm`][llvm].
107+
108+
The final phase, phase six, links the object files into an executable. This is
109+
again outsourced to other tools and not performed by the Rust compiler
110+
directly. The interface is in [`librustc_back`][back] (which also contains some
111+
things used primarily during translation).
112+
113+
A module called the driver coordinates all these phases. It handles all the
114+
highest level coordination of compilation from parsing command line arguments
115+
all the way to invoking the linker to produce an executable.
116+
117+
Modules in the librustc crate
118+
=============================
119+
120+
The librustc crate itself consists of the following submodules
61121
(mostly, but not entirely, in their own directories):
62122

63123
- session: options and data that pertain to the compilation session as
@@ -71,7 +131,7 @@ The rustc crate itself consists of the following submodules
71131
- util: ubiquitous types and helper functions
72132
- lib: bindings to LLVM
73133

74-
The entry-point for the compiler is main() in the librustc_driver
134+
The entry-point for the compiler is main() in the [`librustc_driver`][driver]
75135
crate.
76136

77137
The 3 central data structures:
@@ -106,23 +166,9 @@ The 3 central data structures:
106166
Each of these is an opaque pointer to an LLVM type,
107167
manipulated through the `lib::llvm` interface.
108168

109-
110-
Control and information flow within the compiler:
111-
-------------------------------------------------
112-
113-
- main() in lib.rs assumes control on startup. Options are
114-
parsed, platform is detected, etc.
115-
116-
- `./../libsyntax/parse/parser.rs` parses the input files and produces
117-
an AST that represents the input crate.
118-
119-
- Multiple middle-end passes (`middle/resolve.rs`, `middle/typeck.rs`)
120-
analyze the semantics of the resulting AST. Each pass generates new
121-
information about the AST and stores it in various environment data
122-
structures. The driver passes environments to each compiler pass
123-
that needs to refer to them.
124-
125-
- Finally, the `trans` module in `librustc_trans` translates the Rust
126-
AST to LLVM bitcode in a type-directed way. When it's finished
127-
synthesizing LLVM values, rustc asks LLVM to write them out in some
128-
form (`.bc`, `.o`) and possibly run the system linker.
169+
[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax/
170+
[trans]: https://github.com/rust-lang/rust/tree/master/src/librustc_trans/
171+
[llvm]: https://github.com/rust-lang/rust/tree/master/src/librustc_llvm/
172+
[back]: https://github.com/rust-lang/rust/tree/master/src/librustc_back/
173+
[rustc]: https://github.com/rust-lang/rust/tree/master/src/librustc/
174+
[driver]: https://github.com/rust-lang/rust/tree/master/src/librustc_driver

0 commit comments

Comments
 (0)