Add support for producing shared libraries directly in the rust driver.
This commit is contained in:
parent
9b5ebe726c
commit
a77180f4f5
11
mk/stage3.mk
11
mk/stage3.mk
|
@ -1,13 +1,8 @@
|
||||||
stage3/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
stage3/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
||||||
stage2/rustc$(X) stage2/$(CFG_STDLIB) stage2/intrinsics.bc \
|
stage2/rustc$(X) stage2/$(CFG_STDLIB) stage2/intrinsics.bc \
|
||||||
$(LREQ) $(MKFILES)
|
$(LREQ) $(MKFILES)
|
||||||
@$(call E, compile: $@)
|
@$(call E, compile_and_link: $@)
|
||||||
$(STAGE2) -c --shared -o $@ $<
|
$(STAGE2) --shared -o $@ $<
|
||||||
|
|
||||||
stage3/$(CFG_STDLIB): stage2/std.o stage2/glue.o
|
|
||||||
@$(call E, link: $@)
|
|
||||||
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage2/glue.o $(CFG_GCCISH_LINK_FLAGS) -o \
|
|
||||||
$@ $< -Lstage2 -Lrt -lrustrt
|
|
||||||
|
|
||||||
stage3/librustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ2)
|
stage3/librustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ2)
|
||||||
@$(call E, compile: $@)
|
@$(call E, compile: $@)
|
||||||
|
|
|
@ -399,37 +399,34 @@ fn main(vec[str] args) {
|
||||||
let str prog = "gcc";
|
let str prog = "gcc";
|
||||||
// The invocations of gcc share some flags across platforms
|
// The invocations of gcc share some flags across platforms
|
||||||
|
|
||||||
let vec[str] common_cflags =
|
let vec[str] common_args = [stage, "-Lrt", "-lrustrt",
|
||||||
["-fno-strict-aliasing", "-fPIC", "-Wall", "-fno-rtti",
|
"-fno-strict-aliasing", "-fPIC", "-Wall",
|
||||||
"-fno-exceptions", "-g"];
|
"-fno-rtti", "-fno-exceptions", "-g", glu, "-o",
|
||||||
let vec[str] common_libs =
|
saved_out_filename, saved_out_filename + ".o"];
|
||||||
[stage, "-Lrustllvm", "-Lrt", "-lrustrt", "-lrustllvm", "-lstd",
|
|
||||||
"-lm"];
|
auto shared_cmd;
|
||||||
|
|
||||||
alt (sess.get_targ_cfg().os) {
|
alt (sess.get_targ_cfg().os) {
|
||||||
case (session::os_win32) {
|
case (session::os_win32) {
|
||||||
gcc_args =
|
shared_cmd = "-shared";
|
||||||
common_cflags +
|
gcc_args = common_args + ["-march=i686", "-O2"];
|
||||||
["-march=i686", "-O2", glu, main, "-o",
|
|
||||||
saved_out_filename, saved_out_filename + ".o"] +
|
|
||||||
common_libs;
|
|
||||||
}
|
}
|
||||||
case (session::os_macos) {
|
case (session::os_macos) {
|
||||||
gcc_args =
|
shared_cmd = "-dynamiclib";
|
||||||
common_cflags +
|
gcc_args = common_args + ["-arch i386", "-O0", "-m32"];
|
||||||
["-arch i386", "-O0", "-m32", glu, main, "-o",
|
|
||||||
saved_out_filename, saved_out_filename + ".o"] +
|
|
||||||
common_libs;
|
|
||||||
}
|
}
|
||||||
case (session::os_linux) {
|
case (session::os_linux) {
|
||||||
gcc_args =
|
shared_cmd = "-shared";
|
||||||
common_cflags +
|
gcc_args = common_args + ["-march=i686", "-O2", "-m32"];
|
||||||
["-march=i686", "-O2", "-m32", glu, main, "-o",
|
|
||||||
saved_out_filename, saved_out_filename + ".o"] +
|
|
||||||
common_libs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We run 'gcc' here
|
if (sopts.shared) {
|
||||||
|
gcc_args += [shared_cmd];
|
||||||
|
} else {
|
||||||
|
gcc_args += ["-Lrustllvm", "-lrustllvm", "-lstd", "-lm", main];
|
||||||
|
}
|
||||||
|
|
||||||
|
// We run 'gcc' here
|
||||||
run::run_program(prog, gcc_args);
|
run::run_program(prog, gcc_args);
|
||||||
// Clean up on Darwin
|
// Clean up on Darwin
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue