Guard dlopen/dlsym for platforms without dynamic linking#52
Open
lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
Open
Guard dlopen/dlsym for platforms without dynamic linking#52lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
Conversation
Add #ifdef guards to ffi/load.c and ffi/load_dir.c so HVM4 compiles on platforms where dlopen is unavailable or restricted (WASM, iOS). The guard triggers on __EMSCRIPTEN__ or HVM_NO_DLOPEN. On guarded platforms, ffi_load and ffi_load_dir print an error and exit. Existing behavior on desktop/server is unchanged.
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.
Adds
#ifdefguards toffi/load.candffi/load_dir.cso HVM4 compiles on platforms wheredlopenis unavailable or restricted.On guarded platforms,
ffi_loadandffi_load_dirprint an error message and exit. Primitives should be registered at compile time instead (viaprim_register).Benefits
dlopen/dlsymcause compile errors. This guard removes that barrier.dlopenof code outside the app bundle apparently. Guarding it lets HVM4 compile as a static library for mobile.Changes
Two files modified, zero behavior change on existing platforms.
ffi/load.c- Guard wraps the entire file. When__EMSCRIPTEN__orHVM_NO_DLOPENis defined, provides a stubffi_loadthat prints an error. Otherwise, existingdlopen/dlsymcode is compiled unchanged.ffi/load_dir.c- Same guard. Stubffi_load_dirprints an error. The<dirent.h>and<sys/stat.h>includes (also unavailable on WASM) are inside the#elsebranch.Guard trigger
__EMSCRIPTEN__is auto-defined by Emscripten.HVM_NO_DLOPENis user-defined for other restricted targets.Risk
Don't think any. Guard only triggers when
__EMSCRIPTEN__orHVM_NO_DLOPENis defined. Neither is defined in normal desktop/server builds. All existing tests pass unchanged.