From a896e3d066448b3530dbcaa48869fafefd738f57 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 25 Jul 2023 07:50:22 -0700 Subject: [PATCH 01/68] 3.1.44 (#1260) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 571656ca97..32fbcdc013 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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/emscripten-releases-tags.json b/emscripten-releases-tags.json index ec1f9fd945..bf88f62d32 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.43", + "latest": "3.1.44", "latest-sdk": "latest", "latest-arm64-linux": "3.1.43", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.44": "b90507fcf011da61bacfca613569d882f7749552", + "3.1.44-asserts": "06d00b0c62e435b743aa37c67b4ab76bc8568c79", "3.1.43": "bf3c159888633d232c0507f4c76cc156a43c32dc", "3.1.43-asserts": "3ec53a819a5958665d6bb0ac895c99546921b6ef", "3.1.42": "9d73bf4bd5b5c9ce6e51be0ed5ce6599fcb28e9e", From ef2a8e929d5337755e9b1d1e1d4ad859dc694eee Mon Sep 17 00:00:00 2001 From: martijneken Date: Fri, 28 Jul 2023 17:08:04 -0400 Subject: [PATCH 02/68] wasm_cc_binary: Specify a default OS. Allow users to override platform. (#1262) * wasm_cc_binary: Specify a default OS. Allow users to override platform. Problem: https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/pull/157#discussion_r1277763118 This is solving the problem in two different ways. Please let me know your thoughts about both approaches, as either will work. Signed-off-by: Martijn Stevenson * Rework platform selection to trigger os:wasi off standalone attr Signed-off-by: Martijn Stevenson --------- Signed-off-by: Martijn Stevenson --- bazel/BUILD | 8 ++++++++ bazel/emscripten_toolchain/wasm_cc_binary.bzl | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bazel/BUILD b/bazel/BUILD index bce4adeebf..e67311d074 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -84,3 +84,11 @@ platform( "@platforms//cpu:wasm32", ], ) + +platform( + name = "platform_wasi", + constraint_values = [ + "@platforms//cpu:wasm32", + "@platforms//os:wasi", + ], +) diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl index 416ccae08b..fe77e175b7 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", } From 350c19a36c3356b3202c108a68a20cd102bdc06b Mon Sep 17 00:00:00 2001 From: Matthew Soulanille Date: Tue, 8 Aug 2023 13:14:50 -0700 Subject: [PATCH 03/68] Add starlark highlighting to Bazel readme (#1264) Mark the build files as using the starlark language so they have the correct syntax highlighting. --- bazel/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index 877f2e073d..69a802146b 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", @@ -37,7 +37,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") From c8dcb45665fec5e743336703f1d22a191810f2a8 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 23 Aug 2023 10:27:26 -0700 Subject: [PATCH 04/68] 3.1.45 (#1269) Also update emscripten include dir to v18, and change 17 to wildcard in emscripten deps --- bazel/emscripten_deps.bzl | 2 +- bazel/emscripten_toolchain/toolchain.bzl | 4 ++-- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 219cd93f12..de156c74b0 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -14,7 +14,7 @@ filegroup( "emscripten/cache/sysroot/include/c++/v1/**", "emscripten/cache/sysroot/include/compat/**", "emscripten/cache/sysroot/include/**", - "lib/clang/17/include/**", + "lib/clang/**/include/**", ]), ) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index f1ea1c819e..e92a61257f 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -914,7 +914,7 @@ def _impl(ctx): "-iwithsysroot" + "/include/compat", "-iwithsysroot" + "/include", "-isystem", - emscripten_dir + "/lib/clang/17/include", + emscripten_dir + "/lib/clang/18/include", ], ), # Inputs and outputs @@ -1081,7 +1081,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/18/include", ] artifact_name_patterns = [] diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 32fbcdc013..6145db8a10 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index bf88f62d32..b11ef78a57 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.44", + "latest": "3.1.45", "latest-sdk": "latest", "latest-arm64-linux": "3.1.43", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.45": "2b7c5fb8ffeac3315deb1f82ab7bf8da544f84a1", + "3.1.45-asserts": "2aec03dfd8ce68c95316116dafbe30e273f32a81", "3.1.44": "b90507fcf011da61bacfca613569d882f7749552", "3.1.44-asserts": "06d00b0c62e435b743aa37c67b4ab76bc8568c79", "3.1.43": "bf3c159888633d232c0507f4c76cc156a43c32dc", From 2d22a55df8df049da6530544b7bf9c6c19225136 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 23 Aug 2023 13:43:33 -0700 Subject: [PATCH 05/68] Update linux arm64 build. NFC (#1270) --- emscripten-releases-tags.json | 2 +- scripts/update_linux_arm64.sh | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 scripts/update_linux_arm64.sh diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index b11ef78a57..ccae170967 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -2,7 +2,7 @@ "aliases": { "latest": "3.1.45", "latest-sdk": "latest", - "latest-arm64-linux": "3.1.43", + "latest-arm64-linux": "3.1.45", "latest-64bit": "latest", "sdk-latest-64bit": "latest", "latest-upstream": "latest", diff --git a/scripts/update_linux_arm64.sh b/scripts/update_linux_arm64.sh new file mode 100755 index 0000000000..bddef745db --- /dev/null +++ b/scripts/update_linux_arm64.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Script for updating the linux-arm64 release +# +# Takes as stdin the JSON string generated by the S3 bucket update when +# amazon produces a new build. e.g. +# {"Records":[{"eventVersion":"2.1","eventSource":"aws:s3","awsRegion":"us-west-2","eventTime":"2023-08-23T19:12:29.218Z","eventName":"ObjectCreated:CompleteMultipartUpload","userIdentity":{"principalId":"AWS:AROAZNAVTCTIWSHR6WFTE:i-0124c978819146a2f"},"requestParameters":{"sourceIPAddress":"35.90.239.236"},"responseElements":{"x-amz-request-id":"3SDMWYMG4BN47DCD","x-amz-id-2":"0mRaqwIIZI8ob1B7TmTSd/s0lXxST73ktgGm94MjKj2bnflqD1zCjbh2LeMIYYPvvfgQu0Ocrlev4nYmiOmS9wR0M/lvpCQz"},"s3":{"s3SchemaVersion":"1.0","configurationId":"arn:aws:cloudformation:us-west-2:646437868753:stack/EmscriptenArm64BuilderStack/eb5d5760-ee9a-11ec-a790-06738944b93b--3752220361625282518","bucket":{"name":"emscripten-arm64-4484191c","ownerIdentity":{"principalId":"A2IEUDOSUKZVHO"},"arn":"arn:aws:s3:::emscripten-arm64-4484191c"},"object":{"key":"emscripten-install-3.1.45-linux-arm64.tbz2","size":247058408,"eTag":"bb7f6835c7900deee6e7881a352ab48c-30","sequencer":"0064E65A1BC2C23A2E"}}}]} + +set -e + +if [ $# -ne 1 ]; then + echo "Please specify a single argument which is an emsdk version (e.g. 3.1.45)" + exit +fi + +VERSION=$1 +SHA=$(jq -r ".releases.\"${VERSION}\"" emscripten-releases-tags.json) +URL=$(jq -r '.Records[0] | "https://\(.s3.bucket.name).s3.\(.awsRegion).amazonaws.com/\(.s3.object.key)"') + +wget $URL -O arm64.tbz2 +gsutil cp -n arm64.tbz2 gs://webassembly/emscripten-releases-builds/linux/${SHA}/wasm-binaries-arm64.tbz2 +sed -i "s/\"latest-arm64-linux\": \".*\"/\"latest-arm64-linux\": \"$VERSION\"/" emscripten-releases-tags.json + +echo "done" From 5d347a69dc57af7f960558434ae2419dd040ba8e Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 24 Aug 2023 09:17:36 -0700 Subject: [PATCH 06/68] Fix the format of the .flake8 file, and exclude the script directory from the py2 linter (#1272) Flake8's INI config file format requires commas after each line. Because our file didn't have them, the exclude list wasn't set up correctly, and the --extend-exclude flag wasn't working. This PR fixes the .flake8 file. Also, update flake8 to the latest version available (because version 3.8 is required to get the --extend-exclude flag) and use the flag to exclude the files in the scripts/ directory from the python2 linter (since the scripts are python3). --- .circleci/config.yml | 6 +++--- .flake8 | 31 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c4d2734a2b..bc573c1503 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,9 +60,9 @@ jobs: apt-get install -q -y python-pip python3-pip - run: python2 -m pip install --upgrade 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: python2 -m pip install flake8==3.9.2 + - run: python3 -m pip install flake8==3.9.2 + - run: python2 -m flake8 --show-source --statistics --extend-exclude=./scripts - run: python3 -m flake8 --show-source --statistics test-linux: executor: bionic 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, From 3391e039d6bd3c93eae3315a111b98261a8a7a4e Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 24 Aug 2023 10:10:29 -0700 Subject: [PATCH 07/68] Replace update_bazel_workspace.sh with a python script (#1271) This script is (IMO) more readable, but the real reason for this change is that it raises an error message when the binary package fails to download. (The shell script silently generated a bogus hash instead, because the shell's `set -e` builtin does not affect commands executing inside a $() context. It seemed just as easy to rewrite the script in Python as to fix that. This change also updates some outdated filename references. --- bazel/revisions.bzl | 2 +- scripts/create_release.py | 4 +- scripts/update_bazel_workspace.py | 69 +++++++++++++++++++++++++++++ scripts/update_bazel_workspace.sh | 73 ------------------------------- test/test_bazel.sh | 2 +- test/test_bazel_mac.sh | 2 +- 6 files changed, 75 insertions(+), 77 deletions(-) create mode 100755 scripts/update_bazel_workspace.py delete mode 100755 scripts/update_bazel_workspace.sh diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 6145db8a10..f944578992 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -1,4 +1,4 @@ -# 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 = { 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/update_bazel_workspace.py b/scripts/update_bazel_workspace.py new file mode 100755 index 0000000000..932cc72e35 --- /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', 'tbz2', latest_hash)}", + sha_mac = "{get_sha('mac', 'tbz2', latest_hash)}", + sha_mac_arm64 = "{get_sha('mac', 'tbz2', 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/test/test_bazel.sh b/test/test_bazel.sh index f52daa4473..bc53fcd829 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -14,7 +14,7 @@ HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ | grep -v latest \ | cut -f4 -d\") -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) diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh index 0a26a0c245..58aa9f0ad9 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -14,7 +14,7 @@ HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ | grep -v latest \ | cut -f4 -d\") -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) From 9b0db91883452051aca8deddc932363aab29060b Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Tue, 29 Aug 2023 10:21:25 -0400 Subject: [PATCH 08/68] [bazel] populate all_files (#1274) Fixes #1273. This was broken by #1045 with the comment "* all_files not needed?" They were needed. --- bazel/emscripten_toolchain/BUILD.bazel | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index 7b3f16237f..fb8a6c1b2e 100644 --- a/bazel/emscripten_toolchain/BUILD.bazel +++ b/bazel/emscripten_toolchain/BUILD.bazel @@ -43,6 +43,15 @@ filegroup( ], ) +filegroup( + name = "all_files", + srcs = [ + ":ar_files", + ":compiler_files", + ":linker_files", + ], +) + filegroup(name = "empty") # dlmalloc.bc is implictly added by the emscripten toolchain @@ -61,7 +70,7 @@ emscripten_cc_toolchain_config_rule( cc_toolchain( name = "cc-compiler-wasm", - all_files = ":empty", + all_files = ":all_files", ar_files = ":ar_files", as_files = ":empty", compiler_files = ":compiler_files", From 93360d3670018769b424e4e8f1d3d9b26d32c977 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 15 Sep 2023 13:22:46 -0700 Subject: [PATCH 09/68] 3.1.46 (#1279) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index f944578992..a8c43e9194 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index ccae170967..6d3dccdc09 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.45", + "latest": "3.1.46", "latest-sdk": "latest", "latest-arm64-linux": "3.1.45", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.46": "21644188d5c473e92f1d7df2f9f60c758a78a486", + "3.1.46-asserts": "3e09b252d0d5a8e045d2ca92c606bfb9874bddf8", "3.1.45": "2b7c5fb8ffeac3315deb1f82ab7bf8da544f84a1", "3.1.45-asserts": "2aec03dfd8ce68c95316116dafbe30e273f32a81", "3.1.44": "b90507fcf011da61bacfca613569d882f7749552", From d42c740aa51b961d6e18b649754d2cae8807a277 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 21 Sep 2023 15:16:34 -0700 Subject: [PATCH 10/68] Switch to .xz by default for SDK downloads (#1281) This is a bit of a hack but I can't think of another way to do it. Basically when downloading SDKs, we first try the new `.xz` extension. If that fails, we fall back to the old `.tbz2`. Both these first two download attempts we run in "silent" mode. If both of them fail we re-run the original request in non-silent mode so that the error message will always contain the original `.xz` extension. See #1235 --- emsdk.py | 58 +++++++++++++++++++++++++++++++++++---------- emsdk_manifest.json | 8 +++---- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/emsdk.py b/emsdk.py index 52f2f68cc5..f1079dd64d 100644 --- a/emsdk.py +++ b/emsdk.py @@ -672,7 +672,8 @@ def get_download_target(url, dstpath, filename_prefix=''): # 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) @@ -717,9 +718,10 @@ def download_file(url, dstpath, download_even_if_exists=False, filename_prefix=' print(']') sys.stdout.flush() 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.") + if not silent: + 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: @@ -1407,18 +1409,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: @@ -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('tbz2' 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') diff --git a/emsdk_manifest.json b/emsdk_manifest.json index 1fb2ca26a8..623cb47d6c 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", From 8e82384f27f7d448634d3d9a92a5523bca95a965 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Oct 2023 18:54:56 -0700 Subject: [PATCH 11/68] Update file extension used by create_release script (#1285) This should have been part of #1235 --- emsdk.py | 2 +- scripts/update_bazel_workspace.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emsdk.py b/emsdk.py index f1079dd64d..e0e46b9040 100644 --- a/emsdk.py +++ b/emsdk.py @@ -2101,7 +2101,7 @@ def make_url(ext): ) for release in recent_releases: - make_url('tbz2' if not WINDOWS else 'zip') + make_url('tar.xz' if not WINDOWS else 'zip') try: urlopen(make_url('tar.xz' if not WINDOWS else 'zip')) except: diff --git a/scripts/update_bazel_workspace.py b/scripts/update_bazel_workspace.py index 932cc72e35..874b49b8a2 100755 --- a/scripts/update_bazel_workspace.py +++ b/scripts/update_bazel_workspace.py @@ -39,9 +39,9 @@ def revisions_item(version, latest_hash): return f'''\ "{version}": struct( hash = "{latest_hash}", - sha_linux = "{get_sha('linux', 'tbz2', latest_hash)}", - sha_mac = "{get_sha('mac', 'tbz2', latest_hash)}", - sha_mac_arm64 = "{get_sha('mac', 'tbz2', latest_hash, '-arm64')}", + 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)}", ), ''' From 717174835ab8324c48ff73e3cfcd5c5c39deed7c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Oct 2023 19:24:36 -0700 Subject: [PATCH 12/68] Use .tar.xz extension for arm64 linux binary upload (#1287) --- scripts/update_linux_arm64.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/update_linux_arm64.sh b/scripts/update_linux_arm64.sh index bddef745db..4f78effa87 100755 --- a/scripts/update_linux_arm64.sh +++ b/scripts/update_linux_arm64.sh @@ -17,7 +17,9 @@ SHA=$(jq -r ".releases.\"${VERSION}\"" emscripten-releases-tags.json) URL=$(jq -r '.Records[0] | "https://\(.s3.bucket.name).s3.\(.awsRegion).amazonaws.com/\(.s3.object.key)"') wget $URL -O arm64.tbz2 -gsutil cp -n arm64.tbz2 gs://webassembly/emscripten-releases-builds/linux/${SHA}/wasm-binaries-arm64.tbz2 +tar xf arm64.tbz2 +tar --use-compress-program "xz -T0" -cf arm64.tar.xz install/ +gsutil cp -n arm64.tar.xz gs://webassembly/emscripten-releases-builds/linux/${SHA}/wasm-binaries-arm64.tar.xz sed -i "s/\"latest-arm64-linux\": \".*\"/\"latest-arm64-linux\": \"$VERSION\"/" emscripten-releases-tags.json echo "done" From 37b85e9eaee5be090569d018cca77a15cacc11b7 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Oct 2023 19:57:37 -0700 Subject: [PATCH 13/68] 3.1.47 (#1286) --- bazel/emscripten_deps.bzl | 16 ++++++++-------- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index de156c74b0..a42238c70a 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -121,41 +121,41 @@ def emscripten_deps(emscripten_version = "latest"): http_archive( name = "emscripten_bin_linux", strip_prefix = "install", - url = emscripten_url.format("linux", revision.hash, "", "tbz2"), + url = emscripten_url.format("linux", revision.hash, "", "tar.xz"), sha256 = revision.sha_linux, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = "tar.xz", ) 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", "tar.xz"), # 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 = "tar.xz", ) 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, "", "tar.xz"), sha256 = revision.sha_mac, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = "tar.xz", ) 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", "tar.xz"), sha256 = revision.sha_mac_arm64, build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ""), - type = "tar.bz2", + type = "tar.xz", ) if "emscripten_bin_win" not in excludes: diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index a8c43e9194..015eda99cc 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 6d3dccdc09..bf3fce014f 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.46", + "latest": "3.1.47", "latest-sdk": "latest", "latest-arm64-linux": "3.1.45", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.47": "39ade279e75e6d17dd6b7eb9fba2006e61fe966b", + "3.1.47-asserts": "dc49d84ed226a5a30a5117cefc07c781f6c0d16e", "3.1.46": "21644188d5c473e92f1d7df2f9f60c758a78a486", "3.1.46-asserts": "3e09b252d0d5a8e045d2ca92c606bfb9874bddf8", "3.1.45": "2b7c5fb8ffeac3315deb1f82ab7bf8da544f84a1", From 40e9cd8fbc03cf3c4041d965d9a05b843996b479 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Oct 2023 23:30:01 -0700 Subject: [PATCH 14/68] Update linux arm64 to 3.1.47 (#1288) --- emscripten-releases-tags.json | 2 +- scripts/update_linux_arm64.sh | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index bf3fce014f..8ad4d443cc 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -2,7 +2,7 @@ "aliases": { "latest": "3.1.47", "latest-sdk": "latest", - "latest-arm64-linux": "3.1.45", + "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", "sdk-latest-64bit": "latest", "latest-upstream": "latest", diff --git a/scripts/update_linux_arm64.sh b/scripts/update_linux_arm64.sh index 4f78effa87..097700c751 100755 --- a/scripts/update_linux_arm64.sh +++ b/scripts/update_linux_arm64.sh @@ -16,9 +16,7 @@ VERSION=$1 SHA=$(jq -r ".releases.\"${VERSION}\"" emscripten-releases-tags.json) URL=$(jq -r '.Records[0] | "https://\(.s3.bucket.name).s3.\(.awsRegion).amazonaws.com/\(.s3.object.key)"') -wget $URL -O arm64.tbz2 -tar xf arm64.tbz2 -tar --use-compress-program "xz -T0" -cf arm64.tar.xz install/ +wget $URL -O arm64.tar.xz gsutil cp -n arm64.tar.xz gs://webassembly/emscripten-releases-builds/linux/${SHA}/wasm-binaries-arm64.tar.xz sed -i "s/\"latest-arm64-linux\": \".*\"/\"latest-arm64-linux\": \"$VERSION\"/" emscripten-releases-tags.json From 34e6772389adbcf83b96278e517b08981519eca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Ol=C3=A1h?= Date: Mon, 30 Oct 2023 20:34:41 +0100 Subject: [PATCH 15/68] [Bazel] Add an :all target (#1295) Having an :all target is the most future-proof way here. Closes #1294. --- bazel/emscripten_deps.bzl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index a42238c70a..0e9a321c38 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -8,6 +8,11 @@ def _parse_version(v): BUILD_FILE_CONTENT_TEMPLATE = """ package(default_visibility = ['//visibility:public']) +filegroup( + name = "all", + srcs = glob(["**"]), +) + filegroup( name = "includes", srcs = glob([ From f677ef915645c09794f0ae88f21d3cba2886459f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 5 Nov 2023 17:05:00 -0800 Subject: [PATCH 16/68] 3.1.48 (#1297) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 015eda99cc..aa984505ed 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 8ad4d443cc..e3947521d1 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.47", + "latest": "3.1.48", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.48": "694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc", + "3.1.48-asserts": "6e2b8a97c6db82089c3a405bc88ea9fb125deb16", "3.1.47": "39ade279e75e6d17dd6b7eb9fba2006e61fe966b", "3.1.47-asserts": "dc49d84ed226a5a30a5117cefc07c781f6c0d16e", "3.1.46": "21644188d5c473e92f1d7df2f9f60c758a78a486", From bfda0d0756751114dbab597396e67dcaa63bb331 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 14 Nov 2023 09:35:29 -0800 Subject: [PATCH 17/68] 3.1.49 (#1300) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index aa984505ed..80c775fe77 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index e3947521d1..e5338917da 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.48", + "latest": "3.1.49", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.49": "bd0a2e230466dadb36efc71aa7271f17c6c35420", + "3.1.49-asserts": "4ea035c5bbd6168dae34c970b5f56d7aa4dcf952", "3.1.48": "694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc", "3.1.48-asserts": "6e2b8a97c6db82089c3a405bc88ea9fb125deb16", "3.1.47": "39ade279e75e6d17dd6b7eb9fba2006e61fe966b", From 88c2c9595500de8c64699152fb4da3609aac159f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20K=C3=A4lberer?= Date: Tue, 28 Nov 2023 18:46:12 +0100 Subject: [PATCH 18/68] Fix spelling in README.md (#1305) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3ad91f3efc..8e1c99bb3d 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/Xenial 16.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. From e2627e265d940db5ea58dffa63e490375bfc92e5 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Wed, 29 Nov 2023 22:35:48 -0800 Subject: [PATCH 19/68] 3.1.50 (#1306) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 80c775fe77..ab6fcafd3f 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index e5338917da..097d45b22f 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.49", + "latest": "3.1.50", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.50": "2ce4170cef5ce46f337f9fd907b614a8db772c7d", + "3.1.50-asserts": "0a6fe6ef5880bf5b035d396f3875fda9b7c4bb60", "3.1.49": "bd0a2e230466dadb36efc71aa7271f17c6c35420", "3.1.49-asserts": "4ea035c5bbd6168dae34c970b5f56d7aa4dcf952", "3.1.48": "694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc", From b54a6b662f3fc5637aa2b894a35663346d111637 Mon Sep 17 00:00:00 2001 From: Jamie <5964236+jamsinclair@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:11:09 +0900 Subject: [PATCH 20/68] Auto-publish Arm64 images when emscripten-releases-tags.json is updated (#1231) Add job to conditionally build arm64 images when emscripten-releases-tags.json updated --- .circleci/config.yml | 61 ++++++++++++++++++++++++++++++++++++++++---- docker/Makefile | 3 +++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bc573c1503..3b448514f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,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: @@ -173,7 +173,7 @@ jobs: $env:SYSTEM_FLAG="--system" test/test_path_preservation.ps1 - build-docker-image: + build-docker-image-x64: executor: bionic steps: - checkout @@ -189,7 +189,7 @@ jobs: name: test command: make -C ./docker version=tot test - publish-docker-image: + publish-docker-image-x64: executor: bionic steps: - checkout @@ -209,6 +209,53 @@ 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: check if emscripten-releases-tags.json has changed + command: | + CHANGED_FILES=$(git diff --name-only <>..<>) + if [[ ! $CHANGED_FILES =~ "emscripten-releases-tags.json" ]]; then + echo "emscripten-releases-tags.json has not changed, skipping build and publish" + circleci-agent step halt + fi + - run: + name: extract latest emscripten arm64 linux version + command: | + ARM64_VERSION=$(grep -oP '(?<="latest-arm64-linux": ")[^"]*' emscripten-releases-tags.json) + ARM64_IMAGE_TAG=${ARM64_VERSION}-arm64 + echo "export ARM64_VERSION=$ARM64_VERSION" >> $BASH_ENV + echo "export ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG" >> $BASH_ENV + echo "ARM64_VERSION=$ARM64_VERSION" + echo "ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG" + - run: + name: check if docker image already exists + command: | + if [ -z "$ARM64_VERSION" ]; then + echo "ARM64_VERSION is empty, skipping publish" + circleci-agent step halt + exit 0 + fi + DOCKER_IMAGE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://hub.docker.com/v2/repositories/emscripten/emsdk/tags/$ARM64_IMAGE_TAG) + if [ "$DOCKER_IMAGE_EXISTS" = "200" ]; then + echo "Docker image: $ARM64_VERSION" + echo "Docker image already exists, skipping build and publish" + circleci-agent step halt + fi + - run: + name: build + command: make -C ./docker version=${ARM64_VERSION} build + - run: + name: test + command: make -C ./docker version=${ARM64_VERSION} test + - run: + name: push image + command: | + docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" + make -C ./docker version=${ARM64_VERSION} alias=${ARM64_IMAGE_TAG} only_alias=true push + test-bazel-linux: executor: bionic steps: @@ -284,13 +331,17 @@ 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: + only: main test-bazel-linux: jobs: - test-bazel-linux diff --git a/docker/Makefile b/docker/Makefile index 8e84b2e192..22bea0e722 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -4,6 +4,7 @@ # i.e.: 1.39.18 version = alias = +only_alias = image_name ?= emscripten/emsdk @@ -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} From ef77dcc2c0e2bd483c21b49b39a89349619d401a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 4 Dec 2023 09:26:53 -0800 Subject: [PATCH 21/68] Add suggestion to install using `--permanent` or `--system` on windows. NFC (#1308) Fixes: #1307 --- emsdk.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/emsdk.py b/emsdk.py index e0e46b9040..d2142b0b86 100644 --- a/emsdk.py +++ b/emsdk.py @@ -1508,7 +1508,7 @@ def load_em_config(): pass -def generate_em_config(active_tools): +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" @@ -1546,7 +1546,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,') @@ -2413,7 +2420,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 From cc1b3efbd306b6c5f4897605ade448e5a41340cc Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 8 Dec 2023 10:30:37 -0800 Subject: [PATCH 22/68] Error on unknown arguments passed to --activate (#1313) See #1312 --- emsdk.py | 5 ++--- test/test_activation.ps1 | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/emsdk.py b/emsdk.py index d2142b0b86..52d1e51402 100644 --- a/emsdk.py +++ b/emsdk.py @@ -3047,13 +3047,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] [...]') 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" From 4e2496141eda15040c44e9bbf237a1326368e34c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 13 Dec 2023 16:49:36 -0800 Subject: [PATCH 23/68] 3.1.51 (#1323) --- bazel/emscripten_deps.bzl | 1 - bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 0e9a321c38..6d369453ca 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -27,7 +27,6 @@ filegroup( name = "emcc_common", srcs = [ "emscripten/emcc.py", - "emscripten/emscripten.py", "emscripten/emscripten-version.txt", "emscripten/cache/sysroot_install.stamp", "emscripten/src/settings.js", diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index ab6fcafd3f..4451431247 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 097d45b22f..13c6fce520 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.50", + "latest": "3.1.51", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.51": "4f416d92fbff66ce79901cfc8263768f1b25dd3e", + "3.1.51-asserts": "9035c99beb760aa0ea381bdf11abf440d88bb451", "3.1.50": "2ce4170cef5ce46f337f9fd907b614a8db772c7d", "3.1.50-asserts": "0a6fe6ef5880bf5b035d396f3875fda9b7c4bb60", "3.1.49": "bd0a2e230466dadb36efc71aa7271f17c6c35420", From 8822664a145391eee7cb57f9db7ba3705e19f2fe Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 18 Dec 2023 11:40:24 -0800 Subject: [PATCH 24/68] Remove logic build building native asm.js optimizer. NFC (#1325) We no longer support building fastcomp-based SDKs --- emsdk.py | 57 +++------------------------------------------ emsdk_manifest.json | 16 ++++--------- 2 files changed, 7 insertions(+), 66 deletions(-) diff --git a/emsdk.py b/emsdk.py index 52d1e51402..8901b2c2d5 100644 --- a/emsdk.py +++ b/emsdk.py @@ -1208,28 +1208,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): @@ -1330,29 +1308,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() @@ -1757,9 +1712,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 + '"!') @@ -1910,9 +1863,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 @@ -1962,9 +1913,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 + '"!') diff --git a/emsdk_manifest.json b/emsdk_manifest.json index 623cb47d6c..b9534c3dc2 100644 --- a/emsdk_manifest.json +++ b/emsdk_manifest.json @@ -479,13 +479,9 @@ "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%" }, { "id": "emscripten", @@ -494,13 +490,9 @@ "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%" }, { "id": "emscripten", From 9347bc393b94a17b93450bbc98bc3f66cef2aeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2h=D0=BEm=D0=B0s=20Ll?= Date: Wed, 27 Dec 2023 13:21:55 -0800 Subject: [PATCH 25/68] Fix FileExistsError on subsequent bazel builds on Windows (#1326) (#1326) Fixes #1181. --- bazel/emscripten_toolchain/link_wrapper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/emscripten_toolchain/link_wrapper.py b/bazel/emscripten_toolchain/link_wrapper.py index d6b715dbae..ca6ca48fd8 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 = [ @@ -161,6 +161,6 @@ # cc_binary must output exactly one file; put all the output files in a tarball. cmd = ['tar', 'cf', 'tmp.tar'] + files subprocess.check_call(cmd, cwd=outdir) -os.rename(os.path.join(outdir, 'tmp.tar'), output_file) +os.replace(os.path.join(outdir, 'tmp.tar'), output_file) sys.exit(0) From 0bbae74935d57ff41739648c12cf90b56668398f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 3 Jan 2024 10:25:06 -0800 Subject: [PATCH 26/68] Restore npm install step removed in #1325 (#1329) --- emsdk_manifest.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emsdk_manifest.json b/emsdk_manifest.json index b9534c3dc2..89f0582b09 100644 --- a/emsdk_manifest.json +++ b/emsdk_manifest.json @@ -481,7 +481,8 @@ "download_prefix": "emscripten-e", "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%'", "activated_path": "%installation_dir%", - "activated_env": "EMSCRIPTEN=%installation_dir%" + "activated_env": "EMSCRIPTEN=%installation_dir%", + "custom_install_script": "emscripten_npm_install" }, { "id": "emscripten", @@ -492,7 +493,8 @@ "unix_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.tar.gz", "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%'", "activated_path": "%installation_dir%", - "activated_env": "EMSCRIPTEN=%installation_dir%" + "activated_env": "EMSCRIPTEN=%installation_dir%", + "custom_install_script": "emscripten_npm_install" }, { "id": "emscripten", From 96bd9f0c9abf7ebf145443ae73bb09ff00267d58 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 19 Jan 2024 09:47:51 -0800 Subject: [PATCH 27/68] 3.1.52 (#1332) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 4451431247..a6d1767b41 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 13c6fce520..11235ceb0e 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.51", + "latest": "3.1.52", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.52": "ce2097fb81953331e65543c20b437475f218127c", + "3.1.52-asserts": "49e9a37dd6d1d65aa92472d8908cb8b88092dfaf", "3.1.51": "4f416d92fbff66ce79901cfc8263768f1b25dd3e", "3.1.51-asserts": "9035c99beb760aa0ea381bdf11abf440d88bb451", "3.1.50": "2ce4170cef5ce46f337f9fd907b614a8db772c7d", From f2baa2f56a0c508c33ab2e16ef1efd3d548f42b8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 24 Jan 2024 20:09:59 +0000 Subject: [PATCH 28/68] Only pass -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON when building llvm. NFC (#1334) --- emsdk.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/emsdk.py b/emsdk.py index 8901b2c2d5..530ddd96df 100644 --- a/emsdk.py +++ b/emsdk.py @@ -962,13 +962,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)) @@ -1106,6 +1103,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(',') From 4f0128ee7723a0a22f85074637ae550ab852bb21 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 29 Jan 2024 22:28:36 +0000 Subject: [PATCH 29/68] [ci] Update to latest version of cicleci windows orb (#1339) See https://github.com/emscripten-core/emscripten/pull/21110 --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3b448514f0..6033ad3fe6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - win: circleci/windows@1.0.0 + win: circleci/windows@5.0 executors: bionic: @@ -108,7 +108,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. @@ -289,7 +289,7 @@ jobs: test-bazel-windows: executor: - name: win/vs2019 + name: win/server-2019 shell: powershell.exe -ExecutionPolicy Bypass environment: PYTHONUNBUFFERED: "1" From 2aa74907151b2caa9da865fd0d36436fdce792f0 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 29 Jan 2024 23:20:15 +0000 Subject: [PATCH 30/68] 3.1.53 (#1336) --- bazel/emscripten_toolchain/toolchain.bzl | 4 ++-- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index e92a61257f..835255a0bb 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -914,7 +914,7 @@ def _impl(ctx): "-iwithsysroot" + "/include/compat", "-iwithsysroot" + "/include", "-isystem", - emscripten_dir + "/lib/clang/18/include", + emscripten_dir + "/lib/clang/19/include", ], ), # Inputs and outputs @@ -1081,7 +1081,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/18/include", + emscripten_dir + "/lib/clang/19/include", ] artifact_name_patterns = [] diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index a6d1767b41..0e9c6991f8 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 11235ceb0e..25fe7500b2 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.52", + "latest": "3.1.53", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.53": "e5523d57a0e0dcf80f3b101bbc23613fcc3101aa", + "3.1.53-asserts": "152cef4e00fc17776576bcc57f53badd21b92509", "3.1.52": "ce2097fb81953331e65543c20b437475f218127c", "3.1.52-asserts": "49e9a37dd6d1d65aa92472d8908cb8b88092dfaf", "3.1.51": "4f416d92fbff66ce79901cfc8263768f1b25dd3e", From c18280c8f3f8f088b4337f0f6a5fdb2be0d67179 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 15 Feb 2024 13:46:38 -0800 Subject: [PATCH 31/68] 3.1.54 (#1343) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 0e9c6991f8..8ed517d19a 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 25fe7500b2..1263e0108a 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.53", + "latest": "3.1.54", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.54": "aa1588cd28c250a60457b5ed342557c762f416e3", + "3.1.54-asserts": "d525f56cb765ed6884a0c443dbb906b63b148915", "3.1.53": "e5523d57a0e0dcf80f3b101bbc23613fcc3101aa", "3.1.53-asserts": "152cef4e00fc17776576bcc57f53badd21b92509", "3.1.52": "ce2097fb81953331e65543c20b437475f218127c", From 7815dcaa5c97ee387e925137a42dd4219e7cec82 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 1 Mar 2024 10:59:26 -0800 Subject: [PATCH 32/68] 3.1.55 (#1350) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 8ed517d19a..6813d8679d 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 1263e0108a..92699ca6f4 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.54", + "latest": "3.1.55", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.55": "f5557e3b7166d05bddb5977e363ec48cd06e9d32", + "3.1.55-asserts": "eb23cc30563325fd6dc97fcf85ddf26489ab9110", "3.1.54": "aa1588cd28c250a60457b5ed342557c762f416e3", "3.1.54-asserts": "d525f56cb765ed6884a0c443dbb906b63b148915", "3.1.53": "e5523d57a0e0dcf80f3b101bbc23613fcc3101aa", From 5726cccef5ce9301804d21b9bd97da864f4ea764 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 13 Mar 2024 17:54:26 -0700 Subject: [PATCH 33/68] Remove JS_ENGINES and COMPILER_ENGINE from config file (#1354) `COMPILER_ENGINE` was completely removed from emscripten in https://github.com/emscripten-core/emscripten/pull/9469. `JS_ENGINES` is only used/needed for testing and is no longer needed as of https://github.com/emscripten-core/emscripten/pull/9542. --- emsdk.py | 87 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/emsdk.py b/emsdk.py index 530ddd96df..166f37416d 100644 --- a/emsdk.py +++ b/emsdk.py @@ -1464,6 +1464,21 @@ def load_em_config(): pass +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" @@ -1484,10 +1499,17 @@ def generate_em_config(active_tools, permanently_activate, system): 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 + '") @@ -2488,39 +2510,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 From da5a19215aa252067381d50c269055106e14b93e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Wed, 13 Mar 2024 22:34:27 -0700 Subject: [PATCH 34/68] 3.1.56 (#1353) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 6813d8679d..458337b4b2 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "3.1.56": struct( + hash = "e5eebffb9a0e978c82dd57528cd574c2b0fb9b5c", + sha_linux = "acdd731fa10c8ac55d1d407813200906ebda52185204275be0a395921c6a1b1c", + sha_mac = "949edb4a4cc4e6804d90e9939ca89acf1122d3343aeb1d08585bd015bc1510f1", + sha_mac_arm64 = "9de551d12d1ca9d9999aba505e236b8761e2cbed58852fe43d8d4bcf2fec7d26", + sha_win = "3711f4751c83d110b453ca3455485b430b807366a48a2721bc2382e772818683", + ), "3.1.55": struct( hash = "f5557e3b7166d05bddb5977e363ec48cd06e9d32", sha_linux = "2a1cccc2f6db801219eb966d00af78a026af7822055064092387e7eba18e75ad", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 92699ca6f4..a2f49c2c21 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.55", + "latest": "3.1.56", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.56": "e5eebffb9a0e978c82dd57528cd574c2b0fb9b5c", + "3.1.56-asserts": "0d7db6e7424d13a21a445c9b0c995a1a2c71ae3a", "3.1.55": "f5557e3b7166d05bddb5977e363ec48cd06e9d32", "3.1.55-asserts": "eb23cc30563325fd6dc97fcf85ddf26489ab9110", "3.1.54": "aa1588cd28c250a60457b5ed342557c762f416e3", From 44bf7cfbe6d1300f498942a1eac574e31f0e0e42 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 14 Mar 2024 09:45:41 -0700 Subject: [PATCH 35/68] CI: Build `latest` docker image rather than `tot` (#1359) This means that CI run that update `latest` actually test the thing we are about to ship. We recently had a case where `latest` was broken but `tot` was fixes and we accidentally shipped a broken SDK version (#1353). --- .circleci/config.yml | 6 +++--- docker/Makefile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6033ad3fe6..281f32f19b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -181,13 +181,13 @@ jobs: name: install docker command: apt-get update -q && apt-get install -q -y docker.io - 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-x64: executor: bionic diff --git a/docker/Makefile b/docker/Makefile index 22bea0e722..749ecfe940 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -14,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 From ccd111fb1f0fd8bfdc21e5faecf9ea2073342c49 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 14 Mar 2024 13:19:45 -0700 Subject: [PATCH 36/68] Prefer `curl` for downloading files over `urllib` (#1355) This is especially important on macOS where `urllib` can fail to verify certificates. See https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore Fixes: #1207, #85, #1356, #1357, #1358 --- emsdk.py | 110 +++++++++++++++++++++++++++++++-------------------- test/test.py | 6 +-- 2 files changed, 70 insertions(+), 46 deletions(-) diff --git a/emsdk.py b/emsdk.py index 166f37416d..1983287830 100644 --- a/emsdk.py +++ b/emsdk.py @@ -670,6 +670,54 @@ 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) + 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() + + # 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, @@ -680,53 +728,25 @@ def download_file(url, dstpath, download_even_if_exists=False, 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: - if not silent: - 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) + errlog("Error: Downloading URL '" + url + "': " + str(e)) return None except KeyboardInterrupt: rmfile(file_name) - exit_with_error("aborted by user, exiting") + raise + return file_name @@ -3093,4 +3113,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/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__': From e10826f9196bb0e704014af2252ef58fb4ba261b Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Thu, 14 Mar 2024 17:25:09 -0700 Subject: [PATCH 37/68] 3.1.56 (#1360) #1353 turned out to be broken, so this is the second try. --- bazel/revisions.bzl | 10 +++++----- emscripten-releases-tags.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 458337b4b2..454bb9affc 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -3,11 +3,11 @@ EMSCRIPTEN_TAGS = { "3.1.56": struct( - hash = "e5eebffb9a0e978c82dd57528cd574c2b0fb9b5c", - sha_linux = "acdd731fa10c8ac55d1d407813200906ebda52185204275be0a395921c6a1b1c", - sha_mac = "949edb4a4cc4e6804d90e9939ca89acf1122d3343aeb1d08585bd015bc1510f1", - sha_mac_arm64 = "9de551d12d1ca9d9999aba505e236b8761e2cbed58852fe43d8d4bcf2fec7d26", - sha_win = "3711f4751c83d110b453ca3455485b430b807366a48a2721bc2382e772818683", + hash = "9d106be887796484c4aaffc9dc45f48a8810f336", + sha_linux = "52338cca556002251e5e7d738adb1870d14331ddf463e613af02028b64e05a82", + sha_mac = "fc5cca6a9db571ecb2974bf0d4e12f1bc6068726271464586cf7e8723004b4c6", + sha_mac_arm64 = "aed728d09d801c4a33210505874ce066269292e7809a7d6a6414146be01545f1", + sha_win = "cd5fbe94fb0bcf01badc10eace48eddbca22b34f31229e3d70c68ade7bcdd571", ), "3.1.55": struct( hash = "f5557e3b7166d05bddb5977e363ec48cd06e9d32", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index a2f49c2c21..7e31198872 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -10,8 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { - "3.1.56": "e5eebffb9a0e978c82dd57528cd574c2b0fb9b5c", - "3.1.56-asserts": "0d7db6e7424d13a21a445c9b0c995a1a2c71ae3a", + "3.1.56": "9d106be887796484c4aaffc9dc45f48a8810f336", + "3.1.56-asserts": "2b9c4b912b611dc51f9019e11371e3cdd36fa64e", "3.1.55": "f5557e3b7166d05bddb5977e363ec48cd06e9d32", "3.1.55-asserts": "eb23cc30563325fd6dc97fcf85ddf26489ab9110", "3.1.54": "aa1588cd28c250a60457b5ed342557c762f416e3", From 90d2168e728acb0fd5da852a474ecd01f284c65f Mon Sep 17 00:00:00 2001 From: Damian <11998334+trzeciak@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:04:10 +0200 Subject: [PATCH 38/68] (bazel) Set @platforms//os:emscripten for platform_wasm (#1363) * (bazel) Set @platforms//os:emscripten for platform_wasm * (bazel) Set @platforms//os:emscripten for platform_wasm * (bazel) Set @platforms//os:emscripten for platform_wasm --- bazel/BUILD | 1 + bazel/MODULE.bazel | 1 + bazel/README.md | 5 +++++ bazel/deps.bzl | 9 +++++++++ bazel/test_external/MODULE.bazel | 1 + 5 files changed, 17 insertions(+) create mode 100644 bazel/MODULE.bazel create mode 100644 bazel/test_external/MODULE.bazel diff --git a/bazel/BUILD b/bazel/BUILD index e67311d074..cb3135ce02 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -82,6 +82,7 @@ platform( name = "platform_wasm", constraint_values = [ "@platforms//cpu:wasm32", + "@platforms//os:emscripten", ], ) 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/README.md b/bazel/README.md index 69a802146b..2fd291c328 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -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 diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 337f0bafcd..a83cfaf847 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -2,6 +2,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def deps(): + maybe( + http_archive, + name = "platforms", + urls = [ + "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 = "bazel_skylib", 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") From 229d83fc706e10a39d4948a804cbbf17225cdda0 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 10 Apr 2024 10:11:44 -0700 Subject: [PATCH 39/68] 3.1.57 (#1367) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 454bb9affc..0f08b0c17e 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 7e31198872..5885520409 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.56", + "latest": "3.1.57", "latest-sdk": "latest", "latest-arm64-linux": "3.1.47", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.57": "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", + "3.1.57-asserts": "10b736eeeac0dae3fd5bc29c6b3e32f7f7adf941", "3.1.56": "9d106be887796484c4aaffc9dc45f48a8810f336", "3.1.56-asserts": "2b9c4b912b611dc51f9019e11371e3cdd36fa64e", "3.1.55": "f5557e3b7166d05bddb5977e363ec48cd06e9d32", From 176dec4875db4d74c2038d7e8af3395be38d222c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 10 Apr 2024 16:32:54 -0700 Subject: [PATCH 40/68] arm64-linux binaries are now available for all releases (#1369) --- .circleci/config.yml | 41 +++++------------------------------ emscripten-releases-tags.json | 2 +- emsdk.py | 3 --- scripts/update_linux_arm64.sh | 23 -------------------- 4 files changed, 7 insertions(+), 62 deletions(-) delete mode 100755 scripts/update_linux_arm64.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 281f32f19b..cea7e0e37b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -213,48 +213,17 @@ jobs: executor: linux_arm64 steps: - checkout - - run: - name: check if emscripten-releases-tags.json has changed - command: | - CHANGED_FILES=$(git diff --name-only <>..<>) - if [[ ! $CHANGED_FILES =~ "emscripten-releases-tags.json" ]]; then - echo "emscripten-releases-tags.json has not changed, skipping build and publish" - circleci-agent step halt - fi - - run: - name: extract latest emscripten arm64 linux version - command: | - ARM64_VERSION=$(grep -oP '(?<="latest-arm64-linux": ")[^"]*' emscripten-releases-tags.json) - ARM64_IMAGE_TAG=${ARM64_VERSION}-arm64 - echo "export ARM64_VERSION=$ARM64_VERSION" >> $BASH_ENV - echo "export ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG" >> $BASH_ENV - echo "ARM64_VERSION=$ARM64_VERSION" - echo "ARM64_IMAGE_TAG=$ARM64_IMAGE_TAG" - - run: - name: check if docker image already exists - command: | - if [ -z "$ARM64_VERSION" ]; then - echo "ARM64_VERSION is empty, skipping publish" - circleci-agent step halt - exit 0 - fi - DOCKER_IMAGE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://hub.docker.com/v2/repositories/emscripten/emsdk/tags/$ARM64_IMAGE_TAG) - if [ "$DOCKER_IMAGE_EXISTS" = "200" ]; then - echo "Docker image: $ARM64_VERSION" - echo "Docker image already exists, skipping build and publish" - circleci-agent step halt - fi - run: name: build - command: make -C ./docker version=${ARM64_VERSION} build + command: make -C ./docker version=${CIRCLE_TAG} build - run: name: test - command: make -C ./docker version=${ARM64_VERSION} 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=${ARM64_VERSION} alias=${ARM64_IMAGE_TAG} only_alias=true push + make -C ./docker version=${CIRCLE_TAG} alias=${CIRCLE_TAG}-arm64 only_alias=true push test-bazel-linux: executor: bionic @@ -341,7 +310,9 @@ workflows: - publish-docker-image-arm64: filters: branches: - only: main + ignore: /.*/ + tags: + only: /.*/ test-bazel-linux: jobs: - test-bazel-linux diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 5885520409..51e9104eab 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -2,7 +2,7 @@ "aliases": { "latest": "3.1.57", "latest-sdk": "latest", - "latest-arm64-linux": "3.1.47", + "latest-arm64-linux": "latest", "latest-64bit": "latest", "sdk-latest-64bit": "latest", "latest-upstream": "latest", diff --git a/emsdk.py b/emsdk.py index 1983287830..9eccfb5693 100644 --- a/emsdk.py +++ b/emsdk.py @@ -2040,9 +2040,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])) diff --git a/scripts/update_linux_arm64.sh b/scripts/update_linux_arm64.sh deleted file mode 100755 index 097700c751..0000000000 --- a/scripts/update_linux_arm64.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# Script for updating the linux-arm64 release -# -# Takes as stdin the JSON string generated by the S3 bucket update when -# amazon produces a new build. e.g. -# {"Records":[{"eventVersion":"2.1","eventSource":"aws:s3","awsRegion":"us-west-2","eventTime":"2023-08-23T19:12:29.218Z","eventName":"ObjectCreated:CompleteMultipartUpload","userIdentity":{"principalId":"AWS:AROAZNAVTCTIWSHR6WFTE:i-0124c978819146a2f"},"requestParameters":{"sourceIPAddress":"35.90.239.236"},"responseElements":{"x-amz-request-id":"3SDMWYMG4BN47DCD","x-amz-id-2":"0mRaqwIIZI8ob1B7TmTSd/s0lXxST73ktgGm94MjKj2bnflqD1zCjbh2LeMIYYPvvfgQu0Ocrlev4nYmiOmS9wR0M/lvpCQz"},"s3":{"s3SchemaVersion":"1.0","configurationId":"arn:aws:cloudformation:us-west-2:646437868753:stack/EmscriptenArm64BuilderStack/eb5d5760-ee9a-11ec-a790-06738944b93b--3752220361625282518","bucket":{"name":"emscripten-arm64-4484191c","ownerIdentity":{"principalId":"A2IEUDOSUKZVHO"},"arn":"arn:aws:s3:::emscripten-arm64-4484191c"},"object":{"key":"emscripten-install-3.1.45-linux-arm64.tbz2","size":247058408,"eTag":"bb7f6835c7900deee6e7881a352ab48c-30","sequencer":"0064E65A1BC2C23A2E"}}}]} - -set -e - -if [ $# -ne 1 ]; then - echo "Please specify a single argument which is an emsdk version (e.g. 3.1.45)" - exit -fi - -VERSION=$1 -SHA=$(jq -r ".releases.\"${VERSION}\"" emscripten-releases-tags.json) -URL=$(jq -r '.Records[0] | "https://\(.s3.bucket.name).s3.\(.awsRegion).amazonaws.com/\(.s3.object.key)"') - -wget $URL -O arm64.tar.xz -gsutil cp -n arm64.tar.xz gs://webassembly/emscripten-releases-builds/linux/${SHA}/wasm-binaries-arm64.tar.xz -sed -i "s/\"latest-arm64-linux\": \".*\"/\"latest-arm64-linux\": \"$VERSION\"/" emscripten-releases-tags.json - -echo "done" From ad59642673cdd5ab64e3f0f9a3fc71e6a032be07 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Mon, 22 Apr 2024 11:19:11 -0700 Subject: [PATCH 41/68] fix(bazel): use param file for compile (#1373) * fixes issues on windows when dealing with many dependencies causing a 'command line too long' error --- bazel/emscripten_toolchain/toolchain.bzl | 10 +++ .../long_command_line/BUILD.bazel | 61 +++++++++++++++++++ .../include/long_command_line_file01.hh | 3 + .../include/long_command_line_file02.hh | 3 + .../include/long_command_line_file03.hh | 3 + .../include/long_command_line_file04.hh | 3 + .../include/long_command_line_file05.hh | 3 + .../include/long_command_line_file06.hh | 3 + .../include/long_command_line_file07.hh | 3 + .../include/long_command_line_file08.hh | 3 + .../include/long_command_line_file09.hh | 3 + .../include/long_command_line_file10.hh | 3 + .../include/long_command_line_file11.hh | 3 + .../include/long_command_line_file12.hh | 3 + .../include/long_command_line_file13.hh | 3 + .../include/long_command_line_file14.hh | 3 + .../include/long_command_line_file15.hh | 3 + .../include/long_command_line_file16.hh | 3 + .../include/long_command_line_file17.hh | 3 + .../include/long_command_line_file18.hh | 3 + .../include/long_command_line_file19.hh | 3 + .../include/long_command_line_file20.hh | 3 + .../long_command_line/long_command_line.cc | 43 +++++++++++++ .../long_command_line_file01.cc | 5 ++ .../long_command_line_file02.cc | 5 ++ .../long_command_line_file03.cc | 5 ++ .../long_command_line_file04.cc | 5 ++ .../long_command_line_file05.cc | 5 ++ .../long_command_line_file06.cc | 5 ++ .../long_command_line_file07.cc | 5 ++ .../long_command_line_file08.cc | 5 ++ .../long_command_line_file09.cc | 5 ++ .../long_command_line_file10.cc | 5 ++ .../long_command_line_file11.cc | 5 ++ .../long_command_line_file12.cc | 5 ++ .../long_command_line_file13.cc | 5 ++ .../long_command_line_file14.cc | 5 ++ .../long_command_line_file15.cc | 5 ++ .../long_command_line_file16.cc | 5 ++ .../long_command_line_file17.cc | 5 ++ .../long_command_line_file18.cc | 5 ++ .../long_command_line_file19.cc | 5 ++ .../long_command_line_file20.cc | 5 ++ test/test_bazel.ps1 | 3 + test/test_bazel.sh | 3 +- test/test_bazel_mac.sh | 1 + 46 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 bazel/test_external/long_command_line/BUILD.bazel create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file01.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file02.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file03.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file04.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file05.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file06.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file07.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file08.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file09.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file10.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file11.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file12.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file13.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file14.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file15.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file16.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file17.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file18.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file19.hh create mode 100644 bazel/test_external/long_command_line/include/long_command_line_file20.hh create mode 100644 bazel/test_external/long_command_line/long_command_line.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file01.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file02.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file03.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file04.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file05.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file06.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file07.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file08.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file09.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file10.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file11.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file12.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file13.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file14.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file15.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file16.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file17.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file18.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file19.cc create mode 100644 bazel/test_external/long_command_line/long_command_line_file20.cc diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 835255a0bb..745e27dea7 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -346,6 +346,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. 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/test/test_bazel.ps1 b/test/test_bazel.ps1 index 3fd269c153..b417262e27 100644 --- a/test/test_bazel.ps1 +++ b/test/test_bazel.ps1 @@ -13,6 +13,9 @@ 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 } diff --git a/test/test_bazel.sh b/test/test_bazel.sh index bc53fcd829..d8d40e1716 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -26,9 +26,10 @@ 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 diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh index 58aa9f0ad9..4b58b502bd 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -25,4 +25,5 @@ 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 From e0a6aa06b137fe7f3a3f87b2eec216fce6648f22 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 23 Apr 2024 10:13:28 -0700 Subject: [PATCH 42/68] 3.1.58 (#1372) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 0f08b0c17e..82428f65cd 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 51e9104eab..f705ea72dc 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.57", + "latest": "3.1.58", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.58": "a4d4afb626c5010f6ccda4638b8d77579a63782e", + "3.1.58-asserts": "5bc1c7108d4d91db316b24a75593a37c1117c266", "3.1.57": "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", "3.1.57-asserts": "10b736eeeac0dae3fd5bc29c6b3e32f7f7adf941", "3.1.56": "9d106be887796484c4aaffc9dc45f48a8810f336", From f58f80d3bacc65d7ef6d95f1d23fb97542e120e9 Mon Sep 17 00:00:00 2001 From: Anita Hammer <166057949+anitahammer@users.noreply.github.com> Date: Sun, 28 Apr 2024 04:25:02 +0100 Subject: [PATCH 43/68] Update docker/README.md (#1375) --- docker/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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| From d52c46520124845b1e0e0525f2759299d840143f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 30 Apr 2024 07:56:18 -0700 Subject: [PATCH 44/68] 3.1.59 (#1377) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 82428f65cd..2f96ed667f 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index f705ea72dc..ef0122936d 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.58", + "latest": "3.1.59", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.59": "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", + "3.1.59-asserts": "10ae1e83ccce9f4a363bb2e3090ba8fc32d25851", "3.1.58": "a4d4afb626c5010f6ccda4638b8d77579a63782e", "3.1.58-asserts": "5bc1c7108d4d91db316b24a75593a37c1117c266", "3.1.57": "523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d", From 399e5396df1e7dad849d839f0f71e1883a651205 Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Wed, 15 May 2024 17:20:54 -0400 Subject: [PATCH 45/68] [bazel] add tarball as an optional output (#1383) Usage would be something like: ``` filegroup( name = "hello-world-tarball", srcs = [":hello-world-wasm"], output_group = "_wasm_tar", ) ``` --- bazel/emscripten_toolchain/wasm_cc_binary.bzl | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl index fe77e175b7..23749ed835 100644 --- a/bazel/emscripten_toolchain/wasm_cc_binary.bzl +++ b/bazel/emscripten_toolchain/wasm_cc_binary.bzl @@ -128,12 +128,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] @@ -162,13 +165,16 @@ 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)), - ) + 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)), + ), + OutputGroupInfo(_wasm_tar = cc_target.files), + ] _wasm_cc_binary = rule( implementation = _wasm_cc_binary_impl, From ce74ca2b1c968f897150bdc55daa9e3c12a3fefc Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 20 May 2024 16:41:54 -0700 Subject: [PATCH 46/68] 3.1.60 (#1385) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 2f96ed667f..9a1a18d02c 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index ef0122936d..b3b34917d6 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.59", + "latest": "3.1.60", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.60": "87709b5747de5b1993fe314285528bf4b65c23e1", + "3.1.60-asserts": "e2388e8a528890b8f3ff7b9ab4f52dbe2aeb38b9", "3.1.59": "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", "3.1.59-asserts": "10ae1e83ccce9f4a363bb2e3090ba8fc32d25851", "3.1.58": "a4d4afb626c5010f6ccda4638b8d77579a63782e", From fc9146e09fe62e474f643e9e1e0b2155e48be006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E9=9B=AA=E6=AE=87=E7=92=83=E9=99=8C=E6=A2=A6?= <80821706+DreamOfIce@users.noreply.github.com> Date: Wed, 29 May 2024 02:34:36 +0800 Subject: [PATCH 47/68] Upgrade CI to Ubuntu 20.04 LTS (Focal) (#1183) # Why On one hand Ubuntu18's free LTS cycle is ended, and on the other hand Ubuntu18 does not support nodejs greater than v18. # What's changed. 1. update the Linux Docker image to buildpack-deps:focal 2. some compatibility changes 3. use the new recommended way to install Docker ([see here](https://docs.docker.com/engine/install/ubuntu/)) See #1173 --- .circleci/config.yml | 40 ++++++++++++++++++++++++++-------------- README.md | 2 +- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cea7e0e37b..31f090e68b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,9 +4,9 @@ orbs: win: circleci/windows@5.0 executors: - bionic: + ubuntu: docker: - - image: buildpack-deps:bionic + - image: buildpack-deps:focal mac: environment: EMSDK_NOTTY: "1" @@ -50,22 +50,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.9.2 - run: python3 -m pip install flake8==3.9.2 - - run: python2 -m flake8 --show-source --statistics --extend-exclude=./scripts - - run: python3 -m flake8 --show-source --statistics + - 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 @@ -174,12 +172,19 @@ jobs: test/test_path_preservation.ps1 build-docker-image-x64: - executor: bionic + 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 the `latest` version of EMSDK as docker image - run: @@ -190,12 +195,19 @@ jobs: command: make -C ./docker version=latest test publish-docker-image-x64: - executor: bionic + 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 @@ -226,7 +238,7 @@ jobs: 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 diff --git a/README.md b/README.md index 8e1c99bb3d..9736aea0a2 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ 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 against Ubuntu/Xenial 16.04 LTS 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. From 8c38d2f91540c6ce41bf0b66c8da64daaf8014f2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 28 May 2024 12:12:17 -0700 Subject: [PATCH 48/68] Upgrade node from v16.20.0 to v18.20.3 (#1387) Node v18 is that current LTS release of node and v18.20.3 is the latest release of v18. This change means that emsdk is no longer installable on Ubuntu/Bionic 18.04, and we now require Ubuntu/Focal 20.04. See: #1183 Fixes: #1173 --- docker/Dockerfile | 2 +- emsdk_manifest.json | 62 +++++++++++++++++++++++++++++++++++++----- scripts/update_node.py | 4 +-- 3 files changed, 58 insertions(+), 10 deletions(-) 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/emsdk_manifest.json b/emsdk_manifest.json index 89f0582b09..6af26c2c7f 100644 --- a/emsdk_manifest.json +++ b/emsdk_manifest.json @@ -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", @@ -644,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" }, { @@ -668,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" @@ -683,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" @@ -691,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/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 = [ From 4205979286d4fed33eab7a38e6ed02d5124ed0e8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 28 May 2024 15:12:09 -0700 Subject: [PATCH 49/68] Remove setting of SSL_CERT_FILE from emsdk launcher script (#1391) Since we use curl now (#1355) this should no longer be needed. --- emsdk | 7 ------- 1 file changed, 7 deletions(-) diff --git a/emsdk b/emsdk index 5fae040051..88144c3862 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,11 +20,6 @@ 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 From dd3b9c6208f07583427fe6492357af06cbc09d0c Mon Sep 17 00:00:00 2001 From: Yolanda-Chen Date: Fri, 31 May 2024 03:27:47 +0800 Subject: [PATCH 50/68] Add feature to support WASM Relaxed SIMD (#1389) --- bazel/emscripten_toolchain/toolchain.bzl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 745e27dea7..5a03ada4f3 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -434,6 +434,11 @@ 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, @@ -560,6 +565,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"], From ca7b40ae222a2d8763b6ac845388744b0e57cfb7 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 31 May 2024 22:11:07 -0700 Subject: [PATCH 51/68] 3.1.61 (#1394) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 9a1a18d02c..964682da99 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index b3b34917d6..914395168f 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.60", + "latest": "3.1.61", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.61": "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c", + "3.1.61-asserts": "7fc912687ba2077b3aeae472b51c238b3d201c46", "3.1.60": "87709b5747de5b1993fe314285528bf4b65c23e1", "3.1.60-asserts": "e2388e8a528890b8f3ff7b9ab4f52dbe2aeb38b9", "3.1.59": "e20ee09a8a740544c4bc6de5d4ba5f81f74b74d6", From d29161158e2388f520790d969f5a69df9db4ac2c Mon Sep 17 00:00:00 2001 From: William Izzo Date: Fri, 14 Jun 2024 18:13:50 +0200 Subject: [PATCH 52/68] [Bazel] Let audio workout bootstrap js file be generated. (#1404) * Allows generation of audio worklet bootstrap js file In order to allow users to generate the file, the allowed extension list in `link_wrapper.py` has been updated accordingly. * adds audio worklet js to wasm_cc_binary too --------- Co-authored-by: William Izzo --- bazel/emscripten_toolchain/link_wrapper.py | 3 ++- bazel/emscripten_toolchain/wasm_cc_binary.bzl | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bazel/emscripten_toolchain/link_wrapper.py b/bazel/emscripten_toolchain/link_wrapper.py index ca6ca48fd8..ce7b25c83e 100644 --- a/bazel/emscripten_toolchain/link_wrapper.py +++ b/bazel/emscripten_toolchain/link_wrapper.py @@ -90,7 +90,8 @@ '.data', '.js.symbols', '.wasm.debug.wasm', - '.html' + '.html', + '.aw.js' ] for ext in extensions: diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl index 23749ed835..6ea4f127f0 100644 --- a/bazel/emscripten_toolchain/wasm_cc_binary.bzl +++ b/bazel/emscripten_toolchain/wasm_cc_binary.bzl @@ -70,6 +70,7 @@ _ALLOW_OUTPUT_EXTNAMES = [ ".js.symbols", ".wasm.debug.wasm", ".html", + ".aw.js", ] _WASM_BINARY_COMMON_ATTRS = { @@ -151,6 +152,7 @@ def _wasm_cc_binary_legacy_impl(ctx): ctx.outputs.symbols, ctx.outputs.dwarf, ctx.outputs.html, + ctx.outputs.audio_worklet, ] args = ctx.actions.args() @@ -201,6 +203,7 @@ def _wasm_binary_legacy_outputs(name, cc_target): "symbols": "{}/{}.js.symbols".format(name, basename), "dwarf": "{}/{}.wasm.debug.wasm".format(name, basename), "html": "{}/{}.html".format(name, basename), + "audio_worklet": "{}/{}.aw.js".format(name, basename) } return outputs From 0e8c5bb1e302b743dced52a60525815c44e93534 Mon Sep 17 00:00:00 2001 From: William Izzo Date: Thu, 20 Jun 2024 19:34:22 +0200 Subject: [PATCH 53/68] Sets wasm_worning_as_error disabled by default. (#1406) This removes `-Werror` set by default, thus conforming with default bazel cc toolchain. Co-authored-by: William Izzo --- bazel/emscripten_toolchain/toolchain.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 5a03ada4f3..c3c9f43347 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -445,7 +445,7 @@ def _impl(ctx): ), feature( name = "wasm_warnings_as_errors", - enabled = True, + enabled = False, ), # ASan and UBSan. See also: From 4b9e83d629ec8a9468aa3bf388cec447ab771312 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 20 Jun 2024 16:16:05 -0700 Subject: [PATCH 54/68] Remove Intel mac CircleCI configuration (#1409) Also switch bazel-mac to the arm64 config. The CircleCI Intel mac config will be turned down soon. --- .circleci/config.yml | 26 ++++---------------------- scripts/get_release_info.py | 25 +++++++++++++++++++++++++ test/test_bazel.sh | 9 +++------ test/test_bazel_mac.sh | 9 +++------ 4 files changed, 35 insertions(+), 34 deletions(-) create mode 100755 scripts/get_release_info.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 31f090e68b..91074c9361 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,15 +7,6 @@ executors: ubuntu: docker: - image: buildpack-deps:focal - 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 mac_arm64: environment: EMSDK_NOTTY: "1" @@ -94,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: @@ -257,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: | @@ -301,9 +286,6 @@ workflows: test-linux-arm64: jobs: - test-linux-arm64 - test-mac: - jobs: - - test-mac test-mac-arm64: jobs: - test-mac-arm64 @@ -328,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/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/test/test_bazel.sh b/test/test_bazel.sh index d8d40e1716..51500acee0 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -6,13 +6,10 @@ 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_workspace.py needs to be run !!!" diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh index 4b58b502bd..fa31103632 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -6,13 +6,10 @@ 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_workspace.py needs to be run !!!" From a6db8d2872943e30a62ccad74829b966278151b2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 25 Jun 2024 13:03:25 -0700 Subject: [PATCH 55/68] Add logging of sys.executable on startup. NFC (#1412) --- emsdk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/emsdk.py b/emsdk.py index 9eccfb5693..b2ad3c3a93 100644 --- a/emsdk.py +++ b/emsdk.py @@ -2683,6 +2683,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'): From 8caaa25afb2a9d6bbbaf531d07edb843581de838 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 25 Jun 2024 13:04:03 -0700 Subject: [PATCH 56/68] Add some logging after download is finished. NFC (#1413) Also move some code outside of the `using` block. --- emsdk.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/emsdk.py b/emsdk.py index b2ad3c3a93..1d8276ac4e 100644 --- a/emsdk.py +++ b/emsdk.py @@ -682,20 +682,21 @@ def download_with_curl(url, file_name): 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: - 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: @@ -713,9 +714,12 @@ def download_with_urllib(url, file_name): print('-', end='') sys.stdout.flush() progress_shown += 1 - if not TTY_OUTPUT: - print(']') - sys.stdout.flush() + + 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 From a33daf378cfc036bd39a35c6a2ed266e0bf876a3 Mon Sep 17 00:00:00 2001 From: Daniel Kalmar <1355747+kalmard0@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:50:03 +0200 Subject: [PATCH 57/68] Ensure temporary files have proper unique names for bazel builds. (#1415) This attempts to fix #1386. --- bazel/emscripten_toolchain/link_wrapper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bazel/emscripten_toolchain/link_wrapper.py b/bazel/emscripten_toolchain/link_wrapper.py index ce7b25c83e..1126258988 100644 --- a/bazel/emscripten_toolchain/link_wrapper.py +++ b/bazel/emscripten_toolchain/link_wrapper.py @@ -139,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() @@ -152,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): @@ -160,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.replace(os.path.join(outdir, 'tmp.tar'), output_file) +os.replace(os.path.join(outdir, base_name + '.tar'), output_file) sys.exit(0) From 7fbd555dbec53f863f74e5f119812351f02a7a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 1 Jul 2024 18:22:28 +0200 Subject: [PATCH 58/68] Use "command -v" instead of "which" to detect python executable (#1419) On a Linux distro that doesn't have the `which` program installed we're getting the following error: $ ./emsdk install latest ./emsdk: line 39: exec: python: not found It's failing to detect the installed `python3` and falls back to using `python`, but this distro doesn't provide a python -> python3 symlink so we fail. Fix this by using `command -v` instead which is a POSIX standard. The same change went into emscripten a couple years ago: https://github.com/emscripten-core/emscripten/pull/15071 --- emsdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emsdk b/emsdk index 88144c3862..55d46b925b 100755 --- a/emsdk +++ b/emsdk @@ -26,7 +26,7 @@ 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 From 82d41a76d3c973c894b27e554e5e6f2773bd7925 Mon Sep 17 00:00:00 2001 From: Michael Allwright Date: Mon, 1 Jul 2024 18:23:07 +0200 Subject: [PATCH 59/68] [Bazel] Support generating a secondary cache (#1405) This is a working solution for generating a separate Emscripten cache. Note that this requires an additional entry in the workspace as follows: ```starlark load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache") emsdk_emscripten_cache() ``` When used like this, the default Emscripten cache will be used. However, if the entry is as follows: ```starlark load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache") emsdk_emscripten_cache(flags = ["--lto"]) ``` Then embuilder will be called to build all system libraries and ports (i.e., the `ALL` option to embuilder) with the LTO option enabled. This can take awhile, so I have also made possible to specify which libraries you want to build explicitly: ```starlark load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache") emsdk_emscripten_cache( flags = ["--lto"], libraries = [ "crtbegin", "libprintf_long_double-debug", "libstubs-debug", "libnoexit", "libc-debug", "libdlmalloc", "libcompiler_rt", "libc++-noexcept", "libc++abi-debug-noexcept", "libsockets" ] ) ``` Resolves #807, resolves #971, resolves #1099, resolves #1362, resolves #1401 --- bazel/README.md | 26 +++++ bazel/emscripten_deps.bzl | 1 + bazel/emscripten_toolchain/BUILD.bazel | 4 +- .../{emscripten_config => default_config} | 0 bazel/test_secondary_lto_cache/.bazelrc | 1 + bazel/test_secondary_lto_cache/.gitignore | 4 + bazel/test_secondary_lto_cache/BUILD | 19 ++++ bazel/test_secondary_lto_cache/MODULE.bazel | 1 + bazel/test_secondary_lto_cache/WORKSPACE | 30 ++++++ bazel/test_secondary_lto_cache/hello-world.cc | 6 ++ bazel/toolchains.bzl | 96 ++++++++++++++++++- test/test_bazel.ps1 | 6 ++ test/test_bazel.sh | 4 + test/test_bazel_mac.sh | 4 + 14 files changed, 199 insertions(+), 3 deletions(-) rename bazel/emscripten_toolchain/{emscripten_config => default_config} (100%) create mode 100644 bazel/test_secondary_lto_cache/.bazelrc create mode 100644 bazel/test_secondary_lto_cache/.gitignore create mode 100644 bazel/test_secondary_lto_cache/BUILD create mode 100644 bazel/test_secondary_lto_cache/MODULE.bazel create mode 100644 bazel/test_secondary_lto_cache/WORKSPACE create mode 100644 bazel/test_secondary_lto_cache/hello-world.cc diff --git a/bazel/README.md b/bazel/README.md index 2fd291c328..ce8d210b78 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -66,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/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 6d369453ca..16fd8ee1c6 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -27,6 +27,7 @@ filegroup( name = "emcc_common", srcs = [ "emscripten/emcc.py", + "emscripten/embuilder.py", "emscripten/emscripten-version.txt", "emscripten/cache/sysroot_install.stamp", "emscripten/src/settings.js", diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index fb8a6c1b2e..3cd086064e 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", @@ -60,7 +60,7 @@ 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", diff --git a/bazel/emscripten_toolchain/emscripten_config b/bazel/emscripten_toolchain/default_config similarity index 100% rename from bazel/emscripten_toolchain/emscripten_config rename to bazel/emscripten_toolchain/default_config 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/test/test_bazel.ps1 b/test/test_bazel.ps1 index b417262e27..5c20a15251 100644 --- a/test/test_bazel.ps1 +++ b/test/test_bazel.ps1 @@ -22,3 +22,9 @@ 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 51500acee0..b99a029896 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -30,3 +30,7 @@ bazel build //:hello-embind-wasm --compilation_mode dbg # debug 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 + +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 fa31103632..2b596ee4f7 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -24,3 +24,7 @@ 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 + From 0fde04880048f743056bed17cb0543a42e040fae Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 2 Jul 2024 11:06:41 -0700 Subject: [PATCH 60/68] 3.1.62 (#1421) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index 964682da99..f9d65449da 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # DO NOT MODIFY EMSCRIPTEN_TAGS = { + "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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index 914395168f..bcdbf4f382 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.61", + "latest": "3.1.62", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "latest-releases-upstream": "latest" }, "releases": { + "3.1.62": "d52176ac8e07c47c1773bb2776ebd91e3886c3af", + "3.1.62-asserts": "9d9e7deac8b91fbdd8804045595e807f9d774a53", "3.1.61": "28e4a74b579b4157bda5fc34f23c7d3905a8bd6c", "3.1.61-asserts": "7fc912687ba2077b3aeae472b51c238b3d201c46", "3.1.60": "87709b5747de5b1993fe314285528bf4b65c23e1", From 772828321afe0761c836bbbad3992ba392b9b708 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 12 Jul 2024 09:23:42 -0700 Subject: [PATCH 61/68] 3.1.63 (#1425) --- bazel/revisions.bzl | 7 +++++++ emscripten-releases-tags.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/revisions.bzl b/bazel/revisions.bzl index f9d65449da..8bd1c5ba6f 100644 --- a/bazel/revisions.bzl +++ b/bazel/revisions.bzl @@ -2,6 +2,13 @@ # 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", diff --git a/emscripten-releases-tags.json b/emscripten-releases-tags.json index bcdbf4f382..9693caa54b 100644 --- a/emscripten-releases-tags.json +++ b/emscripten-releases-tags.json @@ -1,6 +1,6 @@ { "aliases": { - "latest": "3.1.62", + "latest": "3.1.63", "latest-sdk": "latest", "latest-arm64-linux": "latest", "latest-64bit": "latest", @@ -10,6 +10,8 @@ "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", From a52ef1401689f82574445c84e223ff7f7b87178a Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:43:11 -0700 Subject: [PATCH 62/68] Remove unnecessary dependencies that make the sandbox slow --- bazel/emscripten_deps.bzl | 82 ++------------------------------------- 1 file changed, 4 insertions(+), 78 deletions(-) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 16fd8ee1c6..3d5e63506e 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): @@ -23,32 +22,12 @@ filegroup( ]), ) -filegroup( - name = "emcc_common", - srcs = [ - "emscripten/emcc.py", - "emscripten/embuilder.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__/**", - ], - ), -) - filegroup( name = "compiler_files", srcs = [ + "emscripten/emcc.py", "bin/clang{bin_extension}", "bin/clang++{bin_extension}", - ":emcc_common", ":includes", ], ) @@ -56,6 +35,7 @@ filegroup( filegroup( name = "linker_files", srcs = [ + "emscripten/emcc.py", "bin/clang{bin_extension}", "bin/llvm-ar{bin_extension}", "bin/llvm-dwarfdump{bin_extension}", @@ -68,14 +48,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( @@ -83,17 +56,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__/**", - ], - ), + ] ) """ @@ -116,11 +79,6 @@ def emscripten_deps(emscripten_version = "latest"): # 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( @@ -173,37 +131,5 @@ 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", - ) - 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", - ) - 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", - ) - - 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", - ) From 9cc27a85daa6f72e97a57077ab586d3810975ec7 Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:44:18 -0700 Subject: [PATCH 63/68] Use -fdebug-prefix-map=$PWD=/figma-root --- bazel/emscripten_toolchain/emcc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 "$@" From de5510fd468c6aa0fad9b289f04d78662dc5da36 Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:47:54 -0700 Subject: [PATCH 64/68] Get node binary via @nodejs//:node --- bazel/emscripten_toolchain/BUILD.bazel | 1 + bazel/emscripten_toolchain/default_config | 9 ++------- bazel/emscripten_toolchain/toolchain.bzl | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index 3cd086064e..620666c969 100644 --- a/bazel/emscripten_toolchain/BUILD.bazel +++ b/bazel/emscripten_toolchain/BUILD.bazel @@ -66,6 +66,7 @@ emscripten_cc_toolchain_config_rule( "@bazel_tools//src/conditions:host_windows": "bat", "//conditions:default": "sh", }), + node_binary = "@nodejs//:node", ) cc_toolchain( diff --git a/bazel/emscripten_toolchain/default_config b/bazel/emscripten_toolchain/default_config index 648a8fef20..d42977b019 100644 --- a/bazel/emscripten_toolchain/default_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/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index c3c9f43347..2e2671b830 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -1060,6 +1060,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 @@ -1135,6 +1139,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], ) From adbb6cb8113e8b437f556b42fcb61df5cca82bac Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:49:05 -0700 Subject: [PATCH 65/68] Remove unnecessary dependencies --- bazel/MODULE.bazel.lock | 64 +++++++++++++++++++++++++++++++++++++++++ bazel/deps.bzl | 22 +------------- 2 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 bazel/MODULE.bazel.lock 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/deps.bzl b/bazel/deps.bzl index a83cfaf847..8c6dd98261 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -11,24 +11,4 @@ def deps(): ], sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b", ) - maybe( - http_archive, - name = "bazel_skylib", - sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", - 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", - ], - ) - 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 From e5797f9ab3fbb7ce79e274aba7248f2dda967235 Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:50:53 -0700 Subject: [PATCH 66/68] Support relocatable pre-compiled headers --- bazel/emscripten_toolchain/toolchain.bzl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 2e2671b830..1773479e42 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -294,6 +294,10 @@ 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"), @@ -930,9 +934,11 @@ 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 + "/emscripten/cache/sysroot/include", "-isystem", emscripten_dir + "/lib/clang/19/include", ], From 6b389f47696fd23c33aef4046b13b224629cf6d8 Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Wed, 26 Jun 2024 22:57:35 -0700 Subject: [PATCH 67/68] Support bazel debuginfo fission --- bazel/BUILD | 12 +++++ bazel/emscripten_deps.bzl | 7 +++ bazel/emscripten_toolchain/BUILD.bazel | 11 ++++- bazel/emscripten_toolchain/dwp.sh | 31 +++++++++++++ bazel/emscripten_toolchain/toolchain.bzl | 44 +++++++++++++++++++ bazel/emscripten_toolchain/wasm_cc_binary.bzl | 22 +++++++++- 6 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 bazel/emscripten_toolchain/dwp.sh diff --git a/bazel/BUILD b/bazel/BUILD index cb3135ce02..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({ diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index 3d5e63506e..be29bc12ab 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -32,6 +32,13 @@ filegroup( ], ) +filegroup( + name = "dwp_files", + srcs = [ + "bin/llvm-dwp", + ], +) + filegroup( name = "linker_files", srcs = [ diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel index 620666c969..2061cfe1b6 100644 --- a/bazel/emscripten_toolchain/BUILD.bazel +++ b/bazel/emscripten_toolchain/BUILD.bazel @@ -43,11 +43,20 @@ filegroup( ], ) +filegroup( + name = "dwp_files", + srcs = [ + "dwp.sh", + "@emsdk//:dwp_files", + ], +) + filegroup( name = "all_files", srcs = [ ":ar_files", ":compiler_files", + ":dwp_files", ":linker_files", ], ) @@ -75,7 +84,7 @@ cc_toolchain( 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/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/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index 1773479e42..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), @@ -302,6 +342,10 @@ def _impl(ctx): # 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?) diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl index 6ea4f127f0..aacca1ff71 100644 --- a/bazel/emscripten_toolchain/wasm_cc_binary.bzl +++ b/bazel/emscripten_toolchain/wasm_cc_binary.bzl @@ -69,6 +69,7 @@ _ALLOW_OUTPUT_EXTNAMES = [ ".fetch.js", ".js.symbols", ".wasm.debug.wasm", + ".wasm.debug.wasm.dwp", ".html", ".aw.js", ] @@ -155,6 +156,20 @@ def _wasm_cc_binary_legacy_impl(ctx): 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) @@ -167,13 +182,15 @@ def _wasm_cc_binary_legacy_impl(ctx): executable = ctx.executable._wasm_binary_extractor, ) + all_outputs = outputs + [ctx.outputs.dwp_file] + return [ DefaultInfo( executable = ctx.outputs.wasm, - files = depset(outputs), + 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(outputs)), + data_runfiles = ctx.runfiles(transitive_files = depset(all_outputs)), ), OutputGroupInfo(_wasm_tar = cc_target.files), ] @@ -202,6 +219,7 @@ 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) } From 332fb832e5a3539a92e3ecb2e20372e71467b513 Mon Sep 17 00:00:00 2001 From: Stanislav Panferov Date: Fri, 19 Jul 2024 08:09:39 -0700 Subject: [PATCH 68/68] Support older emscripten versions --- bazel/emscripten_deps.bzl | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl index be29bc12ab..73350c6142 100644 --- a/bazel/emscripten_deps.bzl +++ b/bazel/emscripten_deps.bzl @@ -80,6 +80,12 @@ 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{}.{}" @@ -91,41 +97,41 @@ def emscripten_deps(emscripten_version = "latest"): http_archive( name = "emscripten_bin_linux", strip_prefix = "install", - url = emscripten_url.format("linux", revision.hash, "", "tar.xz"), + 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.xz", + 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", "tar.xz"), + 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.xz", + 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, "", "tar.xz"), + 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.xz", + 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", "tar.xz"), + 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.xz", + type = archive_type, ) if "emscripten_bin_win" not in excludes: @@ -138,5 +144,14 @@ def emscripten_deps(emscripten_version = "latest"): type = "zip", ) +def is_version_less_than(a, b): + def map(f, list): + return [f(x) for x in list] + + def parse_version(version): + return tuple(map(int, version.split("."))) + a_tuple = parse_version(a) + b_tuple = parse_version(b) + return a_tuple < b_tuple