diff options
-rw-r--r-- | emlink.py | 4 | ||||
-rwxr-xr-x | tests/runner.py | 26 |
2 files changed, 28 insertions, 2 deletions
@@ -28,7 +28,9 @@ Limitations: EMCC_FORCE_STDLIBS=1 emcc .. - which will link in all the C libraries. + which will link in all the libraries (you can also do EMCC_FORCE_STDLIBS=libc for example to + include just libc and its dependencies; run with EMCC_DEBUG=1 to see which are necessary and + include the first one). 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 diff --git a/tests/runner.py b/tests/runner.py index 0db58f4e..b0d86c6a 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -10731,13 +10731,37 @@ f.close() ''', r''' #include "header.h" char *side(const char *data) { - return (char*)data; char *ret = (char*)malloc(strlen(data)+1); strcpy(ret, data); return ret; } ''', ['hello through side\n']) + # libc usage in one modules. must force libc inclusion in the main module if that isn't the one using mallinfo() + try: + os.environ['EMCC_FORCE_STDLIBS'] = 'libc' + test('malloc-1', r''' + #include <string.h> + int side(); + ''', r''' + #include <stdio.h> + #include "header.h" + int main() { + printf("|%d|\n", side()); + return 0; + } + ''', r''' + #include <stdlib.h> + #include <malloc.h> + #include "header.h" + int side() { + struct mallinfo m = mallinfo(); + return m.arena > 1; + } + ''', ['|1|\n']) + finally: + del os.environ['EMCC_FORCE_STDLIBS'] + return # TODO # iostream usage in one and std::string in both |