From c01ba2f2e873b8c37616acb888a3a187953e8878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Thu, 15 Aug 2019 15:34:23 +0200 Subject: [PATCH] add sparc64-unknown-openbsd target 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. --- src/librustc_llvm/build.rs | 7 ++++-- src/librustc_target/spec/mod.rs | 1 + .../spec/sparc64_unknown_openbsd.rs | 22 +++++++++++++++++++ src/libunwind/build.rs | 6 ++++- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/librustc_target/spec/sparc64_unknown_openbsd.rs diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 16cdbb7dd4d39..8391822bb7579 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -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") { diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index ec72c00c28f61..5bd38c1cda5e9 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -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), diff --git a/src/librustc_target/spec/sparc64_unknown_openbsd.rs b/src/librustc_target/spec/sparc64_unknown_openbsd.rs new file mode 100644 index 0000000000000..229e0621e0dc1 --- /dev/null +++ b/src/librustc_target/spec/sparc64_unknown_openbsd.rs @@ -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, + }) +} diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index c1b0dbc0881d3..ef21b0bfca6ba 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -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") {