aboutsummaryrefslogtreecommitdiff
path: root/emlink.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-29 10:05:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-03 15:31:04 -0700
commit7596d284a0fd54be6ed9661d377dd7903a27f072 (patch)
tree813bca30f7f6358b0a7f2935c1f6c5499c8d93be /emlink.py
parent7be8c34546c5c8db548f8b7a5864f7cbd7594ef4 (diff)
refactor invoke generation and add missing invokes when linking
Diffstat (limited to 'emlink.py')
-rw-r--r--emlink.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/emlink.py b/emlink.py
index 229ea907..de06e9d4 100644
--- a/emlink.py
+++ b/emlink.py
@@ -17,6 +17,13 @@ Limitations:
* We duplicate code in some cases, like overlapping names in different modules, and function aliases
* We do not handle sharing of global constants across modules, only code (you can make a function to
access a constant, if you need that)
+ * We do not link in compiled libraries (libc, libc++, etc.) in side modules. If the main module
+ does not automatically link in the ones that side modules will need, you should compile the
+ main module with
+
+ EMCC_FORCE_STDLIBS=1 emcc ..
+
+ which will link in all the C libraries.
Overall, this linking approach should be fast to perform, but generate less-optimal results than
to link all the bitcode together and build to JS as a single project. Final builds should be
@@ -96,6 +103,7 @@ class AsmModule():
# post
self.post_js = self.js[self.end_asm:]
+ self.sendings = set([sending.strip() for sending in self.post_js[self.post_js.find('}, { ')+5:self.post_js.find(' }, buffer);')].split(',')])
self.module_defs = set(re.findall('var [\w\d_$]+ = Module\["[\w\d_$]+"\] = asm\["[\w\d_$]+"\];\n', self.post_js))
def relocate_into(self, main):
@@ -123,6 +131,18 @@ class AsmModule():
replacements[func] = rep
#print >> sys.stderr, 'replacements:', replacements
+ # sendings: add invokes for new tables
+ new_sendings = []
+ for table in self.tables:
+ if table not in main.tables:
+ sig = table[table.rfind('_')+1:]
+ new_sendings.append('"invoke_%s": %s' % (sig, shared.JS.make_invoke(sig, named=False)))
+ if new_sendings:
+ sendings_js = ', '.join(main.sendings.union(new_sendings))
+ sendings_start = main.post_js.find('}, { ')+5
+ sendings_end = main.post_js.find(' }, buffer);')
+ main.post_js = main.post_js[:sendings_start] + sendings_js + main.post_js[sendings_end:]
+
# tables
f_bases = {}
f_sizes = {}