fix: remove static libstdc++ linking on Linux to prevent potential crashes#1080
Open
xfxdev wants to merge 1 commit intoUnity-Technologies:mainfrom
Open
fix: remove static libstdc++ linking on Linux to prevent potential crashes#1080xfxdev wants to merge 1 commit intoUnity-Technologies:mainfrom
xfxdev wants to merge 1 commit intoUnity-Technologies:mainfrom
Conversation
…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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
[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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.