aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-16 12:30:22 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-16 12:30:22 -0800
commit153f2d93520f37525f30a3808b969c5533387a3c (patch)
tree93d691925a910406f0eb5cd0edfa48da4401b43b /src/runtime.js
parent6334c3dd9814ef4174baadd0a4ecfed572596b72 (diff)
RETAIN_COMPILER_SETTINGS, Runtime.getCompilerSetting and emscripten_get_compiler_setting - an optional way to look up compiler flags at runtime
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/runtime.js b/src/runtime.js
index a9265e70..0c724e50 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -487,6 +487,19 @@ var Runtime = {
}
},
+#if RETAIN_COMPILER_SETTINGS
+ compilerSettings: {},
+#endif
+
+ getCompilerSetting: function(name) {
+#if RETAIN_COMPILER_SETTINGS == 0
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+#else
+ if (!(name in Runtime.compilerSettings)) return 'invalid compiler setting: ' + name;
+ return Runtime.compilerSettings[name];
+#endif
+ },
+
#if RUNTIME_DEBUG
debug: true, // Switch to false at runtime to disable logging at the right times
@@ -612,3 +625,12 @@ function reSign(value, bits, ignore) {
// Then 'dynamic' memory for sbrk.
Runtime.GLOBAL_BASE = Runtime.alignMemory(1);
+if (RETAIN_COMPILER_SETTINGS) {
+ var blacklist = set('RELOOPER', 'STRUCT_INFO');
+ for (var x in this) {
+ try {
+ if (x[0] !== '_' && !(x in blacklist) && x == x.toUpperCase() && (typeof this[x] === 'number' || typeof this[x] === 'string' || this.isArray())) Runtime.compilerSettings[x] = this[x];
+ } catch(e){}
+ }
+}
+