The Holy Grail of Linux Binary Compatibility: Musl and Dlopen
Recorded: Jan. 26, 2026, 3 p.m.
| Original | Summarized |
The Holy Grail of Linux Binary Compatibility: musl + dlopen · quaadgras graphics.gd · Discussion #242 · GitHub Skip to content Navigation Menu Toggle navigation
Sign in
Appearance settings PlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub SparkBuild and deploy intelligent appsGitHub ModelsManage and compare promptsMCP RegistryNewIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityAcceleratorArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricing Search or jump to... Search code, repositories, users, issues, pull requests...
Search Clear
Search syntax tips Provide feedback Include my email address so I can be contacted Cancel Submit feedback Saved searches
Name Query To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up
Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. Dismiss alert quaadgras graphics.gd Public Uh oh! There was an error while loading. Please reload this page.
Notifications
Fork
Star Code Issues Pull requests Discussions Actions Projects Security Insights
Additional navigation options
Code Issues Pull requests Discussions Actions Projects Security Insights
The Holy Grail of Linux Binary Compatibility: musl + dlopen Splizard The Holy Grail of Linux Binary Compatibility: musl + dlopen Splizard Jan 26, 2026 Return to top
Discussion options Uh oh! There was an error while loading. Please reload this page. Uh oh! There was an error while loading. Please reload this page. Splizard Jan 26, 2026 Maintainer
- I guess using Go + Godot to build native & installable Android & iOS binaries (without any proprietary SDKs) was too easy. So it's time for a real challenge... Beta
14 👍 👍 🎉 ❤️ 🚀 👀 Replies: 2 comments
Comment options Uh oh! There was an error while loading. Please reload this page. phreda4 Jan 26, 2026
- I use the dlopen/dlsym technique in Linux and loadlibrary/getprocaddress in my language's VM. Beta
2 0 replies
Comment options Uh oh! There was an error while loading. Please reload this page. X-Ryl669 Jan 26, 2026
- Doesn't work for me: Beta
2 0 replies Sign up for free Category 📣 Announcements Labels None yet 3 participants
Footer © 2026 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. |
The Holy Grail of Linux Binary Compatibility: musl + dlopen delves into a significant technical challenge – creating a standalone, hardware-accelerated graphics application (specifically, the "dodge_the_creeps" sample project) that can run on Linux without relying on proprietary SDKs or dynamic library dependencies. The core problem centers around the incompatibility between glibc-based Linux distributions and musl-based distributions, particularly when dealing with graphics acceleration. This essay, by Splizard, details the innovative solution employed to achieve this, highlighting the intricacies of building a single, static binary for Linux using musl. The author’s initial experience, replacing their personal computer’s operating system with Void Linux (a musl-based distribution), directly exposed the fundamental issue. Compiling graphics.gd projects with musl proved incredibly difficult, demonstrating the inherent conflict when libraries like glibc, which rely on dynamic linking and dlopen for accessing graphics drivers, are incompatible with musl’s approach to static linking. The need to integrate with hardware acceleration, a common requirement for graphics applications, further complicates the situation. The solution proposes using Godot’s engine as a fundamental layer. Godot, by design, utilizes dynamic loading for its dependencies on Linux. This means it loads libraries at runtime via dlopen. However, musl refuses to implement dlopen for static binaries, primarily due to fundamental differences in how it handles thread-local storage (TLS) compared to glibc. The ingenious workaround lies in leveraging the “dlopen/dlsym technique.” This method, often employed in languages like Forth, involves creating a small C program that is compiled and executed along with the main application. This program then utilizes dlopen to load a glibc library and uses dlsym to invoke functions from that library. The critical step is a "longjmp" back into the main graphics.gd application, effectively hijacking the execution flow and managing the TLS context. To reconcile this with Godot, the author employs a build-overlay specifically for GOOS=musl. This overlay facilitates the creation of a musl-compatible build of graphics.gd. The key innovation is the explicit rejection of c-shared builds, which are convenient but inherently reliant on the glibc dynamic linking infrastructure. Instead, the application is directly linked with Godot’s c-archive. This creates a single static binary. The single static binary also requires a small C program to be included, acting as a bridge. Despite the successful implementation, the author acknowledges the remaining issue – the inherent difficulties in coordinating a cross-platform distribution of the application. The need for both glibc and musl builds, and the subsequent communication to the end-user to select the correct binary, represents a challenge. The discussion briefly touches on the precedent set by techniques like the "detour technique" and Cosmopolitan’s dlopen approach, both offering similar solutions. The author provides a downloadable build of the "dodge_the_creeps" sample project, packaged as a static binary. The build instructions call for a GOOS=musl build targeting AMD64 architecture. The importance of deleting the export_presets.cfg file is emphasized – this is crucial in triggering the creation of the musl build. The author also notes the potential complexity of managing this project across different platforms, ultimately highlighting the core challenge of achieving truly universal Linux binary compatibility. The discussion concludes with a call for research into solutions for Android and the web, mirroring the complexity of the original challenge. |