Skip to content

Commit

Permalink
add sparc64-unknown-openbsd target
Browse files Browse the repository at this point in the history
on OpenBSD, some architectures relies on libc++ (from LLVM) and some
others on libestdc++ (particular version of libstdc++ from GCC).

sparc64-unknown-openbsd needs libestdc++ and libgcc (as x86_64 some
years ago). Reintroduce the support of them for openbsd, only for
sparc64 arch. Some others architectures on OpenBSD could use them too.
  • Loading branch information
semarie committed Aug 15, 2019
1 parent 1cdcea9 commit c01ba2f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,11 @@ fn main() {
let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX");

let stdcppname = if target.contains("openbsd") {
// llvm-config on OpenBSD doesn't mention stdlib=libc++
"c++"
if target.contains("sparc64") {
"estdc++"
} else {
"c++"
}
} else if target.contains("freebsd") {
"c++"
} else if target.contains("darwin") {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ supported_targets! {

("aarch64-unknown-openbsd", aarch64_unknown_openbsd),
("i686-unknown-openbsd", i686_unknown_openbsd),
("sparc64-unknown-openbsd", sparc64_unknown_openbsd),
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),

("aarch64-unknown-netbsd", aarch64_unknown_netbsd),
Expand Down
22 changes: 22 additions & 0 deletions src/librustc_target/spec/sparc64_unknown_openbsd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::openbsd_base::opts();
base.cpu = "v9".to_string();
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
base.max_atomic_width = Some(64);

Ok(Target {
llvm_target: "sparc64-unknown-openbsd".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
arch: "sparc64".to_string(),
target_os: "openbsd".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
6 changes: 5 additions & 1 deletion src/libunwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ fn main() {
} else if target.contains("netbsd") {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("openbsd") {
println!("cargo:rustc-link-lib=c++abi");
if target.contains("sparc64") {
println!("cargo:rustc-link-lib=gcc");
} else {
println!("cargo:rustc-link-lib=c++abi");
}
} else if target.contains("solaris") {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("dragonfly") {
Expand Down

0 comments on commit c01ba2f

Please sign in to comment.