diff --git a/emcc b/emcc index 025daaf9dcecc..cfec4a0effe12 100755 --- a/emcc +++ b/emcc @@ -221,7 +221,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: elif arg.endswith('.s'): if debug_configure: open(tempout, 'a').write('(compiling .s assembly, must use clang\n') if use_js == 1: use_js = 0 - elif arg == '-E': + elif arg == '-E' or arg == '-M' or arg == '-MM': if use_js == 1: use_js = 0 if src: @@ -330,12 +330,6 @@ for i in range(1, len(sys.argv)): if arg.endswith(C_ENDINGS + OBJC_ENDINGS): use_cxx = False -if '-M' in sys.argv or '-MM' in sys.argv: - # Just output dependencies, do not compile. Warning: clang and gcc behave differently with -MF! (clang seems to not recognize it) - cmd = [CC] + shared.COMPILER_OPTS + sys.argv[1:] - logging.debug('just dependencies: ' + ' '.join(cmd)) - exit(subprocess.call(cmd)) - # Check if a target is specified target = None for i in range(len(sys.argv)-1): @@ -819,7 +813,9 @@ try: target = target_basename + '.o' final_suffix = 'o' if '-E' in newargs: - final_suffix = 'eout' # not bitcode, not js; something else + final_suffix = 'eout' # not bitcode, not js; but just result from preprocessing stage of the input file + if '-M' in newargs or '-MM' in newargs: + final_suffix = 'mout' # not bitcode, not js; but just dependency rule of the input file final_ending = ('.' + final_suffix) if len(final_suffix) > 0 else '' # Find library files @@ -1077,12 +1073,13 @@ try: return args # -E preprocessor-only support - if '-E' in newargs: + if '-E' in newargs or '-M' in newargs or '-MM' in newargs: input_files = map(lambda x: x[1], input_files) cmd = get_bitcode_args(input_files) if specified_target: cmd += ['-o', specified_target] - logging.debug('just preprocessor ' + ' '.join(cmd)) + # Do not compile, but just output the result from preprocessing stage or output the dependency rule. Warning: clang and gcc behave differently with -MF! (clang seems to not recognize it) + logging.debug(('just preprocessor ' if '-E' in newargs else 'just dependencies: ') + ' '.join(cmd)) exit(subprocess.call(cmd)) # First, generate LLVM bitcode. For each input file, we get base.o with bitcode diff --git a/emscripten-version.txt b/emscripten-version.txt index c3078112a4462..fa911e3b71b7c 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -1.33.1 +1.33.2 diff --git a/site/build/text/docs/api_reference/emscripten.h.txt b/site/build/text/docs/api_reference/emscripten.h.txt index 4f791f0e0aa71..4670d5b926665 100644 --- a/site/build/text/docs/api_reference/emscripten.h.txt +++ b/site/build/text/docs/api_reference/emscripten.h.txt @@ -66,7 +66,7 @@ EM_ASM(...) above. * Newlines (\n, \r etc.) are supported in the inline - Javascript. Note that any platform-specific issues with line + JavaScript. Note that any platform-specific issues with line endings in normal JavaScript also apply to inline JavaScript declared using "EM_ASM". @@ -471,7 +471,7 @@ int emscripten_set_main_loop_timing(int mode, int value) US/docs/Web/API/WindowTimers.setTimeout#Inactive_tabs>* for more information. -void emscripten_set_main_loop_timing(int *mode, int *value) +void emscripten_get_main_loop_timing(int *mode, int *value) Returns the current main loop timing mode that is in effect. For interpretation of the values, see the documentation of the @@ -1814,7 +1814,7 @@ void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffe * **perror** -- An out parameter that will be filled with a non- zero value if an error occurred. -void emscripten_idb_store(const char *db_name, const char *file_id, void* ptr, int num, int *perror); +void emscripten_idb_store(const char *db_name, const char *file_id, void* buffer, int num, int *perror); Synchronously stores data to IndexedDB. @@ -1851,14 +1851,12 @@ void emscripten_idb_exists(const char *db_name, const char *file_id, int* pexist * **file_id** -- The name of the file to check - * **perror** -- An out parameter that will be filled with a + * **pexists** -- An out parameter that will be filled with a non- zero value if the file exists in that database. * **perror** -- An out parameter that will be filled with a non- zero value if an error occurred. -void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* pnum, int *perror); - Asyncify functions ================== diff --git a/site/build/text/docs/api_reference/html5.h.txt b/site/build/text/docs/api_reference/html5.h.txt index cd474454ee912..5e46e7b914400 100644 --- a/site/build/text/docs/api_reference/html5.h.txt +++ b/site/build/text/docs/api_reference/html5.h.txt @@ -1397,7 +1397,7 @@ EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH Specifies that the Emscripten runtime should explicitly stretch the CSS size of the target element to cover the whole screen when - trasnsitioning to fullscreen mode. This will change the aspect + transitioning to fullscreen mode. This will change the aspect ratio of the displayed content. EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT @@ -2778,7 +2778,7 @@ EM_BOOL emscripten_webgl_enable_extension(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE conte * **context** (*EMSCRIPTEN_WEBGL_CONTEXT_HANDLE*) -- The WebGL context on which the extension is to be enabled. - * **extension** (*const char**) -- A string identifyingthea + * **extension** (*const char**) -- A string identifying the WebGL extension. For example "OES_texture_float". Returns: diff --git a/site/build/text/docs/api_reference/preamble.js.txt b/site/build/text/docs/api_reference/preamble.js.txt index 01ed7672018e0..f65e889b64775 100644 --- a/site/build/text/docs/api_reference/preamble.js.txt +++ b/site/build/text/docs/api_reference/preamble.js.txt @@ -228,8 +228,8 @@ getValue(ptr, type[, noSafe]) * **type** -- An LLVM IR type as a string (see "note" above). * **noSafe** (*bool*) -- Developers should ignore this - variable. It is on used in "SAFE_HEAP" compilation mode, where - it can be avoid infinite recursion in some specialist use + variable. It is only used in "SAFE_HEAP" compilation mode, where + it can help avoid infinite recursion in some specialist use cases. Returns: @@ -260,14 +260,14 @@ UTF16ToString(ptr) Given a pointer "ptr" to a null-terminated UTF16LE-encoded string in the Emscripten HEAP, returns a copy of that string as a - Javascript "String" object. + JavaScript "String" object. Arguments: * **ptr** -- A pointer to a null-terminated UTF16LE-encoded string in the Emscripten HEAP. Returns: - A Javascript "String" object + A JavaScript "String" object stringToUTF16(str, outPtr) @@ -295,7 +295,7 @@ UTF32ToString(ptr) string in the Emscripten HEAP. Returns: - A Javascript "String" object. + A JavaScript "String" object. stringToUTF32(str, outPtr) diff --git a/site/source/docs/api_reference/Filesystem-API.rst b/site/source/docs/api_reference/Filesystem-API.rst index 8b9767224c4d0..bd00e8386cb57 100644 --- a/site/source/docs/api_reference/Filesystem-API.rst +++ b/site/source/docs/api_reference/Filesystem-API.rst @@ -702,7 +702,7 @@ Paths Looks up the incoming path and returns an object containing both the resolved path and node. - The options (``opts``) allow you to specify whether the object, it’s parent component, a symlink, or the item the symlink points to are returned. For example: :: + The options (``opts``) allow you to specify whether the object, its parent component, a symlink, or the item the symlink points to are returned. For example: :: var lookup = FS.lookupPath(path, { parent: true }); diff --git a/site/source/docs/api_reference/advanced-apis.rst b/site/source/docs/api_reference/advanced-apis.rst index d51a02c8a4e1a..92e676b0c5406 100644 --- a/site/source/docs/api_reference/advanced-apis.rst +++ b/site/source/docs/api_reference/advanced-apis.rst @@ -63,7 +63,6 @@ Advanced File System API :ref:`Filesystem-API` covers the public API that will be relevant to most developers. The following functions are only needed for advanced use-cases (for example, writing a new local file system) or legacy file system compatibility. .. js:function:: FS.handleFSError(e) - FS.handleFSError(e) FS.hashName(parentid, name) FS.hashAddNode(node) FS.hashRemoveNode(node) diff --git a/site/source/docs/api_reference/emscripten.h.rst b/site/source/docs/api_reference/emscripten.h.rst index dc6f16cde9cf7..a03d13dfdaafd 100644 --- a/site/source/docs/api_reference/emscripten.h.rst +++ b/site/source/docs/api_reference/emscripten.h.rst @@ -33,7 +33,7 @@ Defines .. note:: - Double-quotes (") cannot be used in the inline assembly/JavaScript. Single-quotes (‘) can be used, as shown above. - - Newlines (\\n, \\r etc.) are supported in the inline Javascript. Note that any platform-specific issues with line endings in normal JavaScript also apply to inline JavaScript declared using ``EM_ASM``. + - Newlines (\\n, \\r etc.) are supported in the inline JavaScript. Note that any platform-specific issues with line endings in normal JavaScript also apply to inline JavaScript declared using ``EM_ASM``. - You can’t access C variables with :c:macro:`EM_ASM`, nor receive a value back. Instead use :c:macro:`EM_ASM_ARGS`, :c:macro:`EM_ASM_INT`, or :c:macro:`EM_ASM_DOUBLE`. - As of ``1.30.4``, ``EM_ASM`` contents appear as normal JS, outside of the compiled code. Previously we had them as a string that was ``eval``ed. The newer approach avoids the overhead of ``eval``, and also allows for better optimization of ``EM_ASM`` contents by things like closure compiler, as their contents are now visible. Note that this means that closure compiler will optimize them as if they were written together with the rest of the codebase, which is a change from before - you may need to use safety quotes in some places (``a['b']`` instead of ``a.b``). @@ -259,7 +259,7 @@ Functions .. note:: There is a functional difference between ``setTimeout`` and ``requestAnimationFrame``: If the user minimizes the browser window or hides your application tab, browsers will typically stop calling ``requestAnimationFrame`` callbacks, but ``setTimeout``-based main loop will continue to be run, although with heavily throttled intervals. See `setTimeout on MDN ` for more information. -.. c:function:: void emscripten_set_main_loop_timing(int *mode, int *value) +.. c:function:: void emscripten_get_main_loop_timing(int *mode, int *value) Returns the current main loop timing mode that is in effect. For interpretation of the values, see the documentation of the function :c:func:`emscripten_set_main_loop_timing`. The timing mode is controlled by calling the functions :c:func:`emscripten_set_main_loop_timing` and :c:func:`emscripten_set_main_loop`. @@ -1119,7 +1119,7 @@ IndexedDB :param pnum: An out parameter that will be filled with the size of the downloaded data. :param perror: An out parameter that will be filled with a non-zero value if an error occurred. -.. c:function:: void emscripten_idb_store(const char *db_name, const char *file_id, void* ptr, int num, int *perror); +.. c:function:: void emscripten_idb_store(const char *db_name, const char *file_id, void* buffer, int num, int *perror); Synchronously stores data to IndexedDB. @@ -1143,11 +1143,9 @@ IndexedDB :param db_name: The name of the database to check in :param file_id: The name of the file to check - :param perror: An out parameter that will be filled with a non-zero value if the file exists in that database. + :param pexists: An out parameter that will be filled with a non-zero value if the file exists in that database. :param perror: An out parameter that will be filled with a non-zero value if an error occurred. -.. c:function:: void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* pnum, int *perror); - Asyncify functions ================== diff --git a/site/source/docs/api_reference/html5.h.rst b/site/source/docs/api_reference/html5.h.rst index 586b0b3e80ca1..2de30fccc78e3 100644 --- a/site/source/docs/api_reference/html5.h.rst +++ b/site/source/docs/api_reference/html5.h.rst @@ -1024,7 +1024,7 @@ Defines .. c:macro:: EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH - Specifies that the Emscripten runtime should explicitly stretch the CSS size of the target element to cover the whole screen when trasnsitioning to fullscreen mode. This + Specifies that the Emscripten runtime should explicitly stretch the CSS size of the target element to cover the whole screen when transitioning to fullscreen mode. This will change the aspect ratio of the displayed content. .. c:macro:: EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT @@ -2012,7 +2012,7 @@ Functions Enables the given extension on the given context. :param EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context: The WebGL context on which the extension is to be enabled. - :param extension: A string identifyingthea `WebGL extension `_. For example "OES_texture_float". + :param extension: A string identifying the `WebGL extension `_. For example "OES_texture_float". :type extension: const char* :returns: EM_TRUE if the given extension is supported by the context, and EM_FALSE if the extension was not available. :rtype: |EM_BOOL| diff --git a/site/source/docs/api_reference/preamble.js.rst b/site/source/docs/api_reference/preamble.js.rst index 0f56333682f25..5970282e1a36d 100644 --- a/site/source/docs/api_reference/preamble.js.rst +++ b/site/source/docs/api_reference/preamble.js.rst @@ -135,7 +135,7 @@ Accessing memory :param ptr: A pointer (number) representing the memory address. :param type: An LLVM IR type as a string (see "note" above). - :param noSafe: Developers should ignore this variable. It is on used in ``SAFE_HEAP`` compilation mode, where it can be avoid infinite recursion in some specialist use cases. + :param noSafe: Developers should ignore this variable. It is only used in ``SAFE_HEAP`` compilation mode, where it can help avoid infinite recursion in some specialist use cases. :type noSafe: bool :returns: The value stored at the specified memory address. @@ -158,10 +158,10 @@ Conversion functions — strings, pointers and arrays .. js:function:: UTF16ToString(ptr) - Given a pointer ``ptr`` to a null-terminated UTF16LE-encoded string in the Emscripten HEAP, returns a copy of that string as a Javascript ``String`` object. + Given a pointer ``ptr`` to a null-terminated UTF16LE-encoded string in the Emscripten HEAP, returns a copy of that string as a JavaScript ``String`` object. :param ptr: A pointer to a null-terminated UTF16LE-encoded string in the Emscripten HEAP. - :returns: A Javascript ``String`` object + :returns: A JavaScript ``String`` object @@ -182,7 +182,7 @@ Conversion functions — strings, pointers and arrays Given a pointer ``ptr`` to a null-terminated UTF32LE-encoded string in the Emscripten HEAP, returns a copy of that string as a JavaScript ``String`` object. :param ptr: A pointer to a null-terminated UTF32LE-encoded string in the Emscripten HEAP. - :returns: A Javascript ``String`` object. + :returns: A JavaScript ``String`` object. .. js:function:: stringToUTF32(str, outPtr) diff --git a/site/source/docs/building_from_source/configuring_emscripten_settings.rst b/site/source/docs/building_from_source/configuring_emscripten_settings.rst index 395ee574e30c1..1af4399952799 100644 --- a/site/source/docs/building_from_source/configuring_emscripten_settings.rst +++ b/site/source/docs/building_from_source/configuring_emscripten_settings.rst @@ -83,7 +83,7 @@ The compiler configuration file can be edited with the text editor of your choic EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN') or '/home/ubuntu/yourpath/emscripten') # directory -.. comment .. The settings are now correct in the configuration file, but the paths and environment variables are not set in the command prompt/terminal. **HamishW** Follow up with Jukka on htis. +.. comment .. The settings are now correct in the configuration file, but the paths and environment variables are not set in the command prompt/terminal. **HamishW** Follow up with Jukka on this. After setting those paths, run ``emcc`` again. It should again perform the sanity checks to test the specified paths. There are further validation tests available at :ref:`verifying-the-emscripten-environment`. diff --git a/site/source/docs/building_from_source/toolchain_what_is_needed.rst b/site/source/docs/building_from_source/toolchain_what_is_needed.rst index 0115a1b73fc0f..5c7b34faf1924 100644 --- a/site/source/docs/building_from_source/toolchain_what_is_needed.rst +++ b/site/source/docs/building_from_source/toolchain_what_is_needed.rst @@ -25,7 +25,7 @@ A complete Emscripten environment requires the following tools. First test to se - :term:`Node.js` (0.8 or above; 0.10.17 or above to run websocket-using servers in node): - :term:`Python` 2.x (2.7.3 or above preferred) - :term:`Java` (1.6.0_31 or later). Java is optional. It is required to use the :term:`Closure Compiler` (in order to minify your code). - - :term:`Git` client. Git required if building tools from source. + - :term:`Git` client. Git is required if building tools from source. - :term:`Fastcomp` (Emscripten's fork of LLVM and Clang) - The `Emscripten code `_, from GitHub @@ -88,7 +88,7 @@ You can check which tools are already present using the following commands: nodejs --version # Check for node.js on Windows - node --version # + node --version # Check for node.js on Mac OS X node -v diff --git a/site/source/docs/compiling/Building-Projects.rst b/site/source/docs/compiling/Building-Projects.rst index 393e9895a19a7..b5d11efb0f87e 100644 --- a/site/source/docs/compiling/Building-Projects.rst +++ b/site/source/docs/compiling/Building-Projects.rst @@ -130,7 +130,7 @@ For more general information, see the topic :ref:`Debugging`. Using libraries =============== -Built in support is available for a number of standard libraries: *libc*, *libc++* and *SDL*. These will automatically be linked when you compile code that uses them (you do not even need to add ``-lSDL``, but see below for more SDL-specific details). +Built-in support is available for a number of standard libraries: *libc*, *libc++* and *SDL*. These will automatically be linked when you compile code that uses them (you do not even need to add ``-lSDL``, but see below for more SDL-specific details). If your project uses other libraries, for example `zlib `_ or *glib*, you will need to build and link them. The normal approach is to build the libraries to bitcode and then compile library and main program bitcode together to JavaScript. @@ -178,7 +178,7 @@ You should see some notifications about SDL2 being used, and built if it wasn't .. note:: *SDL_image* has also been added to ports, use it with ``-s USE_SDL_IMAGE=2``. To see a list of all available ports, run ``emcc --show-ports``. -.. note:: Emscripten also has support for older SDL1, which is built in. If you do not specify SDL2 as in the command above, then SDL1 is linked in and the SDL1 include paths are used. SDL1 has support for *sdl-config*, which is present in `system/bin `_. Using the native *sdl-config* may result in compilation or missing-symbol errors. You will need to modify the build system to look for files in **emscripten/system** or **emscripten/system/bin** in order to use the Emscripten *sdl-config*. +.. note:: Emscripten also has support for older SDL1, which is built-in. If you do not specify SDL2 as in the command above, then SDL1 is linked in and the SDL1 include paths are used. SDL1 has support for *sdl-config*, which is present in `system/bin `_. Using the native *sdl-config* may result in compilation or missing-symbol errors. You will need to modify the build system to look for files in **emscripten/system** or **emscripten/system/bin** in order to use the Emscripten *sdl-config*. Adding more ports ----------------- diff --git a/site/source/docs/compiling/Running-html-files-with-emrun.rst b/site/source/docs/compiling/Running-html-files-with-emrun.rst index 2005cce72017e..cdd69317e2662 100644 --- a/site/source/docs/compiling/Running-html-files-with-emrun.rst +++ b/site/source/docs/compiling/Running-html-files-with-emrun.rst @@ -150,7 +150,7 @@ When running web pages via ``emrun`` using Firefox, you may want to set one or m dom.max_chrome_script_run_time;0 ; Accelerate browser update background timer tick so that autoupdates take place as quickly as possible. - ; This is useful for continous integration servers wanting to always test the latest browser version. + ; This is useful for continuous integration servers wanting to always test the latest browser version. app.update.download.backgroundInterval;1 ; Always run in private browsing mode to avoid caching any pages (but also disables IndexedDB persistency!). diff --git a/site/source/docs/compiling/index.rst b/site/source/docs/compiling/index.rst index 633db10aefee7..10095f8ff411c 100644 --- a/site/source/docs/compiling/index.rst +++ b/site/source/docs/compiling/index.rst @@ -6,7 +6,7 @@ Compiling and Running Projects This section contains topics about building projects and running the output. -- :ref:`Building-Projects` shows how to use :ref:`emccdoc` as a drop in replacement for *gcc* in your existing project. +- :ref:`Building-Projects` shows how to use :ref:`emccdoc` as a drop-in replacement for *gcc* in your existing project. - :ref:`Running-html-files-with-emrun` explains how to use *emrun* to run generated HTML pages in a locally launched web server. diff --git a/site/source/docs/getting_started/FAQ.rst b/site/source/docs/getting_started/FAQ.rst index ddff74579d3c5..422d85e966928 100644 --- a/site/source/docs/getting_started/FAQ.rst +++ b/site/source/docs/getting_started/FAQ.rst @@ -151,7 +151,7 @@ Libraries not included with Emscripten (like Boost) must be compiled and linked There is a set of libraries ported to Emscripten for convenient use, Emscripten Ports. See :ref:`Building-Projects` -Another option is to implement needed C APIs as JavaScript librarys (see ``--js-library`` in :ref:`emcc ` and :ref:`implement-c-in-javascript`). Emscripten itself does this for *libc* (not including *malloc*) and :term:`SDL` (but not *libc++* or *malloc*). +Another option is to implement needed C APIs as JavaScript libraries (see ``--js-library`` in :ref:`emcc ` and :ref:`implement-c-in-javascript`). Emscripten itself does this for *libc* (not including *malloc*) and :term:`SDL` (but not *libc++* or *malloc*). .. note:: @@ -335,7 +335,7 @@ On Linux and Mac OS X, you can just do ``NODE_JS = ['node', '--stack_size=8192'] Why do I get ``error: cannot compile this aggregate va_arg expression yet`` and it says ``compiler frontend failed to generate LLVM bitcode, halting`` afterwards? -=================================================================================================================================================================== +================================================================================================================================================================== This is a limitation of the asm.js target in :term:`Clang`. This code is not currently supported. diff --git a/site/source/docs/getting_started/bug_reports.rst b/site/source/docs/getting_started/bug_reports.rst index b47d5a08db461..34063b04272f3 100644 --- a/site/source/docs/getting_started/bug_reports.rst +++ b/site/source/docs/getting_started/bug_reports.rst @@ -14,7 +14,7 @@ Please supply as much relevant information as possible, including: - Error symptoms. - Proposed solutions, ideally with a pull request. -.. Tip:: Compile with ``EMCC_DEBUG=1`` and grab the **/tmp/emscripten_temp/emcc-\*** files (these include the bytecode and JavaScript in several stages). Note that the **emscripten_temp** directory should be emptied manually first, so it only contains new content! +.. Tip:: Compile with ``EMCC_DEBUG=1`` and grab the **/tmp/emscripten_temp/emcc-\*** files (these include the bitcode and JavaScript in several stages). Note that the **emscripten_temp** directory should be emptied manually first, so it only contains new content! Fastcomp LLVM-Backend and Clang bugs diff --git a/site/source/docs/getting_started/downloads.rst b/site/source/docs/getting_started/downloads.rst index df6b491ed9f95..c5183c8202231 100644 --- a/site/source/docs/getting_started/downloads.rst +++ b/site/source/docs/getting_started/downloads.rst @@ -114,7 +114,7 @@ Mac OS X - The *python2* command line tool is not present on OSX by default. To manually work around this issue, follow the linked step in :ref:`Getting started on Mac OS X `. -.. **HamishW**: I think that Mac OS X has the same issues as Linux - ie you don't get ANYTHING much in the SDK. YOu will need the command line tools, but mostly for GCC - need to confirm this with Jukka +.. **HamishW**: I think that Mac OS X has the same issues as Linux - ie you don't get ANYTHING much in the SDK. You will need the command line tools, but mostly for GCC - need to confirm this with Jukka Linux ++++++++ @@ -150,6 +150,8 @@ Linux # Install Java sudo apt-get install default-jre + +.. note:: Your system may provide Node.js as ``node`` instead of ``nodejs``. In that case, you may need to also update the ``NODE_JS`` attribute of your ``~/.emscripten`` file. - *Git* is not installed automatically. Git is only needed if you want to use tools from one of the development branches **emscripten-incoming** or **emscripten-master**: diff --git a/site/source/docs/introducing_emscripten/about_emscripten.rst b/site/source/docs/introducing_emscripten/about_emscripten.rst index d4994db4b1fe5..275da7361d1e3 100644 --- a/site/source/docs/introducing_emscripten/about_emscripten.rst +++ b/site/source/docs/introducing_emscripten/about_emscripten.rst @@ -7,7 +7,7 @@ About Emscripten Emscripten is an :ref:`Open Source ` LLVM to JavaScript compiler. Using Emscripten you can: - Compile C and C++ code into JavaScript -- Compile any other code that can be translated into LLVM bytecode into JavaScript. +- Compile any other code that can be translated into LLVM bitcode into JavaScript. - Compile the C/C++ **runtimes** of other languages into JavaScript, and then run code in those other languages in an *indirect* way (this has been done for Python and Lua)! .. tip:: Emscripten makes native code immediately available on the Web: a platform that is standards-based, has numerous independent compatible implementations, and runs everywhere from PCs to iPads. @@ -45,7 +45,7 @@ A high level view of the Emscripten toolchain is given below. The main tool is t .. image:: EmscriptenToolchain.png -*Emcc* uses :term:`Clang` to convert C/C++ files to LLVM bytecode, and :ref:`Fastcomp ` (Emscripten's Compiler Core — an LLVM backend) to compile the bytecode to JavaScript. The output JavaScript can be executed by :term:`node.js`, or from within HTML in a browser. +*Emcc* uses :term:`Clang` to convert C/C++ files to LLVM bitcode, and :ref:`Fastcomp ` (Emscripten's Compiler Core — an LLVM backend) to compile the bitcode to JavaScript. The output JavaScript can be executed by :term:`node.js`, or from within HTML in a browser. The :ref:`emsdk` is used to manage multiple SDKs and tools, and to specify the particular SDK/set of tools currently being used to compile code (the :term:`Active Tool/SDK`). It can even "install" (download and build) the latest toolchain from Github! diff --git a/site/source/docs/porting/connecting_cpp_and_javascript/embind.rst b/site/source/docs/porting/connecting_cpp_and_javascript/embind.rst index 1a50a52c86a4a..c03b0335ebcf8 100644 --- a/site/source/docs/porting/connecting_cpp_and_javascript/embind.rst +++ b/site/source/docs/porting/connecting_cpp_and_javascript/embind.rst @@ -711,7 +711,7 @@ First we use :cpp:func:`~emscripten::val::global` to get the symbol for the global ``AudioContext`` object (or ``webkitAudioContext`` if that does not exist). We then use :cpp:func:`~emscripten::val::new_` to create the context, and from this context we can create an ``oscillator``, -:cpp:func:`~emscripten::val::set` it's properties (again using ``val``) +:cpp:func:`~emscripten::val::set` its properties (again using ``val``) and then play the tone. The example can be compiled on the Linux/Mac OS X terminal with:: diff --git a/site/source/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.rst b/site/source/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.rst index 207de296c1530..9c7d93dac0dfc 100644 --- a/site/source/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.rst +++ b/site/source/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.rst @@ -46,7 +46,7 @@ Instructions #. The added JavaScript should also include code to allow the web worker to communicate with the original thread. - The test code adds the following JavaScript to the web worker for this purpose. It uses ``postMessage()`` to send it's ``stdout`` back to the main thread. + The test code adds the following JavaScript to the web worker for this purpose. It uses ``postMessage()`` to send its ``stdout`` back to the main thread. .. include:: ../../../../../tests/test_browser.py :literal: diff --git a/site/source/docs/porting/guidelines/function_pointer_issues.rst b/site/source/docs/porting/guidelines/function_pointer_issues.rst index 23e51e57803a8..9f02786cdb004 100644 --- a/site/source/docs/porting/guidelines/function_pointer_issues.rst +++ b/site/source/docs/porting/guidelines/function_pointer_issues.rst @@ -58,7 +58,7 @@ As mentioned :ref:`above `, in **asm.js** m There are three solutions to this problem (the second is preferred): - Cast the function pointer back to the correct type before it is called. This is problematic because it requires that the caller knows the original type. - - Make an adapter function that does not need to be cast, and will hence be found in the correct function-pointer table. From the adaptor function call the original function. + - Make an adapter function that does not need to be cast, and will hence be found in the correct function-pointer table. From the adapter function call the original function. - Use ``EMULATE_FUNCTION_POINTER_CASTS``. When you build with ``-s EMULATE_FUNCTION_POINTER_CASTS=1``, Emscripten emits code to emulate function pointer casts at runtime, adding extra arguments/dropping them/changing their type/adding or dropping a return type/etc. This can add significant runtime overhead, so it is not recommended, but might be worth trying. For a real-world example, consider the code below: @@ -71,7 +71,7 @@ For a real-world example, consider the code below: void voidReturn(const char *message) { printf( "voidReturn: %s\n", message ); - } + } int intReturn(const char *message) { diff --git a/site/source/docs/porting/multimedia_and_graphics/OpenGL-support.rst b/site/source/docs/porting/multimedia_and_graphics/OpenGL-support.rst index 0fb7c4c1c3dd3..a3c1eada8410e 100644 --- a/site/source/docs/porting/multimedia_and_graphics/OpenGL-support.rst +++ b/site/source/docs/porting/multimedia_and_graphics/OpenGL-support.rst @@ -55,7 +55,7 @@ To enable this mode, specify the :ref:`emcc ` option ``-s L OpenGL extensions ================= -When porting code, it should be noted that desktop OpenGL, OpenGL ES and WebGL each have their own extension registryes. This means that neither desktop OpenGL or OpenGL ES extensions are automatically also WebGL extensions, although some amount of parity does exist. See the `WebGL 1.0 extension registry `_ for the full list of registered extensions. +When porting code, it should be noted that desktop OpenGL, OpenGL ES and WebGL each have their own extension registries. This means that neither desktop OpenGL or OpenGL ES extensions are automatically also WebGL extensions, although some amount of parity does exist. See the `WebGL 1.0 extension registry `_ for the full list of registered extensions. Additionally, in WebGL, unlike in desktop or mobile OpenGL, extensions must be activated first before the features they expose take effect. If you use one of the native APIs SDL, EGL, GLUT or GLFW to create your GL context, this will be done automatically for most extensions. If instead you use the HTML5 WebGL context creation API, you must explicitly choose whether to autoenable WebGL extensions. If an extension was not automatically enabled at context creation time, the HTML5 API function `emscripten_webgl_enable_extension` can be used to activate it. Debugging related extensions, draft extensions and vendor-prefixed extensions (MOZ_*, WEBKIT_*) are never enabled automatically at context creation time, but must always be activated manually. diff --git a/site/source/docs/site/glossary.rst b/site/source/docs/site/glossary.rst index f0498c1161cae..14d616a58c7e4 100644 --- a/site/source/docs/site/glossary.rst +++ b/site/source/docs/site/glossary.rst @@ -51,7 +51,7 @@ Emscripten tools and dependencies Clang is a compiler front end for C, C++, and other programming languages that uses :term:`LLVM` as its back end. emcc - The :ref:`emccdoc`. Emscripten's drop in replacement for a compiler like *gcc*. + The :ref:`emccdoc`. Emscripten's drop-in replacement for a compiler like *gcc*. Emscripten Command Prompt The :ref:`emcmdprompt` is used to call Emscripten tools from the command line on Windows. diff --git a/src/library_openal.js b/src/library_openal.js index 463873e40d74e..8d93a1985e9b2 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -781,6 +781,14 @@ var LibraryOpenAL = { bytes = 2; channels = 2; break; + case 0x10010 /* AL_FORMAT_MONO_FLOAT32 */: + bytes = 4; + channels = 1; + break; + case 0x10011 /* AL_FORMAT_STEREO_FLOAT32 */: + bytes = 4; + channels = 2; + break; default: #if OPENAL_DEBUG console.error("alBufferData called with invalid format " + format); @@ -809,6 +817,9 @@ var LibraryOpenAL = { var val = {{{ makeGetValue('data', '2*(i*channels+j)', 'i16') }}}; buf[j][i] = val/32768; break; + case 4: + buf[j][i] = {{{ makeGetValue('data', '4*(i*channels+j)', 'float') }}}; + break; } } } @@ -1300,6 +1311,10 @@ var LibraryOpenAL = { }, alIsExtensionPresent: function(extName) { + extName = Pointer_stringify(extName); + + if (extName == "AL_EXT_float32") return 1; + return 0; }, @@ -1339,7 +1354,7 @@ var LibraryOpenAL = { ret = 'WebAudio'; break; case 0xB004 /* AL_EXTENSIONS */: - ret = ''; + ret = 'AL_EXT_float32'; break; default: AL.currentContext.err = 0xA002 /* AL_INVALID_ENUM */; @@ -1425,6 +1440,11 @@ var LibraryOpenAL = { }, alGetEnumValue: function(name) { + name = Pointer_stringify(name); + + if (name == "AL_FORMAT_MONO_FLOAT32") return 0x10010; + if (name == "AL_FORMAT_STEREO_FLOAT32") return 0x10011; + AL.currentContext.err = 0xA003 /* AL_INVALID_VALUE */; return 0; }, diff --git a/src/library_pthread.js b/src/library_pthread.js index c19464692fadd..3a080442ed99d 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -121,7 +121,7 @@ var LibraryPThread = { if (pthread.worker) pthread.worker.pthread = null; }, - // Allocates a the given amount of new web workers and stores them in the pool of unused workers. + // Allocates the given amount of new web workers and stores them in the pool of unused workers. // onFinishedLoading: A callback function that will be called once all of the workers have been initialized and are // ready to host pthreads. Optional. This is used to mitigate bug https://bugzilla.mozilla.org/show_bug.cgi?id=1049079 allocateUnusedWorkers: function(numWorkers, onFinishedLoading) { diff --git a/src/preamble.js b/src/preamble.js index 5128409c413a4..3c348a4ef2d7a 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -497,7 +497,7 @@ function stringToAscii(str, outPtr) { } Module['stringToAscii'] = stringToAscii; -// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the a given array that contains uint8 values, returns +// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns // a copy of that string as a Javascript String object. function UTF8ArrayToString(u8Array, idx) { diff --git a/tests/optimizer/null_if-output.js b/tests/optimizer/null_if-output.js new file mode 100644 index 0000000000000..23cb67dd01908 --- /dev/null +++ b/tests/optimizer/null_if-output.js @@ -0,0 +1 @@ +function _main(){} diff --git a/tests/optimizer/null_if-output2.js b/tests/optimizer/null_if-output2.js new file mode 100644 index 0000000000000..b34d3d3b8ae96 --- /dev/null +++ b/tests/optimizer/null_if-output2.js @@ -0,0 +1,2 @@ +function _main(){if(a);} + diff --git a/tests/optimizer/null_if.js b/tests/optimizer/null_if.js new file mode 100644 index 0000000000000..003277d26fe00 --- /dev/null +++ b/tests/optimizer/null_if.js @@ -0,0 +1,8 @@ +function _main() { + if (a) { + if (b) { + } + } +} +// EMSCRIPTEN_GENERATED_FUNCTIONS + diff --git a/tests/test_other.py b/tests/test_other.py index 28f949eeb7fc9..7fcf26ecabb51 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1753,6 +1753,8 @@ def test_js_optimizer(self): ['asm', 'eliminate']), # eliminate, just enough to trigger asm normalization/denormalization (path_from_root('tests', 'optimizer', 'safeLabelSetting.js'), open(path_from_root('tests', 'optimizer', 'safeLabelSetting-output.js')).read(), ['asm', 'safeLabelSetting']), # eliminate, just enough to trigger asm normalization/denormalization + (path_from_root('tests', 'optimizer', 'null_if.js'), [open(path_from_root('tests', 'optimizer', 'null_if-output.js')).read(), open(path_from_root('tests', 'optimizer', 'null_if-output2.js')).read()], + ['asm', 'registerizeHarder', 'asmLastOpts', 'minifyWhitespace']), # issue 3520 ]: print input, passes @@ -1817,7 +1819,9 @@ def check_json(): json += '\n' + original[original.find('// EXTRA_INFO:'):] open(input_temp + '.js', 'w').write(json) - if 'last' not in passes: # last is only relevant when we emit JS + # last is only relevant when we emit JS + if 'last' not in passes and \ + 'null_if' not in input: # null-if test is js optimizer or native, not a mixture (they mix badly) print ' native (receiveJSON)' output = Popen([js_optimizer.get_native_optimizer(), input_temp + '.js'] + passes + ['receiveJSON', 'emitJSON'], stdin=PIPE, stdout=open(output_temp, 'w')).communicate()[0] check_json() @@ -3323,6 +3327,28 @@ def test_dashE_respect_dashO(self): # issue #3365 assert len(with_dash_o) == 0 assert len(without_dash_o) != 0 + def test_dashM(self): + out = Popen([PYTHON, EMXX, path_from_root('tests', 'hello_world.cpp'), '-M'], stdout=PIPE).communicate()[0] + self.assertContained('hello_world.o:', out) # Verify output is just a dependency rule instead of bitcode or js + + def test_dashM_consistent(self): + normal = Popen([PYTHON, EMXX, '-v', '-Wno-warn-absolute-paths', path_from_root('tests', 'hello_world.cpp'), '-c'], stdout=PIPE, stderr=PIPE).communicate()[1] + dash_m = Popen([PYTHON, EMXX, '-v', '-Wno-warn-absolute-paths', path_from_root('tests', 'hello_world.cpp'), '-M'], stdout=PIPE, stderr=PIPE).communicate()[1] + + import difflib + diff = [a.rstrip()+'\n' for a in difflib.unified_diff(normal.split('\n'), dash_m.split('\n'), fromfile='normal', tofile='dash_m')] + left_std = filter(lambda x: x.startswith('-') and '-std=' in x, diff) + right_std = filter(lambda x: x.startswith('+') and '-std=' in x, diff) + assert len(left_std) == len(right_std) == 1, '\n\n'.join(diff) + bad = filter(lambda x: '-Wno-warn-absolute-paths' in x, diff) + assert len(bad) == 0, '\n\n'.join(diff) + + def test_dashM_respect_dashO(self): + with_dash_o = Popen([PYTHON, EMXX, path_from_root('tests', 'hello_world.cpp'), '-M', '-o', '/dev/null'], stdout=PIPE, stderr=PIPE).communicate()[0] + without_dash_o = Popen([PYTHON, EMXX, path_from_root('tests', 'hello_world.cpp'), '-M'], stdout=PIPE, stderr=PIPE).communicate()[0] + assert len(with_dash_o) == 0 + assert len(without_dash_o) != 0 + def test_malloc_implicit(self): open('src.cpp', 'w').write(r''' #include @@ -4214,7 +4240,7 @@ def do_js_test(name, source, args, output): shutil.copyfile('a.out.js', 'last.js') do_emcc_test('fannkuch.cpp', ['5'], 'Pfannkuchen(5) = 7.', ['-g2', '--profiling']) profiling = open('a.out.js').read() - assert len(profiling) > len(normal) + 300, [len(profiling), len(normal)] # should be much larger + assert len(profiling) > len(normal) + 250, [len(profiling), len(normal)] # should be much larger print 'blacklisting' diff --git a/tools/optimizer/optimizer.cpp b/tools/optimizer/optimizer.cpp index 98316bf0f7d79..513d3eef6342f 100644 --- a/tools/optimizer/optimizer.cpp +++ b/tools/optimizer/optimizer.cpp @@ -4055,9 +4055,10 @@ int main(int argc, char **argv) { clock_t start = clock(); errv("starting %s", str.c_str()); #endif - if (str == "asm") {} // the default for us - else if (str == "asmPreciseF32") {} - else if (str == "receiveJSON" || str == "emitJSON") {} + bool worked = true; + if (str == "asm") { worked = false; } // the default for us + else if (str == "asmPreciseF32") { worked = false; } + else if (str == "receiveJSON" || str == "emitJSON") { worked = false; } else if (str == "eliminateDeadFuncs") eliminateDeadFuncs(doc); else if (str == "eliminate") eliminate(doc); else if (str == "eliminateMemSafe") eliminateMemSafe(doc); @@ -4067,16 +4068,23 @@ int main(int argc, char **argv) { else if (str == "registerize") registerize(doc); else if (str == "registerizeHarder") registerizeHarder(doc); else if (str == "minifyLocals") minifyLocals(doc); - else if (str == "minifyWhitespace") {} + else if (str == "minifyWhitespace") { worked = false; } else if (str == "asmLastOpts") asmLastOpts(doc); - else if (str == "last") {} - else if (str == "noop") {} + else if (str == "last") { worked = false; } + else if (str == "noop") { worked = false; } else { fprintf(stderr, "unrecognized argument: %s\n", str.c_str()); assert(0); } #ifdef PROFILING errv(" %s took %lu microseconds", str.c_str(), clock() - start); +#endif +#ifdef DEBUGGING + if (worked) { + std::cerr << "ast after " << str << ":\n"; + doc->stringify(std::cerr); + std::cerr << "\n"; + } #endif } diff --git a/tools/optimizer/simple_ast.h b/tools/optimizer/simple_ast.h index 6e8e490eb5b49..c92c889ea84ef 100644 --- a/tools/optimizer/simple_ast.h +++ b/tools/optimizer/simple_ast.h @@ -590,7 +590,9 @@ struct JSPrinter { void emit(char c) { maybeSpace(c); - if (!pretty && c == '}' && buffer[used-1] == ';') used--; // optimize ;} into }, the ; is not separating anything + if (!pretty && c == '}' && buffer[used-1] == ';' && buffer[used-2] != ')') { + used--; // optimize ;} into }, the ; is not separating anything (note we must be careful of {if(a);} !) + } ensure(1); buffer[used++] = c; }