You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
941
989
# ignore dynamic linking, since multiple dynamic linkings can interfere with each other
@@ -999,6 +1047,15 @@ def check(input_file):
999
1047
ifshared.get_llvm_target() ==shared.WASM_TARGET:
1000
1048
shared.Settings.WASM_BACKEND=1
1001
1049
1050
+
ifnotshared.Settings.STRICT:
1051
+
# The preprocessor define EMSCRIPTEN is deprecated. Don't pass it to code in strict mode. Code should use the define __EMSCRIPTEN__ instead.
1052
+
shared.COMPILER_OPTS+= ['-DEMSCRIPTEN']
1053
+
1054
+
# The system include path system/include/emscripten/ is deprecated, i.e. instead of #include <emscripten.h>, one should pass in #include <emscripten/emscripten.h>.
1055
+
# This path is not available in Emscripten strict mode.
assertnotuse_closure_compiler, 'cannot use closure compiler on shared modules'
1053
1110
assertnotshared.Settings.ALLOW_MEMORY_GROWTH, 'memory growth is not supported with shared modules yet'
1054
1111
1055
-
ifshared.Settings.ALLOW_MEMORY_GROWTH:
1056
-
logging.warning('not all asm.js optimizations are possible with ALLOW_MEMORY_GROWTH, disabling those')
1057
-
shared.Settings.ASM_JS=2# memory growth does not validate as asm.js http://discourse.wicg.io/t/request-for-comments-switching-resizing-heaps-in-asm-js/641/23
1058
-
1059
1112
ifshared.Settings.EMULATE_FUNCTION_POINTER_CASTS:
1060
1113
shared.Settings.ALIASING_FUNCTION_POINTERS=0
1061
1114
@@ -1155,13 +1208,16 @@ def check(input_file):
1155
1208
1156
1209
ifshared.Settings.USE_PTHREADS:
1157
1210
ifshared.Settings.LINKABLE:
1158
-
logging.error('-s LINKABLE=1 is not supported with -s USE_PTHREADS=1!')
1211
+
logging.error('-s LINKABLE=1 is not supported with -s USE_PTHREADS>0!')
1159
1212
exit(1)
1160
1213
ifshared.Settings.SIDE_MODULE:
1161
-
logging.error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS=1!')
1214
+
logging.error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1162
1215
exit(1)
1163
1216
ifshared.Settings.MAIN_MODULE:
1164
-
logging.error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS=1!')
1217
+
logging.error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1218
+
exit(1)
1219
+
ifshared.Settings.EMTERPRETIFY:
1220
+
logging.error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
1165
1221
exit(1)
1166
1222
1167
1223
ifshared.Settings.OUTLINING_LIMIT:
@@ -1216,6 +1272,12 @@ def check(input_file):
1216
1272
# * and js mem inits are useful for avoiding a side file, but the wasm module avoids that anyhow
logging.warning('not all asm.js optimizations are possible with ALLOW_MEMORY_GROWTH, disabling those')
1279
+
shared.Settings.ASM_JS=2# memory growth does not validate as asm.js http://discourse.wicg.io/t/request-for-comments-switching-resizing-heaps-in-asm-js/641/23
1280
+
1219
1281
ifjs_opts:
1220
1282
shared.Settings.RUNNING_JS_OPTS=1
1221
1283
@@ -1987,6 +2049,14 @@ def do_minify(): # minifies the code. this is also when we do certain optimizati
logging.error('Unrecognized BINARYEN_METHOD "'+m.strip() +'" specified! Please pass a comma-delimited list containing one or more of: '+','.join(valid_methods))
2058
+
sys.exit(1)
2059
+
1990
2060
ifshared.Settings.BINARYEN:
1991
2061
logging.debug('using binaryen, with method: '+shared.Settings.BINARYEN_METHOD)
Copy file name to clipboardExpand all lines: site/source/docs/compiling/Building-Projects.rst
+15-10Lines changed: 15 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,17 +268,22 @@ The :ref:`Tutorial` showed how :ref:`emcc <emccdoc>` can be used to compile sing
268
268
In addition to the capabilities it shares with *gcc*, *emcc* supports options to optimize code, control what debug information is emitted, generate HTML and other output formats, etc. These options are documented in the :ref:`emcc tool reference <emccdoc>` (``./emcc --help`` on the command line).
269
269
270
270
271
-
Alternatives to emcc
272
-
====================
273
-
274
-
.. tip:: Do not attempt to bypass *emcc* and call the Emscripten tools directly from your build system.
275
-
276
-
You can in theory call *clang*, *llvm-ld*, and the other tools yourself. This is however considered dangerous because by default:
277
-
278
-
- *Clang* does not use the Emscripten-bundled headers, which can lead to various errors.
*Emcc* automatically ensures the tools are configured and used properly.
274
+
Emscripten provides the following preprocessor macros that can be used to identify the compiler version and platform:
275
+
276
+
* The preprocessor define ``__EMSCRIPTEN__`` is always defined when compiling programs with Emscripten.
277
+
* The preprocessor variables ``__EMSCRIPTEN_major__``, ``__EMSCRIPTEN_minor__`` and ``__EMSCRIPTEN_tiny__`` specify, as integers, the currently used Emscripten compiler version.
278
+
* Emscripten behaves like a variant of Unix, so the preprocessor defines ``unix``, ``__unix`` and ``__unix__`` are always present when compiling code with Emscripten.
279
+
* Emscripten uses Clang/LLVM as its underlying codegen compiler, so the preprocessor defines ``__llvm__`` and ``__clang__`` are defined, and the preprocessor defines ``__clang_major__``, ``__clang_minor__`` and ``__clang_patchlevel__`` indicate the version of Clang that is used.
280
+
* Clang/LLVM is GCC-compatible, so the preprocessor defines ``__GNUC__``, ``__GNUC_MINOR__`` and ``__GNUC_PATCHLEVEL__`` are also defined to represent the level of GCC compatibility that Clang/LLVM provides.
281
+
* The preprocessor string ``__VERSION__`` indicates the GCC compatible version, which is expanded to also show Emscripten version information.
282
+
* Likewise, ``__clang_version__`` is present and indicates both Emscripten and LLVM version information.
283
+
* Emscripten is a 32-bit platform, so ``size_t`` is a 32-bit unsigned integer, ``__POINTER_WIDTH__=32``, ``__SIZEOF_LONG__=4`` and ``__LONG_MAX__`` equals ``2147483647L``.
284
+
* When targeting asm.js, the preprocessor defines ``__asmjs`` and ``__asmjs__`` are present.
285
+
* When targeting SSEx SIMD APIs using one of the command line compiler flags ``-msse``, ``-msse2``, ``-msse3``, ``-mssse3``, or ``-msse4.1``, one or more of the preprocessor flags ``__SSE__``, ``__SSE2__``, ``__SSE3__``, ``__SSSE3__``, ``__SSE4_1__`` will be present to indicate available support for these instruction sets.
286
+
* If targeting the pthreads multithreading support with the compiler & linker flag ``-s USE_PTHREADS=1``, the preprocessor define ``__EMSCRIPTEN_PTHREADS__`` will be present.
Copy file name to clipboardExpand all lines: site/source/docs/tools_reference/emcc.rst
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -450,6 +450,9 @@ Options that are modified or new in *emcc* are listed below:
450
450
``--output-eol windows|linux``
451
451
Specifies the line ending to generate for the text files that are outputted. If "--output-eol windows" is passed, the final output files will have Windows \r\n line endings in them. With "--output-eol linux", the final generated files will be written with Unix \n line endings.
452
452
453
+
``--cflags``
454
+
Prints out the flags ``emcc`` would pass to ``clang`` to compile source code to object/bitcode form. You can use this to invoke clang yourself, and then run ``emcc`` on those outputs just for the final linking+conversion to JS.
0 commit comments