aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc16
-rw-r--r--src/compiler.js9
-rwxr-xr-xtests/runner.py15
3 files changed, 36 insertions, 4 deletions
diff --git a/emcc b/emcc
index d06bb21c..488f0788 100755
--- a/emcc
+++ b/emcc
@@ -215,6 +215,20 @@ Options that are modified or new in %s include:
(without the external "s in either of those,
you would get an error)
+ You can also specify a file from which the
+ value would be read, for example,
+
+ -s DEAD_FUNCTIONS=@/path/to/file
+
+ The contents of /path/to/file will be read,
+ JSON.parsed and set into DEAD_FUNCTIONS (so
+ the file could contain
+
+ ["_func1", "func2"]
+
+ ). Note that the path must be absolute, not
+ relative.
+
-g Use debug info. Note that you need this during
the last compilation phase from bitcode to
JavaScript, or else we will remove it by
@@ -973,6 +987,8 @@ try:
# Apply -s settings in newargs here (after optimization levels, so they can override them)
for change in settings_changes:
key, value = change.split('=')
+ if value[0] == '@':
+ value = '"' + value + '"'
exec('shared.Settings.' + key + ' = ' + value)
# Apply effects from settings
diff --git a/src/compiler.js b/src/compiler.js
index 447d34b7..f461bcf7 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -141,8 +141,13 @@ if (phase == 'pre') {
if (settings_file) {
var settings = JSON.parse(read(settings_file));
- for (setting in settings) {
- eval(setting + ' = ' + JSON.stringify(settings[setting]));
+ for (key in settings) {
+ var value = settings[key];
+ if (value[0] == '@') {
+ // response file type thing, workaround for large inputs: value is @path-to-file
+ value = JSON.parse(read(value.substr(1)));
+ }
+ eval(key + ' = ' + JSON.stringify(value));
}
}
diff --git a/tests/runner.py b/tests/runner.py
index e5e12b1e..df6c338e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7758,17 +7758,28 @@ def process(filename):
self.emcc_args = map(lambda x: 'ASM_JS=1' if x == 'ASM_JS=0' else x, self.emcc_args)
shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgo.js'))
- pgo_output = run_js(self.in_dir('pgo.js'))
+ pgo_output = run_js(self.in_dir('pgo.js')).split('\n')[1]
+ open('pgo_data', 'w').write(pgo_output)
+
+ # with response file
- open('pgo_data', 'w').write(pgo_output.split('\n')[1])
self.emcc_args += ['@pgo_data']
self.do_run(src, output)
+ self.emcc_args.pop()
shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed.js'))
before = len(open('normal.js').read())
after = len(open('pgoed.js').read())
assert after < 0.66 * before, [before, after] # expect a big size reduction
+ # with response in settings element itself
+
+ open('dead_funcs', 'w').write(pgo_output[pgo_output.find('['):-1])
+ self.emcc_args += ['-s', 'DEAD_FUNCTIONS=@' + self.in_dir('dead_funcs')]
+ self.do_run(src, output)
+ shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed2.js'))
+ assert open('pgoed.js').read() == open('pgoed2.js').read()
+
def test_scriptaclass(self):
if self.emcc_args is None: return self.skip('requires emcc')
if Settings.ASM_JS: return self.skip('asm does not bindings generator yet')