diff --git a/mk/tests.mk b/mk/tests.mk index b3f7278ad62cc..31aa2fff247ff 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -1029,6 +1029,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3))) $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3))) +$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ + export MSVC_LIB := "$$(CFG_MSVC_LIB_$$(HOST_$(3)))" $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ $(S)src/test/run-make/%/Makefile \ $$(CSREQ$(1)_T_$(2)_H_$(3)) diff --git a/src/test/auxiliary/extern-take-value.rs b/src/test/auxiliary/extern-take-value.rs new file mode 100644 index 0000000000000..500c455136b51 --- /dev/null +++ b/src/test/auxiliary/extern-take-value.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern fn f() -> i32 { 1 } +pub extern fn g() -> i32 { 2 } + +pub fn get_f() -> extern fn() -> i32 { f } +pub fn get_g() -> extern fn() -> i32 { g } diff --git a/src/test/auxiliary/fn-abi.rs b/src/test/auxiliary/fn-abi.rs new file mode 100644 index 0000000000000..5d380ea6a5aca --- /dev/null +++ b/src/test/auxiliary/fn-abi.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn foo() {} diff --git a/src/test/run-fail/mir_trans_calls_converging_drops.rs b/src/test/run-fail/mir_trans_calls_converging_drops.rs index 754f616cfd5a0..eb399e07d859d 100644 --- a/src/test/run-fail/mir_trans_calls_converging_drops.rs +++ b/src/test/run-fail/mir_trans_calls_converging_drops.rs @@ -7,7 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + #![feature(rustc_attrs)] + +// ignore-msvc: FIXME(#30941) // error-pattern:converging_fn called // error-pattern:0 dropped // error-pattern:exit diff --git a/src/test/run-fail/mir_trans_calls_converging_drops_2.rs b/src/test/run-fail/mir_trans_calls_converging_drops_2.rs index 5e870be3bc6ec..df4ead387b91f 100644 --- a/src/test/run-fail/mir_trans_calls_converging_drops_2.rs +++ b/src/test/run-fail/mir_trans_calls_converging_drops_2.rs @@ -7,7 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + #![feature(rustc_attrs)] + +// ignore-msvc: FIXME(#30941) // error-pattern:complex called // error-pattern:dropped // error-pattern:exit diff --git a/src/test/run-fail/mir_trans_calls_diverging_drops.rs b/src/test/run-fail/mir_trans_calls_diverging_drops.rs index ffa1ff0827775..cbe8793cceb22 100644 --- a/src/test/run-fail/mir_trans_calls_diverging_drops.rs +++ b/src/test/run-fail/mir_trans_calls_diverging_drops.rs @@ -7,9 +7,13 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + #![feature(rustc_attrs)] + +// ignore-msvc: FIXME(#30941) // error-pattern:diverging_fn called // error-pattern:0 dropped + use std::io::{self, Write}; struct Droppable(u8); diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index fe6a5faf9324a..c4d28223c1a84 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -42,6 +42,12 @@ use syntax::diagnostics::registry::Registry; use syntax::parse::token; fn main() { + // Currently trips an assertion on i686-msvc, presumably because the support + // in LLVM is a little young. + if cfg!(target_env = "msvc") && cfg!(target_arch = "x86") { + return + } + let program = r#" #[no_mangle] pub static TEST_STATIC: i32 = 42; diff --git a/src/test/run-make/extern-fn-with-union/Makefile b/src/test/run-make/extern-fn-with-union/Makefile index cf897dba1f279..71a5407e882dd 100644 --- a/src/test/run-make/extern-fn-with-union/Makefile +++ b/src/test/run-make/extern-fn-with-union/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -all: $(call NATIVE_STATICLIB,test) +all: $(call NATIVE_STATICLIB,ctest) $(RUSTC) testcrate.rs $(RUSTC) test.rs $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-union/test.c b/src/test/run-make/extern-fn-with-union/ctest.c similarity index 100% rename from src/test/run-make/extern-fn-with-union/test.c rename to src/test/run-make/extern-fn-with-union/ctest.c diff --git a/src/test/run-make/extern-fn-with-union/testcrate.rs b/src/test/run-make/extern-fn-with-union/testcrate.rs index ebd62d902dfe7..66978c38511eb 100644 --- a/src/test/run-make/extern-fn-with-union/testcrate.rs +++ b/src/test/run-make/extern-fn-with-union/testcrate.rs @@ -10,11 +10,12 @@ #![crate_type = "lib"] +#[repr(C)] pub struct TestUnion { - val: u64 + _val: u64 } -#[link(name = "test", kind = "static")] +#[link(name = "ctest", kind = "static")] extern { pub fn give_back(tu: TestUnion) -> u64; } diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index efaf1197fbdba..8be34ce427460 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -100,8 +100,13 @@ REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1)) %.a: %.o ar crus $@ $< +ifdef IS_MSVC +%.lib: lib%.o + $(MSVC_LIB) -out:`cygpath -w $@` $< +else %.lib: lib%.o ar crus $@ $< +endif %.dylib: %.o $(CC) -dynamiclib -Wl,-dylib -o $@ $< %.so: %.o diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index b6400c68f5367..a8eade34cbcdd 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -27,12 +27,11 @@ macro_rules! pos { () => ((file!(), line!())) } -#[cfg(any(all(unix, - not(target_os = "macos"), - not(target_os = "ios"), - not(target_os = "android"), - not(all(target_os = "linux", target_arch = "arm"))), - all(windows, not(target_arch = "x86"))))] +#[cfg(all(unix, + not(target_os = "macos"), + not(target_os = "ios"), + not(target_os = "android"), + not(all(target_os = "linux", target_arch = "arm"))))] macro_rules! dump_and_die { ($($pos:expr),*) => ({ // FIXME(#18285): we cannot include the current position because @@ -43,12 +42,11 @@ macro_rules! dump_and_die { } // this does not work on Windows, Android, OSX or iOS -#[cfg(not(any(all(unix, +#[cfg(not(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android"), - not(all(target_os = "linux", target_arch = "arm"))), - all(windows, not(target_arch = "x86")))))] + not(all(target_os = "linux", target_arch = "arm")))))] macro_rules! dump_and_die { ($($pos:expr),*) => ({ let _ = [$($pos),*]; }) } diff --git a/src/test/run-pass/extern-take-value.rs b/src/test/run-pass/extern-take-value.rs index 7ef87b9409d51..f535e45e6cf6e 100644 --- a/src/test/run-pass/extern-take-value.rs +++ b/src/test/run-pass/extern-take-value.rs @@ -8,17 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// aux-build:extern-take-value.rs -extern fn f() { -} - -extern fn g() { -} +extern crate extern_take_value; pub fn main() { - let a: extern "C" fn() = f; - let b: extern "C" fn() = f; - let c: extern "C" fn() = g; + let a: extern "C" fn() -> i32 = extern_take_value::get_f(); + let b: extern "C" fn() -> i32 = extern_take_value::get_f(); + let c: extern "C" fn() -> i32 = extern_take_value::get_g(); assert!(a == b); assert!(a != c); diff --git a/src/test/run-pass/fn-abi.rs b/src/test/run-pass/fn-abi.rs index 521ed6db65be1..0e3005a2aaa65 100644 --- a/src/test/run-pass/fn-abi.rs +++ b/src/test/run-pass/fn-abi.rs @@ -12,12 +12,16 @@ // ABI (#9309). // pretty-expanded FIXME #23616 +// aux-build:fn-abi.rs + +extern crate fn_abi; extern { - fn printf(); + fn foo(); } pub fn main() { - // Will only type check if the type of _p and the decl of printf use the same ABI - let _p: unsafe extern fn() = printf; + // Will only type check if the type of _p and the decl of foo use the + // same ABI + let _p: unsafe extern fn() = foo; } diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index f547519b671f1..a2c55634749cb 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(intrinsics, core)] - macro_rules! assert_approx_eq { ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); @@ -19,96 +16,52 @@ macro_rules! assert_approx_eq { }) } -mod rusti { - extern "rust-intrinsic" { - pub fn sqrtf32(x: f32) -> f32; - pub fn sqrtf64(x: f64) -> f64; - pub fn powif32(a: f32, x: i32) -> f32; - pub fn powif64(a: f64, x: i32) -> f64; - pub fn sinf32(x: f32) -> f32; - pub fn sinf64(x: f64) -> f64; - pub fn cosf32(x: f32) -> f32; - pub fn cosf64(x: f64) -> f64; - pub fn powf32(a: f32, x: f32) -> f32; - pub fn powf64(a: f64, x: f64) -> f64; - pub fn expf32(x: f32) -> f32; - pub fn expf64(x: f64) -> f64; - pub fn exp2f32(x: f32) -> f32; - pub fn exp2f64(x: f64) -> f64; - pub fn logf32(x: f32) -> f32; - pub fn logf64(x: f64) -> f64; - pub fn log10f32(x: f32) -> f32; - pub fn log10f64(x: f64) -> f64; - pub fn log2f32(x: f32) -> f32; - pub fn log2f64(x: f64) -> f64; - pub fn fmaf32(a: f32, b: f32, c: f32) -> f32; - pub fn fmaf64(a: f64, b: f64, c: f64) -> f64; - pub fn fabsf32(x: f32) -> f32; - pub fn fabsf64(x: f64) -> f64; - pub fn floorf32(x: f32) -> f32; - pub fn floorf64(x: f64) -> f64; - pub fn ceilf32(x: f32) -> f32; - pub fn ceilf64(x: f64) -> f64; - pub fn truncf32(x: f32) -> f32; - pub fn truncf64(x: f64) -> f64; - } -} - pub fn main() { - unsafe { - use rusti::*; - - use std::f32; - use std::f64; - - assert_approx_eq!(sqrtf32(64f32), 8f32); - assert_approx_eq!(sqrtf64(64f64), 8f64); + use std::f32; + use std::f64; - assert_approx_eq!(powif32(25f32, -2), 0.0016f32); - assert_approx_eq!(powif64(23.2f64, 2), 538.24f64); + assert_approx_eq!(64f32.sqrt(), 8f32); + assert_approx_eq!(64f64.sqrt(), 8f64); - assert_approx_eq!(sinf32(0f32), 0f32); - assert_approx_eq!(sinf64(f64::consts::PI / 2f64), 1f64); + assert_approx_eq!(25f32.powi(-2), 0.0016f32); + assert_approx_eq!(23.2f64.powi(2), 538.24f64); - assert_approx_eq!(cosf32(0f32), 1f32); - assert_approx_eq!(cosf64(f64::consts::PI * 2f64), 1f64); + assert_approx_eq!(0f32.sin(), 0f32); + assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64); - assert_approx_eq!(powf32(25f32, -2f32), 0.0016f32); - assert_approx_eq!(powf64(400f64, 0.5f64), 20f64); + assert_approx_eq!(0f32.cos(), 1f32); + assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64); - assert_approx_eq!(fabsf32(expf32(1f32) - f32::consts::E), 0f32); - assert_approx_eq!(expf64(1f64), f64::consts::E); + assert_approx_eq!(25f32.powf(-2f32), 0.0016f32); + assert_approx_eq!(400f64.powf(0.5f64), 20f64); - assert_approx_eq!(exp2f32(10f32), 1024f32); - assert_approx_eq!(exp2f64(50f64), 1125899906842624f64); + assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32); + assert_approx_eq!(1f64.exp(), f64::consts::E); - assert_approx_eq!(fabsf32(logf32(f32::consts::E) - 1f32), 0f32); - assert_approx_eq!(logf64(1f64), 0f64); + assert_approx_eq!(10f32.exp2(), 1024f32); + assert_approx_eq!(50f64.exp2(), 1125899906842624f64); - assert_approx_eq!(log10f32(10f32), 1f32); - assert_approx_eq!(log10f64(f64::consts::E), f64::consts::LOG10_E); + assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32); + assert_approx_eq!(1f64.ln(), 0f64); - assert_approx_eq!(log2f32(8f32), 3f32); - assert_approx_eq!(log2f64(f64::consts::E), f64::consts::LOG2_E); + assert_approx_eq!(10f32.log10(), 1f32); + assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E); - assert_approx_eq!(fmaf32(1.0f32, 2.0f32, 5.0f32), 7.0f32); - assert_approx_eq!(fmaf64(0.0f64, -2.0f64, f64::consts::E), f64::consts::E); + assert_approx_eq!(8f32.log2(), 3f32); + assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E); - assert_approx_eq!(fabsf32(-1.0f32), 1.0f32); - assert_approx_eq!(fabsf64(34.2f64), 34.2f64); + assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32); + assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E); - assert_approx_eq!(floorf32(3.8f32), 3.0f32); - assert_approx_eq!(floorf64(-1.1f64), -2.0f64); + assert_approx_eq!((-1.0f32).abs(), 1.0f32); + assert_approx_eq!(34.2f64.abs(), 34.2f64); - // Causes linker error - // undefined reference to llvm.ceil.f32/64 - //assert_eq!(ceilf32(-2.3f32), -2.0f32); - //assert_eq!(ceilf64(3.8f64), 4.0f64); + assert_approx_eq!(3.8f32.floor(), 3.0f32); + assert_approx_eq!((-1.1f64).floor(), -2.0f64); - // Causes linker error - // undefined reference to llvm.trunc.f32/64 - //assert_eq!(truncf32(0.1f32), 0.0f32); - //assert_eq!(truncf64(-0.1f64), 0.0f64); - } + assert_approx_eq!((-2.3f32).ceil(), -2.0f32); + assert_approx_eq!(3.8f64.ceil(), 4.0f64); + assert_approx_eq!(0.1f32.trunc(), 0.0f32); + assert_approx_eq!((-0.1f64).trunc(), 0.0f64); }