More information can be found in the Contribution section of the webside.
- Even after the code of a PR is approved, it should only be landed if the CI on github is green, or the failures are known intermittent things (with very strong reason to think they unrelated to the current PR).
- If you see an approved PR of someone without commit access (that either you or someone else approved), land it for them (after checking CI as mentioned earlier).
- If you approve a PR by someone with commit access, if there is no urgency then leave it for them to land. (They may have other PRs to land alongside it, etc.)
- It is strongly recommended to land PRs with github's "squash" option, which
turns the PR into a single commit. This makes sense if the PR is small,
which is also strongly recommended. However, sometimes separate commits may
make more sense, if and only if:
- The PR is not easily separable into a series of small PRs (e.g., review must consider all the commits, either because the commits are hard to understand by themselves, or because review of a later PR may influence an earlier PR's discussion).
- The individual commits have value (e.g., they are easier to understand one by one).
- The individual commits are compatible with bisection (i.e., all tests should pass after each commit). When landing multiple commits in such a scenario, use the "rebase" option, to avoid a merge commit.
- Add
NFC
to the end of the PR title for Non-Functional Changes (i.e., changes that do not add/modify functionality, such as internal refactoring). - Add a
[prefix]
to start of the PR title to signify the subsystem or area that the PR targets. e.g.[test] Update foo test
or[ports] Fix zlib port
When writing new C/C++ in emscripten follow the LLVM style (as does binaryen).
You can use clang-format
to automatically format new code (and git clang-format origin/main
to format just the lines you are changing).
See .clang-format
for more details.
When editing third party code such (e.g. musl, libc++) follow the upstream conventions.
We use the same LLVM-based style as for C/C++. Sadly, clang-format
doesn't
always work well with our library code since it can use custom macros and
pre-processor. See .clang-format
for more details.
We generally follow the pep8 standard with the major exception that we use 2
spaces for indentation. ruff
is run on all PRs to ensure that Python code
conforms to this style. See pyproject.toml
for more details.
We are beginning to use python3's type annotation syntax, along with the mypy
tool to check python types statically. See .mypy
for more details.
The goal is to one day check all type by running mypy
with
--disallow-untyped-defs
, but this is happening incrementally over time.
When:
- Such an update ensures we clear the cache, so it should be done when required (for example, a change to libc or libc++).
- The emsdk compiled versions are based on the version number, so periodically we can do this when we want a new precompiled emsdk version to be available.
Requirements:
- emscripten-releases build CI is green on all OSes for the desired hash (where the hash is the git hash in the emscripten-releases repo, which then specifies through DEPS exactly which revisions to use in all other repos).
- GitHub CI is green
on the
main
branch for the emscripten commit referred to in DEPS.
How:
- Pick a version for a release and make sure it meets the requirements above.
Let this version SHA be
<non-LTO-sha>
. - If we want to do an LTO release as well, create a CL that copies DEPS
from to DEPS.tagged-release in
emscripten-releases repo. When this CL is committed, let the
resulting SHA be
<LTO-sha>
. An example of this CL is https://chromium-review.googlesource.com/c/emscripten-releases/+/3781978. After landing the CL, wait for a couple hours before proceeding because building and archiving for the new commit will take some time. Check https://ci.chromium.org/p/emscripten-releases/g/main/console to see if the commit has passed "Archive Binaries" phase for all three platforms and additionally "Archive Binaries (arm64)" for Mac. - Run
scripts/create_release.py
in the emsdk repository. When we do both an LTO and a non-LTO release, run:This will make the./scripts/create_release.py <LTO-sha> <non-LTO-sha>
<LTO-sha>
point to the versioned name release (e.g.3.1.7
) and the<non-LTO-sha>
point to the assert build release (e.g.3.1.7-asserts
). When we do only a non-LTO release, run:This will make the./scripts/create_release.py <non-LTO-sha>
<non-LTO-sha>
point directly to the versioned name release (e.g.3.1.7
) and there will be no assert build release. If we runscripts/create_release.py
without any arguments, it will automatically pick a tot version from emscripten-releases repo and make it point to the versioned name release. Running thisscripts/create_release.py
script will update emscripten-releases-tags.json, adding a new version. The script will create a new local git branch and push it up toorigin
. An example of this PR is emscripten-core/emsdk#1071. - Tag the
emsdk
repo with the new version number, on the commit that does the update, after it lands on main. - Tag the
emscripten
repo with the new version number, on the commit referred to in the DEPS (or DEPS.tagged-release) file above. - Run the
tools/maint/create_release.py
tool in the emscripten repo to updateemscripten-version.txt
andChangeLog.md
. An example of such PR is #17439.
When:
- We should do such an update when we have a reasonable assurance of stability.
Requirements:
- All the requirements for a minor update.
- No major change recently landed.
- No major recent regressions have been filed.
- All tests pass locally for the person doing the update, including the main
test suite (no params passed to
runner.py
),other
,browser
,sockets
,sanity
,binaryen*
. (Not all of those are run on all the bots.) - A minor version was recently tagged, no major bugs have been reported on it, and nothing major landed since it did. (Bugs are often only found on tagged versions, so a big feature should first be in a minor version update before it is in a major one.)
How:
- Follow the same steps for a minor version update.
The site is currently hosted in gh-pages
branch of the separate site
repository. To update the docs, rebuild them and copy them into
this repository. There is a script that will perform these steps automatically:
tools/maint/update_docs.py
. Just run this script with no
arguments if the emscripten-site repository is checked out alongside emscripten
itself, or pass the location of the checkout if not.
You will need the specific sphinx version installed, which you can do using
pip3 install -r requirements-dev.txt
(depending on your system, you may then
need to add ~/.local/bin
to your path, if pip installs to there).
To build the site locally for testing purposes you only need a subset of the
update_docs.py
command just mentioned above. Specifically:
- Run
pip3
to install python dependencies, as described above. - Run
make -C site html
. - Run a local webserver on the outout of that command, e.g.,
python3 -m http.server 8000 -d site/build/html
. - Browse to
http://localhost:8000/
(assuming you use port 8000 as above).
emcc --help
output is generated from the main documentation under site/
,
so it is the same as shown on the website, but it is rendered to text. After
updating emcc.rst
in a PR, the following should be done:
- In your emscripten repo checkout, enter
site
. - Run
make clean
(without this, it may not emit the right output). - Run
make text
. - Copy the output
build/text/docs/tools_reference/emcc.txt
to../docs/emcc.txt
(both paths relative to thesite/
directory in emscripten that you entered in step 1), and add that change to your PR.
See notes above on installing sphinx.
We maintain our ports of compiler-rt, libcxx, libcxxabi, and libunwind under https://github.com/emscripten-core/emscripten/tree/main/system/lib from the upstream LLVM repository and periodically update them to a newer version when a new LLVM release comes out.
We maintain a fork of LLVM for library updates, where we create a branch for each new LLVM major release. For example, the branch for LLVM 16 is https://github.com/emscripten-core/llvm-project/tree/emscripten-libs-16. We create a new branch for a major version update and reuse the existing branch for a minor version update. We mostly do updates per LLVM major release.
To update our libraries to a newer LLVM release:
-
If you are updating an existing branch the first step is to run
push_llvm_changes.py
to make sure the current branch is up-to-date with the current emscripten codebase../system/lib/push_llvm_changes.py <Emscripten's LLVM fork directory>
(The existing library branch should be checked out in your Emscripten's LLVM fork directory.) An example of such PR is emscripten-core/llvm-project#5.
If you are creating a new branch, first make sure the previous/existing branch is up-to-date using
push_llvm_changes.py
. Then create the new branch and cherry-pick all the emscripten-specific changes from the old branch, resolving any conflicts that might arise.In either case, once that branch is up-to-date use the update scripts to copy the llvm branch contents into the emscripten tree. Its important in both cases to run
push_llvm_changes.py
first to ensure that no emscripten changes are lost in the process. -
Create a PR to merge new LLVM release tag in the upstream repo into our new library branch. For example, if we want to merge
llvmorg-16.0.6
tag into ouremscripten-libs-16
branch, you can dogit co emscripten-libs-16 git remote add upstream [email protected]:llvm/llvm-project.git git fetch --tags upstream git merge llvmorg-16.0.6
An example of such PR is emscripten-core/llvm-project#3.
-
Now we have merged all the changes to our LLVM fork branch, pull those changes with the new version back into the Emscripten repo. You can use
update_compiler_rt.py
,update_libcxx.py
,update_libcxxabi.py
,update_libunwind.py
for that. For example,./system/lib/update_comiler_rt.py <Emscripten's LLVM fork directory>
(The library branch should be checked out in your Emscripten's LLVM fork directory.) An example of such PR is #19515.
We maintain our musl in https://github.com/emscripten-core/emscripten/tree/main/system/lib/libc/musl. We maintain a fork of musl in https://github.com/emscripten-core/musl for updates and periodically update it to a newer version.
The process for updating musl is similar to that of updating the LLVM libraries. To update our libraries to a newer musl release:
-
If you are updating an existing branch the first step is to run
push_musl_changes.py
to make sure the current branch is up-to-date with the current emscripten codebase.If you are creating a new branch, first make sure the previous/existing branch is up-to-date using
push_musl_changes.py
. Then create the new branch and cherry-pick all the emscripten-specific changes from the old branch, resolving any conflicts that might arise. -
Create a PR to merge new mrelease tag in the upstream repo into our new library branch. For example, if we want to merge musl's
v1.2.4
tag into ourmerge-v1.2.4
branch, you can dogit co merge-v1.2.4 git remote add upstream git://git.musl-libc.org/musl git fetch --tags upstream git merge v1.2.4
-
Now we have merged all the changes to our musl fork branch, pull those changes with the new version back into the Emscripten repo. You can use
update_musl.py
for that.