Get tests working on MSVC 32-bit

This commit is contained in:
Alex Crichton 2015-12-14 15:40:43 -08:00
parent 3e9589c0f4
commit 58f1b9c7fc
15 changed files with 105 additions and 102 deletions

View File

@ -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))

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 }

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[no_mangle]
pub extern fn foo() {}

View File

@ -7,7 +7,10 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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

View File

@ -7,7 +7,10 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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

View File

@ -7,9 +7,13 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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);

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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),*]; })
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
use std::f32;
use std::f64;
assert_approx_eq!(64f32.sqrt(), 8f32);
assert_approx_eq!(64f64.sqrt(), 8f64);
assert_approx_eq!(sqrtf32(64f32), 8f32);
assert_approx_eq!(sqrtf64(64f64), 8f64);
assert_approx_eq!(25f32.powi(-2), 0.0016f32);
assert_approx_eq!(23.2f64.powi(2), 538.24f64);
assert_approx_eq!(powif32(25f32, -2), 0.0016f32);
assert_approx_eq!(powif64(23.2f64, 2), 538.24f64);
assert_approx_eq!(0f32.sin(), 0f32);
assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64);
assert_approx_eq!(sinf32(0f32), 0f32);
assert_approx_eq!(sinf64(f64::consts::PI / 2f64), 1f64);
assert_approx_eq!(0f32.cos(), 1f32);
assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64);
assert_approx_eq!(cosf32(0f32), 1f32);
assert_approx_eq!(cosf64(f64::consts::PI * 2f64), 1f64);
assert_approx_eq!(25f32.powf(-2f32), 0.0016f32);
assert_approx_eq!(400f64.powf(0.5f64), 20f64);
assert_approx_eq!(powf32(25f32, -2f32), 0.0016f32);
assert_approx_eq!(powf64(400f64, 0.5f64), 20f64);
assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32);
assert_approx_eq!(1f64.exp(), f64::consts::E);
assert_approx_eq!(fabsf32(expf32(1f32) - f32::consts::E), 0f32);
assert_approx_eq!(expf64(1f64), f64::consts::E);
assert_approx_eq!(10f32.exp2(), 1024f32);
assert_approx_eq!(50f64.exp2(), 1125899906842624f64);
assert_approx_eq!(exp2f32(10f32), 1024f32);
assert_approx_eq!(exp2f64(50f64), 1125899906842624f64);
assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32);
assert_approx_eq!(1f64.ln(), 0f64);
assert_approx_eq!(fabsf32(logf32(f32::consts::E) - 1f32), 0f32);
assert_approx_eq!(logf64(1f64), 0f64);
assert_approx_eq!(10f32.log10(), 1f32);
assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E);
assert_approx_eq!(log10f32(10f32), 1f32);
assert_approx_eq!(log10f64(f64::consts::E), f64::consts::LOG10_E);
assert_approx_eq!(8f32.log2(), 3f32);
assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E);
assert_approx_eq!(log2f32(8f32), 3f32);
assert_approx_eq!(log2f64(f64::consts::E), f64::consts::LOG2_E);
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!(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!((-1.0f32).abs(), 1.0f32);
assert_approx_eq!(34.2f64.abs(), 34.2f64);
assert_approx_eq!(fabsf32(-1.0f32), 1.0f32);
assert_approx_eq!(fabsf64(34.2f64), 34.2f64);
assert_approx_eq!(3.8f32.floor(), 3.0f32);
assert_approx_eq!((-1.1f64).floor(), -2.0f64);
assert_approx_eq!(floorf32(3.8f32), 3.0f32);
assert_approx_eq!(floorf64(-1.1f64), -2.0f64);
// Causes linker error
// undefined reference to llvm.ceil.f32/64
//assert_eq!(ceilf32(-2.3f32), -2.0f32);
//assert_eq!(ceilf64(3.8f64), 4.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);
}