Skip to content

Conversation

xfxdev
Copy link

@xfxdev xfxdev commented Apr 17, 2025

fix #1079

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.

…ashes

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.
@unity-cla-assistant
Copy link

unity-cla-assistant commented Apr 17, 2025

CLA assistant check
All committers have signed the CLA.

@karasusan karasusan requested a review from Copilot August 7, 2025 01:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes crashes on Linux by removing static libstdc++ linking from the Unity native plugin. The change addresses runtime mismatches between Unity's dynamic libstdc++ and the plugin's static linking, which caused crashes when destroying C++ standard library objects.

Key Changes

  • Removed static libstdc++ linking flags from Linux build configuration
  • Switched to dynamic linking to match Unity's runtime environment
  • Updated build comments to reflect the simplified linking approach

# 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.
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment should explain why lld linker is preferred over GNU ld to provide better context for future maintainers.

Suggested change
# Use lld linker instead of GNU ld.
# Use lld linker instead of GNU ld because lld provides significantly faster link times and better diagnostics,
# which improves developer productivity and reduces build times, especially for large projects.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Crash on Linux
2 participants