about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/back/link.rs32
-rw-r--r--src/librustc/driver/driver.rs11
2 files changed, 22 insertions, 21 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index c66cc2bf991..db61042b9ff 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -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);
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index 1ddebbb4280..4328bd36751 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -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,