Compile via external assembler on Windows.

This commit is contained in:
Vadim Chugunov 2013-08-18 23:43:42 -07:00
parent 84e683063b
commit 3768bb32cd
2 changed files with 22 additions and 21 deletions

View File

@ -419,16 +419,8 @@ pub mod write {
}
}
pub fn run_ndk(sess: Session, assembly: &Path, object: &Path) {
let cc_prog: ~str = match &sess.opts.android_cross_path {
&Some(ref path) => {
fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
}
&None => {
sess.fatal("need Android NDK path for building \
(--android-cross-path)")
}
};
pub fn run_assembler(sess: Session, assembly: &Path, object: &Path) {
let cc_prog = super::get_cc_prog(sess);
let cc_args = ~[
~"-c",
@ -813,12 +805,7 @@ pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
}
// If the user wants an exe generated we need to invoke
// cc to link the object file with some libs
pub fn link_binary(sess: Session,
obj_filename: &Path,
out_filename: &Path,
lm: LinkMeta) {
pub fn get_cc_prog(sess: Session) -> ~str {
// In the future, FreeBSD will use clang as default compiler.
// It would be flexible to use cc (system's default C compiler)
// instead of hard-coded gcc.
@ -841,9 +828,18 @@ pub fn link_binary(sess: Session,
session::os_win32 => ~"g++",
_ => ~"cc"
}
};
// The invocations of cc share some flags across platforms
}
}
// If the user wants an exe generated we need to invoke
// cc to link the object file with some libs
pub fn link_binary(sess: Session,
obj_filename: &Path,
out_filename: &Path,
lm: LinkMeta) {
let cc_prog = get_cc_prog(sess);
// The invocations of cc share some flags across platforms
let output = if *sess.building_library {
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);

View File

@ -333,8 +333,13 @@ pub fn phase_5_run_llvm_passes(sess: Session,
trans: &CrateTranslation,
outputs: &OutputFilenames) {
// NB: Android hack
if sess.targ_cfg.os == session::os_android &&
// On Windows, LLVM integrated assembler emits bad stack unwind tables when
// segmented stacks are enabled. However, unwind info directives in assembly
// output are OK, so we generate assembly first and then run it through
// an external assembler.
// Same for Android.
if (sess.targ_cfg.os == session::os_android ||
sess.targ_cfg.os == session::os_win32) &&
(sess.opts.output_type == link::output_type_object ||
sess.opts.output_type == link::output_type_exe) {
let output_type = link::output_type_assembly;
@ -347,7 +352,7 @@ pub fn phase_5_run_llvm_passes(sess: Session,
output_type,
&obj_filename));
link::write::run_ndk(sess, &obj_filename, &outputs.obj_filename);
link::write::run_assembler(sess, &obj_filename, &outputs.obj_filename);
} else {
time(sess.time_passes(), ~"LLVM passes", ||
link::write::run_passes(sess,