From a391b10d5e921628bc8d962f0cdd332a93eb55c5 Mon Sep 17 00:00:00 2001 From: xfxdev <9671222+xfxdev@users.noreply.github.com> Date: Thu, 17 Apr 2025 14:26:46 -0400 Subject: [PATCH] fix: remove static libstdc++ linking on Linux to prevent potential crashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unity on Linux is dynamically linked against the system's libstdc++.so. Statically linking libstdc++ in a native plugin caused runtime mismatches, leading to crashes when destroying C++ standard library objects. This was observed with local std::stringstream instances, but likely affects other STL types relying on shared runtime state (e.g. std::locale, iostreams, allocators). Switched to dynamic linking of libstdc++ to ensure compatibility with Unity’s runtime environment. --- Plugin~/CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) mode change 100644 => 100755 Plugin~/CMakeLists.txt diff --git a/Plugin~/CMakeLists.txt b/Plugin~/CMakeLists.txt old mode 100644 new mode 100755 index 9b454318e9..5f9cda5a1a --- a/Plugin~/CMakeLists.txt +++ b/Plugin~/CMakeLists.txt @@ -51,12 +51,9 @@ if(XCODE) endif() endif() -# Use lld linker instead of GNU ld. Link glibc++ statically because of -# compatibility of lower version of GLIBCXX. This package must support Ubuntu -# version 16.04, 18.04, 20.04. +# Use lld linker instead of GNU ld. if(Linux) - set(CMAKE_CXX_FLAG "${CMAKE_CXX_FLAG} -static-libstdc++") - add_link_options(-static-libstdc++ -fuse-ld=lld-11) + add_link_options(-fuse-ld=lld-11) endif() # enable debug output