Skip to content

Instantly share code, notes, and snippets.

@ethankhall
Last active June 4, 2023 09:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethankhall/516ddcefd22297a6cb9f736648386292 to your computer and use it in GitHub Desktop.
Save ethankhall/516ddcefd22297a6cb9f736648386292 to your computer and use it in GitHub Desktop.
Sorbet Linux-ARM build
# syntax=docker/dockerfile:1.4
FROM gusto/ruby:2.7.6-ubuntu20.04 as build
ARG GIT_TAG=0.5.10458.20220926130158-4007ec60a
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN <<END_OF_RUN
set -ex
apt-get update
apt-get install -y software-properties-common
apt-get update
apt-get install -y git build-essential curl perl unzip python autoconf libffi-dev libgmp-dev libtinfo5 libtinfo-dev python python3 git libssl-dev libreadline-dev zlib1g-dev
ln -s /usr/lib/gcc/aarch64-linux-gnu/9/cc1plus /usr/local/bin
END_OF_RUN
RUN <<END_OF_RUN
set -ex
curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.14.0/bazelisk-linux-arm64 --output /usr/local/bin/bazel
chmod +x /usr/local/bin/bazel
END_OF_RUN
RUN <<END_OF_RUN
set -ex
add-apt-repository ppa:ubuntu-toolchain-r/test
cat <<EOF > /etc/apt/sources.list.d/llvm.list
deb http://apt.llvm.org/focal/ llvm-toolchain-focal main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main
# 14
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
# 15
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
EOF
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
apt-get update
apt-get install -y libc++-14-dev clang-tools-14 clang-14
rm /usr/bin/sh
ln -s /bin/bash /usr/bin/sh
END_OF_RUN
# ^ is needed because jmalloc runs a bash script with "sh" which means that `if [[ .. ]]; then` doesn't work
ENV PATH=/usr/lib/llvm-14/bin/:/usr/local/bin:$PATH
ENV USE_BAZEL_VERSION 5.2.0
ENV CXX=clang++-14
ENV CC=clang-14
ENV PATH=/root/.rbenv/bin:/root/.rbenv/shims:$PATH
RUN <<END_OF_RUN
curl -fsSL https://raw.githubusercontent.com/rbenv/rbenv-installer/108c12307621a0aa06f19799641848dde1987deb/bin/rbenv-installer | bash -x
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /root/.bashrc
rbenv install '2.7.2' && \
rbenv global 2.7.2 && \
gem install bundler && \
ln -s /root/.rbenv/versions/2.7.2 /root/.rbenv/versions/2.7
END_OF_RUN
RUN git clone --depth 1 --branch ${GIT_TAG} https://github.com/sorbet/sorbet.git /sorbet
RUN <<END_OF_RUN
gem install mocha minitest
END_OF_RUN
WORKDIR /sorbet
COPY sorbet.patch /sorbet.patch
RUN <<END_OF_RUN
set -ex
git apply /sorbet.patch
mkdir /output
END_OF_RUN
RUN .buildkite/build-sorbet-runtime.sh && cp _out_/gems/* /output
RUN .buildkite/build-static-release.sh && cp _out_/gems/* /output
FROM alpine AS release
# the intent of the final layer is to simply expose .gem files that can be
# copied into other images for use in applications as local bundler overrides
# (effectively fulfilling Gemfile.lock via a local tarball). if you instead
# want the entire build image to do whatever with, just select that stage via
# CLI/docker-compose/etc. arguments
COPY --from=build /sorbet/_out_/gems/*.gem /output/
# syntax=docker/dockerfile:1.4
FROM gusto/ruby:2.7.6-ubuntu20.04 as base
ARG GIT_TAG=0.5.10297.20220808161710-f52d11a1f
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN <<END_OF_RUN
set -ex
apt-get update
apt-get install -y software-properties-common
apt-get update
apt-get install -y git build-essential curl perl unzip python autoconf libffi-dev libgmp-dev libtinfo5 libtinfo-dev python python3 git libssl-dev libreadline-dev zlib1g-dev
ln -s /usr/lib/gcc/aarch64-linux-gnu/9/cc1plus /usr/local/bin
END_OF_RUN
RUN <<END_OF_RUN
set -ex
curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.14.0/bazelisk-linux-arm64 --output /usr/local/bin/bazel
chmod +x /usr/local/bin/bazel
END_OF_RUN
RUN <<END_OF_RUN
set -ex
add-apt-repository ppa:ubuntu-toolchain-r/test
cat <<EOF > /etc/apt/sources.list.d/llvm.list
deb http://apt.llvm.org/focal/ llvm-toolchain-focal main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main
# 14
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
# 15
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
EOF
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
apt-get update
apt-get install -y libc++-14-dev clang-tools-14 clang-14
rm /usr/bin/sh
ln -s /bin/bash /usr/bin/sh
END_OF_RUN
# ^ is needed because jmalloc runs a bash script with "sh" which means that `if [[ .. ]]; then` doesn't work
ENV PATH=/usr/lib/llvm-14/bin/:/usr/local/bin:$PATH
ENV USE_BAZEL_VERSION 5.2.0
ENV CXX=clang++-14
ENV CC=clang-14
ENV PATH=/root/.rbenv/bin:/root/.rbenv/shims:$PATH
RUN <<END_OF_RUN
curl -fsSL https://raw.githubusercontent.com/rbenv/rbenv-installer/108c12307621a0aa06f19799641848dde1987deb/bin/rbenv-installer | bash -x
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /root/.bashrc
rbenv install '2.7.2' && \
rbenv global 2.7.2 && \
gem install bundler && \
ln -s /root/.rbenv/versions/2.7.2 /root/.rbenv/versions/2.7
END_OF_RUN
RUN git clone --depth 1 --branch ${GIT_TAG} https://github.com/sorbet/sorbet.git /sorbet
RUN <<END_OF_RUN
gem install mocha minitest
END_OF_RUN
WORKDIR /sorbet
COPY sorbet-f52d11a1f.patch /sorbet-f52d11a1f.patch
RUN <<END_OF_RUN
set -ex
git apply /sorbet-f52d11a1f.patch
rm bazel
ln -s /usr/local/bin/bazel bazel
mkdir /output
END_OF_RUN
FROM base as build
RUN .buildkite/build-sorbet-runtime.sh && cp _out_/gems/* /output
RUN .buildkite/build-static-release.sh && cp _out_/gems/* /output
FROM alpine AS release
# the intent of the final layer is to simply expose .gem files that can be
# copied into other images for use in applications as local bundler overrides
# (effectively fulfilling Gemfile.lock via a local tarball). if you instead
# want the entire build image to do whatever with, just select that stage via
# CLI/docker-compose/etc. arguments
COPY --from=build /sorbet/_out_/gems/*.gem /output/
diff --git a/.bazelrc b/.bazelrc
index 4d1e64598..dd7af19bc 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,7 +12,7 @@ common:test --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1
##
## Custom toolchain.
##
-build --crosstool_top=@llvm_toolchain_12_0_0//:toolchain --copt=-D_LIBCPP_ENABLE_NODISCARD
+build --incompatible_enable_cc_toolchain_resolution
##
## Common build options across all build configurations
@@ -95,23 +95,15 @@ build:release-debug-common --config=debugsymbols
build:release-debug-common --config=skipslowenforce
# harden: mark relocation sections read-only
-build:release-linux --linkopt=-Wl,-z,relro,-z,now
-build:release-linux --config=lto-linux --config=release-common --platforms=@//tools/config:linux_x86_64
-
-# This is to turn on vector instructions where available.
-# We used to do this unconditionally, but Rosetta 2 doesn't translate all vector instructions well.
-#
-# If we ever start making universal x86-64 + aarch64 binaries for macOS, we
-# could think about re-enabling the vector instructions for x86-64.
-#
-# At Stripe: developer laptops run skylake, devboxes run skylake-avx512
-# however some AWS instances in our fleet still run Sandy Bridge (Skylake predecessor), as of 2018.
-build:release-linux --copt=-march=sandybridge
-build:release-sanitized-linux --copt=-march=sandybridge
+build:release-linux-x86_64 --linkopt=-Wl,-z,relro,-z,now
+build:release-linux-x86_64 --config=lto-linux --config=release-common --platforms=@//tools/config:linux_x86_64
+
+build:release-linux-aarch64 --linkopt=-Wl,-z,relro,-z,now
+build:release-linux-aarch64 --config=lto-linux --config=release-common --platforms=@//tools/config:linux_aarch64
build:release-mac --config=release-common --platforms=@//tools/config:darwin_x86_64
-build:release-debug-linux --config=release-linux
+build:release-debug-linux --config=release-linux-x86_64
build:release-debug-linux --config=release-debug-common
build:release-debug-mac --config=release-mac
diff --git a/.buildkite/build-sorbet-runtime.sh b/.buildkite/build-sorbet-runtime.sh
index 17ee1250c..f2982f669 100755
--- a/.buildkite/build-sorbet-runtime.sh
+++ b/.buildkite/build-sorbet-runtime.sh
@@ -7,7 +7,7 @@ pushd gems/sorbet-runtime
echo "--- setup :ruby:"
eval "$(rbenv init -)"
-runtime_versions=(2.6.3 2.7.2)
+runtime_versions=(2.7.2)
for runtime_version in "${runtime_versions[@]}"; do
rbenv install --skip-existing "$runtime_version"
@@ -39,8 +39,7 @@ for runtime_version in "${runtime_versions[@]}"; do
done
echo "--- build"
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-runtime.gemspec
gem build sorbet-runtime.gemspec
popd
diff --git a/.buildkite/build-sorbet-static-and-runtime.sh b/.buildkite/build-sorbet-static-and-runtime.sh
index 38e1fdc04..02ca25fb2 100755
--- a/.buildkite/build-sorbet-static-and-runtime.sh
+++ b/.buildkite/build-sorbet-static-and-runtime.sh
@@ -15,8 +15,7 @@ for runtime_version in "${runtime_versions[@]}"; do
done
echo "--- build"
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-static-and-runtime.gemspec
gem build sorbet-static-and-runtime.gemspec
diff --git a/.buildkite/build-static-release.sh b/.buildkite/build-static-release.sh
index ebfebe8d1..9048a7f06 100755
--- a/.buildkite/build-static-release.sh
+++ b/.buildkite/build-static-release.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-set -euo pipefail
+set -euxo pipefail
export JOB_NAME=build-static-release
source .buildkite/tools/setup-bazel.sh
@@ -13,7 +13,7 @@ case "${unameOut}" in
esac
if [[ "linux" == "$platform" ]]; then
- CONFIG_OPTS="--config=release-linux"
+ CONFIG_OPTS="--config=release-linux-$(arch)"
elif [[ "mac" == "$platform" ]]; then
CONFIG_OPTS="--config=release-mac"
command -v autoconf >/dev/null 2>&1 || brew install autoconf
@@ -29,8 +29,8 @@ cp bazel-bin/main/sorbet gems/sorbet-static/libexec/
rbenv install --skip-existing
pushd gems/sorbet-static
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
+echo $release_version
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-static.gemspec
if [[ "mac" == "$platform" ]]; then
# Our binary should work on almost all OSes. The oldest v8 publishes is -14
@@ -74,6 +74,6 @@ if [[ "mac" == "$platform" ]]; then
rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-universal-darwin-18.gem
else
- rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-x86_64-linux.gem
+ rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-$(arch)-linux.gem
fi
rbenv exec gem install sorbet-*.gem
@@ -95,6 +95,9 @@ cp ../../.ruby-version "$smoke_test_dir"
)
rm -rf srb-init-smoke-test
+mkdir -p ./vendor/cache/
+cp $(find /sorbet/gems/ -name '*.gem' | tr '\n' ' ') ./vendor/cache/
+
rbenv exec bundle
rbenv exec bundle exec rake test
diff --git a/WORKSPACE b/WORKSPACE
index e40f0a29c..78c30f020 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -17,14 +17,13 @@ load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain(
name = "llvm_toolchain_12_0_0",
absolute_paths = True,
- llvm_mirror_prefixes = [
- "https://sorbet-deps.s3-us-west-2.amazonaws.com/",
- "https://artifactory-content.stripe.build/artifactory/github-archives/llvm/llvm-project/releases/download/llvmorg-",
- "https://github.com/llvm/llvm-project/releases/download/llvmorg-",
- ],
llvm_version = "12.0.0",
)
+load("@llvm_toolchain_12_0_0//:toolchains.bzl", "llvm_register_toolchains")
+
+llvm_register_toolchains()
+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
diff --git a/common/crypto_hashing/BUILD b/common/crypto_hashing/BUILD
index 0c27a10d0..4118b5d55 100644
--- a/common/crypto_hashing/BUILD
+++ b/common/crypto_hashing/BUILD
@@ -8,8 +8,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = ["//common"] + select({
"//tools/config:webasm": ["@com_github_blake2_blake2"],
- "//tools/config:darwin": ["@com_github_blake2_libb2"],
- "//tools/config:linux": ["@com_github_blake2_libb2"],
+ "//tools/config:darwin": ["@com_github_blake2_blake2"],
+ "//tools/config:linux": ["@com_github_blake2_blake2"],
"//conditions:default": ["@com_github_blake2_blake2"],
}),
)
diff --git a/common/crypto_hashing/crypto_hashing.h b/common/crypto_hashing/crypto_hashing.h
index da09d4e51..82009c59f 100644
--- a/common/crypto_hashing/crypto_hashing.h
+++ b/common/crypto_hashing/crypto_hashing.h
@@ -3,11 +3,7 @@
#include "common/common.h"
extern "C" {
-#if defined(__i386__) || defined(__x86_64__)
-#include "blake2.h"
-#else
#include "ref/blake2.h"
-#endif
};
namespace sorbet::crypto_hashing {
@@ -15,12 +11,10 @@ inline std::array<uint8_t, 64> hash64(std::string_view data) {
static_assert(BLAKE2B_OUTBYTES == 64);
std::array<uint8_t, 64> res;
-#if defined(__i386__) || defined(__x86_64__)
- int err = blake2b(&res[0], data.begin(), nullptr, std::size(res), data.size(), 0);
-#else
+
// it has different order of arguments \facepalm
int err = blake2b(&res[0], std::size(res), data.begin(), data.size(), nullptr, 0);
-#endif
+
ENFORCE(err == 0);
return res;
};
diff --git a/third_party/externals.bzl b/third_party/externals.bzl
index 2d9fad8af..c45e44834 100644
--- a/third_party/externals.bzl
+++ b/third_party/externals.bzl
@@ -168,12 +168,15 @@ def register_sorbet_dependencies():
strip_prefix = "bazel-compilation-database-6b9329e37295eab431f82af5fe24219865403e0f",
)
- # NOTE: we use the sorbet branch for development to keep our changes rebasable on grailio/bazel-toolchain
+ LLVM_BAZEL_TOOLCHAIN_TAG = "0.7.2"
+ LLVM_BAZEL_TOOLCHAIN_SHA = "f7aa8e59c9d3cafde6edb372d9bd25fb4ee7293ab20b916d867cd0baaa642529"
+
http_archive(
name = "com_grail_bazel_toolchain",
- urls = _github_public_urls("sorbet/bazel-toolchain/archive/a685e1e6bd1e7cc9a5b84f832539585bb68d8ab4.zip"),
- sha256 = "90c59f14cada755706a38bdd0f5ad8f0402cbf766387929cfbee9c3f1b4c82d7",
- strip_prefix = "bazel-toolchain-a685e1e6bd1e7cc9a5b84f832539585bb68d8ab4",
+ sha256 = LLVM_BAZEL_TOOLCHAIN_SHA,
+ strip_prefix = "bazel-toolchain-{tag}".format(tag = LLVM_BAZEL_TOOLCHAIN_TAG),
+ canonical_id = LLVM_BAZEL_TOOLCHAIN_TAG,
+ url = "https://github.com/grailbio/bazel-toolchain/archive/{tag}.tar.gz".format(tag = LLVM_BAZEL_TOOLCHAIN_TAG),
)
http_archive(
@@ -196,15 +199,6 @@ def register_sorbet_dependencies():
strip_prefix = "buildtools-5bcc31df55ec1de770cb52887f2e989e7068301f",
)
- # optimized version of blake2 hashing algorithm
- http_archive(
- name = "com_github_blake2_libb2",
- urls = _github_public_urls("BLAKE2/libb2/archive/fa83ddbe179912e9a7a57edf0333b33f6ff83056.zip"),
- sha256 = "dd25f7ac53371c2a15761fc1689d04de2ff948ac7e213a10d13961e24b0c9ae6",
- build_file = "@com_stripe_ruby_typer//third_party:libb2.BUILD",
- strip_prefix = "libb2-fa83ddbe179912e9a7a57edf0333b33f6ff83056",
- )
-
# portable reference implementation of blake2
http_archive(
name = "com_github_blake2_blake2",
diff --git a/third_party/libb2.BUILD b/third_party/libb2.BUILD
deleted file mode 100644
index 7004c0196..000000000
--- a/third_party/libb2.BUILD
+++ /dev/null
@@ -1,33 +0,0 @@
-BLAKE2_COPTS = [
- "-Wno-unused-const-variable",
- "-Wno-unused-function",
-]
-
-genrule(
- name = "stub_config",
- srcs = ["src/blake2-config.h"],
- outs = ["src/config.h"],
- cmd = "cat $(location src/blake2-config.h) > $@",
-)
-
-cc_library(
- name = "com_github_blake2_libb2",
- srcs = [
- "src/blake2s.c",
- "src/blake2b.c",
- "src/config.h",
- ] + glob(["src/*.h"]),
- hdrs = [
- "src/blake2.h",
- ],
- copts = BLAKE2_COPTS,
- defines = ["SUFFIX="],
- includes = [
- "src",
- ],
- linkstatic = select({
- "@com_stripe_ruby_typer//tools/config:linkshared": 0,
- "//conditions:default": 1,
- }),
- visibility = ["//visibility:public"],
-)
diff --git a/third_party/llvm/llvm.bzl b/third_party/llvm/llvm.bzl
index e3edb437f..1ee37e44f 100644
--- a/third_party/llvm/llvm.bzl
+++ b/third_party/llvm/llvm.bzl
@@ -310,7 +310,7 @@ llvm_all_cmake_vars = select({
"@com_stripe_ruby_typer//tools/config:linux": cmake_var_string(
_dict_add(
cmake_vars,
- llvm_target_cmake_vars("X86", "x86_64-unknown-linux_gnu"),
+ llvm_target_cmake_vars("AARCH64", "aarch64-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
diff --git a/tools/clang.bzl b/tools/clang.bzl
index 1b0e856ae..b0a67d515 100644
--- a/tools/clang.bzl
+++ b/tools/clang.bzl
@@ -30,6 +30,6 @@ _clang_tool = rule(
def clang_tool(name):
_clang_tool(
name = name,
- tool = "@llvm_toolchain_12_0_0//:bin/" + name,
+ tool = "@llvm_toolchain_12_0_0//:" + name,
visibility = ["//visibility:public"],
)
diff --git a/tools/config/BUILD b/tools/config/BUILD
index 3c66534fe..43c6523d7 100644
--- a/tools/config/BUILD
+++ b/tools/config/BUILD
@@ -16,6 +16,14 @@ platform(
],
)
+platform(
+ name = "linux_aarch64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:arm64",
+ ],
+)
+
config_setting(
name = "darwin",
constraint_values = [
@@ -28,10 +36,14 @@ config_setting(
name = "linux",
constraint_values = [
"@platforms//os:linux",
- "@platforms//cpu:x86_64",
],
)
+config_setting(
+ name = "aarch64",
+ values = {"host_cpu": "aarch64"},
+)
+
config_setting(
name = "opt",
values = {"compilation_mode": "opt"},
diff --git a/.bazelrc b/.bazelrc
index 4d1e64598..dd7af19bc 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,7 +12,7 @@ common:test --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1
##
## Custom toolchain.
##
-build --crosstool_top=@llvm_toolchain_12_0_0//:toolchain --copt=-D_LIBCPP_ENABLE_NODISCARD
+build --incompatible_enable_cc_toolchain_resolution
##
## Common build options across all build configurations
@@ -95,23 +95,15 @@ build:release-debug-common --config=debugsymbols
build:release-debug-common --config=skipslowenforce
# harden: mark relocation sections read-only
-build:release-linux --linkopt=-Wl,-z,relro,-z,now
-build:release-linux --config=lto-linux --config=release-common --platforms=@//tools/config:linux_x86_64
-
-# This is to turn on vector instructions where available.
-# We used to do this unconditionally, but Rosetta 2 doesn't translate all vector instructions well.
-#
-# If we ever start making universal x86-64 + aarch64 binaries for macOS, we
-# could think about re-enabling the vector instructions for x86-64.
-#
-# At Stripe: developer laptops run skylake, devboxes run skylake-avx512
-# however some AWS instances in our fleet still run Sandy Bridge (Skylake predecessor), as of 2018.
-build:release-linux --copt=-march=sandybridge
-build:release-sanitized-linux --copt=-march=sandybridge
+build:release-linux-x86_64 --linkopt=-Wl,-z,relro,-z,now
+build:release-linux-x86_64 --config=lto-linux --config=release-common --platforms=@//tools/config:linux_x86_64
+
+build:release-linux-aarch64 --linkopt=-Wl,-z,relro,-z,now
+build:release-linux-aarch64 --config=lto-linux --config=release-common --platforms=@//tools/config:linux_aarch64
build:release-mac --config=release-common --platforms=@//tools/config:darwin_x86_64
-build:release-debug-linux --config=release-linux
+build:release-debug-linux --config=release-linux-x86_64
build:release-debug-linux --config=release-debug-common
build:release-debug-mac --config=release-mac
diff --git a/.buildkite/build-sorbet-runtime.sh b/.buildkite/build-sorbet-runtime.sh
index 17ee1250c..f2982f669 100755
--- a/.buildkite/build-sorbet-runtime.sh
+++ b/.buildkite/build-sorbet-runtime.sh
@@ -7,7 +7,7 @@ pushd gems/sorbet-runtime
echo "--- setup :ruby:"
eval "$(rbenv init -)"
-runtime_versions=(2.6.3 2.7.2)
+runtime_versions=(2.7.2)
for runtime_version in "${runtime_versions[@]}"; do
rbenv install --skip-existing "$runtime_version"
@@ -39,8 +39,7 @@ for runtime_version in "${runtime_versions[@]}"; do
done
echo "--- build"
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-runtime.gemspec
gem build sorbet-runtime.gemspec
popd
diff --git a/.buildkite/build-sorbet-static-and-runtime.sh b/.buildkite/build-sorbet-static-and-runtime.sh
index 38e1fdc04..02ca25fb2 100755
--- a/.buildkite/build-sorbet-static-and-runtime.sh
+++ b/.buildkite/build-sorbet-static-and-runtime.sh
@@ -15,8 +15,7 @@ for runtime_version in "${runtime_versions[@]}"; do
done
echo "--- build"
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-static-and-runtime.gemspec
gem build sorbet-static-and-runtime.gemspec
diff --git a/.buildkite/build-static-release.sh b/.buildkite/build-static-release.sh
index ebfebe8d1..9048a7f06 100755
--- a/.buildkite/build-static-release.sh
+++ b/.buildkite/build-static-release.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-set -euo pipefail
+set -euxo pipefail
export JOB_NAME=build-static-release
source .buildkite/tools/setup-bazel.sh
@@ -13,7 +13,7 @@ case "${unameOut}" in
esac
if [[ "linux" == "$platform" ]]; then
- CONFIG_OPTS="--config=release-linux"
+ CONFIG_OPTS="--config=release-linux-$(arch)"
elif [[ "mac" == "$platform" ]]; then
CONFIG_OPTS="--config=release-mac"
command -v autoconf >/dev/null 2>&1 || brew install autoconf
@@ -29,8 +29,8 @@ cp bazel-bin/main/sorbet gems/sorbet-static/libexec/
rbenv install --skip-existing
pushd gems/sorbet-static
-git_commit_count=$(git rev-list --count HEAD)
-release_version="0.5.${git_commit_count}"
+release_version=$(git describe --tags | cut -d. -f1-3)
+echo $release_version
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-static.gemspec
if [[ "mac" == "$platform" ]]; then
# Our binary should work on almost all OSes. The oldest v8 publishes is -14
@@ -74,7 +74,7 @@ if [[ "mac" == "$platform" ]]; then
gem_platform="$(ruby -e "(platform = Gem::Platform.local).cpu = 'universal'; puts(platform.to_s)")"
rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-"$gem_platform".gem
else
- rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-x86_64-linux.gem
+ rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-$(arch)-linux.gem
fi
rbenv exec gem install sorbet-*.gem
@@ -95,6 +95,9 @@ cp ../../.ruby-version "$smoke_test_dir"
)
rm -rf srb-init-smoke-test
+mkdir -p ./vendor/cache/
+cp $(find /sorbet/gems/ -name '*.gem' | tr '\n' ' ') ./vendor/cache/
+
rbenv exec bundle
rbenv exec bundle exec rake test
diff --git a/WORKSPACE b/WORKSPACE
index e40f0a29c..78c30f020 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -17,14 +17,13 @@ load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain(
name = "llvm_toolchain_12_0_0",
absolute_paths = True,
- llvm_mirror_prefixes = [
- "https://sorbet-deps.s3-us-west-2.amazonaws.com/",
- "https://artifactory-content.stripe.build/artifactory/github-archives/llvm/llvm-project/releases/download/llvmorg-",
- "https://github.com/llvm/llvm-project/releases/download/llvmorg-",
- ],
llvm_version = "12.0.0",
)
+load("@llvm_toolchain_12_0_0//:toolchains.bzl", "llvm_register_toolchains")
+
+llvm_register_toolchains()
+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
diff --git a/bazel b/bazel
deleted file mode 100755
index f407ff6f0..000000000
--- a/bazel
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/bash
-
-#
-# ./bazel
-#
-# Reads the BAZEL_VERSION variable in the WORKSPACE file and executes the
-# corresponding Bazel version. Downloads and installs it if needed.
-#
-
-set -euo pipefail
-
-if [ "${LOCAL_BAZEL_OVERRIDE:-}" != "" ]; then
- exec "$LOCAL_BAZEL_OVERRIDE" "$@"
-fi
-
-old_pwd="$PWD"
-cd "$(dirname "${BASH_SOURCE[0]}")"
-
-if [[ "$PWD" = */tools ]]; then
- cd ..
-fi
-repo_root="$PWD"
-
-if ! [ -f WORKSPACE ]; then
- echo >&2 "Didn't find the workspace"
- exit 1
-fi
-
-cd "$old_pwd"
-
-workspace_contents=$(< "$repo_root/WORKSPACE")
-
-bazel_version_regex='BAZEL_VERSION = "([^"]+)"'
-if [[ $workspace_contents =~ $bazel_version_regex ]]; then
- export BAZEL_VERSION="${BASH_REMATCH[1]}"
-else
- echo >&2 "$0: Failed to extract BAZEL_VERSION from WORKSPACE"
- exit 1
-fi
-
-bazel_bin_loc="${bazel_bin_loc:-$HOME/.bazel_binaries}"
-bazel_exec_path="$bazel_bin_loc/$BAZEL_VERSION/bin/bazel-real"
-
-if [ -f "$bazel_exec_path" ]; then
- exec "$bazel_exec_path" "$@"
-fi
-
-# ----- slow path -----
-
-echo >&2 "No cached Bazel v$BAZEL_VERSION found, installing..."
-
-kernel_name="$(uname -s | tr 'A-Z' 'a-z')"
-processor_name="$(uname -m)"
-
-bazel_installer_platform="${kernel_name}-${processor_name}"
-case "$bazel_installer_platform" in
- linux-x86_64) ;;
- darwin-x86_64) ;;
- darwin-arm64)
- # Pseudo Apple Silicon support by forcing x86_64 (Rosetta) for now
- bazel_installer_platform="darwin-x86_64"
- ;;
- *)
- echo >&2 "Building on $bazel_installer_platform is not implemented"
- exit 1
- ;;
-esac
-
-bazel_installer_platform_var="$(echo "$bazel_installer_platform" | tr 'a-z-' 'A-Z_')"
-bazel_installer_sha_variable="BAZEL_INSTALLER_VERSION_${bazel_installer_platform_var}_SHA"
-bazel_installer_sha_regex="$bazel_installer_sha_variable = \"([^\"]+)\""
-if [[ $workspace_contents =~ $bazel_installer_sha_regex ]]; then
- export expected_sha="${BASH_REMATCH[1]}"
-else
- echo >&2 "$0: Failed to extract Bazel version from WORKSPACE"
- exit 1
-fi
-
-BUILD_DIR="$(mktemp -d)"
-export BUILD_DIR
-mkdir -p "$BUILD_DIR"
-
-(
- set -euo pipefail
- cd "$BUILD_DIR"
- echo "$PWD"
-
- installer_name="bazel-${BAZEL_VERSION}-installer-${bazel_installer_platform}.sh"
- BAZEL_REMOTE_SOURCE="${BAZEL_REMOTE_SOURCE:-https://github.com/bazelbuild/bazel/releases/download}"
- BAZEL_INSTALLER_PATH="${BAZEL_INSTALLER_PATH:-$BAZEL_REMOTE_SOURCE/${BAZEL_VERSION}/$installer_name}"
-
- curl -O -L "$BAZEL_INSTALLER_PATH"
-
- actual_sha="$(shasum -a 256 "$installer_name" | awk '{print $1}')"
- if [ "$actual_sha" != "$expected_sha" ]; then
- echo >&2 "Installer checksum mismatch:"
- echo >&2 " Expected: $expected_sha"
- echo >&2 " Actual: $actual_sha"
- echo >&2 "To accept this mismatch, update $bazel_installer_sha_variable in the WORKSPACE file and re-run."
- exit 1
- fi
-
- chmod +x "$installer_name"
- mkdir -p "$bazel_bin_loc"
- "./${installer_name}" --base="${bazel_bin_loc}/${BAZEL_VERSION}" --bin="${bazel_bin_loc}/${BAZEL_VERSION}/bin_t"
-)
-rm -rf "$BUILD_DIR"
-
-exec "$bazel_exec_path" "$@"
diff --git a/bazel b/bazel
new file mode 120000
index 000000000..704f74f10
--- /dev/null
+++ b/bazel
@@ -0,0 +1 @@
+/usr/local/bin/bazel
\ No newline at end of file
diff --git a/common/crypto_hashing/BUILD b/common/crypto_hashing/BUILD
index 0c27a10d0..4118b5d55 100644
--- a/common/crypto_hashing/BUILD
+++ b/common/crypto_hashing/BUILD
@@ -8,8 +8,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = ["//common"] + select({
"//tools/config:webasm": ["@com_github_blake2_blake2"],
- "//tools/config:darwin": ["@com_github_blake2_libb2"],
- "//tools/config:linux": ["@com_github_blake2_libb2"],
+ "//tools/config:darwin": ["@com_github_blake2_blake2"],
+ "//tools/config:linux": ["@com_github_blake2_blake2"],
"//conditions:default": ["@com_github_blake2_blake2"],
}),
)
diff --git a/common/crypto_hashing/crypto_hashing.h b/common/crypto_hashing/crypto_hashing.h
index da09d4e51..82009c59f 100644
--- a/common/crypto_hashing/crypto_hashing.h
+++ b/common/crypto_hashing/crypto_hashing.h
@@ -3,11 +3,7 @@
#include "common/common.h"
extern "C" {
-#if defined(__i386__) || defined(__x86_64__)
-#include "blake2.h"
-#else
#include "ref/blake2.h"
-#endif
};
namespace sorbet::crypto_hashing {
@@ -15,12 +11,10 @@ inline std::array<uint8_t, 64> hash64(std::string_view data) {
static_assert(BLAKE2B_OUTBYTES == 64);
std::array<uint8_t, 64> res;
-#if defined(__i386__) || defined(__x86_64__)
- int err = blake2b(&res[0], data.begin(), nullptr, std::size(res), data.size(), 0);
-#else
+
// it has different order of arguments \facepalm
int err = blake2b(&res[0], std::size(res), data.begin(), data.size(), nullptr, 0);
-#endif
+
ENFORCE(err == 0);
return res;
};
diff --git a/third_party/externals.bzl b/third_party/externals.bzl
index 2d9fad8af..c45e44834 100644
--- a/third_party/externals.bzl
+++ b/third_party/externals.bzl
@@ -168,12 +168,15 @@ def register_sorbet_dependencies():
strip_prefix = "bazel-compilation-database-6b9329e37295eab431f82af5fe24219865403e0f",
)
- # NOTE: we use the sorbet branch for development to keep our changes rebasable on grailio/bazel-toolchain
+ LLVM_BAZEL_TOOLCHAIN_TAG = "0.7.2"
+ LLVM_BAZEL_TOOLCHAIN_SHA = "f7aa8e59c9d3cafde6edb372d9bd25fb4ee7293ab20b916d867cd0baaa642529"
+
http_archive(
name = "com_grail_bazel_toolchain",
- urls = _github_public_urls("sorbet/bazel-toolchain/archive/a685e1e6bd1e7cc9a5b84f832539585bb68d8ab4.zip"),
- sha256 = "90c59f14cada755706a38bdd0f5ad8f0402cbf766387929cfbee9c3f1b4c82d7",
- strip_prefix = "bazel-toolchain-a685e1e6bd1e7cc9a5b84f832539585bb68d8ab4",
+ sha256 = LLVM_BAZEL_TOOLCHAIN_SHA,
+ strip_prefix = "bazel-toolchain-{tag}".format(tag = LLVM_BAZEL_TOOLCHAIN_TAG),
+ canonical_id = LLVM_BAZEL_TOOLCHAIN_TAG,
+ url = "https://github.com/grailbio/bazel-toolchain/archive/{tag}.tar.gz".format(tag = LLVM_BAZEL_TOOLCHAIN_TAG),
)
http_archive(
@@ -196,15 +199,6 @@ def register_sorbet_dependencies():
strip_prefix = "buildtools-5bcc31df55ec1de770cb52887f2e989e7068301f",
)
- # optimized version of blake2 hashing algorithm
- http_archive(
- name = "com_github_blake2_libb2",
- urls = _github_public_urls("BLAKE2/libb2/archive/fa83ddbe179912e9a7a57edf0333b33f6ff83056.zip"),
- sha256 = "dd25f7ac53371c2a15761fc1689d04de2ff948ac7e213a10d13961e24b0c9ae6",
- build_file = "@com_stripe_ruby_typer//third_party:libb2.BUILD",
- strip_prefix = "libb2-fa83ddbe179912e9a7a57edf0333b33f6ff83056",
- )
-
# portable reference implementation of blake2
http_archive(
name = "com_github_blake2_blake2",
diff --git a/third_party/libb2.BUILD b/third_party/libb2.BUILD
deleted file mode 100644
index 7004c0196..000000000
--- a/third_party/libb2.BUILD
+++ /dev/null
@@ -1,33 +0,0 @@
-BLAKE2_COPTS = [
- "-Wno-unused-const-variable",
- "-Wno-unused-function",
-]
-
-genrule(
- name = "stub_config",
- srcs = ["src/blake2-config.h"],
- outs = ["src/config.h"],
- cmd = "cat $(location src/blake2-config.h) > $@",
-)
-
-cc_library(
- name = "com_github_blake2_libb2",
- srcs = [
- "src/blake2s.c",
- "src/blake2b.c",
- "src/config.h",
- ] + glob(["src/*.h"]),
- hdrs = [
- "src/blake2.h",
- ],
- copts = BLAKE2_COPTS,
- defines = ["SUFFIX="],
- includes = [
- "src",
- ],
- linkstatic = select({
- "@com_stripe_ruby_typer//tools/config:linkshared": 0,
- "//conditions:default": 1,
- }),
- visibility = ["//visibility:public"],
-)
diff --git a/third_party/llvm/llvm.bzl b/third_party/llvm/llvm.bzl
index e3edb437f..1ee37e44f 100644
--- a/third_party/llvm/llvm.bzl
+++ b/third_party/llvm/llvm.bzl
@@ -310,7 +310,7 @@ llvm_all_cmake_vars = select({
"@com_stripe_ruby_typer//tools/config:linux": cmake_var_string(
_dict_add(
cmake_vars,
- llvm_target_cmake_vars("X86", "x86_64-unknown-linux_gnu"),
+ llvm_target_cmake_vars("AARCH64", "aarch64-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
diff --git a/tools/clang.bzl b/tools/clang.bzl
index 1b0e856ae..b0a67d515 100644
--- a/tools/clang.bzl
+++ b/tools/clang.bzl
@@ -30,6 +30,6 @@ _clang_tool = rule(
def clang_tool(name):
_clang_tool(
name = name,
- tool = "@llvm_toolchain_12_0_0//:bin/" + name,
+ tool = "@llvm_toolchain_12_0_0//:" + name,
visibility = ["//visibility:public"],
)
diff --git a/tools/config/BUILD b/tools/config/BUILD
index 3c66534fe..43c6523d7 100644
--- a/tools/config/BUILD
+++ b/tools/config/BUILD
@@ -16,6 +16,14 @@ platform(
],
)
+platform(
+ name = "linux_aarch64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:arm64",
+ ],
+)
+
config_setting(
name = "darwin",
constraint_values = [
@@ -28,10 +36,14 @@ config_setting(
name = "linux",
constraint_values = [
"@platforms//os:linux",
- "@platforms//cpu:x86_64",
],
)
+config_setting(
+ name = "aarch64",
+ values = {"host_cpu": "aarch64"},
+)
+
config_setting(
name = "opt",
values = {"compilation_mode": "opt"},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment