Skip to content

Commit 2190f6c

Browse files
committed
Auto merge of #38086 - semarie:openbsd-i686, r=alexcrichton
Add i686-unknown-openbsd target. It is a preliminary work. I still have some tests failing, but I have a working rustc binary which is able to rebuild itself. an update of libc should be required too, but I dunno how to do it with vendor/ layout. r? @alexcrichton
2 parents b462e8f + 6774e7a commit 2190f6c

File tree

6 files changed

+67
-2
lines changed

6 files changed

+67
-2
lines changed

mk/cfg/i686-unknown-openbsd.mk

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# i686-unknown-openbsd configuration
2+
CC_i686-unknown-openbsd=$(CC)
3+
CXX_i686-unknown-openbsd=$(CXX)
4+
CPP_i686-unknown-openbsd=$(CPP)
5+
AR_i686-unknown-openbsd=$(AR)
6+
CFG_LIB_NAME_i686-unknown-openbsd=lib$(1).so
7+
CFG_STATIC_LIB_NAME_i686-unknown-openbsd=lib$(1).a
8+
CFG_LIB_GLOB_i686-unknown-openbsd=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_i686-unknown-openbsd=$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_i686-unknown-openbsd := -m32 -I/usr/include $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_i686-unknown-openbsd := -g -fPIC -m32 -I/usr/include $(CFLAGS)
12+
CFG_GCCISH_LINK_FLAGS_i686-unknown-openbsd := -shared -fPIC -g -pthread -m32
13+
CFG_GCCISH_DEF_FLAG_i686-unknown-openbsd := -Wl,--export-dynamic,--dynamic-list=
14+
CFG_LLC_FLAGS_i686-unknown-openbsd :=
15+
CFG_INSTALL_NAME_i686-unknown-openbsd =
16+
CFG_EXE_SUFFIX_i686-unknown-openbsd :=
17+
CFG_WINDOWSY_i686-unknown-openbsd :=
18+
CFG_UNIXY_i686-unknown-openbsd := 1
19+
CFG_LDPATH_i686-unknown-openbsd :=
20+
CFG_RUN_i686-unknown-openbsd=$(2)
21+
CFG_RUN_TARG_i686-unknown-openbsd=$(call CFG_RUN_i686-unknown-openbsd,,$(2))
22+
CFG_GNU_TRIPLE_i686-unknown-openbsd := i686-unknown-openbsd
23+
RUSTC_FLAGS_i686-unknown-openbsd=-C linker=$(call FIND_COMPILER,$(CC))
24+
CFG_DISABLE_JEMALLOC_i686-unknown-openbsd := 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2016 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+
use target::{Target, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let mut base = super::openbsd_base::opts();
15+
base.cpu = "pentium4".to_string();
16+
base.max_atomic_width = Some(64);
17+
base.pre_link_args.push("-m32".to_string());
18+
19+
Ok(Target {
20+
llvm_target: "i686-unknown-openbsd".to_string(),
21+
target_endian: "little".to_string(),
22+
target_pointer_width: "32".to_string(),
23+
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
24+
arch: "x86".to_string(),
25+
target_os: "openbsd".to_string(),
26+
target_env: "".to_string(),
27+
target_vendor: "unknown".to_string(),
28+
options: base,
29+
})
30+
}

src/librustc_back/target/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ supported_targets! {
168168
("x86_64-unknown-dragonfly", x86_64_unknown_dragonfly),
169169

170170
("x86_64-unknown-bitrig", x86_64_unknown_bitrig),
171+
172+
("i686-unknown-openbsd", i686_unknown_openbsd),
171173
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
174+
172175
("x86_64-unknown-netbsd", x86_64_unknown_netbsd),
173176
("x86_64-rumprun-netbsd", x86_64_rumprun_netbsd),
174177

@@ -299,6 +302,9 @@ pub struct TargetOptions {
299302
pub staticlib_suffix: String,
300303
/// OS family to use for conditional compilation. Valid options: "unix", "windows".
301304
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,
302308
/// Whether the target toolchain is like OSX's. Only useful for compiling against iOS/OS X, in
303309
/// particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
304310
pub is_like_osx: bool,
@@ -403,6 +409,7 @@ impl Default for TargetOptions {
403409
staticlib_prefix: "lib".to_string(),
404410
staticlib_suffix: ".a".to_string(),
405411
target_family: None,
412+
is_like_openbsd: false,
406413
is_like_osx: false,
407414
is_like_solaris: false,
408415
is_like_windows: false,
@@ -569,6 +576,7 @@ impl Target {
569576
key!(staticlib_prefix);
570577
key!(staticlib_suffix);
571578
key!(target_family, optional);
579+
key!(is_like_openbsd, bool);
572580
key!(is_like_osx, bool);
573581
key!(is_like_solaris, bool);
574582
key!(is_like_windows, bool);
@@ -730,6 +738,7 @@ impl ToJson for Target {
730738
target_option_val!(staticlib_prefix);
731739
target_option_val!(staticlib_suffix);
732740
target_option_val!(target_family);
741+
target_option_val!(is_like_openbsd);
733742
target_option_val!(is_like_osx);
734743
target_option_val!(is_like_solaris);
735744
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)