Skip to content

Commit 11698cb

Browse files
committed
Get tests working on MSVC 32-bit
1 parent 47c7581 commit 11698cb

15 files changed

+105
-102
lines changed

mk/tests.mk

+2
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10291029
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
10301030
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10311031
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
1032+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1033+
export MSVC_LIB := "$$(CFG_MSVC_LIB_$$(HOST_$(3)))"
10321034
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10331035
$(S)src/test/run-make/%/Makefile \
10341036
$$(CSREQ$(1)_T_$(2)_H_$(3))
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub extern fn f() -> i32 { 1 }
12+
pub extern fn g() -> i32 { 2 }
13+
14+
pub fn get_f() -> extern fn() -> i32 { f }
15+
pub fn get_g() -> extern fn() -> i32 { g }

src/test/auxiliary/fn-abi.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[no_mangle]
12+
pub extern fn foo() {}

src/test/run-fail/mir_trans_calls_converging_drops.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
1011
#![feature(rustc_attrs)]
12+
13+
// ignore-msvc: FIXME(#30941)
1114
// error-pattern:converging_fn called
1215
// error-pattern:0 dropped
1316
// error-pattern:exit

src/test/run-fail/mir_trans_calls_converging_drops_2.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
1011
#![feature(rustc_attrs)]
12+
13+
// ignore-msvc: FIXME(#30941)
1114
// error-pattern:complex called
1215
// error-pattern:dropped
1316
// error-pattern:exit

src/test/run-fail/mir_trans_calls_diverging_drops.rs

+4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
1011
#![feature(rustc_attrs)]
12+
13+
// ignore-msvc: FIXME(#30941)
1114
// error-pattern:diverging_fn called
1215
// error-pattern:0 dropped
16+
1317
use std::io::{self, Write};
1418

1519
struct Droppable(u8);

src/test/run-make/execution-engine/test.rs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ use syntax::diagnostics::registry::Registry;
4242
use syntax::parse::token;
4343

4444
fn main() {
45+
// Currently trips an assertion on i686-msvc, presumably because the support
46+
// in LLVM is a little young.
47+
if cfg!(target_env = "msvc") && cfg!(target_arch = "x86") {
48+
return
49+
}
50+
4551
let program = r#"
4652
#[no_mangle]
4753
pub static TEST_STATIC: i32 = 42;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-include ../tools.mk
22

3-
all: $(call NATIVE_STATICLIB,test)
3+
all: $(call NATIVE_STATICLIB,ctest)
44
$(RUSTC) testcrate.rs
55
$(RUSTC) test.rs
66
$(call RUN,test) || exit 1

src/test/run-make/extern-fn-with-union/testcrate.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
#![crate_type = "lib"]
1212

13+
#[repr(C)]
1314
pub struct TestUnion {
14-
val: u64
15+
_val: u64
1516
}
1617

17-
#[link(name = "test", kind = "static")]
18+
#[link(name = "ctest", kind = "static")]
1819
extern {
1920
pub fn give_back(tu: TestUnion) -> u64;
2021
}

src/test/run-make/tools.mk

+5
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
100100

101101
%.a: %.o
102102
ar crus $@ $<
103+
ifdef IS_MSVC
104+
%.lib: lib%.o
105+
$(MSVC_LIB) -out:`cygpath -w $@` $<
106+
else
103107
%.lib: lib%.o
104108
ar crus $@ $<
109+
endif
105110
%.dylib: %.o
106111
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
107112
%.so: %.o

src/test/run-pass/backtrace-debuginfo.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ macro_rules! pos {
2727
() => ((file!(), line!()))
2828
}
2929

30-
#[cfg(any(all(unix,
31-
not(target_os = "macos"),
32-
not(target_os = "ios"),
33-
not(target_os = "android"),
34-
not(all(target_os = "linux", target_arch = "arm"))),
35-
all(windows, not(target_arch = "x86"))))]
30+
#[cfg(all(unix,
31+
not(target_os = "macos"),
32+
not(target_os = "ios"),
33+
not(target_os = "android"),
34+
not(all(target_os = "linux", target_arch = "arm"))))]
3635
macro_rules! dump_and_die {
3736
($($pos:expr),*) => ({
3837
// FIXME(#18285): we cannot include the current position because
@@ -43,12 +42,11 @@ macro_rules! dump_and_die {
4342
}
4443

4544
// this does not work on Windows, Android, OSX or iOS
46-
#[cfg(not(any(all(unix,
45+
#[cfg(not(all(unix,
4746
not(target_os = "macos"),
4847
not(target_os = "ios"),
4948
not(target_os = "android"),
50-
not(all(target_os = "linux", target_arch = "arm"))),
51-
all(windows, not(target_arch = "x86")))))]
49+
not(all(target_os = "linux", target_arch = "arm")))))]
5250
macro_rules! dump_and_die {
5351
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
5452
}

