Skip to content

Commit 2b49991

Browse files
committed
Get tests working on MSVC 32-bit
1 parent c44026c commit 2b49991

File tree

11 files changed

+89
-102
lines changed

11 files changed

+89
-102
lines changed

mk/tests.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10521052
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
10531053
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10541054
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
1055+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1056+
export MSVC_LIB := "$$(CFG_MSVC_LIB_$$(HOST_$(3)))"
10551057
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10561058
$(S)src/test/run-make/%/Makefile \
10571059
$$(CSREQ$(1)_T_$(2)_H_$(3))
Lines changed: 15 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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() {}
Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 5 additions & 0 deletions
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:$@ $<
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

Lines changed: 7 additions & 9 deletions
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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 7 additions & 3 deletions
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
}

0 commit comments

Comments
 (0)