Skip to content

Commit 6774e7a

Browse files
committed
OpenBSD under x86 has particular ABI for returning a struct.
It is like OSX or Windows: small structs are returned as integers.
1 parent 53ebf5a commit 6774e7a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/librustc_back/target/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ pub struct TargetOptions {
302302
pub staticlib_suffix: String,
303303
/// OS family to use for conditional compilation. Valid options: "unix", "windows".
304304
pub target_family: Option<String>,
305+
/// Whether the target toolchain is like OpenBSD's.
306+
/// Only useful for compiling against OpenBSD, for configuring abi when returning a struct.
307+
pub is_like_openbsd: bool,
305308
/// Whether the target toolchain is like OSX's. Only useful for compiling against iOS/OS X, in
306309
/// particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
307310
pub is_like_osx: bool,
@@ -406,6 +409,7 @@ impl Default for TargetOptions {
406409
staticlib_prefix: "lib".to_string(),
407410
staticlib_suffix: ".a".to_string(),
408411
target_family: None,
412+
is_like_openbsd: false,
409413
is_like_osx: false,
410414
is_like_solaris: false,
411415
is_like_windows: false,
@@ -572,6 +576,7 @@ impl Target {
572576
key!(staticlib_prefix);
573577
key!(staticlib_suffix);
574578
key!(target_family, optional);
579+
key!(is_like_openbsd, bool);
575580
key!(is_like_osx, bool);
576581
key!(is_like_solaris, bool);
577582
key!(is_like_windows, bool);
@@ -733,6 +738,7 @@ impl ToJson for Target {
733738
target_option_val!(staticlib_prefix);
734739
target_option_val!(staticlib_suffix);
735740
target_option_val!(target_family);
741+
target_option_val!(is_like_openbsd);
736742
target_option_val!(is_like_osx);
737743
target_option_val!(is_like_solaris);
738744
target_option_val!(is_like_windows);

src/librustc_back/target/openbsd_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn opts() -> TargetOptions {
1717
executables: true,
1818
linker_is_gnu: true,
1919
has_rpath: true,
20+
is_like_openbsd: true,
2021
pre_link_args: vec![
2122
// GNU-style linkers will use this to omit linking to libraries
2223
// which don't actually fulfill any relocations, but only for

src/librustc_trans/cabi_x86.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
2525
// http://www.angelcode.com/dev/callconv/callconv.html
2626
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
2727
let t = &ccx.sess().target.target;
28-
if t.options.is_like_osx || t.options.is_like_windows {
28+
if t.options.is_like_osx || t.options.is_like_windows
29+
|| t.options.is_like_openbsd {
2930
match llsize_of_alloc(ccx, fty.ret.ty) {
3031
1 => fty.ret.cast = Some(Type::i8(ccx)),
3132
2 => fty.ret.cast = Some(Type::i16(ccx)),

0 commit comments

Comments
 (0)