Skip to content

Commit 3768bb3

Browse files
committed
Compile via external assembler on Windows.
1 parent 84e6830 commit 3768bb3

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/librustc/back/link.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -419,16 +419,8 @@ pub mod write {
419419
}
420420
}
421421

422-
pub fn run_ndk(sess: Session, assembly: &Path, object: &Path) {
423-
let cc_prog: ~str = match &sess.opts.android_cross_path {
424-
&Some(ref path) => {
425-
fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
426-
}
427-
&None => {
428-
sess.fatal("need Android NDK path for building \
429-
(--android-cross-path)")
430-
}
431-
};
422+
pub fn run_assembler(sess: Session, assembly: &Path, object: &Path) {
423+
let cc_prog = super::get_cc_prog(sess);
432424

433425
let cc_args = ~[
434426
~"-c",
@@ -813,12 +805,7 @@ pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
813805
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
814806
}
815807

816-
// If the user wants an exe generated we need to invoke
817-
// cc to link the object file with some libs
818-
pub fn link_binary(sess: Session,
819-
obj_filename: &Path,
820-
out_filename: &Path,
821-
lm: LinkMeta) {
808+
pub fn get_cc_prog(sess: Session) -> ~str {
822809
// In the future, FreeBSD will use clang as default compiler.
823810
// It would be flexible to use cc (system's default C compiler)
824811
// instead of hard-coded gcc.
@@ -841,9 +828,18 @@ pub fn link_binary(sess: Session,
841828
session::os_win32 => ~"g++",
842829
_ => ~"cc"
843830
}
844-
};
845-
// The invocations of cc share some flags across platforms
831+
}
832+
}
833+
834+
// If the user wants an exe generated we need to invoke
835+
// cc to link the object file with some libs
836+
pub fn link_binary(sess: Session,
837+
obj_filename: &Path,
838+
out_filename: &Path,
839+
lm: LinkMeta) {
846840

841+
let cc_prog = get_cc_prog(sess);
842+
// The invocations of cc share some flags across platforms
847843

848844
let output = if *sess.building_library {
849845
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);

src/librustc/driver/driver.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,13 @@ pub fn phase_5_run_llvm_passes(sess: Session,
333333
trans: &CrateTranslation,
334334
outputs: &OutputFilenames) {
335335

336-
// NB: Android hack
337-
if sess.targ_cfg.os == session::os_android &&
336+
// On Windows, LLVM integrated assembler emits bad stack unwind tables when
337+
// segmented stacks are enabled. However, unwind info directives in assembly
338+
// output are OK, so we generate assembly first and then run it through
339+
// an external assembler.
340+
// Same for Android.
341+
if (sess.targ_cfg.os == session::os_android ||
342+
sess.targ_cfg.os == session::os_win32) &&
338343
(sess.opts.output_type == link::output_type_object ||
339344
sess.opts.output_type == link::output_type_exe) {
340345
let output_type = link::output_type_assembly;
@@ -347,7 +352,7 @@ pub fn phase_5_run_llvm_passes(sess: Session,
347352
output_type,
348353
&obj_filename));
349354

350-
link::write::run_ndk(sess, &obj_filename, &outputs.obj_filename);
355+
link::write::run_assembler(sess, &obj_filename, &outputs.obj_filename);
351356
} else {
352357
time(sess.time_passes(), ~"LLVM passes", ||
353358
link::write::run_passes(sess,

0 commit comments

Comments
 (0)