src/test/run-pass/extern-take-value.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// aux-build:extern-take-value.rs
1112

12-
extern fn f() {
13-
}
14-
15-
extern fn g() {
16-
}
13+
extern crate extern_take_value;
1714

1815
pub fn main() {
19-
let a: extern "C" fn() = f;
20-
let b: extern "C" fn() = f;
21-
let c: extern "C" fn() = g;
16+
let a: extern "C" fn() -> i32 = extern_take_value::get_f();
17+
let b: extern "C" fn() -> i32 = extern_take_value::get_f();
18+
let c: extern "C" fn() -> i32 = extern_take_value::get_g();
2219

2320
assert!(a == b);
2421
assert!(a != c);

src/test/run-pass/fn-abi.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
// ABI (#9309).
1313

1414
// pretty-expanded FIXME #23616
15+
// aux-build:fn-abi.rs
16+
17+
extern crate fn_abi;
1518

1619
extern {
17-
fn printf();
20+
fn foo();
1821
}
1922

2023
pub fn main() {
21-
// Will only type check if the type of _p and the decl of printf use the same ABI
22-
let _p: unsafe extern fn() = printf;
24+
// Will only type check if the type of _p and the decl of foo use the
25+
// same ABI
26+
let _p: unsafe extern fn() = foo;
2327
}

src/test/run-pass/intrinsics-math.rs

+32-79
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
12-
#![feature(intrinsics, core)]
13-
1411
macro_rules! assert_approx_eq {
1512
($a:expr, $b:expr) => ({
1613
let (a, b) = (&$a, &$b);
@@ -19,96 +16,52 @@ macro_rules! assert_approx_eq {
1916
})
2017
}
2118

22-
mod rusti {
23-
extern "rust-intrinsic" {
24-
pub fn sqrtf32(x: f32) -> f32;
25-
pub fn sqrtf64(x: f64) -> f64;
26-
pub fn powif32(a: f32, x: i32) -> f32;
27-
pub fn powif64(a: f64, x: i32) -> f64;
28-
pub fn sinf32(x: f32) -> f32;
29-
pub fn sinf64(x: f64) -> f64;
30-
pub fn cosf32(x: f32) -> f32;
31-
pub fn cosf64(x: f64) -> f64;
32-
pub fn powf32(a: f32, x: f32) -> f32;
33-
pub fn powf64(a: f64, x: f64) -> f64;
34-
pub fn expf32(x: f32) -> f32;
35-
pub fn expf64(x: f64) -> f64;
36-
pub fn exp2f32(x: f32) -> f32;
37-
pub fn exp2f64(x: f64) -> f64;
38-
pub fn logf32(x: f32) -> f32;
39-
pub fn logf64(x: f64) -> f64;
40-
pub fn log10f32(x: f32) -> f32;
41-
pub fn log10f64(x: f64) -> f64;
42-
pub fn log2f32(x: f32) -> f32;
43-
pub fn log2f64(x: f64) -> f64;
44-
pub fn fmaf32(a: f32, b: f32, c: f32) -> f32;
45-
pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;
46-
pub fn fabsf32(x: f32) -> f32;
47-
pub fn fabsf64(x: f64) -> f64;
48-
pub fn floorf32(x: f32) -> f32;
49-
pub fn floorf64(x: f64) -> f64;
50-
pub fn ceilf32(x: f32) -> f32;
51-
pub fn ceilf64(x: f64) -> f64;
52-
pub fn truncf32(x: f32) -> f32;
53-
pub fn truncf64(x: f64) -> f64;
54-
}
55-
}
56-
5719
pub fn main() {
58-
unsafe {
59-
use rusti::*;
60-
61-
use std::f32;
62-
use std::f64;
63-
64-
assert_approx_eq!(sqrtf32(64f32), 8f32);
65-
assert_approx_eq!(sqrtf64(64f64), 8f64);
20+
use std::f32;
21+
use std::f64;
6622

67-
assert_approx_eq!(powif32(25f32, -2), 0.0016f32);
68-
assert_approx_eq!(powif64(23.2f64, 2), 538.24f64);
23+
assert_approx_eq!(64f32.sqrt(), 8f32);
24+
assert_approx_eq!(64f64.sqrt(), 8f64);
6925

70-
assert_approx_eq!(sinf32(0f32), 0f32);
71-
assert_approx_eq!(sinf64(f64::consts::PI / 2f64), 1f64);
26+
assert_approx_eq!(25f32.powi(-2), 0.0016f32);
27+
assert_approx_eq!(23.2f64.powi(2), 538.24f64);
7228

73-
assert_approx_eq!(cosf32(0f32), 1f32);
74-
assert_approx_eq!(cosf64(f64::consts::PI * 2f64), 1f64);
29+
assert_approx_eq!(0f32.sin(), 0f32);
30+
assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64);
7531

76-
assert_approx_eq!(powf32(25f32, -2f32), 0.0016f32);
77-
assert_approx_eq!(powf64(400f64, 0.5f64), 20f64);
32+
assert_approx_eq!(0f32.cos(), 1f32);
33+
assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64);
7834

79-
assert_approx_eq!(fabsf32(expf32(1f32) - f32::consts::E), 0f32);
80-
assert_approx_eq!(expf64(1f64), f64::consts::E);
35+
assert_approx_eq!(25f32.powf(-2f32), 0.0016f32);
36+
assert_approx_eq!(400f64.powf(0.5f64), 20f64);
8137

82-
assert_approx_eq!(exp2f32(10f32), 1024f32);
83-
assert_approx_eq!(exp2f64(50f64), 1125899906842624f64);
38+
assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32);
39+
assert_approx_eq!(1f64.exp(), f64::consts::E);
8440

85-
assert_approx_eq!(fabsf32(logf32(f32::consts::E) - 1f32), 0f32);
86-
assert_approx_eq!(logf64(1f64), 0f64);
41+
assert_approx_eq!(10f32.exp2(), 1024f32);
42+
assert_approx_eq!(50f64.exp2(), 1125899906842624f64);
8743

88-
assert_approx_eq!(log10f32(10f32), 1f32);
89-
assert_approx_eq!(log10f64(f64::consts::E), f64::consts::LOG10_E);
44+
assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32);
45+
assert_approx_eq!(1f64.ln(), 0f64);
9046

