Skip to content

Commit c5142d2

Browse files
committed
---
yaml --- r: 1145 b: refs/heads/master c: 2c6dd18 h: refs/heads/master i: 1143: b662d41 v: v3
1 parent 3414661 commit c5142d2

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f900792fa344d9518bf34fe416f25a89be555ba1
2+
refs/heads/master: 2c6dd18224a926ed0da365511e05fcb8e5e817a5

trunk/src/comp/driver/rustc.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import std.option.none;
1313
import std._str;
1414
import std._vec;
1515

16-
impure fn compile_input(session.session sess, str input, str output) {
16+
impure fn compile_input(session.session sess, str input, str output,
17+
bool shared) {
1718
auto p = parser.new_parser(sess, 0, input);
1819
auto crate = parser.parse_crate(p);
1920
crate = resolve.resolve_crate(sess, crate);
2021
crate = typeck.check_crate(sess, crate);
21-
trans.trans_crate(sess, crate, output);
22+
trans.trans_crate(sess, crate, output, shared);
2223
}
2324

2425
fn warn_wrong_compiler() {
@@ -34,6 +35,7 @@ fn usage(session.session sess, str argv0) {
3435
log "";
3536
log " -o <filename> write output to <filename>";
3637
log " -nowarn suppress wrong-compiler warning";
38+
log " -shared compile a shared-library crate";
3739
log " -h display this message";
3840
log "";
3941
log "";
@@ -59,6 +61,7 @@ impure fn main(vec[str] args) {
5961
let option.t[str] input_file = none[str];
6062
let option.t[str] output_file = none[str];
6163
let bool do_warn = true;
64+
let bool shared = false;
6265

6366
auto i = 1u;
6467
auto len = _vec.len[str](args);
@@ -69,6 +72,8 @@ impure fn main(vec[str] args) {
6972
if (_str.byte_len(arg) > 0u && arg.(0) == '-' as u8) {
7073
if (_str.eq(arg, "-nowarn")) {
7174
do_warn = false;
75+
} else if (_str.eq(arg, "-shared")) {
76+
shared = true;
7277
} else {
7378
// FIXME: rust could use an elif construct.
7479
if (_str.eq(arg, "-o")) {
@@ -120,10 +125,10 @@ impure fn main(vec[str] args) {
120125
parts = _vec.pop[str](parts);
121126
parts += ".bc";
122127
auto ofile = _str.concat(parts);
123-
compile_input(sess, ifile, ofile);
128+
compile_input(sess, ifile, ofile, shared);
124129
}
125130
case (some[str](?ofile)) {
126-
compile_input(sess, ifile, ofile);
131+
compile_input(sess, ifile, ofile, shared);
127132
}
128133
}
129134
}

trunk/src/comp/middle/trans.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,8 @@ fn make_glues(ModuleRef llmod) -> @glue_fns {
30553055
no_op_type_glue = make_no_op_type_glue(llmod));
30563056
}
30573057

3058-
fn trans_crate(session.session sess, @ast.crate crate, str output) {
3058+
fn trans_crate(session.session sess, @ast.crate crate, str output,
3059+
bool shared) {
30593060
auto llmod =
30603061
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
30613062
llvm.LLVMGetGlobalContext());
@@ -3095,7 +3096,9 @@ fn trans_crate(session.session sess, @ast.crate crate, str output) {
30953096

30963097
trans_mod(cx, crate.node.module);
30973098
trans_exit_task_glue(cx);
3098-
trans_main_fn(cx, crate_constant(cx));
3099+
if (!shared) {
3100+
trans_main_fn(cx, crate_constant(cx));
3101+
}
30993102

31003103
check_module(llmod);
31013104

0 commit comments

Comments
 (0)