Skip to content

Commit c0b7972

Browse files
committed
auto merge of #10422 : alexcrichton/rust/explicit-crate-map, r=pcwalton
As we start to move runtime components into the crate map, it's becoming harder and harder to start the runtime from a C function as rust is embedded in another application. Right now if you compile a rust crate as a dynamic library which is then linked to another application, when using std::rt::start there are no I/O local services, even though rustuv was linked against and requested. The reason for this is that there is no top level crate map available specifying where to find libuv I/O. This option is not meant to be used regularly, but rather whenever compiling a final library crate and linking it into another application. This lifts the requirement that to get a crate map you must have the final destination be an executable.
2 parents 88e383e + 2eb92b7 commit c0b7972

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc/driver/session.rs

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub static no_vectorize_loops: uint = 1 << 26;
7676
pub static no_vectorize_slp: uint = 1 << 27;
7777
pub static no_prepopulate_passes: uint = 1 << 28;
7878
pub static use_softfp: uint = 1 << 29;
79+
pub static gen_crate_map: uint = 1 << 30;
7980

8081
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
8182
~[("verbose", "in general, enable more debug printouts", verbose),
@@ -128,6 +129,7 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
128129
"Don't run LLVM's SLP vectorization passes",
129130
no_vectorize_slp),
130131
("soft-float", "Generate software floating point library calls", use_softfp),
132+
("gen-crate-map", "Force generation of a toplevel crate map", gen_crate_map),
131133
]
132134
}
133135

@@ -331,6 +333,9 @@ impl Session_ {
331333
pub fn no_vectorize_slp(&self) -> bool {
332334
self.debugging_opt(no_vectorize_slp)
333335
}
336+
pub fn gen_crate_map(&self) -> bool {
337+
self.debugging_opt(gen_crate_map)
338+
}
334339

335340
// pointless function, now...
336341
pub fn str_of(&self, id: ast::Ident) -> @str {

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2949,7 +2949,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29492949
let mut n_subcrates = 1;
29502950
let cstore = sess.cstore;
29512951
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
2952-
let mapname = if *sess.building_library {
2952+
let mapname = if *sess.building_library && !sess.gen_crate_map() {
29532953
format!("{}_{}_{}", mapmeta.name, mapmeta.vers, mapmeta.extras_hash)
29542954
} else {
29552955
~"toplevel"

0 commit comments

Comments
 (0)