Skip to content

Commit d3a58f3

Browse files
committed
auto merge of #5943 : brson/rust/struct-return, r=graydon
Mac appears to follow the same ABI as MSVC. This fixes one case but leaves others broken, like windows.
2 parents 9618e5b + 8a6d6dd commit d3a58f3

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/librustc/middle/trans/cabi_x86.rs

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

11-
use driver::session::os_win32;
11+
use driver::session::{os_win32, os_macos};
1212
use core::option::*;
1313
use lib::llvm::*;
1414
use lib::llvm::llvm::*;
@@ -38,12 +38,12 @@ impl ABIInfo for X86_ABIInfo {
3838

3939
// Rules for returning structs taken from
4040
// http://www.angelcode.com/dev/callconv/callconv.html
41+
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
4142
let sret = {
4243
let returning_a_struct = unsafe { LLVMGetTypeKind(rty) == Struct && ret_def };
43-
let big_struct = if self.ccx.sess.targ_cfg.os != os_win32 {
44-
true
45-
} else {
46-
llsize_of_alloc(self.ccx, rty) > 8
44+
let big_struct = match self.ccx.sess.targ_cfg.os {
45+
os_win32 | os_macos => llsize_of_alloc(self.ccx, rty) > 8,
46+
_ => true
4747
};
4848
returning_a_struct && big_struct
4949
};

src/test/run-pass/extern-pass-TwoU32s.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// Test a foreign function that accepts and returns a struct
1212
// by value.
1313

14-
// xfail-macos Broken on mac i686
15-
1614
#[deriving(Eq)]
1715
struct TwoU32s {
1816
one: u32, two: u32

src/test/run-pass/extern-return-TwoU32s.rs

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

11-
// xfail-macos Broken on mac i686
12-
1311
struct TwoU32s {
1412
one: u32, two: u32
1513
}

0 commit comments

Comments
 (0)