-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable loading of libLLVM at runtime #7499
Merged
Merged
Conversation
This file contains 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
Context: xamarin/monodroid@d887d87d8f Context: llvm/llvm-project@c10ca90 Disable loading of `libLLVM.so` on Android API 21 and newer, because the symbol we're looking for is no longer present in the library on those Android versions. The hack was implemented on April 8, 2014: Disable LLVM signal handlers. Fixes #18016. This happens when RenderScript needs to be compiled. See https://bugzilla.xamarin.com/show_bug.cgi?id=18016 This happens only on first run of the app. LLVM is used to compiled the RenderScript scripts. LLVM, been a nice and smart library installs a ton of signal handlers and don't chain at all, completely breaking us. This is a hack to set llvm::DisablePrettyStackTrace to true and avoid this source of signal handlers. LLVM commit referenced above made the stack pretty print feature opt-in instead of opt-out, removing the `DisablePrettyStackTrace` symbol. Thus, LLVM no longer installs the signal handlers mentioned above and, in effect, doesn't break us anymore. Consequently, the code is completely disabled for .NET builds, since they build against API 21. For classic builds we now check the API level and load the library only if running on API < 21.
grendello
added a commit
to grendello/xamarin-android
that referenced
this pull request
Oct 27, 2022
* main: [monodroid] Disable loading of libLLVM at runtime (dotnet#7499) Bump to dotnet/installer@8c1708f 8.0.100-alpha.1.22526.2 (dotnet#7497)
grendello
added a commit
to grendello/xamarin-android
that referenced
this pull request
Nov 4, 2022
* main: [Tests] Replace azurestorage with a github repo. (dotnet#7524) Bump to xamarin/Java.Interop/main@5318261 (dotnet#7502) [build] fix 8.0.100-alpha.1 version band (dotnet#7500) [monodroid] Disable loading of libLLVM at runtime (dotnet#7499) Bump to dotnet/installer@8c1708f 8.0.100-alpha.1.22526.2 (dotnet#7497)
jonathanpeppers
pushed a commit
that referenced
this pull request
Nov 16, 2022
Context: xamarin/monodroid@d887d87d8f Context: llvm/llvm-project@c10ca90 Way back in 2014-Feb-26, private bug [#18016][0] was filed against Xamarin.Android 4.10.2: when a project contained RenderScript and ran on an Android 4.0.4 device, it could eventually hang. No exception, no error message, no nothing. After investigation, the cause of the hang was that the RenderScript compiler would use the same Unix signals as the Mono for Android GC, and did not properly chain those signals. Thus, if the on-device RenderScript compiler hit particular code paths which caused it to register those Unix signals, the Mono for Android GC would no longer work from that point onward. It was determined that the `llvm::DisablePrettyStackTrace` global variable within `libLLVM.so` could control this behavior. The "fix"/workaround was to *prevent* the RenderScript compiler from subscribing to those Unix signals by: 1. Loading `libLLVM.so` at runtime, 2. Looking for the symbol `_ZN4llvm23DisablePrettyStackTraceE`, which is the name mangled form of `bool llvm::DisablePrettyStackTrace`. 3. Set the value to 1/`true`. xamarin/monodroid@d887d87d8f commit message contents: > Disable LLVM signal handlers. Fixes #18016. > > This happens when RenderScript needs to be compiled. > See https://bugzilla.xamarin.com/show_bug.cgi?id=18016 > > This happens only on first run of the app. LLVM is used to compiled > the RenderScript scripts. LLVM, been a nice and smart library > installs a ton of signal handlers and don't chain at all, completely > breaking us. > > This is a hack to set llvm::DisablePrettyStackTrace to true and > avoid this source of signal handlers. The `llvm::DisablePrettyStackTrace` variable was *removed* from LLVM in 2013-Nov-3 via llvm/llvm-project@c10ca903, but Android continued to redistribute a version of LLVM which contained that symbol until Android 5.0 / API-21. Update `MonodroidRuntime::disable_external_signal_handlers()` to do nothing for .NET 6+ -- as .NET 6 has API-21 as a minimum API level -- and update Classic Xamarin.Android to only look for `libLLVM.so!_ZN4llvm23DisablePrettyStackTraceE` on pre-API-21 targets. This removes the warning message: Failed to load shared library 'libLLVM.so' when running .NET Android apps. [0]: https://bugzilla.xamarin.com/18/18016/bug.html
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Context: https://github.com/xamarin/monodroid/commit/d887d87d8f
Context: llvm/llvm-project@c10ca90
Disable loading of
libLLVM.so
on Android API 21 and newer, because the symbol we're looking for is no longer present in the library on those Android versions.The hack was implemented on April 8, 2014:
LLVM commit referenced above made the stack pretty print feature opt-in instead of opt-out, removing the
DisablePrettyStackTrace
symbol. Thus, LLVM no longer installs the signal handlers mentioned above and, in effect, doesn't break us anymore.Consequently, the code is completely disabled for .NET builds, since they build against API 21.
For classic builds we now check the API level and load the library only if running on API < 21.