Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a -shared option to rustc #187

Merged
1 commit merged into from
Dec 29, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/comp/driver/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import std.option.none;
import std._str;
import std._vec;

impure fn compile_input(session.session sess, str input, str output) {
impure fn compile_input(session.session sess, str input, str output,
bool shared) {
auto p = parser.new_parser(sess, 0, input);
auto crate = parser.parse_crate(p);
crate = resolve.resolve_crate(sess, crate);
crate = typeck.check_crate(sess, crate);
trans.trans_crate(sess, crate, output);
trans.trans_crate(sess, crate, output, shared);
}

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

auto i = 1u;
auto len = _vec.len[str](args);
Expand All @@ -69,6 +72,8 @@ impure fn main(vec[str] args) {
if (_str.byte_len(arg) > 0u && arg.(0) == '-' as u8) {
if (_str.eq(arg, "-nowarn")) {
do_warn = false;
} else if (_str.eq(arg, "-shared")) {
shared = true;
} else {
// FIXME: rust could use an elif construct.
if (_str.eq(arg, "-o")) {
Expand Down Expand Up @@ -120,10 +125,10 @@ impure fn main(vec[str] args) {
parts = _vec.pop[str](parts);
parts += ".bc";
auto ofile = _str.concat(parts);
compile_input(sess, ifile, ofile);
compile_input(sess, ifile, ofile, shared);
}
case (some[str](?ofile)) {
compile_input(sess, ifile, ofile);
compile_input(sess, ifile, ofile, shared);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,8 @@ fn make_glues(ModuleRef llmod) -> @glue_fns {
no_op_type_glue = make_no_op_type_glue(llmod));
}

fn trans_crate(session.session sess, @ast.crate crate, str output) {
fn trans_crate(session.session sess, @ast.crate crate, str output,
bool shared) {
auto llmod =
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
llvm.LLVMGetGlobalContext());
Expand Down Expand Up @@ -3095,7 +3096,9 @@ fn trans_crate(session.session sess, @ast.crate crate, str output) {

trans_mod(cx, crate.node.module);
trans_exit_task_glue(cx);
trans_main_fn(cx, crate_constant(cx));
if (!shared) {
trans_main_fn(cx, crate_constant(cx));
}

check_module(llmod);

Expand Down