From 833f59309cb19291192d9d7da157a48aeadd9da3 Mon Sep 17 00:00:00 2001 From: Kesavan Yogeswaran Date: Sun, 22 Dec 2024 15:22:18 -0500 Subject: [PATCH] Add -ObjC link flag to fix OSX crashes Add `-ObjC` link flag when building on OSX. As noted in https://github.com/SFML/SFML/issues/2920, this is required when statically linking against SFML since it contains Objective-C source files. Without this flag, compiling and linking succeeds but binaries will crash at runtime. --- build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.rs b/build.rs index 7196aaaa..cb30e581 100644 --- a/build.rs +++ b/build.rs @@ -303,6 +303,9 @@ fn main() { if feat_audio { unix_audio_link_support_libs(); } + // SFML contains Objective-C source files on OSX + // https://github.com/SFML/SFML/issues/2920 + println!("cargo::rustc-link-arg=-ObjC"); } else { panic!("Uhhh... Can't determine your environment. Sorry."); }