diff --git a/.circleci/config.yml b/.circleci/config.yml index c4d2734a2b..91074c9361 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,21 +1,12 @@ version: 2.1 orbs: - win: circleci/windows@1.0.0 + win: circleci/windows@5.0 executors: - bionic: + ubuntu: docker: - - image: buildpack-deps:bionic - mac: - environment: - EMSDK_NOTTY: "1" - # Without this, any `brew install` command will result in self-update of - # brew itself which takes more than 4 minutes. - HOMEBREW_NO_AUTO_UPDATE: "1" - macos: - xcode: "12.5.1" - resource_class: macos.x86.medium.gen2 + - image: buildpack-deps:focal mac_arm64: environment: EMSDK_NOTTY: "1" @@ -27,7 +18,7 @@ executors: resource_class: macos.m1.medium.gen1 linux_arm64: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2004:2023.07.1 resource_class: arm.medium commands: @@ -50,22 +41,20 @@ commands: jobs: flake8: - executor: bionic + executor: ubuntu steps: - checkout - run: name: install pip command: | apt-get update -q - apt-get install -q -y python-pip python3-pip - - run: python2 -m pip install --upgrade pip + apt-get install -q -y python3-pip - run: python3 -m pip install --upgrade pip - - run: python2 -m pip install flake8==3.7.8 - - run: python3 -m pip install flake8==3.7.8 - - run: python2 -m flake8 --show-source --statistics - - run: python3 -m flake8 --show-source --statistics + - run: python3 -m pip install flake8==3.9.2 + - run: python3 -m flake8 --show-source --statistics --extend-exclude=./scripts + test-linux: - executor: bionic + executor: ubuntu environment: EMSDK_NOTTY: "1" # This is needed because the old gcc-7 that is installed on debian/bionic @@ -96,11 +85,6 @@ jobs: name: Install debian packages command: sudo apt-get update -q && sudo apt-get install -q cmake build-essential openjdk-8-jre-headless - run: test/test.sh - test-mac: - executor: mac - steps: - - setup-macos - - test-macos test-mac-arm64: executor: mac_arm64 steps: @@ -108,7 +92,7 @@ jobs: - test-macos test-windows: executor: - name: win/vs2019 + name: win/server-2019 shell: bash.exe environment: # We need python installed before we can test anytyhing. @@ -173,29 +157,43 @@ jobs: $env:SYSTEM_FLAG="--system" test/test_path_preservation.ps1 - build-docker-image: - executor: bionic + build-docker-image-x64: + executor: ubuntu steps: - checkout - run: name: install docker - command: apt-get update -q && apt-get install -q -y docker.io + command: | + apt-get update -q + apt-get install -q -y ca-certificates curl gnupg lsb-release + mkdir -p /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update -q + apt-get install -q -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - setup_remote_docker - # Build and test the tip-of-tree build of EMSDK + # Build the `latest` version of EMSDK as docker image - run: name: build - command: make -C ./docker version=tot build + command: make -C ./docker version=latest build - run: name: test - command: make -C ./docker version=tot test + command: make -C ./docker version=latest test - publish-docker-image: - executor: bionic + publish-docker-image-x64: + executor: ubuntu steps: - checkout - run: name: install docker - command: apt-get update -q && apt-get install -q -y docker.io + command: | + apt-get update -q + apt-get install -q -y ca-certificates curl gnupg lsb-release + mkdir -p /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update -q + apt-get install -q -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - setup_remote_docker - run: name: build @@ -209,8 +207,24 @@ jobs: docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" make -C ./docker version=${CIRCLE_TAG} alias=latest push + publish-docker-image-arm64: + executor: linux_arm64 + steps: + - checkout + - run: + name: build + command: make -C ./docker version=${CIRCLE_TAG} build + - run: + name: test + command: make -C ./docker version=${CIRCLE_TAG} test + - run: + name: push image + command: | + docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" + make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-arm64 only_alias=true push + test-bazel-linux: - executor: bionic + executor: ubuntu steps: - checkout - run: apt-get install -q -y curl gnupg @@ -229,11 +243,10 @@ jobs: apt-get install -q -y bazel - run: test/test_bazel.sh - test-bazel-mac: - executor: mac + test-bazel-mac-arm64: + executor: mac_arm64 steps: - checkout - - run: brew install grep - run: name: install bazelisk command: | @@ -242,7 +255,7 @@ jobs: test-bazel-windows: executor: - name: win/vs2019 + name: win/server-2019 shell: powershell.exe -ExecutionPolicy Bypass environment: PYTHONUNBUFFERED: "1" @@ -273,9 +286,6 @@ workflows: test-linux-arm64: jobs: - test-linux-arm64 - test-mac: - jobs: - - test-mac test-mac-arm64: jobs: - test-mac-arm64 @@ -284,8 +294,14 @@ workflows: - test-windows build-docker-image: jobs: - - build-docker-image - - publish-docker-image: + - build-docker-image-x64 + - publish-docker-image-x64: + filters: + branches: + ignore: /.*/ + tags: + only: /.*/ + - publish-docker-image-arm64: filters: branches: ignore: /.*/ @@ -294,9 +310,9 @@ workflows: test-bazel-linux: jobs: - test-bazel-linux - test-bazel-mac: + test-bazel-mac-arm64: jobs: - - test-bazel-mac + - test-bazel-mac-arm64 test-bazel-windows: jobs: - test-bazel-windows diff --git a/.flake8 b/.flake8 index 4a0ec27194..e49d748821 100644 --- a/.flake8 +++ b/.flake8 @@ -5,19 +5,20 @@ ignore = E501, # Line too long E121, # Continuation line under-indented for hanging indent E722 # bare excepts + E741, # Variable names such as 'l', 'O', or 'I' exclude = - ./llvm - ./gnu - ./upstream - ./fastcomp - ./fastcomp-clang - ./releases - ./clang - ./emscripten - ./binaryen - ./git - ./node - ./python - ./temp - ./downloads - ./crunch + ./llvm, + ./gnu, + ./upstream, + ./fastcomp, + ./fastcomp-clang, + ./releases, + ./clang, + ./emscripten, + ./binaryen, + ./git, + ./node, + ./python, + ./temp, + ./downloads, + ./crunch, diff --git a/README.md b/README.md index 3ad91f3efc..9736aea0a2 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ important concepts to help understanding the internals of the SDK: ## System Requirements Using the emsdk pre-compiled packages requires only the minimal set of -dependenencies lists below. When building from source a wider set of tools +dependencies lists below. When building from source a wider set of tools include git, cmake, and a host compiler are required. See: https://emscripten.org/docs/building_from_source/toolchain_what_is_needed.html. @@ -67,8 +67,8 @@ https://emscripten.org/docs/building_from_source/toolchain_what_is_needed.html. - `python`: Version 2.7.0 or above. - `java`: For running closure compiler (optional) -The emsdk pre-compiled binaries are built aginst Ubuntu/Xenial 16.04 LTS and -therefore depend on system libraries compatiable with versions of `glibc` and +The emsdk pre-compiled binaries are built against Ubuntu/Focal 20.04 LTS and +therefore depend on system libraries compatible with versions of `glibc` and `libstdc++` present in that release. If your linux distribution is very old you may not be able to use the pre-compiled binaries packages. diff --git a/bazel/BUILD b/bazel/BUILD index bce4adeebf..c529bdf1c0 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -66,6 +66,18 @@ alias( }), ) +alias( + name = "dwp_files", + actual = select({ + ":linux": "@emscripten_bin_linux//:dwp_files", + ":linux_arm64": "@emscripten_bin_linux_arm64//:dwp_files", + ":macos": "@emscripten_bin_mac//:dwp_files", + ":macos_arm64": "@emscripten_bin_mac_arm64//:dwp_files", + ":windows": "@emscripten_bin_win//:dwp_files", + "//conditions:default": ":empty", + }), +) + alias( name = "ar_files", actual = select({ @@ -82,5 +94,14 @@ platform( name = "platform_wasm", constraint_values = [ "@platforms//cpu:wasm32", + "@platforms//os:emscripten", + ], +) + +platform( + name = "platform_wasi", + constraint_values = [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi", ], ) diff --git a/bazel/MODULE.bazel b/bazel/MODULE.bazel new file mode 100644 index 0000000000..7f51cebf45 --- /dev/null +++ b/bazel/MODULE.bazel @@ -0,0 +1 @@ +bazel_dep(name = "platforms", version = "0.0.9") diff --git a/bazel/MODULE.bazel.lock b/bazel/MODULE.bazel.lock new file mode 100644 index 0000000000..ed98fda9d0 --- /dev/null +++ b/bazel/MODULE.bazel.lock @@ -0,0 +1,64 @@ +{ + "lockFileVersion": 11, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", + "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.1/source.json": "a96f95e02123320aa015b956f29c00cb818fa891ef823d55148e1a362caacf29", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", + "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", + "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" + }, + "selectedYankedVersions": {}, + "moduleExtensions": {} +} diff --git a/bazel/README.md b/bazel/README.md index 877f2e073d..ce8d210b78 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -3,7 +3,7 @@ ## Setup Instructions In `WORKSPACE` file, put: -``` +```starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "emsdk", @@ -26,6 +26,11 @@ The SHA1 hash in the above `strip_prefix` and `url` parameters correspond to the newer versions, you'll need to update those. To make use of older versions, change the parameter of `emsdk_emscripten_deps()`. Supported versions are listed in `revisions.bzl` +Bazel 7+ additionally requires `platforms` dependencies in the `MODULE.bazel` file. +```starlark +bazel_dep(name = "platforms", version = "0.0.9") +``` + ## Building @@ -37,7 +42,7 @@ build --incompatible_enable_cc_toolchain_resolution Then write a new rule wrapping your `cc_binary`. -``` +```starlark load("@rules_cc//cc:defs.bzl", "cc_binary") load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") @@ -61,4 +66,30 @@ rules. and all of its dependencies, and does not require amending `.bazelrc`. This is the preferred way, since it also unpacks the resulting tarball. +The Emscripten cache shipped by default does not include LTO, 64-bit or PIC +builds of the system libraries and ports. If you wish to use these features you +will need to declare the cache when you register the toolchain as follows. Note +that the configuration consists of the same flags that can be passed to +embuilder. If `targets` is not provided, all system libraries and ports will be +built, i.e., the `ALL` option to embuilder. + +```starlark +load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains") +register_emscripten_toolchains(cache = { + "configuration": ["--lto"], + "targets": [ + "crtbegin", + "libprintf_long_double-debug", + "libstubs-debug", + "libnoexit", + "libc-debug", + "libdlmalloc", + "libcompiler_rt", + "libc++-noexcept", + "libc++abi-debug-noexcept", + "libsockets" + ] +}) +``` + See `test_external/` for an example using [embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html). diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 337f0bafcd..8c6dd98261 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -4,22 +4,11 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def deps(): maybe( http_archive, - name = "bazel_skylib", - sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", + name = "platforms", urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz", ], + sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b", ) - maybe( - http_archive, - name = "rules_nodejs", - sha256 = "08337d4fffc78f7fe648a93be12ea2fc4e8eb9795a4e6aa48595b66b34555626", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-core-5.8.0.tar.gz"], - ) - maybe( - http_archive, - name = "build_bazel_rules_nodejs", - sha256 = "dcc55f810142b6cf46a44d0180a5a7fb923c04a5061e2e8d8eb05ccccc60864b", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-5.8.0.tar.gz"], - ) + pass diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 219cd93f12..73350c6142 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -1,5 +1,4 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install") load(":revisions.bzl", "EMSCRIPTEN_TAGS") def _parse_version(v): @@ -8,49 +7,42 @@ def _parse_version(v): BUILD_FILE_CONTENT_TEMPLATE = """ package(default_visibility = ['//visibility:public']) +filegroup( + name = "all", + srcs = glob(["**"]), +) + filegroup( name = "includes", srcs = glob([ "emscripten/cache/sysroot/include/c++/v1/**", "emscripten/cache/sysroot/include/compat/**", "emscripten/cache/sysroot/include/**", - "lib/clang/17/include/**", + "lib/clang/**/include/**", ]), ) filegroup( - name = "emcc_common", + name = "compiler_files", srcs = [ "emscripten/emcc.py", - "emscripten/emscripten.py", - "emscripten/emscripten-version.txt", - "emscripten/cache/sysroot_install.stamp", - "emscripten/src/settings.js", - "emscripten/src/settings_internal.js", - ] + glob( - include = [ - "emscripten/third_party/**", - "emscripten/tools/**", - ], - exclude = [ - "**/__pycache__/**", - ], - ), + "bin/clang{bin_extension}", + "bin/clang++{bin_extension}", + ":includes", + ], ) filegroup( - name = "compiler_files", + name = "dwp_files", srcs = [ - "bin/clang{bin_extension}", - "bin/clang++{bin_extension}", - ":emcc_common", - ":includes", + "bin/llvm-dwp", ], ) filegroup( name = "linker_files", srcs = [ + "emscripten/emcc.py", "bin/clang{bin_extension}", "bin/llvm-ar{bin_extension}", "bin/llvm-dwarfdump{bin_extension}", @@ -63,14 +55,7 @@ filegroup( "bin/wasm-opt{bin_extension}", "bin/wasm-split{bin_extension}", "bin/wasm2js{bin_extension}", - ":emcc_common", - ] + glob( - include = [ - "emscripten/cache/sysroot/lib/**", - "emscripten/node_modules/**", - "emscripten/src/**", - ], - ), + ] ) filegroup( @@ -78,17 +63,7 @@ filegroup( srcs = [ "bin/llvm-ar{bin_extension}", "emscripten/emar.py", - "emscripten/emscripten-version.txt", - "emscripten/src/settings.js", - "emscripten/src/settings_internal.js", - ] + glob( - include = [ - "emscripten/tools/**", - ], - exclude = [ - "**/__pycache__/**", - ], - ), + ] ) """ @@ -105,57 +80,58 @@ def emscripten_deps(emscripten_version = "latest"): fail(error_msg) revision = EMSCRIPTEN_TAGS[version] + archive_ext = "tar.xz" + archive_type = "tar.xz" + + if is_version_less_than(version, "3.1.47"): + archive_ext = "tbz2" + archive_type = "tar.bz2" emscripten_url = "https://storage.googleapis.com/webassembly/emscripten-releases-builds/{}/{}/wasm-binaries{}.{}" # This could potentially backfire for projects with multiple emscripten # dependencies that use different emscripten versions excludes = native.existing_rules().keys() - if "nodejs_toolchains" not in excludes: - # Node 16 is the first version that supports darwin_arm64 - node_repositories( - node_version = "16.6.2", - ) if "emscripten_bin_linux" not in excludes: http_archive( name = "emscripten_bin_linux", strip_prefix = "install", - url = emscripten_url.format("linux", revision.hash, "", "tbz2"), + url = emscripten_url.format("linux", revision.hash, "", archive_ext), sha256 = revision.sha_linux, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = archive_type, ) if "emscripten_bin_linux_arm64" not in excludes: http_archive( name = "emscripten_bin_linux_arm64", strip_prefix = "install", - url = emscripten_url.format("linux", revision.hash, "-arm64", "tbz2"), + url = emscripten_url.format("linux", revision.hash, "-arm64", archive_ext), # Not all versions have a linux/arm64 release: https://github.com/emscripten-core/emsdk/issues/547 sha256 = getattr(revision, "sha_linux_arm64", None), build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = archive_type, ) if "emscripten_bin_mac" not in excludes: http_archive( name = "emscripten_bin_mac", strip_prefix = "install", - url = emscripten_url.format("mac", revision.hash, "", "tbz2"), + url = emscripten_url.format("mac", revision.hash, "", archive_ext), sha256 = revision.sha_mac, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = archive_type, ) if "emscripten_bin_mac_arm64" not in excludes: http_archive( name = "emscripten_bin_mac_arm64", strip_prefix = "install", - url = emscripten_url.format("mac", revision.hash, "-arm64", "tbz2"), + url = emscripten_url.format("mac", revision.hash, "-arm64", archive_ext), sha256 = revision.sha_mac_arm64, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = archive_type, ) if "emscripten_bin_win" not in excludes: @@ -168,37 +144,14 @@ def emscripten_deps(emscripten_version = "latest"): type = "zip", ) - if "emscripten_npm_linux" not in excludes: - npm_install( - name = "emscripten_npm_linux", - package_json = "@emscripten_bin_linux//:emscripten/package.json", - package_lock_json = "@emscripten_bin_linux//:emscripten/package-lock.json", - ) - - if "emscripten_npm_linux_arm64" not in excludes: - npm_install( - name = "emscripten_npm_linux_arm64", - package_json = "@emscripten_bin_linux_arm64//:emscripten/package.json", - package_lock_json = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json", - ) +def is_version_less_than(a, b): + def map(f, list): + return [f(x) for x in list] - if "emscripten_npm_mac" not in excludes: - npm_install( - name = "emscripten_npm_mac", - package_json = "@emscripten_bin_mac//:emscripten/package.json", - package_lock_json = "@emscripten_bin_mac//:emscripten/package-lock.json", - ) + def parse_version(version): + return tuple(map(int, version.split("."))) - if "emscripten_npm_mac_arm64" not in excludes: - npm_install( - name = "emscripten_npm_mac", - package_json = "@emscripten_bin_mac_arm64//:emscripten/package.json", - package_lock_json = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json", - ) + a_tuple = parse_version(a) + b_tuple = parse_version(b) - if "emscripten_npm_win" not in excludes: - npm_install( - name = "emscripten_npm_win", - package_json = "@emscripten_bin_win//:emscripten/package.json", - package_lock_json = "@emscripten_bin_win//:emscripten/package-lock.json", - ) + return a_tuple < b_tuple diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index 7b3f16237f..2061cfe1b6 100644 --- a/bazel/emscripten_toolchain/BUILD.bazel +++ b/bazel/emscripten_toolchain/BUILD.bazel @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) filegroup( name = "common_files", srcs = [ - "emscripten_config", + "@emscripten_cache//:emscripten_config", "env.sh", "env.bat", "@nodejs//:node_files", @@ -43,6 +43,24 @@ filegroup( ], ) +filegroup( + name = "dwp_files", + srcs = [ + "dwp.sh", + "@emsdk//:dwp_files", + ], +) + +filegroup( + name = "all_files", + srcs = [ + ":ar_files", + ":compiler_files", + ":dwp_files", + ":linker_files", + ], +) + filegroup(name = "empty") # dlmalloc.bc is implictly added by the emscripten toolchain @@ -51,21 +69,22 @@ cc_library(name = "malloc") emscripten_cc_toolchain_config_rule( name = "wasm", cpu = "wasm", - em_config = "emscripten_config", + em_config = "@emscripten_cache//:emscripten_config", emscripten_binaries = "@emsdk//:compiler_files", script_extension = select({ "@bazel_tools//src/conditions:host_windows": "bat", "//conditions:default": "sh", }), + node_binary = "@nodejs//:node", ) cc_toolchain( name = "cc-compiler-wasm", - all_files = ":empty", + all_files = ":all_files", ar_files = ":ar_files", as_files = ":empty", compiler_files = ":compiler_files", - dwp_files = ":empty", + dwp_files = ":dwp_files", linker_files = ":linker_files", objcopy_files = ":empty", strip_files = ":empty", diff --git a/bazel/emscripten_toolchain/emscripten_config b/bazel/emscripten_toolchain/default_config similarity index 69% rename from bazel/emscripten_toolchain/emscripten_config rename to bazel/emscripten_toolchain/default_config index 648a8fef20..d42977b019 100644 --- a/bazel/emscripten_toolchain/emscripten_config +++ b/bazel/emscripten_toolchain/default_config @@ -7,17 +7,12 @@ BINARYEN_ROOT = os.path.join(ROOT_DIR, os.environ["EM_BIN_PATH"]) LLVM_ROOT = os.path.join(BINARYEN_ROOT, "bin") FROZEN_CACHE = True -system = platform.system() - -machine = "arm64" if platform.machine() in ('arm64', 'aarch64') else "amd64" -nodejs_binary = "bin/nodejs/node.exe" if(system =="Windows") else "bin/node" -NODE_JS = ROOT_DIR + "/external/nodejs_{}_{}/{}".format(system.lower(), machine, nodejs_binary) - +NODE_JS = os.path.join(ROOT_DIR, os.environ["NODE_JS"]) # This works around an issue with Bazel RBE where the symlinks in node_modules/.bin # are uploaded as the linked files, which means the cli.js cannot load its # dependencies from the expected locations. # See https://github.com/emscripten-core/emscripten/pull/16640 for more -if system != "Windows": +if platform.system() != "Windows": CLOSURE_COMPILER = [NODE_JS, os.path.join(EMSCRIPTEN_ROOT, "node_modules", "google-closure-compiler", "cli.js")] diff --git a/bazel/emscripten_toolchain/dwp.sh b/bazel/emscripten_toolchain/dwp.sh new file mode 100644 index 0000000000..7de2016d30 --- /dev/null +++ b/bazel/emscripten_toolchain/dwp.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# We find llvm-dwp through a relative path, which depends on platform + +# First, check if we're on a mac +if [[ "$OSTYPE" == "darwin"* ]]; then + # Now, check if this is an intel mac + if [[ $(uname -m) == "x86_64" ]]; then + emscripten_bin="emscripten_bin_mac" + elif [[ $(uname -m) == "arm64" ]]; then + emscripten_bin="emscripten_bin_mac_arm64" + else + echo "Unknown architecture: $(uname -m)" + exit 1 + fi +elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Now, check if this is intel + if [[ $(uname -m) == "x86_64" ]]; then + emscripten_bin="emscripten_bin_linux" + elif [[ $(uname -m) == "aarch64" ]]; then + emscripten_bin="emscripten_bin_linux_arm64" + else + echo "Unknown architecture: $(uname -m)" + exit 1 + fi +else + echo "Unknown OS: $OSTYPE" + exit 1 +fi + +exec "$(dirname $0)"/../../"$emscripten_bin"/bin/llvm-dwp "$@" diff --git a/bazel/emscripten_toolchain/emcc.sh b/bazel/emscripten_toolchain/emcc.sh index 5fdaf9c295..cd77dd5ef6 100755 --- a/bazel/emscripten_toolchain/emcc.sh +++ b/bazel/emscripten_toolchain/emcc.sh @@ -2,4 +2,4 @@ source $(dirname $0)/env.sh -exec python3 $EMSCRIPTEN/emcc.py "$@" +exec python3 $EMSCRIPTEN/emcc.py -fdebug-prefix-map=$PWD=/figma-root "$@" diff --git a/bazel/emscripten_toolchain/link_wrapper.py b/bazel/emscripten_toolchain/link_wrapper.py index d6b715dbae..1126258988 100644 --- a/bazel/emscripten_toolchain/link_wrapper.py +++ b/bazel/emscripten_toolchain/link_wrapper.py @@ -61,7 +61,7 @@ # If the output name has no extension, give it the appropriate extension. if not base_name_split[1]: - os.rename(output_file, output_file + '.' + oformat) + os.replace(output_file, output_file + '.' + oformat) # If the output name does have an extension and it matches the output format, # change the base_name so it doesn't have an extension. @@ -77,7 +77,7 @@ # Please don't do that. else: base_name = base_name_split[0] - os.rename(output_file, os.path.join(outdir, base_name + '.' + oformat)) + os.replace(output_file, os.path.join(outdir, base_name + '.' + oformat)) files = [] extensions = [ @@ -90,7 +90,8 @@ '.data', '.js.symbols', '.wasm.debug.wasm', - '.html' + '.html', + '.aw.js' ] for ext in extensions: @@ -138,7 +139,7 @@ final_bytes.extend((base_name + '.wasm.debug.wasm').encode()) # Write our length + filename bytes to a temp file. - with open('debugsection.tmp', 'wb+') as f: + with open(base_name + '_debugsection.tmp', 'wb+') as f: f.write(final_bytes) f.close() @@ -151,7 +152,7 @@ subprocess.check_call([ llvm_objcopy, wasm_base, - '--add-section=external_debug_info=debugsection.tmp']) + '--add-section=external_debug_info=' + base_name + '_debugsection.tmp']) # Make sure we have at least one output file. if not len(files): @@ -159,8 +160,8 @@ sys.exit(1) # cc_binary must output exactly one file; put all the output files in a tarball. -cmd = ['tar', 'cf', 'tmp.tar'] + files +cmd = ['tar', 'cf', base_name + '.tar'] + files subprocess.check_call(cmd, cwd=outdir) -os.rename(os.path.join(outdir, 'tmp.tar'), output_file) +os.replace(os.path.join(outdir, base_name + '.tar'), output_file) sys.exit(0) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index f1ea1c819e..a1c516905b 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -77,6 +77,7 @@ def _impl(ctx): emcc_script = "emcc.%s" % ctx.attr.script_extension emcc_link_script = "emcc_link.%s" % ctx.attr.script_extension emar_script = "emar.%s" % ctx.attr.script_extension + dwp_path = "dwp.sh" ################################################################ # Tools @@ -98,6 +99,7 @@ def _impl(ctx): tool_path(name = "nm", path = "NOT_USED"), tool_path(name = "objdump", path = "/bin/false"), tool_path(name = "strip", path = "NOT_USED"), + tool_path(name = "dwp", path = dwp_path), ] ################################################################ @@ -277,6 +279,44 @@ def _impl(ctx): # Features ################################################################ + per_object_debug_info_feature = feature( + name = "per_object_debug_info", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ], + flag_groups = [ + flag_group( + flags = ["-gsplit-dwarf", "-g3"], + expand_if_available = "per_object_debug_info_file", + ), + ], + ), + ], + ) + + fission_support_feature = feature( + name = "fission_support", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["-Wl,--gdb-index"], + expand_if_available = "is_using_fission", + ), + ], + ), + ], + ) + + features = [ # This set of magic "feature"s are important configuration information for blaze. feature(name = "no_legacy_features", enabled = True), @@ -294,10 +334,18 @@ def _impl(ctx): # Formerly "needsPic" attribute feature(name = "supports_pic", enabled = False), + # At figma, this toolchain supports relocatable pre-compiled headers. + # This is provided through the `cc-shim` used to create `emcc.sh` + feature(name = "supports_relocatable_pch", enabled = True), + # Blaze requests this feature by default. # Blaze also tests if this feature is supported, before setting the "pic" build-variable. feature(name = "pic"), + # Support bazel debug info fission + per_object_debug_info_feature, + fission_support_feature, + # Blaze requests this feature by default. # Blaze also tests if this feature is supported before setting preprocessor_defines # (...but why?) @@ -346,6 +394,16 @@ def _impl(ctx): provides = ["variant:crosstool_build_mode"], ), + # Feature to prevent 'command line too long' issues + feature( + name = "archive_param_file", + enabled = True, + ), + feature( + name = "compiler_param_file", + enabled = True, + ), + #### User-settable features # Set if enabling exceptions. @@ -424,13 +482,18 @@ def _impl(ctx): name = "wasm_simd", requires = [feature_set(features = ["llvm_backend"])], ), + # Adds relaxed-simd support, only available with the llvm backend. + feature( + name = "wasm_relaxed_simd", + requires = [feature_set(features = ["llvm_backend"])], + ), feature( name = "precise_long_double_printf", enabled = True, ), feature( name = "wasm_warnings_as_errors", - enabled = True, + enabled = False, ), # ASan and UBSan. See also: @@ -550,6 +613,11 @@ def _impl(ctx): flags = ["-msimd128"], features = ["wasm_simd"], ), + flag_set( + actions = all_compile_actions + all_link_actions, + flags = ["-msimd128", "-mrelaxed-simd"], + features = ["wasm_relaxed_simd"], + ), flag_set( actions = all_link_actions, flags = ["-s", "PRINTF_LONG_DOUBLE=1"], @@ -910,11 +978,13 @@ def _impl(ctx): actions = preprocessor_compile_actions + [ACTION_NAMES.cc_flags_make_variable], flags = [ - "-iwithsysroot" + "/include/c++/v1", - "-iwithsysroot" + "/include/compat", - "-iwithsysroot" + "/include", + emscripten_dir + "/emscripten/cache/sysroot/include/c++/v1", + "-isystem", + emscripten_dir + "/emscripten/cache/sysroot/include/compat", "-isystem", - emscripten_dir + "/lib/clang/17/include", + emscripten_dir + "/emscripten/cache/sysroot/include", + "-isystem", + emscripten_dir + "/lib/clang/19/include", ], ), # Inputs and outputs @@ -1040,6 +1110,10 @@ def _impl(ctx): key = "EM_CONFIG_PATH", value = ctx.file.em_config.path, ), + env_entry( + key = "NODE_JS", + value = ctx.file.node_binary.path, + ) ], ), # Use llvm backend. Off by default, enabled via --features=llvm_backend @@ -1081,7 +1155,7 @@ def _impl(ctx): emscripten_dir + "/emscripten/cache/sysroot/include/c++/v1", emscripten_dir + "/emscripten/cache/sysroot/include/compat", emscripten_dir + "/emscripten/cache/sysroot/include", - emscripten_dir + "/lib/clang/17/include", + emscripten_dir + "/lib/clang/19/include", ] artifact_name_patterns = [] @@ -1115,6 +1189,7 @@ emscripten_cc_toolchain_config_rule = rule( "em_config": attr.label(mandatory = True, allow_single_file = True), "emscripten_binaries": attr.label(mandatory = True, cfg = "exec"), "script_extension": attr.string(mandatory = True, values = ["sh", "bat"]), + "node_binary": attr.label(mandatory = True, allow_single_file = True, cfg = "exec"), }, provides = [CcToolchainConfigInfo], ) diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl index 416ccae08b..aacca1ff71 100644 --- a/bazel/emscripten_toolchain/wasm_cc_binary.bzl +++ b/bazel/emscripten_toolchain/wasm_cc_binary.bzl @@ -25,7 +25,9 @@ def _wasm_transition_impl(settings, attr): if attr.simd: features.append("wasm_simd") + platform = "@emsdk//:platform_wasm" if attr.standalone: + platform = "@emsdk//:platform_wasi" features.append("wasm_standalone") return { @@ -35,7 +37,7 @@ def _wasm_transition_impl(settings, attr): "//command_line_option:features": features, "//command_line_option:dynamic_mode": "off", "//command_line_option:linkopt": linkopts, - "//command_line_option:platforms": ["@emsdk//:platform_wasm"], + "//command_line_option:platforms": [platform], "//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc", } @@ -67,7 +69,9 @@ _ALLOW_OUTPUT_EXTNAMES = [ ".fetch.js", ".js.symbols", ".wasm.debug.wasm", + ".wasm.debug.wasm.dwp", ".html", + ".aw.js", ] _WASM_BINARY_COMMON_ATTRS = { @@ -126,12 +130,15 @@ def _wasm_cc_binary_impl(ctx): executable = ctx.executable._wasm_binary_extractor, ) - return DefaultInfo( - files = depset(ctx.outputs.outputs), - # This is needed since rules like web_test usually have a data - # dependency on this target. - data_runfiles = ctx.runfiles(transitive_files = depset(ctx.outputs.outputs)), - ) + return [ + DefaultInfo( + files = depset(ctx.outputs.outputs), + # This is needed since rules like web_test usually have a data + # dependency on this target. + data_runfiles = ctx.runfiles(transitive_files = depset(ctx.outputs.outputs)), + ), + OutputGroupInfo(_wasm_tar = cc_target.files), + ] def _wasm_cc_binary_legacy_impl(ctx): cc_target = ctx.attr.cc_target[0] @@ -146,8 +153,23 @@ def _wasm_cc_binary_legacy_impl(ctx): ctx.outputs.symbols, ctx.outputs.dwarf, ctx.outputs.html, + ctx.outputs.audio_worklet, ] + if cc_target[DebugPackageInfo].dwp_file: + # We'll receive a `dwp_file` if fission was enabled. + ctx.actions.symlink( + output = ctx.outputs.dwp_file, + target_file = cc_target[DebugPackageInfo].dwp_file, + ) + else: + # Otherwise, we'll create an empty file. + ctx.actions.write( + output = ctx.outputs.dwp_file, + content = "", + ) + + args = ctx.actions.args() args.add("--allow_empty_outputs") args.add_all("--archive", ctx.files.cc_target) @@ -160,13 +182,18 @@ def _wasm_cc_binary_legacy_impl(ctx): executable = ctx.executable._wasm_binary_extractor, ) - return DefaultInfo( - executable = ctx.outputs.wasm, - files = depset(outputs), - # This is needed since rules like web_test usually have a data - # dependency on this target. - data_runfiles = ctx.runfiles(transitive_files = depset(outputs)), - ) + all_outputs = outputs + [ctx.outputs.dwp_file] + + return [ + DefaultInfo( + executable = ctx.outputs.wasm, + files = depset(all_outputs), + # This is needed since rules like web_test usually have a data + # dependency on this target. + data_runfiles = ctx.runfiles(transitive_files = depset(all_outputs)), + ), + OutputGroupInfo(_wasm_tar = cc_target.files), + ] _wasm_cc_binary = rule( implementation = _wasm_cc_binary_impl, @@ -192,7 +219,9 @@ def _wasm_binary_legacy_outputs(name, cc_target): "data": "{}/{}.data".format(name, basename), "symbols": "{}/{}.js.symbols".format(name, basename), "dwarf": "{}/{}.wasm.debug.wasm".format(name, basename), + "dwp_file": "{}/{}.wasm.debug.wasm.dwp".format(name, basename), "html": "{}/{}.html".format(name, basename), + "audio_worklet": "{}/{}.aw.js".format(name, basename) } return outputs diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 571656ca97..8bd1c5ba6f 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -1,7 +1,147 @@ -# This file is automatically updated by emsdk/scripts/update_bazel_workspace.sh +# This file is automatically updated by emsdk/scripts/update_bazel_workspace.py # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "3.1.63": struct( + hash = "aeb36a44b29e8ca9f4c7efbb4735b69003ac2bb9", + sha_linux = "2a38ac1ea2fe3b7169879f0f666ea278f344cbb5db6e34421b9554939559109c", + sha_mac = "7e192b84aecfade22817b5b38f0c69d1f795a9b990308188d39ed1d218692cd3", + sha_mac_arm64 = "751ef26a3682f5f23dfdc1c2f80cd0604a32cad61e6373c823de774722ecb9af", + sha_win = "947f8e867e781750d374d659644897f2345a133ad3d0f9ade23afcb81eeaddd3", + ), + "3.1.62": struct( + hash = "d52176ac8e07c47c1773bb2776ebd91e3886c3af", + sha_linux = "fd303a2b2a85c4b3ab8aa29595d70c5fde9df71c5254d56ed19d54e9ee98e881", + sha_mac = "d9cfef7ba8f44bf21be715244d0d5f909f1ccc2a481a301b3c01d12d1babc049", + sha_mac_arm64 = "de5484d60c858aaa8b93ba6485924adffe734cf4f8296765c089900cf9ce0701", + sha_win = "7455680bf9c19a26fe4868111ac01401023b0f92e862d3cabadf7950b87707fd", + ), + "3.1.61": struct( + hash = "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c", + sha_linux = "e3e20e09219fd47a0019bb3252e17db4a00ded39b39b41634bc73f840a8ff2be", + sha_mac = "1fe69a3c42fb2857b80c8e77bfab780cb212ed7cf81ae57c0c4d235504df5269", + sha_mac_arm64 = "4ba702eea409e2d4bfabc73a68919217d3993e7585d95734e3e40a3c9ce1bd21", + sha_win = "bbafba849ff072a61dd34a8ffc0c85eed20a417854a3ca751b092e3565a92581", + ), + "3.1.60": struct( + hash = "87709b5747de5b1993fe314285528bf4b65c23e1", + sha_linux = "ff5eb062165920c7cb69935d396f13e9f8ca5b13f2d7f3af2759bcacb5e877e2", + sha_mac = "45586fab1bad65a4293ea8939dafb5ec711ba92ae7b4d1edbaae3b4486f398b5", + sha_mac_arm64 = "8dc27416a378ad07285d380f68717cfe0db1ea6252fdb1ad012af95e4d3f342e", + sha_win = "f3147ef2d4ca48ea2624039969fd0529d0bacb63bf49ee4809c681902768b973", + ), + "3.1.59": struct( + hash = "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", + sha_linux = "ae59d1946cb92e1651cbb904fe824b3f07b39f42fa25f582116b5aaa226fa239", + sha_mac = "af175bd559cb80459749e504da314af0163291f195461bf4d376d6980c4c60c3", + sha_mac_arm64 = "e17553bca5d00b30c920595e785281627e973f9e7e14c5dc0a73c355ccafe113", + sha_win = "bb54256fc3b7824cb75d5474f887d9bf8e1e63c15b351bdfbed898aa293ee4ab", + ), + "3.1.58": struct( + hash = "a4d4afb626c5010f6ccda4638b8d77579a63782e", + sha_linux = "b188249ecb939dadc679aaf2d3d9afd0fe19ab942f91b7bc926b4f252915dd1a", + sha_mac = "2092aa4bef3b9f88d3f343b042a417ba617d4e04454656d8f2e101ba53f854e8", + sha_mac_arm64 = "7a9a15845257629b7602d15bdf7633a8e10472b0fa9b3d9ee7149938aa2f2039", + sha_win = "9fe76b6189566d56f0cf9aecbd23a006778530aa87184a900f5662e39ce7272a", + ), + "3.1.57": struct( + hash = "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", + sha_linux = "5bc444132258d4404d396f2044a4a334064ad0f1022555cad5ec72804a98ba5a", + sha_mac = "31ddccb68c86f0a45332982938c49505158860ed4f7e8ccef72a48382e0e3c96", + sha_mac_arm64 = "cc5fdb65b339464f99b9c731cc63c233ec9577268886a856fa49f227ca2a56d1", + sha_win = "b53555420bb9b6e31c153e4c59427000ec692be17ae900f659a9b774d1ecebed", + ), + "3.1.56": struct( + hash = "9d106be887796484c4aaffc9dc45f48a8810f336", + sha_linux = "52338cca556002251e5e7d738adb1870d14331ddf463e613af02028b64e05a82", + sha_mac = "fc5cca6a9db571ecb2974bf0d4e12f1bc6068726271464586cf7e8723004b4c6", + sha_mac_arm64 = "aed728d09d801c4a33210505874ce066269292e7809a7d6a6414146be01545f1", + sha_win = "cd5fbe94fb0bcf01badc10eace48eddbca22b34f31229e3d70c68ade7bcdd571", + ), + "3.1.55": struct( + hash = "f5557e3b7166d05bddb5977e363ec48cd06e9d32", + sha_linux = "2a1cccc2f6db801219eb966d00af78a026af7822055064092387e7eba18e75ad", + sha_mac = "f1f8f4ebd086d0cd8bd54c41c6a0e86bbb26d7b8020484fef3dba67cd9e6906c", + sha_mac_arm64 = "7533b7a1beaa692a4f1e57b91c456b13e6bcc367dc9a414cb066350e8a2058c7", + sha_win = "204984cbb755f9aa09c21b49129d908f59617a60d5aebd8742097a9a2c196abb", + ), + "3.1.54": struct( + hash = "aa1588cd28c250a60457b5ed342557c762f416e3", + sha_linux = "5c8db804abe1ac7ddaa99a6997683cf9fa9004de655b32b5b612d59a94bd59d0", + sha_mac = "e6d2b8c6983767c7ced83d40b87081a221f05bab08d0fa4f0c6de652547c8a9f", + sha_mac_arm64 = "83764751ee5c7b42529e1df168695d4a51a23c9c165f3f90693baa9bd9256efa", + sha_win = "c0a1c9f3e1dfc9bb2e600501aea999f53b34a16f82da387317fdcae7e9c2a79b", + ), + "3.1.53": struct( + hash = "e5523d57a0e0dcf80f3b101bbc23613fcc3101aa", + sha_linux = "1025c0c738fbaedf3f8fcffee23bef71c8d04a95b30ea8a69a47231fb35d1c8b", + sha_mac = "318dc0cc51a237040bc1cb0a9e7d6c214196c8a100b50d0e298cf3ea7c365dbe", + sha_mac_arm64 = "e346ef588f7cfe1e41623de2257a11ecf8381fbd3bde63a8773b3a663411ea12", + sha_win = "af7f7175ab0b3c1e9121c713764e8ac1d970b6dbee8a84602b4a69cc5ec5940d", + ), + "3.1.52": struct( + hash = "ce2097fb81953331e65543c20b437475f218127c", + sha_linux = "1c0cd572067c6348cea5e347b9ef7c5460493ca3f0d84bb991689731d0e140ef", + sha_mac = "5d9c801f9cfe81337d65969e174e0b3ef4cf2b47eb548ff4695abe3a2e69ba70", + sha_mac_arm64 = "7ce8fef7542437c85412143cb59b13b8804bb06243a106d2d342c7d9132edc8e", + sha_win = "82ed01d965f5c2765191c67da5baecd2d3ce3f82a8cf30fc47fcd56d47826cf6", + ), + "3.1.51": struct( + hash = "4f416d92fbff66ce79901cfc8263768f1b25dd3e", + sha_linux = "09af08eb562cccf85770e4b8e368acb5accb1759fe3bc436b8fad80c27f90c79", + sha_mac = "b12201caf9ff2b981349edebd2d2c022ff000c74241ef96305b831abbd4f9450", + sha_mac_arm64 = "65fbee020cf965f9216607bad56215795529cbe8cef318fadcb33141dd6b5e82", + sha_win = "65c2d005a6be80723fa795ea724d4db9960601cf7d59d880f2882ecd45c8ad2b", + ), + "3.1.50": struct( + hash = "2ce4170cef5ce46f337f9fd907b614a8db772c7d", + sha_linux = "8822050b999286694cd4ffc7d959a8ea3137e3a910121d78b5377439ede9b598", + sha_mac = "39ce2f689be348b558df9c2c988b03472d43f8ac0827624397f7c0bb56a1e893", + sha_mac_arm64 = "5a9fa8de121db400bb46e716d861283b938ad87257d7c48f99dd5557100bd3ea", + sha_win = "29096f5596d93dbf620a9547fd1ecec8f54f3f52d49b13f09959d852310220db", + ), + "3.1.49": struct( + hash = "bd0a2e230466dadb36efc71aa7271f17c6c35420", + sha_linux = "18f452f8bdcd13e0d3a65c569180d1b83579775eadb8069cb32bca1f2e751751", + sha_mac = "c5275eab15e42abb3a42bbe1cfe38ee1b852febc78f65f5605b8972a7bee672f", + sha_mac_arm64 = "10a722e2c7dcc97236f70f2d68b23a7975800ebf27ec4fdf76deddf483b1c6d6", + sha_win = "4361fc18faaf70a2dc342c219b13c39a8196e9a48e6897d08c7b0dca6ba6525d", + ), + "3.1.48": struct( + hash = "694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc", + sha_linux = "689fffcb60f93a60a7bb52cc205ead43ab31f252753cfef39ae2074f6a442634", + sha_mac = "8ac2a3f32b4cba0d84ca5a1fe1db883dbfc2731432833ab5a7e6967c5f4ab7dc", + sha_mac_arm64 = "10dd40f94fe5c5f8c4efc838d1623cafe98c629d4c7872ad8c15cd7b0836f281", + sha_win = "9276435ea7c402c18572a4301d6a26426eac73414b0ed5cb3e721044a50f651d", + ), + "3.1.47": struct( + hash = "39ade279e75e6d17dd6b7eb9fba2006e61fe966b", + sha_linux = "bdc50abe5c7d4b4f14acea4ec36b270e86770cea2da4b0c393b80a692dc7eb7a", + sha_mac = "6a3a116707037d75a967a7d971894d8ace74a2a230aa50ba55e88e7cd7b94953", + sha_mac_arm64 = "b13d228e6a1c89c13a1500fff07dcf093fb01fa621d458496d4a6d7f05cfd600", + sha_win = "66a6c4f0cda4ace14a86d3e59d20685d35211854d21670632b0566ac73638245", + ), + "3.1.46": struct( + hash = "21644188d5c473e92f1d7df2f9f60c758a78a486", + sha_linux = "75cbf14629b06e417b597d3f897ad7d881c53762380aca2f0dd85f1b15891511", + sha_mac = "06f45608381203d501141be632cab960aa105626c3a0f7a48657b79728103880", + sha_mac_arm64 = "c2a85b509a91663b390f77d51fba775421d42456211466fd3757f9dede7af9e4", + sha_win = "1ed3a3f36dee5d373ebea213fc723b3eeb7d6ba4c43da6a951ea0d76f265f234", + ), + "3.1.45": struct( + hash = "2b7c5fb8ffeac3315deb1f82ab7bf8da544f84a1", + sha_linux = "1c0576765f8b34603eead6f2bd4bc77bf68ea2f0a39ed4c144514103e85bc7d9", + sha_mac = "87f63ebb2f9807435016b238bbf46ccb94c919ec0786b46463cd788634391b0c", + sha_mac_arm64 = "29e698772c0e00c21ce120dd1db1586f5c65507168babff148c2e628add6e72a", + sha_win = "891d49f8828f715ef621d55fe202de4929bbdc89b69101fd33963571458a7f47", + ), + "3.1.44": struct( + hash = "b90507fcf011da61bacfca613569d882f7749552", + sha_linux = "5ffa2bab560a9cda6db6ee041a635d10e1ef26c8fc63675d682917b8d3d53263", + sha_mac = "291b2653f7576f8354f0267047e47a5ddef11223c89d5be399d04618f13b3832", + sha_mac_arm64 = "ad1625821b49ccbbe733596223fdf99fd786470d679f2c9dfabd4a1a7b929282", + sha_win = "8b61f60ef169b1c20207361067c40192c83b96cdbdb2f4cff21dfb20b9ee528d", + ), "3.1.43": struct( hash = "bf3c159888633d232c0507f4c76cc156a43c32dc", sha_linux = "147a67a3454783b8c351780ec0111329d1e6fbb1d2fcdfe1c035e1c0997e0701", diff --git a/bazel/test_external/MODULE.bazel b/bazel/test_external/MODULE.bazel new file mode 100644 index 0000000000..7f51cebf45 --- /dev/null +++ b/bazel/test_external/MODULE.bazel @@ -0,0 +1 @@ +bazel_dep(name = "platforms", version = "0.0.9") diff --git a/bazel/test_external/long_command_line/BUILD.bazel b/bazel/test_external/long_command_line/BUILD.bazel new file mode 100644 index 0000000000..4ffe247604 --- /dev/null +++ b/bazel/test_external/long_command_line/BUILD.bazel @@ -0,0 +1,61 @@ +load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") + +_TEST_TARGETS = [ + "long_command_line_file01", + "long_command_line_file02", + "long_command_line_file03", + "long_command_line_file04", + "long_command_line_file05", + "long_command_line_file06", + "long_command_line_file07", + "long_command_line_file08", + "long_command_line_file09", + "long_command_line_file10", + "long_command_line_file11", + "long_command_line_file12", + "long_command_line_file13", + "long_command_line_file14", + "long_command_line_file15", + "long_command_line_file16", + "long_command_line_file17", + "long_command_line_file18", + "long_command_line_file19", + "long_command_line_file20", +] + +_TEST_TARGET_SUFFIXES = [ + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", +] + +[cc_library( + name = "{}_{}".format(target, suffix), + hdrs = ["include/{}.hh".format(target)], + # stripping include prefix to create more flags passed to emcc + strip_include_prefix = "include", + srcs = ["{}.cc".format(target)], +) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES] + +cc_binary( + name = "long_command_line", + linkshared = True, + srcs = ["long_command_line.cc"], + deps = [":{}_{}".format(target, suffix) for target in _TEST_TARGETS for suffix in _TEST_TARGET_SUFFIXES], +) + +wasm_cc_binary( + name = "long_command_line_wasm", + cc_target = ":long_command_line", + outputs = [ + "long_command_line.js", + "long_command_line.wasm", + ], +) diff --git a/bazel/test_external/long_command_line/include/long_command_line_file01.hh b/bazel/test_external/long_command_line/include/long_command_line_file01.hh new file mode 100644 index 0000000000..8dd06bad8c --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file01.hh @@ -0,0 +1,3 @@ +#pragma once + +void f1(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file02.hh b/bazel/test_external/long_command_line/include/long_command_line_file02.hh new file mode 100644 index 0000000000..7a3a0ff11a --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file02.hh @@ -0,0 +1,3 @@ +#pragma once + +void f2(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file03.hh b/bazel/test_external/long_command_line/include/long_command_line_file03.hh new file mode 100644 index 0000000000..16880553f6 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file03.hh @@ -0,0 +1,3 @@ +#pragma once + +void f3(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file04.hh b/bazel/test_external/long_command_line/include/long_command_line_file04.hh new file mode 100644 index 0000000000..45ef1fca9b --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file04.hh @@ -0,0 +1,3 @@ +#pragma once + +void f4(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file05.hh b/bazel/test_external/long_command_line/include/long_command_line_file05.hh new file mode 100644 index 0000000000..707ad50280 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file05.hh @@ -0,0 +1,3 @@ +#pragma once + +void f5(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file06.hh b/bazel/test_external/long_command_line/include/long_command_line_file06.hh new file mode 100644 index 0000000000..5d91450067 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file06.hh @@ -0,0 +1,3 @@ +#pragma once + +void f6(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file07.hh b/bazel/test_external/long_command_line/include/long_command_line_file07.hh new file mode 100644 index 0000000000..b0bf811868 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file07.hh @@ -0,0 +1,3 @@ +#pragma once + +void f7(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file08.hh b/bazel/test_external/long_command_line/include/long_command_line_file08.hh new file mode 100644 index 0000000000..994b7ea7cd --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file08.hh @@ -0,0 +1,3 @@ +#pragma once + +void f8(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file09.hh b/bazel/test_external/long_command_line/include/long_command_line_file09.hh new file mode 100644 index 0000000000..90c19583c4 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file09.hh @@ -0,0 +1,3 @@ +#pragma once + +void f9(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file10.hh b/bazel/test_external/long_command_line/include/long_command_line_file10.hh new file mode 100644 index 0000000000..6a4388182a --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file10.hh @@ -0,0 +1,3 @@ +#pragma once + +void f10(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file11.hh b/bazel/test_external/long_command_line/include/long_command_line_file11.hh new file mode 100644 index 0000000000..878c9396b4 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file11.hh @@ -0,0 +1,3 @@ +#pragma once + +void f11(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file12.hh b/bazel/test_external/long_command_line/include/long_command_line_file12.hh new file mode 100644 index 0000000000..b5e0bc3e94 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file12.hh @@ -0,0 +1,3 @@ +#pragma once + +void f12(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file13.hh b/bazel/test_external/long_command_line/include/long_command_line_file13.hh new file mode 100644 index 0000000000..634dcef138 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file13.hh @@ -0,0 +1,3 @@ +#pragma once + +void f13(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file14.hh b/bazel/test_external/long_command_line/include/long_command_line_file14.hh new file mode 100644 index 0000000000..8fa9666214 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file14.hh @@ -0,0 +1,3 @@ +#pragma once + +void f14(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file15.hh b/bazel/test_external/long_command_line/include/long_command_line_file15.hh new file mode 100644 index 0000000000..1f7b7706a7 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file15.hh @@ -0,0 +1,3 @@ +#pragma once + +void f15(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file16.hh b/bazel/test_external/long_command_line/include/long_command_line_file16.hh new file mode 100644 index 0000000000..c9fa2fcefc --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file16.hh @@ -0,0 +1,3 @@ +#pragma once + +void f16(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file17.hh b/bazel/test_external/long_command_line/include/long_command_line_file17.hh new file mode 100644 index 0000000000..b959207b74 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file17.hh @@ -0,0 +1,3 @@ +#pragma once + +void f17(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file18.hh b/bazel/test_external/long_command_line/include/long_command_line_file18.hh new file mode 100644 index 0000000000..af0bacf55f --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file18.hh @@ -0,0 +1,3 @@ +#pragma once + +void f18(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file19.hh b/bazel/test_external/long_command_line/include/long_command_line_file19.hh new file mode 100644 index 0000000000..0ac9b4b027 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file19.hh @@ -0,0 +1,3 @@ +#pragma once + +void f19(); diff --git a/bazel/test_external/long_command_line/include/long_command_line_file20.hh b/bazel/test_external/long_command_line/include/long_command_line_file20.hh new file mode 100644 index 0000000000..0f10c733b7 --- /dev/null +++ b/bazel/test_external/long_command_line/include/long_command_line_file20.hh @@ -0,0 +1,3 @@ +#pragma once + +void f20(); diff --git a/bazel/test_external/long_command_line/long_command_line.cc b/bazel/test_external/long_command_line/long_command_line.cc new file mode 100644 index 0000000000..1ae13abecb --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line.cc @@ -0,0 +1,43 @@ +#include "long_command_line_file01.hh" +#include "long_command_line_file02.hh" +#include "long_command_line_file03.hh" +#include "long_command_line_file04.hh" +#include "long_command_line_file05.hh" +#include "long_command_line_file06.hh" +#include "long_command_line_file07.hh" +#include "long_command_line_file08.hh" +#include "long_command_line_file09.hh" +#include "long_command_line_file10.hh" +#include "long_command_line_file11.hh" +#include "long_command_line_file12.hh" +#include "long_command_line_file13.hh" +#include "long_command_line_file14.hh" +#include "long_command_line_file15.hh" +#include "long_command_line_file16.hh" +#include "long_command_line_file17.hh" +#include "long_command_line_file18.hh" +#include "long_command_line_file19.hh" +#include "long_command_line_file20.hh" + +int main() { + f1(); + f2(); + f3(); + f4(); + f5(); + f6(); + f7(); + f8(); + f9(); + f10(); + f11(); + f12(); + f13(); + f14(); + f15(); + f16(); + f17(); + f18(); + f19(); + f20(); +} diff --git a/bazel/test_external/long_command_line/long_command_line_file01.cc b/bazel/test_external/long_command_line/long_command_line_file01.cc new file mode 100644 index 0000000000..3bf8d4aa07 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file01.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file01.hh" + +#include + +void f1() { std::cout << "hello from f1()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file02.cc b/bazel/test_external/long_command_line/long_command_line_file02.cc new file mode 100644 index 0000000000..b8ac8141c5 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file02.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file02.hh" + +#include + +void f2() { std::cout << "hello from f2()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file03.cc b/bazel/test_external/long_command_line/long_command_line_file03.cc new file mode 100644 index 0000000000..294e777419 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file03.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file03.hh" + +#include + +void f3() { std::cout << "hello from f3()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file04.cc b/bazel/test_external/long_command_line/long_command_line_file04.cc new file mode 100644 index 0000000000..c0d537d1b8 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file04.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file04.hh" + +#include + +void f4() { std::cout << "hello from f4()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file05.cc b/bazel/test_external/long_command_line/long_command_line_file05.cc new file mode 100644 index 0000000000..310e3e04ca --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file05.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file05.hh" + +#include + +void f5() { std::cout << "hello from f5()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file06.cc b/bazel/test_external/long_command_line/long_command_line_file06.cc new file mode 100644 index 0000000000..2c218fdcc4 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file06.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file06.hh" + +#include + +void f6() { std::cout << "hello from f6()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file07.cc b/bazel/test_external/long_command_line/long_command_line_file07.cc new file mode 100644 index 0000000000..c78dc400c8 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file07.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file07.hh" + +#include + +void f7() { std::cout << "hello from f7()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file08.cc b/bazel/test_external/long_command_line/long_command_line_file08.cc new file mode 100644 index 0000000000..1c2e10f889 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file08.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file08.hh" + +#include + +void f8() { std::cout << "hello from f8()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file09.cc b/bazel/test_external/long_command_line/long_command_line_file09.cc new file mode 100644 index 0000000000..6c0028dc32 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file09.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file09.hh" + +#include + +void f9() { std::cout << "hello from f9()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file10.cc b/bazel/test_external/long_command_line/long_command_line_file10.cc new file mode 100644 index 0000000000..9f0be9cf42 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file10.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file10.hh" + +#include + +void f10() { std::cout << "hello from f10()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file11.cc b/bazel/test_external/long_command_line/long_command_line_file11.cc new file mode 100644 index 0000000000..2ef8f96e2d --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file11.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file11.hh" + +#include + +void f11() { std::cout << "hello from f11()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file12.cc b/bazel/test_external/long_command_line/long_command_line_file12.cc new file mode 100644 index 0000000000..76349962b8 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file12.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file12.hh" + +#include + +void f12() { std::cout << "hello from f12()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file13.cc b/bazel/test_external/long_command_line/long_command_line_file13.cc new file mode 100644 index 0000000000..bca66d0cda --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file13.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file13.hh" + +#include + +void f13() { std::cout << "hello from f13()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file14.cc b/bazel/test_external/long_command_line/long_command_line_file14.cc new file mode 100644 index 0000000000..543179f6c2 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file14.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file14.hh" + +#include + +void f14() { std::cout << "hello from f14()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file15.cc b/bazel/test_external/long_command_line/long_command_line_file15.cc new file mode 100644 index 0000000000..28767ef84d --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file15.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file15.hh" + +#include + +void f15() { std::cout << "hello from f15()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file16.cc b/bazel/test_external/long_command_line/long_command_line_file16.cc new file mode 100644 index 0000000000..ca7ff99b61 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file16.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file16.hh" + +#include + +void f16() { std::cout << "hello from f16()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file17.cc b/bazel/test_external/long_command_line/long_command_line_file17.cc new file mode 100644 index 0000000000..2230d36faf --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file17.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file17.hh" + +#include + +void f17() { std::cout << "hello from f17()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file18.cc b/bazel/test_external/long_command_line/long_command_line_file18.cc new file mode 100644 index 0000000000..822cd14847 --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file18.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file18.hh" + +#include + +void f18() { std::cout << "hello from f18()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file19.cc b/bazel/test_external/long_command_line/long_command_line_file19.cc new file mode 100644 index 0000000000..b8640642fa --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file19.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file19.hh" + +#include + +void f19() { std::cout << "hello from f19()\n"; } diff --git a/bazel/test_external/long_command_line/long_command_line_file20.cc b/bazel/test_external/long_command_line/long_command_line_file20.cc new file mode 100644 index 0000000000..0562be6dda --- /dev/null +++ b/bazel/test_external/long_command_line/long_command_line_file20.cc @@ -0,0 +1,5 @@ +#include "long_command_line_file20.hh" + +#include + +void f20() { std::cout << "hello from f20()\n"; } diff --git a/bazel/test_secondary_lto_cache/.bazelrc b/bazel/test_secondary_lto_cache/.bazelrc new file mode 100644 index 0000000000..fbd75a7ea7 --- /dev/null +++ b/bazel/test_secondary_lto_cache/.bazelrc @@ -0,0 +1 @@ +build --incompatible_enable_cc_toolchain_resolution diff --git a/bazel/test_secondary_lto_cache/.gitignore b/bazel/test_secondary_lto_cache/.gitignore new file mode 100644 index 0000000000..9d50f0bb1e --- /dev/null +++ b/bazel/test_secondary_lto_cache/.gitignore @@ -0,0 +1,4 @@ +bazel-bin +bazel-out +bazel-test_secondary_lto_cache +bazel-testlogs \ No newline at end of file diff --git a/bazel/test_secondary_lto_cache/BUILD b/bazel/test_secondary_lto_cache/BUILD new file mode 100644 index 0000000000..f364f3778f --- /dev/null +++ b/bazel/test_secondary_lto_cache/BUILD @@ -0,0 +1,19 @@ +load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") + +cc_binary( + name = "hello-world", + srcs = ["hello-world.cc"], + linkopts = [ + "-sAUTO_NATIVE_LIBRARIES=0", + "-flto", + ], +) + +wasm_cc_binary( + name = "hello-world-wasm", + cc_target = ":hello-world", + outputs = [ + "hello-world.js", + "hello-world.wasm", + ], +) diff --git a/bazel/test_secondary_lto_cache/MODULE.bazel b/bazel/test_secondary_lto_cache/MODULE.bazel new file mode 100644 index 0000000000..7f51cebf45 --- /dev/null +++ b/bazel/test_secondary_lto_cache/MODULE.bazel @@ -0,0 +1 @@ +bazel_dep(name = "platforms", version = "0.0.9") diff --git a/bazel/test_secondary_lto_cache/WORKSPACE b/bazel/test_secondary_lto_cache/WORKSPACE new file mode 100644 index 0000000000..d0bdd3b4c0 --- /dev/null +++ b/bazel/test_secondary_lto_cache/WORKSPACE @@ -0,0 +1,30 @@ +local_repository( + name = "emsdk", + path = "..", +) + +load("@emsdk//:deps.bzl", "deps") + +deps() + +load("@emsdk//:emscripten_deps.bzl", "emscripten_deps") + +emscripten_deps() + +load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains") + +register_emscripten_toolchains(cache = { + "configuration": ["--lto"], + "targets": [ + "crtbegin", + "libprintf_long_double-debug", + "libstubs-debug", + "libnoexit", + "libc-debug", + "libdlmalloc", + "libcompiler_rt", + "libc++-noexcept", + "libc++abi-debug-noexcept", + "libsockets" + ] +}) diff --git a/bazel/test_secondary_lto_cache/hello-world.cc b/bazel/test_secondary_lto_cache/hello-world.cc new file mode 100644 index 0000000000..ee72c53171 --- /dev/null +++ b/bazel/test_secondary_lto_cache/hello-world.cc @@ -0,0 +1,6 @@ +#include + +int main(int argc, char** argv) { + std::cout << "hello world!" << std::endl; + return 0; +} diff --git a/bazel/toolchains.bzl b/bazel/toolchains.bzl index 6d50b3d3d5..ae71413dfd 100644 --- a/bazel/toolchains.bzl +++ b/bazel/toolchains.bzl @@ -1,2 +1,96 @@ -def register_emscripten_toolchains(): +BUILD_FILE_CONTENT_TEMPLATE = """ +package(default_visibility = ['//visibility:public']) +exports_files(['emscripten_config']) +""" + +EMBUILDER_CONFIG_TEMPLATE = """ +CACHE = '{cache}' +BINARYEN_ROOT = '{binaryen_root}' +LLVM_ROOT = '{llvm_root}' +""" + +def get_root_and_script_ext(repository_ctx): + if repository_ctx.os.name.startswith('linux'): + if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch: + return (repository_ctx.path(Label("@emscripten_bin_linux//:BUILD.bazel")).dirname, '') + elif 'aarch64' in repository_ctx.os.arch: + return (repository_ctx.path(Label("@emscripten_bin_linux_arm64//:BUILD.bazel")).dirname, '') + else: + fail('Unsupported architecture for Linux') + elif repository_ctx.os.name.startswith('mac'): + if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch: + return (repository_ctx.path(Label("@emscripten_bin_mac//:BUILD.bazel")).dirname, '') + elif 'aarch64' in repository_ctx.os.arch: + return (repository_ctx.path(Label("@emscripten_bin_mac_arm64//:BUILD.bazel")).dirname, '') + else: + fail('Unsupported architecture for MacOS') + elif repository_ctx.os.name.startswith('windows'): + return (repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname, '.bat') + else: + fail('Unsupported operating system') + +def _emscripten_cache_impl(repository_ctx): + # Read the default emscripten configuration file + default_config = repository_ctx.read( + repository_ctx.path( + Label("@emsdk//emscripten_toolchain:default_config") + ) + ) + + if repository_ctx.attr.targets or repository_ctx.attr.configuration: + root, script_ext = get_root_and_script_ext(repository_ctx) + llvm_root = root.get_child("bin") + cache = repository_ctx.path("cache") + # Create configuration file + embuilder_config_content = EMBUILDER_CONFIG_TEMPLATE.format( + cache=cache, + binaryen_root=root, + llvm_root=llvm_root, + ) + repository_ctx.file("embuilder_config", embuilder_config_content) + embuilder_config_path = repository_ctx.path("embuilder_config") + embuilder_path = "{}{}".format(root.get_child("emscripten").get_child("embuilder"), script_ext) + # Prepare the command line + if repository_ctx.attr.targets: + targets = repository_ctx.attr.targets + else: + # If no targets are requested, build everything + targets = ["ALL"] + flags = ["--em-config", embuilder_config_path] + repository_ctx.attr.configuration + embuilder_args = [embuilder_path] + flags + ["build"] + targets + # Run embuilder + repository_ctx.report_progress("Building secondary cache") + result = repository_ctx.execute( + embuilder_args, + quiet=True, + environment = { + "EM_IGNORE_SANITY": "1", + "EM_NODE_JS": "empty", + } + ) + if result.return_code != 0: + fail("Embuilder exited with a non-zero return code") + # Override Emscripten's cache with the secondary cache + default_config += "CACHE = '{}'\n".format(cache) + + # Create the configuration file for the toolchain and export + repository_ctx.file('emscripten_config', default_config) + repository_ctx.file('BUILD.bazel', BUILD_FILE_CONTENT_TEMPLATE) + +_emscripten_cache = repository_rule( + implementation = _emscripten_cache_impl, + attrs = { + "configuration": attr.string_list(), + "targets": attr.string_list(), + }, + local = True +) + +def register_emscripten_toolchains(cache = {}): + _emscripten_cache( + name = "emscripten_cache", + configuration = cache["configuration"] if "configuration" in cache else [], + targets = cache["targets"] if "targets" in cache else [], + ) + native.register_toolchains(str(Label("//emscripten_toolchain:cc-toolchain-wasm"))) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4cb32f18c6..e70df960ac 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -63,7 +63,7 @@ COPY --from=stage_build /emsdk /emsdk # using `--entrypoint /bin/bash` in CLI). # This corresponds to the env variables set during: `source ./emsdk_env.sh` ENV EMSDK=/emsdk \ - PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/node/16.20.0_64bit/bin:${PATH}" + PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/node/18.20.3_64bit/bin:${PATH}" # ------------------------------------------------------------------------------ # Create a 'standard` 1000:1000 user diff --git a/docker/Makefile b/docker/Makefile index 8e84b2e192..749ecfe940 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -4,6 +4,7 @@ # i.e.: 1.39.18 version = alias = +only_alias = image_name ?= emscripten/emsdk @@ -13,7 +14,7 @@ ifndef version endif build: Dockerfile .TEST - cd .. && docker build --network host --build-arg=EMSCRIPTEN_VERSION=${version} -t ${image_name}:${version} -f docker/$< . + cd .. && docker build --progress=plain --network host --build-arg=EMSCRIPTEN_VERSION=${version} -t ${image_name}:${version} -f docker/$< . test: test_dockerimage.sh .TEST # test as non-root @@ -21,7 +22,9 @@ test: test_dockerimage.sh .TEST docker run --rm -u `id -u`:`id -g` -w /emsdk/docker --net=host --entrypoint /bin/bash ${image_name}:${version} $< push: .TEST +ifndef only_alias docker push ${image_name}:${version} +endif ifdef alias docker tag ${image_name}:${version} ${image_name}:${alias} docker push ${image_name}:${alias} diff --git a/docker/README.md b/docker/README.md index 8a284b3a19..62e6c022a0 100644 --- a/docker/README.md +++ b/docker/README.md @@ -23,7 +23,7 @@ EOF # compile with docker image docker run \ --rm \ - -v $(pwd):/src \ + -v "$(pwd):$(pwd)" \ -u $(id -u):$(id -g) \ emscripten/emsdk \ emcc helloworld.cpp -o helloworld.js @@ -38,7 +38,7 @@ Teardown of compilation command: |---|---| |`docker run`| A standard command to run a command in a container| |`--rm`|remove a container after execution (optimization)| -|`-v $(pwd):$(pwd)`|Mounting current folder from the host system into mirrored path on the container
TIP: This helps to investigate possible problem as we preserve exactly the same paths like in host. In such case modern editors (like Sublime, Atom, VS Code) let us to CTRL+Click on a problematic file | +|`-v "$(pwd):$(pwd)"`|Mounting current folder from the host system into mirrored path on the container
TIP: This helps to investigate possible problem as we preserve exactly the same paths like in host. In such case modern editors (like Sublime, Atom, VS Code) let us to CTRL+Click on a problematic file | |`-u $(id -u):$(id -g)`| Run the container as a non-root user with the same UID and GID as local user. Hence all files produced by this are accessible to non-root users| |`emscripten/emsdk`|Get the latest tag of this container| |`emcc helloworld.cpp -o helloworld.js`|Execute `emcc` command with following arguments inside container, effectively compile our source code| diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index ec1f9fd945..9693caa54b 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,8 +1,8 @@ { "aliases": { - "latest": "3.1.43", + "latest": "3.1.63", "latest-sdk": "latest", - "latest-arm64-linux": "3.1.43", + "latest-arm64-linux": "latest", "latest-64bit": "latest", "sdk-latest-64bit": "latest", "latest-upstream": "latest", @@ -10,6 +10,46 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.63": "aeb36a44b29e8ca9f4c7efbb4735b69003ac2bb9", + "3.1.63-asserts": "b0275806047b42f2f88998c5c8159aec90e195ab", + "3.1.62": "d52176ac8e07c47c1773bb2776ebd91e3886c3af", + "3.1.62-asserts": "9d9e7deac8b91fbdd8804045595e807f9d774a53", + "3.1.61": "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c", + "3.1.61-asserts": "7fc912687ba2077b3aeae472b51c238b3d201c46", + "3.1.60": "87709b5747de5b1993fe314285528bf4b65c23e1", + "3.1.60-asserts": "e2388e8a528890b8f3ff7b9ab4f52dbe2aeb38b9", + "3.1.59": "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", + "3.1.59-asserts": "10ae1e83ccce9f4a363bb2e3090ba8fc32d25851", + "3.1.58": "a4d4afb626c5010f6ccda4638b8d77579a63782e", + "3.1.58-asserts": "5bc1c7108d4d91db316b24a75593a37c1117c266", + "3.1.57": "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", + "3.1.57-asserts": "10b736eeeac0dae3fd5bc29c6b3e32f7f7adf941", + "3.1.56": "9d106be887796484c4aaffc9dc45f48a8810f336", + "3.1.56-asserts": "2b9c4b912b611dc51f9019e11371e3cdd36fa64e", + "3.1.55": "f5557e3b7166d05bddb5977e363ec48cd06e9d32", + "3.1.55-asserts": "eb23cc30563325fd6dc97fcf85ddf26489ab9110", + "3.1.54": "aa1588cd28c250a60457b5ed342557c762f416e3", + "3.1.54-asserts": "d525f56cb765ed6884a0c443dbb906b63b148915", + "3.1.53": "e5523d57a0e0dcf80f3b101bbc23613fcc3101aa", + "3.1.53-asserts": "152cef4e00fc17776576bcc57f53badd21b92509", + "3.1.52": "ce2097fb81953331e65543c20b437475f218127c", + "3.1.52-asserts": "49e9a37dd6d1d65aa92472d8908cb8b88092dfaf", + "3.1.51": "4f416d92fbff66ce79901cfc8263768f1b25dd3e", + "3.1.51-asserts": "9035c99beb760aa0ea381bdf11abf440d88bb451", + "3.1.50": "2ce4170cef5ce46f337f9fd907b614a8db772c7d", + "3.1.50-asserts": "0a6fe6ef5880bf5b035d396f3875fda9b7c4bb60", + "3.1.49": "bd0a2e230466dadb36efc71aa7271f17c6c35420", + "3.1.49-asserts": "4ea035c5bbd6168dae34c970b5f56d7aa4dcf952", + "3.1.48": "694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc", + "3.1.48-asserts": "6e2b8a97c6db82089c3a405bc88ea9fb125deb16", + "3.1.47": "39ade279e75e6d17dd6b7eb9fba2006e61fe966b", + "3.1.47-asserts": "dc49d84ed226a5a30a5117cefc07c781f6c0d16e", + "3.1.46": "21644188d5c473e92f1d7df2f9f60c758a78a486", + "3.1.46-asserts": "3e09b252d0d5a8e045d2ca92c606bfb9874bddf8", + "3.1.45": "2b7c5fb8ffeac3315deb1f82ab7bf8da544f84a1", + "3.1.45-asserts": "2aec03dfd8ce68c95316116dafbe30e273f32a81", + "3.1.44": "b90507fcf011da61bacfca613569d882f7749552", + "3.1.44-asserts": "06d00b0c62e435b743aa37c67b4ab76bc8568c79", "3.1.43": "bf3c159888633d232c0507f4c76cc156a43c32dc", "3.1.43-asserts": "3ec53a819a5958665d6bb0ac895c99546921b6ef", "3.1.42": "9d73bf4bd5b5c9ce6e51be0ed5ce6599fcb28e9e", diff --git a/emsdk b/emsdk index 5fae040051..55d46b925b 100755 --- a/emsdk +++ b/emsdk @@ -9,10 +9,8 @@ # First look for python bundled in Emsdk if [ -z "$EMSDK_PYTHON" ]; then PYTHON3="$(dirname "$0")/python/3.9.2-1_64bit/bin/python3" - PYTHON3_CERT_FILE="$(dirname "$0")/python/3.9.2-1_64bit/lib/python3.9/site-packages/certifi/cacert.pem" if [ ! -f "$PYTHON3" ]; then PYTHON3="$(dirname "$0")/python/3.7.4-2_64bit/bin/python3" - PYTHON3_CERT_FILE="$(dirname "$0")/python/3.7.4-2_64bit/lib/python3.7/site-packages/certifi/cacert.pem" fi if [ -f "$PYTHON3" ]; then EMSDK_PYTHON="$PYTHON3" @@ -22,18 +20,13 @@ if [ -z "$EMSDK_PYTHON" ]; then # https://github.com/emscripten-core/emsdk/issues/598 unset PYTHONHOME unset PYTHONPATH - - # This is needed for MacOS. Without this, the urlopen - # code will try to use /usr/local/etc/openssl/cert.pem - # which may or may not exist on the system. - export SSL_CERT_FILE="$PYTHON3_CERT_FILE" fi fi # If bundled python is not found, look for `python3` in PATH. This is especially important on macOS (See: # https://github.com/emscripten-core/emsdk/pull/273) if [ -z "$EMSDK_PYTHON" ]; then - if PYTHON3="$(which python3 2>/dev/null)"; then + if PYTHON3="$(command -v python3 2>/dev/null)"; then EMSDK_PYTHON=$PYTHON3 fi fi diff --git a/emsdk.py b/emsdk.py index 52f2f68cc5..1d8276ac4e 100644 --- a/emsdk.py +++ b/emsdk.py @@ -670,61 +670,87 @@ def get_download_target(url, dstpath, filename_prefix=''): return file_name +def download_with_curl(url, file_name): + print("Downloading: %s from %s" % (file_name, url)) + if not which('curl'): + exit_with_error('curl not found in PATH') + # -#: show progress bar + # -L: Follow HTTP 3XX redirections + # -f: Fail on HTTP errors + subprocess.check_call(['curl', '-#', '-f', '-L', '-o', file_name, url]) + + +def download_with_urllib(url, file_name): + u = urlopen(url) + file_size = get_content_length(u) + if file_size > 0: + print("Downloading: %s from %s, %s Bytes" % (file_name, url, file_size)) + else: + print("Downloading: %s from %s" % (file_name, url)) + + file_size_dl = 0 + # Draw a progress bar 80 chars wide (in non-TTY mode) + progress_max = 80 - 4 + progress_shown = 0 + block_sz = 256 * 1024 + if not TTY_OUTPUT: + print(' [', end='') + + with open(file_name, 'wb') as f: + while True: + buffer = u.read(block_sz) + if not buffer: + break + + file_size_dl += len(buffer) + f.write(buffer) + if file_size: + percent = file_size_dl * 100.0 / file_size + if TTY_OUTPUT: + status = r" %10d [%3.02f%%]" % (file_size_dl, percent) + print(status, end='\r') + else: + while progress_shown < progress_max * percent / 100: + print('-', end='') + sys.stdout.flush() + progress_shown += 1 + + if not TTY_OUTPUT: + print(']') + sys.stdout.flush() + + debug_print('finished downloading (%d bytes)' % file_size_dl) + + # On success, returns the filename on the disk pointing to the destination file that was produced # On failure, returns None. -def download_file(url, dstpath, download_even_if_exists=False, filename_prefix=''): +def download_file(url, dstpath, download_even_if_exists=False, + filename_prefix='', silent=False): debug_print('download_file(url=' + url + ', dstpath=' + dstpath + ')') file_name = get_download_target(url, dstpath, filename_prefix) if os.path.exists(file_name) and not download_even_if_exists: print("File '" + file_name + "' already downloaded, skipping.") return file_name + + mkdir_p(os.path.dirname(file_name)) + try: - u = urlopen(url) - mkdir_p(os.path.dirname(file_name)) - with open(file_name, 'wb') as f: - file_size = get_content_length(u) - if file_size > 0: - print("Downloading: %s from %s, %s Bytes" % (file_name, url, file_size)) - else: - print("Downloading: %s from %s" % (file_name, url)) - - file_size_dl = 0 - # Draw a progress bar 80 chars wide (in non-TTY mode) - progress_max = 80 - 4 - progress_shown = 0 - block_sz = 256 * 1024 - if not TTY_OUTPUT: - print(' [', end='') - while True: - buffer = u.read(block_sz) - if not buffer: - break - - file_size_dl += len(buffer) - f.write(buffer) - if file_size: - percent = file_size_dl * 100.0 / file_size - if TTY_OUTPUT: - status = r" %10d [%3.02f%%]" % (file_size_dl, percent) - print(status, end='\r') - else: - while progress_shown < progress_max * percent / 100: - print('-', end='') - sys.stdout.flush() - progress_shown += 1 - if not TTY_OUTPUT: - print(']') - sys.stdout.flush() + # Use curl on macOS to avoid CERTIFICATE_VERIFY_FAILED issue with + # python's urllib: + # https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore + # Unlike on linux or windows, curl is always available on macOS systems. + if MACOS: + download_with_curl(url, file_name) + else: + download_with_urllib(url, file_name) except Exception as e: errlog("Error: Downloading URL '" + url + "': " + str(e)) - if "SSL: CERTIFICATE_VERIFY_FAILED" in str(e) or "urlopen error unknown url type: https" in str(e): - errlog("Warning: Possibly SSL/TLS issue. Update or install Python SSL root certificates (2048-bit or greater) supplied in Python folder or https://pypi.org/project/certifi/ and try again.") - rmfile(file_name) return None except KeyboardInterrupt: rmfile(file_name) - exit_with_error("aborted by user, exiting") + raise + return file_name @@ -960,13 +986,10 @@ def cmake_configure(generator, build_root, src_root, build_type, extra_cmake_arg generator = [] cmdline = ['cmake'] + generator + ['-DCMAKE_BUILD_TYPE=' + build_type, '-DPYTHON_EXECUTABLE=' + sys.executable] - # Target macOS 10.14 at minimum, to support widest range of Mac devices from "Early 2008" and newer: + # Target macOS 10.14 at minimum, to support widest range of Mac devices + # from "Early 2008" and newer: # https://en.wikipedia.org/wiki/MacBook_(2006-2012)#Supported_operating_systems cmdline += ['-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14'] - # To enable widest possible chance of success for building, let the code - # compile through with older toolchains that are about to be deprecated by - # upstream LLVM. - cmdline += ['-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON'] cmdline += extra_cmake_args + [src_root] print('Running CMake: ' + str(cmdline)) @@ -1104,6 +1127,10 @@ def build_llvm(tool): # (there instead of $(Configuration), one would need ${CMAKE_BUILD_TYPE} ?) # It looks like compiler-rt is not compatible to build on Windows? args += ['-DLLVM_ENABLE_PROJECTS=clang;lld'] + # To enable widest possible chance of success for building, let the code + # compile through with older toolchains that are about to be deprecated by + # upstream LLVM. + args += ['-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON'] if os.getenv('LLVM_CMAKE_ARGS'): extra_args = os.environ['LLVM_CMAKE_ARGS'].split(',') @@ -1206,28 +1233,6 @@ def build_ccache(tool): return success -# Emscripten asm.js optimizer build scripts: -def optimizer_build_root(tool): - build_root = tool.installation_path().strip() - if build_root.endswith('/') or build_root.endswith('\\'): - build_root = build_root[:-1] - generator_prefix = cmake_generator_prefix() - build_root = build_root + generator_prefix + '_' + str(tool.bitness) + 'bit_optimizer' - return build_root - - -def uninstall_optimizer(tool): - debug_print('uninstall_optimizer(' + str(tool) + ')') - build_root = optimizer_build_root(tool) - print("Deleting path '" + build_root + "'") - remove_tree(build_root) - - -def is_optimizer_installed(tool): - build_root = optimizer_build_root(tool) - return os.path.exists(build_root) - - # Finds the newest installed version of a given tool def find_latest_installed_tool(name): for t in reversed(tools): @@ -1328,29 +1333,6 @@ def emscripten_npm_install(tool, directory): return True -def emscripten_post_install(tool): - debug_print('emscripten_post_install(' + str(tool) + ')') - src_root = os.path.join(tool.installation_path(), 'tools', 'optimizer') - build_root = optimizer_build_root(tool) - build_type = decide_cmake_build_type(tool) - - # Configure - cmake_generator, args = get_generator_and_config_args(tool) - - success = cmake_configure(cmake_generator, build_root, src_root, build_type, args) - if not success: - return False - - # Make - success = make_build(build_root, build_type) - if not success: - return False - - success = emscripten_npm_install(tool, tool.installation_path()) - - return True - - # Binaryen build scripts: def binaryen_build_root(tool): build_root = tool.installation_path().strip() @@ -1407,18 +1389,36 @@ def download_and_extract(archive, dest_dir, filename_prefix='', clobber=True): debug_print('download_and_extract(archive=' + archive + ', dest_dir=' + dest_dir + ')') url = urljoin(emsdk_packages_url, archive) - download_target = get_download_target(url, download_dir, filename_prefix) - received_download_target = download_file(url, download_dir, not KEEP_DOWNLOADS, filename_prefix) - if not received_download_target: + def try_download(url, silent=False): + return download_file(url, download_dir, not KEEP_DOWNLOADS, + filename_prefix, silent=silent) + + # Special hack for the wasm-binaries we transitioned from `.bzip2` to + # `.xz`, but we can't tell from the version/url which one to use, so + # try one and then fall back to the other. + success = False + if 'wasm-binaries' in archive and os.path.splitext(archive)[1] == '.xz': + success = try_download(url, silent=True) + if not success: + alt_url = url.replace('.tar.xz', '.tbz2') + success = try_download(alt_url, silent=True) + if success: + url = alt_url + + if not success: + success = try_download(url) + + if not success: return False - assert received_download_target == download_target # Remove the old directory, since we have some SDKs that install into the # same directory. If we didn't do this contents of the previous install # could remain. if clobber: remove_tree(dest_dir) + + download_target = get_download_target(url, download_dir, filename_prefix) if archive.endswith('.zip'): return unzip(download_target, dest_dir) else: @@ -1488,7 +1488,22 @@ def load_em_config(): pass -def generate_em_config(active_tools): +def find_emscripten_root(active_tools): + """Find the currently active emscripten root. + + If there is more than one tool that defines EMSCRIPTEN_ROOT (this + should not happen under normal circumstances), assume the last one takes + precedence. + """ + root = None + for tool in active_tools: + config = tool.activated_config() + if 'EMSCRIPTEN_ROOT' in config: + root = config['EMSCRIPTEN_ROOT'] + return root + + +def generate_em_config(active_tools, permanently_activate, system): cfg = 'import os\n' cfg += "emsdk_path = os.path.dirname(os.getenv('EM_CONFIG')).replace('\\\\', '/')\n" @@ -1508,10 +1523,17 @@ def generate_em_config(active_tools): for name, value in activated_config.items(): cfg += name + " = '" + value + "'\n" - cfg += '''\ -COMPILER_ENGINE = NODE_JS -JS_ENGINES = [NODE_JS] -''' + emroot = find_emscripten_root(active_tools) + if emroot: + version = parse_emscripten_version(emroot) + # Older emscripten versions of emscripten depend on certain config + # keys that are no longer used. + # See https://github.com/emscripten-core/emscripten/pull/9469 + if version < [1, 38, 46]: + cfg += 'COMPILER_ENGINE = NODE_JS\n' + # See https://github.com/emscripten-core/emscripten/pull/9542 + if version < [1, 38, 48]: + cfg += 'JS_ENGINES = [NODE_JS]\n' cfg = cfg.replace("'" + EMSDK_PATH, "emsdk_path + '") @@ -1526,7 +1548,14 @@ def generate_em_config(active_tools): rmfile(os.path.join(EMSDK_PATH, ".emscripten_sanity")) path_add = get_required_path(active_tools) - if not WINDOWS: + + # Give some recommended next step, depending on the platform + if WINDOWS: + if not permanently_activate and not system: + print('Next steps:') + print('- Consider running `emsdk activate` with --permanent or --system') + print(' to have emsdk settings available on startup.') + else: emsdk_env = sdk_path('emsdk_env.sh') print('Next steps:') print('- To conveniently access emsdk tools from the command line,') @@ -1730,9 +1759,7 @@ def is_installed(self, skip_version_check=False): content_exists = False if hasattr(self, 'custom_is_installed_script'): - if self.custom_is_installed_script == 'is_optimizer_installed': - return is_optimizer_installed(self) - elif self.custom_is_installed_script == 'is_binaryen_installed': + if self.custom_is_installed_script == 'is_binaryen_installed': return is_binaryen_installed(self) else: raise Exception('Unknown custom_is_installed_script directive "' + self.custom_is_installed_script + '"!') @@ -1883,9 +1910,7 @@ def install_tool(self): exit_with_error("installation failed!") if hasattr(self, 'custom_install_script'): - if self.custom_install_script == 'emscripten_post_install': - success = emscripten_post_install(self) - elif self.custom_install_script == 'emscripten_npm_install': + if self.custom_install_script == 'emscripten_npm_install': success = emscripten_npm_install(self, self.installation_path()) elif self.custom_install_script in ('build_llvm', 'build_ninja', 'build_ccache'): # 'build_llvm' is a special one that does the download on its @@ -1935,9 +1960,7 @@ def uninstall(self): return print("Uninstalling tool '" + str(self) + "'..") if hasattr(self, 'custom_uninstall_script'): - if self.custom_uninstall_script == 'uninstall_optimizer': - uninstall_optimizer(self) - elif self.custom_uninstall_script == 'uninstall_binaryen': + if self.custom_uninstall_script == 'uninstall_binaryen': uninstall_binaryen(self) else: raise Exception('Unknown custom_uninstall_script directive "' + self.custom_uninstall_script + '"!') @@ -2021,9 +2044,6 @@ def find_latest_hash(): def resolve_sdk_aliases(name, verbose=False): releases_info = load_releases_info() - if name == 'latest' and LINUX and ARCH == 'arm64': - errlog("WARNING: 'latest' on arm64-linux may be slightly behind other architectures") - name = 'latest-arm64-linux' while name in releases_info['aliases']: if verbose: print("Resolving SDK alias '%s' to '%s'" % (name, releases_info['aliases'][name])) @@ -2071,17 +2091,29 @@ def get_emscripten_releases_tot(): arch = '' if ARCH == 'arm64': arch = '-arm64' - for release in recent_releases: - url = emscripten_releases_download_url_template % ( + + def make_url(ext): + return emscripten_releases_download_url_template % ( os_name(), release, arch, - 'tbz2' if not WINDOWS else 'zip' + ext, ) + + for release in recent_releases: + make_url('tar.xz' if not WINDOWS else 'zip') try: - urlopen(url) + urlopen(make_url('tar.xz' if not WINDOWS else 'zip')) except: - continue + if not WINDOWS: + # Try the old `.tbz2` name + # TODO:remove this once tot builds are all using xz + try: + urlopen(make_url('tbz2')) + except: + continue + else: + continue return release exit_with_error('failed to find build of any recent emsdk revision') @@ -2381,7 +2413,7 @@ def set_active_tools(tools_to_activate, permanently_activate, system): print('Setting the following tools as active:\n ' + '\n '.join(map(lambda x: str(x), tools))) print('') - generate_em_config(tools_to_activate) + generate_em_config(tools_to_activate, permanently_activate, system) # Construct a .bat or .ps1 script that will be invoked to set env. vars and PATH # We only do this on cmd or powershell since emsdk.bat/ps1 is able to modify the @@ -2499,39 +2531,38 @@ def get_env_vars_to_add(tools_to_activate, system, user): env_vars_to_add += [('EMSDK', EMSDK_PATH)] for tool in tools_to_activate: - config = tool.activated_config() - if 'EMSCRIPTEN_ROOT' in config: - # For older emscripten versions that don't use an embedded cache by - # default we need to export EM_CACHE. - # - # Sadly, we can't put this in the config file since those older versions - # also didn't read the `CACHE` key from the config file: - # - # History: - # - 'CACHE' config started being honored in 1.39.16 - # https://github.com/emscripten-core/emscripten/pull/11091 - # - Default to embedded cache also started in 1.39.16 - # https://github.com/emscripten-core/emscripten/pull/11126 - # - Emscripten supports automatically locating the embedded - # config in 1.39.13: - # https://github.com/emscripten-core/emscripten/pull/10935 - # - # Since setting EM_CACHE in the environment effects the entire machine - # we want to avoid this except when installing these older emscripten - # versions that really need it. - version = parse_emscripten_version(config['EMSCRIPTEN_ROOT']) - if version < [1, 39, 16]: - em_cache_dir = os.path.join(config['EMSCRIPTEN_ROOT'], 'cache') - env_vars_to_add += [('EM_CACHE', em_cache_dir)] - if version < [1, 39, 13]: - env_vars_to_add += [('EM_CONFIG', os.path.normpath(EM_CONFIG_PATH))] - - envs = tool.activated_environment() - for env in envs: + for env in tool.activated_environment(): key, value = parse_key_value(env) value = to_native_path(tool.expand_vars(value)) env_vars_to_add += [(key, value)] + emroot = find_emscripten_root(tools_to_activate) + if emroot: + # For older emscripten versions that don't use an embedded cache by + # default we need to export EM_CACHE. + # + # Sadly, we can't put this in the config file since those older versions + # also didn't read the `CACHE` key from the config file: + # + # History: + # - 'CACHE' config started being honored in 1.39.16 + # https://github.com/emscripten-core/emscripten/pull/11091 + # - Default to embedded cache also started in 1.39.16 + # https://github.com/emscripten-core/emscripten/pull/11126 + # - Emscripten supports automatically locating the embedded + # config in 1.39.13: + # https://github.com/emscripten-core/emscripten/pull/10935 + # + # Since setting EM_CACHE in the environment effects the entire machine + # we want to avoid this except when installing these older emscripten + # versions that really need it. + version = parse_emscripten_version(emroot) + if version < [1, 39, 16]: + em_cache_dir = os.path.join(emroot, 'cache') + env_vars_to_add += [('EM_CACHE', em_cache_dir)] + if version < [1, 39, 13]: + env_vars_to_add += [('EM_CONFIG', os.path.normpath(EM_CONFIG_PATH))] + return env_vars_to_add @@ -2656,6 +2687,7 @@ def main(args): errlog("Missing command; Type 'emsdk help' to get a list of commands.") return 1 + debug_print('esmdk.py running under `%s`' % sys.executable) cmd = args.pop(0) if cmd in ('help', '--help', '-h'): @@ -3008,13 +3040,12 @@ def print_tools(t): print('') tools_to_activate = currently_active_tools() - args = [x for x in args if not x.startswith('--')] for arg in args: tool = find_tool(arg) if tool is None: tool = find_sdk(arg) - if tool is None: - error_on_missing_tool(arg) + if tool is None: + error_on_missing_tool(arg) tools_to_activate += [tool] if not tools_to_activate: errlog('No tools/SDKs specified to activate! Usage:\n emsdk activate tool/sdk1 [tool/sdk2] [...]') @@ -3084,4 +3115,8 @@ def print_tools(t): if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) + try: + sys.exit(main(sys.argv[1:])) + except KeyboardInterrupt: + exit_with_error('aborted by user, exiting') + sys.exit(1) diff --git a/emsdk_manifest.json b/emsdk_manifest.json index 1fb2ca26a8..6af26c2c7f 100644 --- a/emsdk_manifest.json +++ b/emsdk_manifest.json @@ -34,8 +34,8 @@ "version": "%releases-tag%", "bitness": 64, "arch": "x86_64", - "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tbz2", - "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tbz2", + "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tar.xz", + "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tar.xz", "windows_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/%releases-tag%/wasm-binaries.zip", "download_prefix": "%releases-tag%-", "install_path": "upstream", @@ -48,8 +48,8 @@ "version": "%releases-tag%", "bitness": 64, "arch": "arm64", - "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tbz2", - "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tbz2", + "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tar.xz", + "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tar.xz", "download_prefix": "%releases-tag%-", "install_path": "upstream", "activated_path": "%installation_dir%/emscripten", @@ -346,6 +346,54 @@ "activated_env": "EMSDK_NODE=%installation_dir%/bin/node%.exe%" }, + { + "id": "node", + "version": "18.20.3", + "bitness": 32, + "arch": "x86", + "windows_url": "node-v18.20.3-win-x86.zip", + "activated_path": "%installation_dir%/bin", + "activated_path_skip": "node", + "activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'", + "activated_env": "EMSDK_NODE=%installation_dir%/bin/node%.exe%" + }, + { + "id": "node", + "version": "18.20.3", + "arch": "arm", + "bitness": 32, + "linux_url": "node-v18.20.3-linux-armv7l.tar.xz", + "activated_path": "%installation_dir%/bin", + "activated_path_skip": "node", + "activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'", + "activated_env": "EMSDK_NODE=%installation_dir%/bin/node%.exe%" + }, + { + "id": "node", + "version": "18.20.3", + "bitness": 64, + "arch": "x86_64", + "macos_url": "node-v18.20.3-darwin-x64.tar.gz", + "windows_url": "node-v18.20.3-win-x64.zip", + "linux_url": "node-v18.20.3-linux-x64.tar.xz", + "activated_path": "%installation_dir%/bin", + "activated_path_skip": "node", + "activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'", + "activated_env": "EMSDK_NODE=%installation_dir%/bin/node%.exe%" + }, + { + "id": "node", + "version": "18.20.3", + "arch": "arm64", + "bitness": 64, + "macos_url": "node-v18.20.3-darwin-arm64.tar.gz", + "linux_url": "node-v18.20.3-linux-arm64.tar.xz", + "activated_path": "%installation_dir%/bin", + "activated_path_skip": "node", + "activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'", + "activated_env": "EMSDK_NODE=%installation_dir%/bin/node%.exe%" + }, + { "id": "python", @@ -479,13 +527,10 @@ "windows_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.zip", "unix_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.tar.gz", "download_prefix": "emscripten-e", - "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%';EMSCRIPTEN_NATIVE_OPTIMIZER='%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%'", + "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%'", "activated_path": "%installation_dir%", - "activated_env": "EMSCRIPTEN=%installation_dir%;EMSCRIPTEN_NATIVE_OPTIMIZER=%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%", - "cmake_build_type": "Release", - "custom_install_script": "emscripten_post_install", - "custom_is_installed_script": "is_optimizer_installed", - "custom_uninstall_script": "uninstall_optimizer" + "activated_env": "EMSCRIPTEN=%installation_dir%", + "custom_install_script": "emscripten_npm_install" }, { "id": "emscripten", @@ -494,13 +539,10 @@ "append_bitness": false, "windows_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.zip", "unix_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.tar.gz", - "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%';EMSCRIPTEN_NATIVE_OPTIMIZER='%installation_dir%%generator_prefix%_64bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%'", + "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%'", "activated_path": "%installation_dir%", - "activated_env": "EMSCRIPTEN=%installation_dir%;EMSCRIPTEN_NATIVE_OPTIMIZER=%installation_dir%%generator_prefix%_64bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%", - "cmake_build_type": "Release", - "custom_install_script": "emscripten_post_install", - "custom_is_installed_script": "is_optimizer_installed", - "custom_uninstall_script": "uninstall_optimizer" + "activated_env": "EMSCRIPTEN=%installation_dir%", + "custom_install_script": "emscripten_npm_install" }, { "id": "emscripten", @@ -650,19 +692,19 @@ { "version": "main", "bitness": 64, - "uses": ["python-3.9.2-nuget-64bit", "llvm-git-main-64bit", "node-16.20.0-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], + "uses": ["python-3.9.2-nuget-64bit", "llvm-git-main-64bit", "node-18.20.3-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], "os": "win" }, { "version": "main", "bitness": 64, - "uses": ["python-3.9.2-64bit", "llvm-git-main-64bit", "node-16.20.0-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], + "uses": ["python-3.9.2-64bit", "llvm-git-main-64bit", "node-18.20.3-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], "os": "macos" }, { "version": "main", "bitness": 64, - "uses": ["llvm-git-main-64bit", "node-16.20.0-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], + "uses": ["llvm-git-main-64bit", "node-18.20.3-64bit", "emscripten-main-64bit", "binaryen-main-64bit"], "os": "linux" }, { @@ -674,14 +716,14 @@ { "version": "releases-%releases-tag%", "bitness": 64, - "uses": ["node-16.20.0-64bit", "releases-%releases-tag%-64bit"], + "uses": ["node-18.20.3-64bit", "releases-%releases-tag%-64bit"], "os": "linux", "custom_install_script": "emscripten_npm_install" }, { "version": "releases-%releases-tag%", "bitness": 64, - "uses": ["node-16.20.0-64bit", "python-3.9.2-64bit", "releases-%releases-tag%-64bit"], + "uses": ["node-18.20.3-64bit", "python-3.9.2-64bit", "releases-%releases-tag%-64bit"], "os": "macos", "arch": "x86_64", "custom_install_script": "emscripten_npm_install" @@ -689,7 +731,7 @@ { "version": "releases-%releases-tag%", "bitness": 64, - "uses": ["node-16.20.0-64bit", "python-3.9.2-64bit", "releases-%releases-tag%-64bit"], + "uses": ["node-18.20.3-64bit", "python-3.9.2-64bit", "releases-%releases-tag%-64bit"], "os": "macos", "arch": "arm64", "custom_install_script": "emscripten_npm_install" @@ -697,7 +739,7 @@ { "version": "releases-%releases-tag%", "bitness": 64, - "uses": ["node-16.20.0-64bit", "python-3.9.2-nuget-64bit", "java-8.152-64bit", "releases-%releases-tag%-64bit"], + "uses": ["node-18.20.3-64bit", "python-3.9.2-nuget-64bit", "java-8.152-64bit", "releases-%releases-tag%-64bit"], "os": "win", "custom_install_script": "emscripten_npm_install" } diff --git a/scripts/create_release.py b/scripts/create_release.py index 418dcabae0..2d6d312771 100755 --- a/scripts/create_release.py +++ b/scripts/create_release.py @@ -53,7 +53,9 @@ def main(args): f.write(json.dumps(release_info, indent=2)) f.write('\n') - subprocess.check_call([os.path.join(script_dir, 'update_bazel_workspace.sh')], cwd=root_dir) + subprocess.check_call( + [sys.executable, os.path.join(script_dir, 'update_bazel_workspace.py')], + cwd=root_dir) branch_name = 'version_' + new_version diff --git a/scripts/get_release_info.py b/scripts/get_release_info.py new file mode 100755 index 0000000000..01044cad94 --- /dev/null +++ b/scripts/get_release_info.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import json +import os +import sys + +def get_latest(tagfile): + with open(tagfile) as f: + versions = json.load(f) + print(versions['aliases']['latest']) + return 0 + + +def get_hash(tagfile, version): + with open(tagfile) as f: + versions = json.load(f) + print(versions['releases'][version]) + return 0 + + +if __name__ == '__main__': + if sys.argv[2] == 'latest': + sys.exit(get_latest(sys.argv[1])) + if sys.argv[2] == 'hash': + sys.exit(get_hash(sys.argv[1], sys.argv[3])) diff --git a/scripts/update_bazel_workspace.py b/scripts/update_bazel_workspace.py new file mode 100755 index 0000000000..874b49b8a2 --- /dev/null +++ b/scripts/update_bazel_workspace.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +# This script will update emsdk/bazel/revisons.bzl to the latest version of +# emscripten. It reads emsdk/emscripten-releases-tags.json to get the latest +# version number. Then, it downloads the prebuilts for that version and computes +# the sha256sum for the archive. It then puts all this information into the +# emsdk/bazel/revisions.bzl file. + +import hashlib +import json +import os +import requests +import sys + +STORAGE_URL = 'https://storage.googleapis.com/webassembly/emscripten-releases-builds' + +EMSDK_ROOT = os.path.dirname(os.path.dirname(__file__)) +RELEASES_TAGS_FILE = EMSDK_ROOT + '/emscripten-releases-tags.json' +BAZEL_REVISIONS_FILE = EMSDK_ROOT + '/bazel/revisions.bzl' + + +def get_latest_info(): + with open(RELEASES_TAGS_FILE) as f: + info = json.load(f) + latest = info['aliases']['latest'] + return latest, info['releases'][latest] + + +def get_sha(platform, archive_fmt, latest_hash, arch_suffix=''): + r = requests.get(f'{STORAGE_URL}/{platform}/{latest_hash}/wasm-binaries{arch_suffix}.{archive_fmt}') + r.raise_for_status() + print(f'Fetching {r.url}') + h = hashlib.new('sha256') + for chunk in r.iter_content(chunk_size=1024): + h.update(chunk) + return h.hexdigest() + + +def revisions_item(version, latest_hash): + return f'''\ + "{version}": struct( + hash = "{latest_hash}", + sha_linux = "{get_sha('linux', 'tar.xz', latest_hash)}", + sha_mac = "{get_sha('mac', 'tar.xz', latest_hash)}", + sha_mac_arm64 = "{get_sha('mac', 'tar.xz', latest_hash, '-arm64')}", + sha_win = "{get_sha('win', 'zip', latest_hash)}", + ), +''' + + +def insert_revision(item): + with open(BAZEL_REVISIONS_FILE, 'r') as f: + lines = f.readlines() + + lines.insert(lines.index('EMSCRIPTEN_TAGS = {\n') + 1, item) + + with open(BAZEL_REVISIONS_FILE, 'w') as f: + f.write(''.join(lines)) + + +def main(argv): + version, latest_hash = get_latest_info() + item = revisions_item(version, latest_hash) + print('inserting item:') + print(item) + insert_revision(item) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/scripts/update_bazel_workspace.sh b/scripts/update_bazel_workspace.sh deleted file mode 100755 index b2f707892d..0000000000 --- a/scripts/update_bazel_workspace.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# This script will update emsdk/bazel/WORKSPACE to the latest version of -# emscripten. It reads emsdk/emscripten-releases-tags.json to get the latest -# version number. Then, it downloads the prebuilts for that version and computes -# the sha256sum for the archive. It then puts all this information into the -# emsdk/bazel/WORKSPACE file. - -ERR=0 -# Attempt to change to the emsdk root directory -cd $(dirname $0)/.. - -# If the previous command succeeded. We are in the emsdk root. Check to make -# sure the files and directories we need are present. -if [[ $? = 0 ]]; then - if [[ ! -f emscripten-releases-tags.json ]]; then - echo "Cannot find emscripten-releases-tags.json." - ERR=1 - fi - - if [[ ! -d bazel ]]; then - echo "Cannot find the bazel directory." - ERR=1 - elif [[ ! -f bazel/WORKSPACE ]]; then - echo "Cannot find bazel/WORKSPACE." - ERR=1 - fi -else - ERR=1 -fi - -if [[ $ERR = 1 ]]; then - echo "Unable to cd into the emsdk root directory." - exit 1 -fi - -URL1=https://storage.googleapis.com/webassembly/emscripten-releases-builds/ -URL2=/wasm-binaries - -# Get commit hash for $1 version -get_hash () { - echo $(grep "$1" emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\") -} - -# Get sha256 for $1 os $2 extname $3 hash $4 architecture -get_sha () { - echo $(curl "${URL1}$1/$3${URL2}$4.$2" 2>/dev/null | sha256sum | awk '{print $1}') -} - -# Assemble dictionary line -revisions_item () { - hash=$(get_hash $1) - echo \ - "\ \"$1\": struct(\n" \ - "\ hash = \"$(get_hash ${hash})\",\n" \ - "\ sha_linux = \"$(get_sha linux tbz2 ${hash})\",\n" \ - "\ sha_mac = \"$(get_sha mac tbz2 ${hash})\",\n" \ - "\ sha_mac_arm64 = \"$(get_sha mac tbz2 ${hash} -arm64)\",\n" \ - "\ sha_win = \"$(get_sha win zip ${hash})\",\n" \ - "\ )," -} - -append_revision () { - sed -i "5 i $(revisions_item $1)" bazel/revisions.bzl -} - -# Get the latest version number from emscripten-releases-tag.json. -VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ - | sed --expression "s/\./\\\./g") - -append_revision ${VER} - -echo "Done!" diff --git a/scripts/update_node.py b/scripts/update_node.py index 2c3a786d33..b16d3e5b1f 100755 --- a/scripts/update_node.py +++ b/scripts/update_node.py @@ -16,8 +16,8 @@ import os import shutil -version = '16.20.0' -base = 'https://nodejs.org/dist/latest-v16.x/' +version = '18.20.3' +base = 'https://nodejs.org/dist/latest-v18.x/' upload_base = 'gs://webassembly/emscripten-releases-builds/deps/' suffixes = [ diff --git a/test/test.py b/test/test.py index 1b1233c613..ce98b9e06f 100755 --- a/test/test.py +++ b/test/test.py @@ -270,9 +270,9 @@ def test_keep_downloads(self): # install of 2.0.28, and again when we install 2.0.29, but not on the # second install of 2.0.28 because the zip should already be local. shutil.rmtree('downloads') - checked_call_with_output(emsdk + ' install 2.0.28', expected='Downloading:', env=env) - checked_call_with_output(emsdk + ' install 2.0.29', expected='Downloading:', env=env) - checked_call_with_output(emsdk + ' install 2.0.28', expected='already downloaded, skipping', unexpected='Downloading:', env=env) + checked_call_with_output(emsdk + ' install 3.1.54', expected='Downloading:', env=env) + checked_call_with_output(emsdk + ' install 3.1.55', expected='Downloading:', env=env) + checked_call_with_output(emsdk + ' install 3.1.54', expected='already downloaded, skipping', unexpected='Downloading:', env=env) if __name__ == '__main__': diff --git a/test/test_activation.ps1 b/test/test_activation.ps1 index 6aeb5e53a9..fdab08fb45 100644 --- a/test/test_activation.ps1 +++ b/test/test_activation.ps1 @@ -15,8 +15,7 @@ try { & "$repo_root/emsdk.ps1" install latest - $esc = '--%' - & "$repo_root/emsdk.ps1" activate latest $esc $env:PERMANENT_FLAG $env:SYSTEM_FLAG + & "$repo_root/emsdk.ps1" activate latest $env:PERMANENT_FLAG $env:SYSTEM_FLAG if ($env:SYSTEM_FLAG) { $env_type = "Machine" diff --git a/test/test_bazel.ps1 b/test/test_bazel.ps1 index 3fd269c153..5c20a15251 100644 --- a/test/test_bazel.ps1 +++ b/test/test_bazel.ps1 @@ -13,9 +13,18 @@ Set-Location test_external bazel build //:hello-world-wasm if (-not $?) { Exit $LastExitCode } +bazel build //long_command_line:long_command_line_wasm +if (-not $?) { Exit $LastExitCode } + bazel build //:hello-embind-wasm --compilation_mode dbg # debug if (-not $?) { Exit $LastExitCode } # Test use of the closure compiler bazel build //:hello-embind-wasm --compilation_mode opt # release if (-not $?) { Exit $LastExitCode } + +Set-Location ..\test_secondary_lto_cache + +bazel build //:hello-world-wasm +if (-not $?) { Exit $LastExitCode } + diff --git a/test/test_bazel.sh b/test/test_bazel.sh index f52daa4473..b99a029896 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -6,15 +6,12 @@ set -x set -e # Get the latest version number from emscripten-releases-tag.json. -VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ - | sed --expression "s/\./\\\./g") +VER=$(scripts/get_release_info.py emscripten-releases-tags.json latest) + # Based on the latest version number, get the commit hash for that version. -HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ - | grep -v latest \ - | cut -f4 -d\") +HASH=$(scripts/get_release_info.py emscripten-releases-tags.json hash ${VER}) -FAILMSG="!!! scripts/update_bazel_toolchain.sh needs to be run !!!" +FAILMSG="!!! scripts/update_bazel_workspace.py needs to be run !!!" # Ensure the WORKSPACE file is up to date with the latest version. grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false) @@ -26,9 +23,14 @@ bazel build //hello-world:hello-world-wasm-simd cd test_external bazel build //:hello-world-wasm +bazel build //long_command_line:long_command_line_wasm bazel build //:hello-embind-wasm --compilation_mode dbg # debug # Test use of the closure compiler bazel build //:hello-embind-wasm --compilation_mode opt # release # This function should not be minified if the externs file is loaded correctly. -grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js \ No newline at end of file +grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js + +cd ../test_secondary_lto_cache +bazel build //:hello-world-wasm + diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh index 0a26a0c245..2b596ee4f7 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -6,15 +6,12 @@ set -x set -e # Get the latest version number from emscripten-releases-tag.json. -VER=$(ggrep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ - | sed "s/\./\\\./g") +VER=$(scripts/get_release_info.py emscripten-releases-tags.json latest) + # Based on the latest version number, get the commit hash for that version. -HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ - | grep -v latest \ - | cut -f4 -d\") +HASH=$(scripts/get_release_info.py emscripten-releases-tags.json hash ${VER}) -FAILMSG="!!! scripts/update_bazel_toolchain.sh needs to be run !!!" +FAILMSG="!!! scripts/update_bazel_workspace.py needs to be run !!!" # Ensure the WORKSPACE file is up to date with the latest version. grep ${VER} bazel/revisions.bzl || (echo ${FAILMSG} && false) @@ -25,4 +22,9 @@ bazel build //hello-world:hello-world-wasm bazel build //hello-world:hello-world-wasm-simd cd test_external +bazel build //long_command_line:long_command_line_wasm +bazel build //:hello-world-wasm + +cd ../test_secondary_lto_cache bazel build //:hello-world-wasm +