Skip to content

Commit 70dd9fa

Browse files
committed
---
yaml --- r: 123767 b: refs/heads/master c: 350f3aa h: refs/heads/master i: 123765: 2b6720e 123763: 94ef67a 123759: 67496ea v: v3
1 parent 9457147 commit 70dd9fa

Some content is hidden

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

45 files changed

+984
-396
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8fab111e79b8352e611040209af37dd8e24ec4aa
2+
refs/heads/master: 350f3aa856682fed816a0a2018b3bcf50178eeff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8ddd286ea4ba4384a0dc9eae393ed515460a986e
55
refs/heads/try: 296eb104620b346d88bc4a2c2ab7693e6d3db019

trunk/man/rustc.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ This program is a compiler for the Rust language, available at
1111

1212
.SH OPTIONS
1313

14+
.TP
15+
\fB\-\-crate-name NAME\fR
16+
Specify the name of the crate being built
1417
.TP
1518
\fB\-\-crate-type=[bin|lib|dylib|rlib|staticlib]\fR
1619
Configure the flavor of rust crate that is generated (default `bin`)

trunk/mk/install.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ else
1414
MAYBE_DISABLE_VERIFY=
1515
endif
1616

17-
install: dist-install-dir-$(CFG_BUILD)-with-target-libs
18-
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
17+
install: dist-install-dir-$(CFG_BUILD)-with-target-libs | tmp/empty_dir
18+
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
1919
# Remove tmp files while we can because they may have been created under sudo
2020
$(Q)rm -R tmp/dist
2121

22-
uninstall: dist-install-dir-$(CFG_BUILD)-with-target-libs
23-
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
22+
uninstall: dist-install-dir-$(CFG_BUILD)-with-target-libs | tmp/empty_dir
23+
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
2424
# Remove tmp files while we can because they may have been created under sudo
2525
$(Q)rm -R tmp/dist
2626

27+
tmp/empty_dir:
28+
mkdir -p $@
2729

2830
######################################################################
2931
# Android remote installation

trunk/src/etc/install.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ while read p; do
466466
# The manifest lists all files to install
467467
done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in"
468468

469+
# Run ldconfig to make dynamic libraries available to the linker
470+
if [ "$CFG_OSTYPE" = "Linux" ]
471+
then
472+
ldconfig
473+
if [ $? -ne 0 ]
474+
then
475+
warn "failed to run ldconfig."
476+
warn "this may happen when not installing as root and may be fine"
477+
fi
478+
fi
479+
469480
# Sanity check: can we run the installed binaries?
470481
#
471482
# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
@@ -489,13 +500,11 @@ then
489500
err "${ERR}"
490501
else
491502
echo
492-
echo " please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
493-
echo
503+
echo " Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
494504
fi
495505
fi
496506
fi
497507

498-
499508
echo
500509
echo " Rust is ready to roll."
501510
echo

