Skip to content

Commit

Permalink
Add linux/arm64 support to bazel rules (#1156)
Browse files Browse the repository at this point in the history
* Add linux/arm64 support to bazel rules

* Make linux arm64 sha optional and PR feedback

Not all releases have linux shas. Use getattr to default to no sha if none was
present. This way non linux arm64 builds should not fail.

* Update linux arm64 sha for 3.1.33

This is the latest arm64 release according to #1204. There do not seem to be a any releases between .21 and .33.
  • Loading branch information
robbertvanginkel authored Mar 30, 2023
1 parent a2ccccb commit 04944dd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ config_setting(
],
)

config_setting(
name = "linux_arm64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
)

config_setting(
name = "macos",
constraint_values = [
Expand Down Expand Up @@ -38,6 +46,7 @@ alias(
name = "compiler_files",
actual = select({
":linux": "@emscripten_bin_linux//:compiler_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:compiler_files",
":macos": "@emscripten_bin_mac//:compiler_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:compiler_files",
":windows": "@emscripten_bin_win//:compiler_files",
Expand All @@ -49,6 +58,7 @@ alias(
name = "linker_files",
actual = select({
":linux": "@emscripten_bin_linux//:linker_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:linker_files",
":macos": "@emscripten_bin_mac//:linker_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:linker_files",
":windows": "@emscripten_bin_win//:linker_files",
Expand All @@ -60,6 +70,7 @@ alias(
name = "ar_files",
actual = select({
":linux": "@emscripten_bin_linux//:ar_files",
":linux_arm64": "@emscripten_bin_linux_arm64//:ar_files",
":macos": "@emscripten_bin_mac//:ar_files",
":macos_arm64": "@emscripten_bin_mac_arm64//:ar_files",
":windows": "@emscripten_bin_win//:ar_files",
Expand Down
18 changes: 18 additions & 0 deletions bazel/emscripten_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ def emscripten_deps(emscripten_version = "latest"):
type = "tar.bz2",
)

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"),
# 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",
)

if "emscripten_bin_mac" not in excludes:
http_archive(
name = "emscripten_bin_mac",
Expand Down Expand Up @@ -164,6 +175,13 @@ def emscripten_deps(emscripten_version = "latest"):
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",
Expand Down
2 changes: 1 addition & 1 deletion bazel/emscripten_toolchain/emscripten_config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROZEN_CACHE = True

system = platform.system()

machine = "arm64" if platform.machine() == "arm64" else "amd64"
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)

Expand Down
2 changes: 2 additions & 0 deletions bazel/revisions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EMSCRIPTEN_TAGS = {
"3.1.33": struct(
hash = "49b960bd03b3a9da478a08541ce6eafe792a58a8",
sha_linux = "eab02b3f4b7c076974452ba602f908a36adf597afa15b16095b441f191ede1bb",
sha_linux_arm64 = "5e15af6affcf37c9ce6c304b4aeccb87a2758e1ef029dbc996f9d77d7444378e",
sha_mac = "b8dad3cddb19c1daf9dae99020bd17b903ae9649cfc58e433ea4951e758804de",
sha_mac_arm64 = "fbf03d06c7503f091191e440b8ea577d65b3261167cdb47359d053f12888974b",
sha_win = "031f951668eaeea39bd9363abb3f514efc3401506374984fa9b1d7ba3130a62f",
Expand Down Expand Up @@ -96,6 +97,7 @@ EMSCRIPTEN_TAGS = {
"3.1.21": struct(
hash = "a16a8bca2466eb144f7c93fa899c0272c8815dc3",
sha_linux = "7045ddb3b37a2cc63cb1cf976019a6a3b7f8dbdc71254db0eee5b0452f94e9e7",
sha_linux_arm64 = "2852c8b108ec748d52d31dab3f4854bc6022df008019daff1c7e31ac00363b3f",
sha_mac = "2a8d3d3ad721fec81ca1a4a581e4183b6e732e9905beb874531851846a05a367",
sha_mac_arm64 = "cf788a7bdc38bb40d01f94b2d46acafb0e2f02d8ee3b3d69541c114e467ee37f",
sha_win = "81518bba13f41717ffe6990b6d4a5af635d0c9d0f71a8d3bc0980cd0bc8f5f66",
Expand Down

0 comments on commit 04944dd

Please sign in to comment.