Use `emcc` rather than `./emcc` in most documentation (#14073)

Suggesting that users should be in the emscripten directory
when they run `emcc` is a little misleading.

I think we can instead assume that most users will be either using
`emsdk` or manually add `emcc` to their path, or generally understand
how to run commands on the command line.
This commit is contained in:
Sam Clegg 2021-05-10 12:14:58 -07:00 коммит произвёл GitHub
Родитель ff773e0bd5
Коммит 05e2403aa2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 36 добавлений и 36 удалений

Просмотреть файл

@ -126,7 +126,7 @@ Prebuilt libraries
Ideally a packaged installation can include a fully populated cache directory
containing pre-built libraries. If you want to do this you can use
`./embuilder build ALL` to populate the cache directory. You can them ship the
`embuilder build ALL` to populate the cache directory. You can them ship the
`cache` directory inside the emscripten directory. When shipping the cache
directory on a multi-user system where users cannot modify the `cache` you need
to be sure that all possible configurations of the libraries are built.

Просмотреть файл

@ -26,10 +26,10 @@ To build with Emscripten, you would instead use the following commands:
.. code-block:: bash
# Run emconfigure with the normal configure command as an argument.
./emconfigure ./configure
emconfigure ./configure
# Run emmake with the normal make to generate wasm object files.
./emmake make
emmake make
# Compile the linked code generated by make to JavaScript + WebAssembly.
# 'project.o' should be replaced with the make output for your project, and
@ -39,7 +39,7 @@ To build with Emscripten, you would instead use the following commands:
# If the project output is a library, you may need to add your 'main.c' file
# here as well.
# [-Ox] represents build optimisations (discussed in the next section).
./emcc [-Ox] project.o -o project.js
emcc [-Ox] project.o -o project.js
*emconfigure* is called with the normal *configure* as an argument (in *configure*-based build systems), and *emmake* with *make* as an argument. If your build system uses **CMake**, replace ``./configure`` with ``cmake .`` etc. in the above example. If your build system doesn't use configure or CMake, then you can omit the first step and just run ``make`` (although then you may need to edit the ``Makefile`` manually).
@ -119,28 +119,28 @@ Consider the examples below:
.. code-block:: bash
# Sub-optimal - JavaScript/WebAssembly optimizations are omitted
./emcc -O2 a.cpp -c -o a.o
./emcc -O2 b.cpp -c -o b.o
./emcc a.o b.o -o project.js
emcc -O2 a.cpp -c -o a.o
emcc -O2 b.cpp -c -o b.o
emcc a.o b.o -o project.js
# Sub-optimal - LLVM optimizations omitted
./emcc a.cpp -c -o a.o
./emcc b.cpp -c -o b.o
./emcc -O2 a.o b.o -o project.js
emcc a.cpp -c -o a.o
emcc b.cpp -c -o b.o
emcc -O2 a.o b.o -o project.js
# Usually the right thing: The same options are provided at compile and link.
./emcc -O2 a.cpp -c -o a.o
./emcc -O2 b.cpp -c -o b.o
./emcc -O2 a.o b.o -o project.js
emcc -O2 a.cpp -c -o a.o
emcc -O2 b.cpp -c -o b.o
emcc -O2 a.o b.o -o project.js
However, sometimes you may want slightly different optimizations on certain files:
.. code-block:: bash
# Optimize the first file for size, and the rest using `-O2`.
./emcc -Oz a.cpp -c -o a.o
./emcc -O2 b.cpp -c -o b.o
./emcc -O2 a.o b.o -o project.js
emcc -Oz a.cpp -c -o a.o
emcc -O2 b.cpp -c -o b.o
emcc -O2 a.o b.o -o project.js
.. note:: Unfortunately each build-system defines its own mechanisms for setting compiler and optimization methods. **You will need to work out the correct approach to set the LLVM optimization flags for your system**.
@ -151,7 +151,7 @@ JavaScript/WebAssembly optimizations are specified in the final step (sometimes
.. code-block:: bash
# Compile the object file to JavaScript with -O1 optimizations.
./emcc -O1 project.o -o project.js
emcc -O1 project.o -o project.js
.. _building-projects-debug:
@ -178,7 +178,7 @@ must specify :ref:`-g <emcc-g>` or one of the
# Compile the wasm object file to JavaScript+WebAssembly, with debug info
# -g or -gN can be used to set the debug level (N)
./emcc -g project.o -o project.js
emcc -g project.o -o project.js
For more general information, see the topic :ref:`Debugging`.
@ -199,12 +199,12 @@ For example, consider the case where a project "project" uses a library "libstuf
.. code-block:: bash
# Compile libstuff to libstuff.a
./emconfigure ./configure
./emmake make
emconfigure ./configure
emmake make
# Compile project to project.o
./emconfigure ./configure
./emmake make
emconfigure ./configure
emmake make
# Link the library and code together.
emcc project.o libstuff.a -o final.html
@ -217,7 +217,7 @@ Emscripten Ports is a collection of useful libraries, ported to Emscripten. They
.. code-block:: bash
./emcc tests/sdl2glshader.c -s USE_SDL=2 -s LEGACY_GL_EMULATION=1 -o sdl2.html
emcc tests/sdl2glshader.c -s USE_SDL=2 -s LEGACY_GL_EMULATION=1 -o sdl2.html
You should see some notifications about SDL2 being used, and built if it wasn't previously. You can then view ``sdl2.html`` in your browser.
@ -297,34 +297,34 @@ The :ref:`Tutorial` showed how :ref:`emcc <emccdoc>` can be used to compile sing
::
# Generate a.out.js from C++. Can also take .ll (LLVM assembly) or .bc (LLVM bitcode) as input
./emcc src.cpp
emcc src.cpp
# Generate an object file called src.o.
./emcc src.cpp -c
emcc src.cpp -c
# Generate result.js containing JavaScript.
./emcc src.cpp -o result.js
emcc src.cpp -o result.js
# Generate an object file called result.o
./emcc src.cpp -c -o result.o
emcc src.cpp -c -o result.o
# Generate a.out.js from two C++ sources.
./emcc src1.cpp src2.cpp
emcc src1.cpp src2.cpp
# Generate object files src1.o and src2.o
./emcc src1.cpp src2.cpp -c
emcc src1.cpp src2.cpp -c
# Combine two object files into a.out.js
./emcc src1.o src2.o
emcc src1.o src2.o
# Combine two object files into another object file (not normally needed)
./emcc src1.o src2.o -r -o combined.o
emcc src1.o src2.o -r -o combined.o
# Combine two object files into library file
./emar rcs libfoo.a src1.o src2.o
emar rcs libfoo.a src1.o src2.o
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).
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).
Detecting Emscripten in Preprocessor

Просмотреть файл

@ -162,7 +162,7 @@ To run this example, first compile it with
::
./emcc example.c -O3 -o a.html -s ASYNCIFY -s 'ASYNCIFY_IMPORTS=["do_fetch"]'
emcc example.c -O3 -o a.html -s ASYNCIFY -s 'ASYNCIFY_IMPORTS=["do_fetch"]'
Note that you must tell the compiler that ``do_fetch()`` can do an
asynchronous operation, using ``ASYNCIFY_IMPORTS``, otherwise it won't
@ -228,7 +228,7 @@ You can build this with
::
../emcc example.c -s ASYNCIFY=1 -s 'ASYNCIFY_IMPORTS=["get_digest_size"]' -o a.html -O2
emcc example.c -s ASYNCIFY=1 -s 'ASYNCIFY_IMPORTS=["get_digest_size"]' -o a.html -O2
This example calls the Promise-returning ``window.crypto.subtle()`` API (the
example is based off of

Просмотреть файл

@ -70,7 +70,7 @@ to prevent C++ name mangling.
To compile this code run the following command in the Emscripten
home directory::
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]'
emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]'
``EXPORTED_FUNCTIONS`` tells the compiler what we want to be accessible from the
compiled code (everything else might be removed if it is not used), and