]> git.lizzy.rs Git - rust.git/commitdiff
trans: Re-enable unwinding on 64-bit MSVC
authorAlex Crichton <alex@alexcrichton.com>
Tue, 11 Aug 2015 18:48:43 +0000 (11:48 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 11 Aug 2015 23:45:02 +0000 (16:45 -0700)
This commit leverages the runtime support for DWARF exception info added
in #27210 to enable unwinding by default on 64-bit MSVC. This also additionally
adds a few minor fixes here and there in the test harness and such to get
`make check` entirely passing on 64-bit MSVC:

* The invocation of `maketest.py` now works with spaces/quotes in CC
* debuginfo tests are disabled on MSVC
* A link error for librustc was hacked around (see #27438)

mk/tests.mk
src/etc/maketest.py
src/librustc/lib.rs
src/librustc_back/target/x86_64_pc_windows_msvc.rs
src/librustc_data_structures/lib.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/intrinsic.rs
src/libstd/rt/unwind/mod.rs

index 28837e05195fdedcc1eb47d4a74d5842c8b74698..f91828838a8ea6b1b4a66eab2fafb9d6591d15d4 100644 (file)
@@ -597,6 +597,10 @@ CTEST_DISABLE_debuginfo-gdb =
 CTEST_DISABLE_debuginfo-lldb = "lldb tests are disabled on android"
 endif
 
+ifeq ($(findstring msvc,$(CFG_TARGET)),msvc)
+CTEST_DISABLE_debuginfo-gdb = "gdb tests are disabled on MSVC"
+endif
+
 # CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
 # test group to be disabled *unless* the target is able to build a
 # compiler (i.e. when the target triple is in the set of of host
@@ -1050,7 +1054,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
         $$(MAKE) \
            $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
            $(3)/test/run-make/$$* \
-           "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
+           $$(CC_$(3)) \
+           "$$(CFG_GCCISH_CFLAGS_$(3))" \
            $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
            "$$(TESTNAME)" \
            $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
index f500de5e15d00c623784a62c8662c3ca0c2ab982..04bf81a96aaf3ab09d6389712645c05228e6ddf2 100644 (file)
@@ -41,14 +41,14 @@ def convert_path_spec(name, value):
 make = sys.argv[2]
 putenv('RUSTC', os.path.abspath(sys.argv[3]))
 putenv('TMPDIR', os.path.abspath(sys.argv[4]))
-putenv('CC', sys.argv[5])
-putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
-filt = sys.argv[7]
-putenv('LD_LIB_PATH_ENVVAR', sys.argv[8])
-putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[9]))
-putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[10]))
-putenv('RUST_BUILD_STAGE', sys.argv[11])
-putenv('S', os.path.abspath(sys.argv[12]))
+putenv('CC', sys.argv[5] + ' ' + sys.argv[6])
+putenv('RUSTDOC', os.path.abspath(sys.argv[7]))
+filt = sys.argv[8]
+putenv('LD_LIB_PATH_ENVVAR', sys.argv[9])
+putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[10]))
+putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[11]))
+putenv('RUST_BUILD_STAGE', sys.argv[12])
+putenv('S', os.path.abspath(sys.argv[13]))
 putenv('PYTHON', sys.executable)
 
 if filt not in sys.argv[1]:
index bb44abc4f078db917575bd65d8371ab53f8849c4..935f75040ef01d27f7992075bf4c85f9addcacaf 100644 (file)
@@ -179,5 +179,18 @@ mod rustc {
     pub use lint;
 }
 
+// FIXME(#27438): right now the unit tests of librustc don't refer to any actual
+//                functions generated in librustc_data_structures (all
+//                references are through generic functions), but statics are
+//                referenced from time to time. Due to this bug we won't
+//                actually correctly link in the statics unless we also
+//                reference a function, so be sure to reference a dummy
+//                function.
+#[test]
+fn noop() {
+    rustc_data_structures::__noop_fix_for_27438();
+}
+
+
 // Build the diagnostics array at the end so that the metadata includes error use sites.
 __build_diagnostic_array! { librustc, DIAGNOSTICS }
