Skip to content

Commit 09a91aa

Browse files
committed
Error at link time if dlfcn functions are used without MAIN_MODULE
Only if ALLOW_UNIMPLEMENTED_SYSCALLS (which is also set by STRICT) is used. This was previously only ever a runtime error. Should help with #15276 (comment)
1 parent ff23b8c commit 09a91aa

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/library_dylink.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//
44
// ==========================================================================
55

6+
var dlopenMissingError = "To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking"
7+
68
var LibraryDylink = {
79
#if RELOCATABLE
810
$resolveGlobalSymbol__deps: ['$asmjsMangle'],
@@ -182,14 +184,19 @@ var LibraryDylink = {
182184
#endif
183185

184186
#if MAIN_MODULE == 0
187+
#if !ALLOW_UNIMPLEMENTED_SYSCALLS
188+
_dlopen_js__deps: [function() { error(dlopenMissingError); }],
189+
_emscripten_dlopen_js__deps: [function() { error(dlopenMissingError); }],
190+
_dlsym_js__deps: [function() { error(dlopenMissingError); }],
191+
#endif
185192
_dlopen_js: function(filename, flag) {
186-
abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
193+
abort(dlopenMissingError);
187194
},
188195
_emscripten_dlopen_js: function(filename, flags, user_data, onsuccess, onerror) {
189-
abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
196+
abort(dlopenMissingError);
190197
},
191198
_dlsym_js: function(handle, symbol) {
192-
abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
199+
abort(dlopenMissingError);
193200
},
194201
#else // MAIN_MODULE != 0
195202
// dynamic linker/loader (a-la ld.so on ELF systems)

0 commit comments

Comments
 (0)