aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-30 16:57:42 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-03 14:41:30 -0700
commitd6e21d7851004b2853327d1de468e25ee97fe595 (patch)
treea76703a2013701f0f6036b9a2550d0f641322377
parent2cd835bc76300c6979a91e3deaa2f50ce1aa3379 (diff)
do not require LINKABLE in DLOPEN_SUPPORT
-rwxr-xr-xemcc1
-rw-r--r--src/settings.js6
-rw-r--r--tests/test_core.py9
3 files changed, 8 insertions, 8 deletions
diff --git a/emcc b/emcc
index a68f0fc9..d5dff4bb 100755
--- a/emcc
+++ b/emcc
@@ -1105,7 +1105,6 @@ try:
debug_level = max(debug_level, 2)
if shared.Settings.DLOPEN_SUPPORT:
- shared.Settings.LINKABLE = 1
if shared.Settings.ALIASING_FUNCTION_POINTERS:
logging.warning('disabling ALIASING_FUNCTION_POINTERS for dlopen support')
shared.Settings.ALIASING_FUNCTION_POINTERS = 0
diff --git a/src/settings.js b/src/settings.js
index 245699b1..a2267393 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -355,9 +355,9 @@ var LINKABLE = 0; // If set to 1, this file can be linked with others, either as
// generated code very significantly, by removing everything not actually used.
var DLOPEN_SUPPORT = 0; // Whether to support dlopen(NULL, ...) which enables dynamic access to the
- // module's functions and globals. Implies LINKABLE=1, because we do not want
- // dead code elimination. XXX remove LINKABLE=1 here, people should keep
- // the things they want alive using the normal mechanisms (see faq).
+ // module's functions and globals. Note that you must use EMSCRIPTEN_KEEPALIVE
+ // to ensure that functions and globals can be accessed through dlsym,
+ // otherwise LLVM may optimize them out.
var RUNTIME_TYPE_INFO = 0; // Whether to expose type info to the script at run time. This
// increases the size of the generated script, but allows you
diff --git a/tests/test_core.py b/tests/test_core.py
index d72d325f..d2db0cbf 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -5964,14 +5964,15 @@ def process(filename):
src = r'''
#include <stdio.h>
#include <dlfcn.h>
+#include <emscripten.h>
-int global = 123;
+int EMSCRIPTEN_KEEPALIVE global = 123;
-extern "C" __attribute__((noinline)) void foo(int x) {
+extern "C" EMSCRIPTEN_KEEPALIVE void foo(int x) {
printf("%d\n", x);
}
-extern "C" __attribute__((noinline)) void repeatable() {
+extern "C" EMSCRIPTEN_KEEPALIVE void repeatable() {
void* self = dlopen(NULL, RTLD_LAZY);
int* global_ptr = (int*)dlsym(self, "global");
void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo");
@@ -5994,7 +5995,7 @@ return 0;
raise Exception('Could not find symbol table!')
table = table[table.find('{'):table.rfind('}')+1]
# ensure there aren't too many globals; we don't want unnamed_addr
- assert table.count(',') == 3
+ assert table.count(',') <= 4
self.do_run(src, '123\n123', post_build=(None, post))