Skip to content

Commit

Permalink
Auto merge of #108792 - Amanieu:ohos, r=petrochenkov
Browse files Browse the repository at this point in the history
Add OpenHarmony targets

- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`

Compiler team MCP: rust-lang/compiler-team#568
  • Loading branch information
bors committed Mar 29, 2023
2 parents bcb1f92 + a78e289 commit 7d947a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
libc = { version = "0.2.139", default-features = false, features = ['rustc-dep-of-std'] }
libc = { version = "0.2.140", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.87" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
Expand Down
5 changes: 4 additions & 1 deletion std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ pub fn set_errno(e: i32) {
/// Gets a detailed string description for the given error number.
pub fn error_string(errno: i32) -> String {
extern "C" {
#[cfg_attr(any(target_os = "linux", target_env = "newlib"), link_name = "__xpg_strerror_r")]
#[cfg_attr(
all(any(target_os = "linux", target_env = "newlib"), not(target_env = "ohos")),
link_name = "__xpg_strerror_r"
)]
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t) -> c_int;
}

Expand Down
16 changes: 16 additions & 0 deletions unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ cfg_if::cfg_if! {
}
}

// This is the same as musl except that we default to using the system libunwind
// instead of libgcc.
#[cfg(target_env = "ohos")]
cfg_if::cfg_if! {
if #[cfg(all(feature = "llvm-libunwind", feature = "system-llvm-libunwind"))] {
compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
} else if #[cfg(feature = "llvm-libunwind")] {
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
} else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
}
}

#[cfg(target_os = "android")]
cfg_if::cfg_if! {
if #[cfg(feature = "llvm-libunwind")] {
Expand Down

0 comments on commit 7d947a0

Please sign in to comment.