trunk/src/etc/zsh/_rust

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ _rustc_opts_switches=(
99
-c'[Compile and assemble, but do not link]'
1010
--cfg'[Configure the compilation environment]'
1111
--crate-id'[Output the crate id and exit]'
12-
--crate-file-name'[Output the file(s) that would be written if compilation continued and exit]'
13-
--crate-name'[Output the crate name and exit]'
14-
--dep-info'[Output dependency info to <filename> after compiling]'
12+
--crate-file-name'[deprecated in favor of --print-file-name]'
13+
--crate-name'[Specify the name of the crate being built]'
1514
--crate-type'[Specify the type of crate to crate]'
15+
--debuginfo'[Emit DWARF debug info to the objects created: 0 = no debug info, 1 = line-tables only (for stacktraces and breakpoints), 2 = full debug info with variable and type information (same as -g)]'
16+
--dep-info'[Output dependency info to <filename> after compiling]'
17+
-g'[Equivalent to --debuginfo=2]'
1618
{-h,--help}'[Display this message]'
1719
-L'[Add a directory to the library search path]'
1820
--linker'[Program to use for linking instead of the default.]'
@@ -29,6 +31,8 @@ _rustc_opts_switches=(
2931
--parse-only'[Parse only; do not compile, assemble, or link]'
3032
--passes'[Comma or space separated list of pass names to use]'
3133
--pretty'[Pretty-print the input instead of compiling]'
34+
--print-crate-name'[Output the crate name and exit]'
35+
--print-file-name'[Output the file(s) that would be written if compilation continued and exit]'
3236
--save-temps'[Write intermediate files (.bc, .opt.bc, .o) in addition to normal output]'
3337
--sysroot'[Override the system root]'
3438
--test'[Build a test harness]'

trunk/src/libgreen/stack.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::ptr;
1112
use std::sync::atomics;
1213
use std::os::{errno, page_size, MemoryMap, MapReadable, MapWritable,
13-
MapNonStandardFlags, MapVirtual, getenv};
14+
MapNonStandardFlags, getenv};
1415
use libc;
1516

1617
/// A task's stack. The name "Stack" is a vestige of segmented stacks.
1718
pub struct Stack {
18-
buf: MemoryMap,
19+
buf: Option<MemoryMap>,
1920
min_size: uint,
2021
valgrind_id: libc::c_uint,
2122
}
@@ -52,11 +53,11 @@ impl Stack {
5253
// guaranteed to be aligned properly.
5354
if !protect_last_page(&stack) {
5455
fail!("Could not memory-protect guard page. stack={}, errno={}",
55-
stack.data, errno());
56+
stack.data(), errno());
5657
}
5758

5859
let mut stk = Stack {
59-
buf: stack,
60+
buf: Some(stack),
6061
min_size: size,
6162
valgrind_id: 0
6263
};
@@ -71,22 +72,23 @@ impl Stack {
7172
/// Create a 0-length stack which starts (and ends) at 0.
7273
pub unsafe fn dummy_stack() -> Stack {
7374
Stack {
74-
buf: MemoryMap { data: 0 as *mut u8, len: 0, kind: MapVirtual },
75+
buf: None,
7576
min_size: 0,
7677
valgrind_id: 0
7778
}
7879
}
7980

8081
/// Point to the low end of the allocated stack
8182
pub fn start(&self) -> *const uint {
82-
self.buf.data as *const uint
83+
self.buf.as_ref().map(|m| m.data() as *const uint)
84+
.unwrap_or(ptr::null())
8385
}
8486

8587
/// Point one uint beyond the high end of the allocated stack
8688
pub fn end(&self) -> *const uint {
87-
unsafe {
88-
self.buf.data.offset(self.buf.len as int) as *const uint
89-
}
89+
self.buf.as_ref().map(|buf| unsafe {
90+
buf.data().offset(buf.len() as int) as *const uint
91+
}).unwrap_or(ptr::null())
9092
}
9193
}
9294

@@ -96,7 +98,7 @@ fn protect_last_page(stack: &MemoryMap) -> bool {
9698
// This may seem backwards: the start of the segment is the last page?
9799
// Yes! The stack grows from higher addresses (the end of the allocated
98100
// block) to lower addresses (the start of the allocated block).
99-
let last_page = stack.data as *mut libc::c_void;
101+
let last_page = stack.data() as *mut libc::c_void;
100102
libc::mprotect(last_page, page_size() as libc::size_t,
101103
libc::PROT_NONE) != -1
102104
}
@@ -106,7 +108,7 @@ fn protect_last_page(stack: &MemoryMap) -> bool {
106108
fn protect_last_page(stack: &MemoryMap) -> bool {
107109
unsafe {
108110
// see above
109-
let last_page = stack.data as *mut libc::c_void;
111+
let last_page = stack.data() as *mut libc::c_void;
110112
let mut old_prot: libc::DWORD = 0;
111113
libc::VirtualProtect(last_page, page_size() as libc::SIZE_T,
112114
libc::PAGE_NOACCESS,

trunk/src/librustc/driver/driver.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
270270
}
271271
);
272272

273+
// JBC: make CFG processing part of expansion to avoid this problem:
274+
273275
// strip again, in case expansion added anything with a #[cfg].
274276
krate = time(time_passes, "configuration 2", krate, |krate|
275277
front::config::strip_unconfigured_items(krate));
@@ -290,6 +292,9 @@ pub fn phase_2_configure_and_expand(sess: &Session,
290292
krate.encode(&mut json).unwrap();
291293
}
292294

295+
time(time_passes, "checking that all macro invocations are gone", &krate, |krate|
296+
syntax::ext::expand::check_for_macros(&sess.parse_sess, krate));
297+
293298
Some((krate, map))
294299
}
295300

@@ -302,14 +307,14 @@ pub struct CrateAnalysis {
302307
pub name: String,
303308
}
304309

310+
305311
/// Run the resolution, typechecking, region checking and other
306312
/// miscellaneous analysis passes on the crate. Return various
307313
/// structures carrying the results of the analysis.
308314
pub fn phase_3_run_analysis_passes(sess: Session,
309315
krate: &ast::Crate,
310316
ast_map: syntax::ast_map::Map,
311317
name: String) -> CrateAnalysis {
312-
313318
let time_passes = sess.time_passes();
314319

315320
time(time_passes, "external crate/lib resolution", (), |_|

trunk/src/librustc/driver/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ use syntax::{ast, codemap};
2929
use std::os;
3030
use std::cell::{Cell, RefCell};
3131

32-
32+
// Represents the data associated with a compilation
33+
// session for a single crate.
3334
pub struct Session {
3435
pub targ_cfg: config::Config,
3536
pub opts: config::Options,

trunk/src/librustc/front/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use syntax::codemap;
1414

1515
use std::gc::{Gc, GC};
1616

17+
/// A folder that strips out items that do not belong in the current
18+
/// configuration.
1719
struct Context<'a> {
1820
in_cfg: |attrs: &[ast::Attribute]|: 'a -> bool,
1921
}
@@ -41,6 +43,9 @@ impl<'a> fold::Folder for Context<'a> {
4143
fn fold_expr(&mut self, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
4244
fold_expr(self, expr)
4345
}
46+
fn fold_mac(&mut self, mac: &ast::Mac) -> ast::Mac {
47+
fold::fold_mac(mac, self)
48+
}
4449
}
4550

4651
pub fn strip_items(krate: ast::Crate,

trunk/src/librustc/metadata/creader.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl<'a> PluginMetadataReader<'a> {
446446
should_match_name: true,
447447
};
448448
let library = match load_ctxt.maybe_load_library_crate() {
449-
Some (l) => l,
449+
Some(l) => l,
450450
None if is_cross => {
451451
// try loading from target crates (only valid if there are
452452
// no syntax extensions)
@@ -473,6 +473,14 @@ impl<'a> PluginMetadataReader<'a> {
473473
let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| {
474474
decoder::get_symbol(library.metadata.as_slice(), id)
475475
});
476+
if library.dylib.is_none() && registrar.is_some() {
477+
let message = format!("plugin crate `{}` only found in rlib format, \
478+
but must be available in dylib format",
479+
info.ident);
480+
self.env.sess.span_err(krate.span, message.as_slice());
481+
// No need to abort because the loading code will just ignore this
482+
// empty dylib.
483+
}
476484
let pc = PluginMetadata {
477485
lib: library.dylib.clone(),
478486
macros: macros,

trunk/src/librustc/metadata/encoder.rs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ fn encode_info_for_struct(ecx: &EncodeContext,
693693
encode_name(ebml_w, nm);
694694
encode_type(ecx, ebml_w, node_id_to_type(tcx, id));
695695
encode_def_id(ebml_w, local_def(id));
696+
697+
let stab = stability::lookup(ecx.tcx, field.id);
698+
encode_stability(ebml_w, stab);
699+
696700
ebml_w.end_tag();
697701
}
698702
index
@@ -1584,37 +1588,25 @@ fn encode_plugin_registrar_fn(ecx: &EncodeContext, ebml_w: &mut Encoder) {
15841588
}
15851589
}
15861590

1587-
struct MacroDefVisitor<'a, 'b, 'c> {
1588-
ecx: &'a EncodeContext<'b>,
1589-
ebml_w: &'a mut Encoder<'c>
1590-
}
1591-
1592-
impl<'a, 'b, 'c> Visitor<()> for MacroDefVisitor<'a, 'b, 'c> {
1593-
fn visit_item(&mut self, item: &Item, _: ()) {
1594-
match item.node {
1595-
ItemMac(..) => {
1596-
let def = self.ecx.tcx.sess.codemap().span_to_snippet(item.span)
1597-
.expect("Unable to find source for macro");
1598-
self.ebml_w.start_tag(tag_macro_def);
1599-
self.ebml_w.wr_str(def.as_slice());
1600-
self.ebml_w.end_tag();
1601-
}
1602-
_ => {}
1603-
}
1604-
visit::walk_item(self, item, ());
1605-
}
1591+
/// Given a span, write the text of that span into the output stream
1592+
/// as an exported macro
1593+
fn encode_macro_def(ecx: &EncodeContext,
1594+
ebml_w: &mut Encoder,
1595+
span: &syntax::codemap::Span) {
1596+
let def = ecx.tcx.sess.codemap().span_to_snippet(*span)
1597+
.expect("Unable to find source for macro");
1598+
ebml_w.start_tag(tag_macro_def);
1599+
ebml_w.wr_str(def.as_slice());
1600+
ebml_w.end_tag();
16061601
}
16071602

1608-
fn encode_macro_defs<'a>(ecx: &'a EncodeContext,
1609-
krate: &Crate,
1610-
ebml_w: &'a mut Encoder) {
1603+
/// Serialize the text of the exported macros
1604+
fn encode_macro_defs(ecx: &EncodeContext,
1605+
krate: &Crate,
1606+
ebml_w: &mut Encoder) {
16111607
ebml_w.start_tag(tag_exported_macros);
1612-
{
1613-
let mut visitor = MacroDefVisitor {
1614-
ecx: ecx,
1615-
ebml_w: ebml_w,
1616-
};
1617-
visit::walk_crate(&mut visitor, krate, ());
1608+
for span in krate.exported_macros.iter() {
1609+
encode_macro_def(ecx, ebml_w, span);
16181610
}
16191611
ebml_w.end_tag();
16201612
}

trunk/src/librustc/middle/stability.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
use util::nodemap::{NodeMap, DefIdMap};
1515
use syntax::codemap::Span;
1616
use syntax::{attr, visit};
17+
use syntax::ast;
1718
use syntax::ast::{Attribute, Block, Crate, DefId, FnDecl, NodeId, Variant};
1819
use syntax::ast::{Item, Required, Provided, TraitMethod, TypeMethod, Method};
19-
use syntax::ast::{Generics, StructDef, Ident};
20+
use syntax::ast::{Generics, StructDef, StructField, Ident};
2021
use syntax::ast_util::is_local;
2122
use syntax::attr::Stability;
2223
use syntax::visit::{FnKind, FkMethod, Visitor};
@@ -91,6 +92,11 @@ impl Visitor<Option<Stability>> for Annotator {
9192
s.ctor_id.map(|id| self.annotate(id, &[], parent.clone()));
9293
visit::walk_struct_def(self, s, parent)
9394
}
95+
96+
fn visit_struct_field(&mut self, s: &StructField, parent: Option<Stability>) {
97+
let stab = self.annotate(s.node.id, s.node.attrs.as_slice(), parent);
98+
visit::walk_struct_field(self, s, stab)
99+
}
94100
}
95101

96102
impl Index {
@@ -102,8 +108,8 @@ impl Index {
102108
extern_cache: DefIdMap::new()
103109
}
104110
};
105-
visit::walk_crate(&mut annotator, krate,
106-
attr::find_stability(krate.attrs.as_slice()));
111+
let stab = annotator.annotate(ast::CRATE_NODE_ID, krate.attrs.as_slice(), None);
112+
visit::walk_crate(&mut annotator, krate, stab);
107113
annotator.index
108114
}
109115
}

trunk/src/librustc/plugin/load.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate) -> Plugins {
7272
loader.plugins
7373
}
7474

75+
// note that macros aren't expanded yet, and therefore macros can't add plugins.
7576
impl<'a> Visitor<()> for PluginLoader<'a> {
7677
fn visit_view_item(&mut self, vi: &ast::ViewItem, _: ()) {
7778
match vi.node {
@@ -109,6 +110,10 @@ impl<'a> Visitor<()> for PluginLoader<'a> {
109110
_ => (),
110111
}
111112
}
113+
fn visit_mac(&mut self, _: &ast::Mac, _:()) {
114+
// bummer... can't see plugins inside macros.
115+
// do nothing.
116+
}
112117
}
113118

114119
impl<'a> PluginLoader<'a> {

0 commit comments

Comments
 (0)