| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a6ae6e3 commit fe3510c
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1184,9 +1184,6 @@ def check(input_file): | |||
| 1184 | 1184 | if shared.Settings.BINARYEN_PASSES: | |
| 1185 | 1185 | shared.Settings.BINARYEN_PASSES += ',' | |
| 1186 | 1186 | shared.Settings.BINARYEN_PASSES += 'safe-heap' | |
| 1187 | - # ensure the binaryen port is available, if we are using it. if we do, then | ||
| 1188 | - # we need it to build to wasm | ||
| 1189 | - system_libs.get_port('binaryen', shared.Settings) | ||
| 1190 | 1187 | ||
| 1191 | 1188 | # wasm outputs are only possible with a side wasm | |
| 1192 | 1189 | if target.endswith(WASM_ENDINGS): | |
@@ -2240,7 +2237,7 @@ def binaryen_method_sanity_check(): | |||
| 2240 | 2237 | def do_binaryen(final, target, asm_target, options, memfile, wasm_binary_target, | |
| 2241 | 2238 | wasm_text_target, misc_temp_files, optimizer): | |
| 2242 | 2239 | logging.debug('using binaryen, with method: ' + shared.Settings.BINARYEN_METHOD) | |
| 2243 | - binaryen_bin = os.path.join(shared.Settings.BINARYEN_ROOT, 'bin') | ||
| 2240 | + binaryen_bin = shared.Building.get_binaryen_bin() | ||
| 2244 | 2241 | # Emit wasm.js at the top of the js. This is *not* optimized with the rest of the code, since | |
| 2245 | 2242 | # (1) it contains asm.js, whose validation would be broken, and (2) it's very large so it would | |
| 2246 | 2243 | # be slow in cleanup/JSDCE etc. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,3 @@ | |||
| 1 | - #include <memory.h> | ||
| 2 | 1 | #include <string.h> | |
| 3 | 2 | #include <stdio.h> | |
| 4 | 3 | #include <stdlib.h> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,3 @@ | |||
| 1 | - #include <memory.h> | ||
| 2 | 1 | #include <string.h> | |
| 3 | 2 | #include <stdio.h> | |
| 4 | 3 | #include <stdlib.h> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,7 @@ OBJECTS = \ | |||
| 51 | 51 | all: box2d.a | |
| 52 | 52 | ||
| 53 | 53 | %.o: %.cpp | |
| 54 | - $(CXX) -I. $< -o $@ -O2 -c | ||
| 54 | + $(CXX) $(CFLAGS) -I. $< -o $@ -O2 -c | ||
| 55 | 55 | ||
| 56 | 56 | box2d.a: $(OBJECTS) | |
| 57 | 57 | $(AR) rvs $@ $(OBJECTS) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -965,6 +965,26 @@ def test_with_fake(report, expected): | |||
| 965 | 965 | finally: | |
| 966 | 966 | del os.environ['EMCC_WASM_BACKEND'] | |
| 967 | 967 | ||
| 968 | + def test_wasm_backend_builds(self): | ||
| 969 | + # we can build a program using the wasm backend, rebuilding binaryen etc. as needed | ||
| 970 | + restore() | ||
| 971 | + def check(): | ||
| 972 | + print(self.do([PYTHON, EMCC, '--clear-cache'])) | ||
| 973 | + print(self.do([PYTHON, EMCC, '--clear-ports'])) | ||
| 974 | + try: | ||
| 975 | + os.environ['EMCC_WASM_BACKEND'] = '1' | ||
| 976 | + self.check_working([EMCC, 'tests/hello_world.c'], '') | ||
| 977 | + finally: | ||
| 978 | + del os.environ['EMCC_WASM_BACKEND'] | ||
| 979 | + print('normally') | ||
| 980 | + check() | ||
| 981 | + print('with no BINARYEN_ROOT') | ||
| 982 | + open(CONFIG_FILE, 'a').write(''' | ||
| 983 | + BINARYEN_ROOT = '' | ||
| 984 | + ''') | ||
| 985 | + print(open(CONFIG_FILE).read()) | ||
| 986 | + check() | ||
| 987 | + | ||
| 968 | 988 | def test_binaryen(self): | |
| 969 | 989 | import tools.ports.binaryen as binaryen | |
| 970 | 990 | tag_file = Cache.get_path('binaryen_tag_' + binaryen.TAG + '.txt') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,23 +6,23 @@ | |||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | 8 | // don't inline, to be friendly to js engine osr | |
| 9 | - void __attribute__ ((noinline)) doit(char *buffer, int size, int i) { | ||
| 10 | - static char *buffer2 = NULL; | ||
| 11 | - static char *buffer3 = NULL; | ||
| 9 | + void __attribute__ ((noinline)) doit(unsigned char *buffer, int size, int i) { | ||
| 10 | + static unsigned char *buffer2 = NULL; | ||
| 11 | + static unsigned char *buffer3 = NULL; | ||
| 12 | 12 | ||
| 13 | 13 | unsigned long maxCompressedSize = compressBound(size); | |
| 14 | 14 | ||
| 15 | - if (!buffer2) buffer2 = (char*)malloc(maxCompressedSize); | ||
| 16 | - if (!buffer3) buffer3 = (char*)malloc(size); | ||
| 15 | + if (!buffer2) buffer2 = (unsigned char*)malloc(maxCompressedSize); | ||
| 16 | + if (!buffer3) buffer3 = (unsigned char*)malloc(size); | ||
| 17 | 17 | ||
| 18 | 18 | unsigned long compressedSize = maxCompressedSize; | |
| 19 | 19 | compress(buffer2, &compressedSize, buffer, size); | |
| 20 | - if (i == 0) printf("sizes: %d,%d\n", size, compressedSize); | ||
| 20 | + if (i == 0) printf("sizes: %d,%d\n", size, (int)compressedSize); | ||
| 21 | 21 | ||
| 22 | 22 | unsigned long decompressedSize = size; | |
| 23 | - uncompress(buffer3, &decompressedSize, buffer2, compressedSize); | ||
| 23 | + uncompress(buffer3, &decompressedSize, buffer2, (int)compressedSize); | ||
| 24 | 24 | assert(decompressedSize == size); | |
| 25 | - if (i == 0) assert(strcmp(buffer, buffer3) == 0); | ||
| 25 | + if (i == 0) assert(strcmp((char*)buffer, (char*)buffer3) == 0); | ||
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | 28 | int main(int argc, char **argv) { | |
@@ -38,7 +38,7 @@ int main(int argc, char **argv) { | |||
| 38 | 38 | default: printf("error: %d\\n", arg); return -1; | |
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | - char *buffer = malloc(size); | ||
| 41 | + unsigned char *buffer = (unsigned char*)malloc(size); | ||
| 42 | 42 | ||
| 43 | 43 | int i = 0; | |
| 44 | 44 | int run = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2297,6 +2297,21 @@ def path_to_system_js_libraries_for_settings(link_settings): | |||
| 2297 | 2297 | if 'USE_SDL=2' in link_settings: system_js_libraries += ['library_egl.js', 'library_glut.js', 'library_gl.js'] | |
| 2298 | 2298 | return [path_from_root('src', x) for x in system_js_libraries] | |
| 2299 | 2299 | ||
| 2300 | + @staticmethod | ||
| 2301 | + def get_binaryen(): | ||
| 2302 | + # fetch the port, so we have binaryen set up. indicate we need binaryen | ||
| 2303 | + # using the settings | ||
| 2304 | + import system_libs | ||
| 2305 | + old = Settings.BINARYEN | ||
| 2306 | + Settings.BINARYEN = 1 | ||
| 2307 | + system_libs.get_port('binaryen', Settings) | ||
| 2308 | + Settings.BINARYEN = old | ||
| 2309 | + | ||
| 2310 | + @staticmethod | ||
| 2311 | + def get_binaryen_bin(): | ||
| 2312 | + Building.get_binaryen() | ||
| 2313 | + return os.path.join(Settings.BINARYEN_ROOT, 'bin') | ||
| 2314 | + | ||
| 2300 | 2315 | # compatibility with existing emcc, etc. scripts | |
| 2301 | 2316 | Cache = cache.Cache(debug=DEBUG_CACHE) | |
| 2302 | 2317 | chunkify = cache.chunkify | |
| Back | FazBrowse Home | New Git URL |
0 commit comments