index addaaeb1b636da2cf7353eed6b96eeca3942cd43..85756db96061fc81f8b1fa227f33ab37e207c863 100644 (file)
@@ -13,6 +13,7 @@
 pub fn target() -> Target {
     let mut base = super::windows_msvc_base::opts();
     base.cpu = "x86-64".to_string();
+    base.custom_unwind_resume = true;
 
     Target {
         llvm_target: "x86_64-pc-windows-msvc".to_string(),
index 558d15610dff25f60184bafd6612300b34a071db..b056ec2cb05ce466d69fce035f6c6d016d86b55e 100644 (file)
@@ -38,3 +38,7 @@
 pub mod bitvec;
 pub mod ivar;
 pub mod unify;
+
+// See comments in src/librustc/lib.rs
+#[doc(hidden)]
+pub fn __noop_fix_for_27438() {}
index 716b12908172413cc91793545a449b3281917703..947c902b2a91b392d2750c0ccc50f9daca506ca6 100644 (file)
@@ -745,13 +745,22 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 }
 
+/// Returns whether this session's target will use SEH-based unwinding.
+///
+/// This is only true for MSVC targets, and even then the 64-bit MSVC target
+/// currently uses SEH-ish unwinding with DWARF info tables to the side (same as
+/// 64-bit MinGW) instead of "full SEH".
+pub fn wants_msvc_seh(sess: &Session) -> bool {
+    sess.target.target.options.is_like_msvc && sess.target.target.arch == "x86"
+}
+
 pub fn need_invoke(bcx: Block) -> bool {
-    // FIXME(#25869) currently unwinding is not implemented for MSVC and our
-    //               normal unwinding infrastructure ends up just causing linker
-    //               errors with the current LLVM implementation, so landing
-    //               pads are disabled entirely for MSVC targets
-    if bcx.sess().no_landing_pads() ||
-       bcx.sess().target.target.options.is_like_msvc {
+    // FIXME(#25869) currently SEH-based unwinding is pretty buggy in LLVM and
+    //               is being overhauled as this is being written. Until that
+    //               time such that upstream LLVM's implementation is more solid
+    //               and we start binding it we need to skip invokes for any
+    //               target which wants SEH-based unwinding.
+    if bcx.sess().no_landing_pads() || wants_msvc_seh(bcx.sess()) {
         return false;
     }
 
index f57612789b53fc8ab6377baece70f92c44a65c03..98301221f96e8aa803e5c6589fec557736f48a7f 100644 (file)
@@ -595,7 +595,7 @@ pub fn eh_personality(&self) -> ValueRef {
         // landing pads as "landing pads for SEH".
         let target = &self.ccx.sess().target.target;
         match self.ccx.tcx().lang_items.eh_personality() {
-            Some(def_id) if !target.options.is_like_msvc => {
+            Some(def_id) if !base::wants_msvc_seh(self.ccx.sess()) => {
                 callee::trans_fn_ref(self.ccx, def_id, ExprId(0),
                                      self.param_substs).val
             }
@@ -604,7 +604,7 @@ pub fn eh_personality(&self) -> ValueRef {
                 match *personality {
                     Some(llpersonality) => llpersonality,
                     None => {
-                        let name = if !target.options.is_like_msvc {
+                        let name = if !base::wants_msvc_seh(self.ccx.sess()) {
                             "rust_eh_personality"
                         } else if target.arch == "x86" {
                             "_except_handler3"
index 0400771dff15c0cebe0f1b967447b2af19b95d34..293a0a6a4ca084cc1e30051c714ad6995add355e 100644 (file)
@@ -1037,7 +1037,7 @@ fn try_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         Call(bcx, func, &[data], None, dloc);
         Store(bcx, C_null(Type::i8p(bcx.ccx())), dest);
         bcx
-    } else if bcx.sess().target.target.options.is_like_msvc {
+    } else if wants_msvc_seh(bcx.sess()) {
         trans_msvc_try(bcx, func, data, dest, dloc)
     } else {
         trans_gnu_try(bcx, func, data, dest, dloc)
index bb43eec8db1c94bc84969b2e525299a015d51a21..4feb2d49a98ba8b27dec53c3cfbdb25af005560d 100644 (file)
 // implementations. One goes through SEH on Windows and the other goes through
 // libgcc via the libunwind-like API.
 
-// *-pc-windows-msvc
-#[cfg(all(windows, target_env = "msvc"))]
+// i686-pc-windows-msvc
+#[cfg(all(windows, target_arch = "x86", target_env = "msvc"))]
 #[path = "seh.rs"] #[doc(hidden)]
 pub mod imp;
 
-// x86_64-pc-windows-gnu
-#[cfg(all(windows, target_arch="x86_64", target_env="gnu"))]
+// x86_64-pc-windows-*
+#[cfg(all(windows, target_arch = "x86_64"))]
 #[path = "seh64_gnu.rs"] #[doc(hidden)]
 pub mod imp;
 
 // i686-pc-windows-gnu and all others
-#[cfg(any(unix, all(windows, target_arch="x86", target_env="gnu")))]
+#[cfg(any(unix, all(windows, target_arch = "x86", target_env = "gnu")))]
 #[path = "gcc.rs"] #[doc(hidden)]
 pub mod imp;