91-
assert_approx_eq!(log2f32(8f32), 3f32);
92-
assert_approx_eq!(log2f64(f64::consts::E), f64::consts::LOG2_E);
47+
assert_approx_eq!(10f32.log10(), 1f32);
48+
assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E);
9349

94-
assert_approx_eq!(fmaf32(1.0f32, 2.0f32, 5.0f32), 7.0f32);
95-
assert_approx_eq!(fmaf64(0.0f64, -2.0f64, f64::consts::E), f64::consts::E);
50+
assert_approx_eq!(8f32.log2(), 3f32);
51+
assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E);
9652

97-
assert_approx_eq!(fabsf32(-1.0f32), 1.0f32);
98-
assert_approx_eq!(fabsf64(34.2f64), 34.2f64);
53+
assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32);
54+
assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E);
9955

100-
assert_approx_eq!(floorf32(3.8f32), 3.0f32);
101-
assert_approx_eq!(floorf64(-1.1f64), -2.0f64);
56+
assert_approx_eq!((-1.0f32).abs(), 1.0f32);
57+
assert_approx_eq!(34.2f64.abs(), 34.2f64);
10258

103-
// Causes linker error
104-
// undefined reference to llvm.ceil.f32/64
105-
//assert_eq!(ceilf32(-2.3f32), -2.0f32);
106-
//assert_eq!(ceilf64(3.8f64), 4.0f64);
59+
assert_approx_eq!(3.8f32.floor(), 3.0f32);
60+
assert_approx_eq!((-1.1f64).floor(), -2.0f64);
10761

108-
// Causes linker error
109-
// undefined reference to llvm.trunc.f32/64
110-
//assert_eq!(truncf32(0.1f32), 0.0f32);
111-
//assert_eq!(truncf64(-0.1f64), 0.0f64);
112-
}
62+
assert_approx_eq!((-2.3f32).ceil(), -2.0f32);
63+
assert_approx_eq!(3.8f64.ceil(), 4.0f64);
11364

65+
assert_approx_eq!(0.1f32.trunc(), 0.0f32);
66+
assert_approx_eq!((-0.1f64).trunc(), 0.0f64);
11467
}

0 commit comments

Comments
 (0)