diff --git a/crates/runtime/src/helpers.c b/crates/runtime/src/helpers.c index 6436922243da..6f9fc9520804 100644 --- a/crates/runtime/src/helpers.c +++ b/crates/runtime/src/helpers.c @@ -27,6 +27,15 @@ void* GetPcFromUContext(ucontext_t *cx) { } #endif +#if defined(__FreeBSD__) && defined(__x86_64__) +#include + +void* GetPcFromUContext(ucontext_t *cx) { + return (void*) cx->uc_mcontext.mc_rip; +} +#endif + + #if defined(__linux__) && defined(__aarch64__) #include diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs index 9ec38ba87247..76075e501141 100644 --- a/crates/runtime/src/traphandlers.rs +++ b/crates/runtime/src/traphandlers.rs @@ -164,7 +164,7 @@ cfg_if::cfg_if! { fn GetPcFromUContext(cx: *mut libc::c_void) -> *const u8; } GetPcFromUContext(cx) - } else if #[cfg(target_os = "macos")] { + } else if #[cfg(any(target_os = "macos", target_os = "freebsd"))] { // FIXME(rust-lang/libc#1702) - once that lands and is // released we should inline the definition here extern "C" {