Skip to content

Commit

Permalink
chore: Update scip-ruby/master with latest changes from upstream mast…
Browse files Browse the repository at this point in the history
…er (#208)
  • Loading branch information
varungandhi-src authored Jul 9, 2024
2 parents d442b63 + a44f215 commit 9086c63
Show file tree
Hide file tree
Showing 1,975 changed files with 32,138 additions and 83,510 deletions.
65 changes: 40 additions & 25 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ common:build --define absl=1
common:test --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1

##
## Custom toolchain.
## Custom toolchain (bazel-contrib/toolchains_llvm).
##
build --crosstool_top=@llvm_toolchain_12_0_0//:toolchain --copt=-D_LIBCPP_ENABLE_NODISCARD
# Not needed after https://github.com/bazelbuild/bazel/issues/7260 is closed
build --incompatible_enable_cc_toolchain_resolution
# For macOS only, needed for Bazel versions before 7.
# Without this, one can use `--linkopt='-undefined dynamic_lookup'`.
# This feature is intentionally not supported on macOS.
build --features=-supports_dynamic_linker
# Not needed after https://github.com/grailbio/bazel-toolchain/pull/229.
build --features=-libtool

##
## Common build options across all build configurations
Expand All @@ -25,11 +32,6 @@ build --crosstool_top=@llvm_toolchain_12_0_0//:toolchain --copt=-D_LIBCPP_ENABLE
# this flag here once flipped in Bazel again.
build --incompatible_strict_action_env

# Enforce that we don't rely on `@bazel_tools//platforms` and instead use the
# `@platforms` repository for constraint resolution. See
# https://github.com/bazelbuild/bazel/issues/8622 for more information.
build --incompatible_use_platforms_repo_for_constraints

# C / C++ Options
# Don't depend on system compiler
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
Expand All @@ -40,6 +42,8 @@ build --copt=-fstack-protector

build --copt=-Werror --copt=-Wimplicit-fallthrough --copt=-Wmissing-field-initializers

build --copt=-D_LIBCPP_ENABLE_NODISCARD

build --host_copt=-O1
build --host_copt=-DFORCE_DEBUG
build --host_cxxopt=-Wno-unused-variable --host_cxxopt=-Wno-overloaded-virtual --host_cxxopt=-Wno-unused-const-variable # ragel violates those and we want a silent build
Expand All @@ -49,8 +53,6 @@ build --host_cxxopt=-Wno-pass-failed # host build doesn't have enough optimizati
# <command line>:1:9: and <built-in>:355:9: so sadly we turn them all off
build --copt=-Wno-macro-redefined

# Clang 12.0.0 has warnings when compiling LLVM 12.0.0 on C++20, sadly.
# TODO(jez) When we upgrade to LLVM 13.0.0+ can we delete this?
# TODO(jez) We will need these to build C++20, but emscripten doesn't even know about these options yet.
# Leaving them commented out so we can uncomment them after upgrading emscripten.
# build --host_cxxopt=-Wno-deprecated-anon-enum-enum-conversion
Expand All @@ -59,13 +61,16 @@ build --copt=-Wno-macro-redefined
# build --cxxopt=-Wno-deprecated-enum-enum-conversion
# build --cxxopt=-Wno-ambiguous-reversed-operator

# TODO(jez) Something between Clang 12 and Clang 15 seems to have introduced a
# warning saying _never_ use unqualified `std` calls...
build --cxxopt=-Wno-unqualified-std-cast-call --host_cxxopt=-Wno-unqualified-std-cast-call

##
## debug configuration
##
build:dbg --copt=-O0
build:dbg --compilation_mode=dbg
build:dbg --config=debugsymbols
build:dbg --config=rubydbg

build:rubydbg --copt=-DRUBY_DEBUG --copt=-DVM_CHECK_MODE=1 --copt=-DTRANSIENT_HEAP_CHECK_MODE --copt=-DRGENGC_CHECK_MODE --copt=-DENC_DEBUG

Expand All @@ -84,7 +89,6 @@ build:dbg-linux --config=dbg --platforms=@//tools/platforms:linux_x86_64
##
# release version: optimized, with debug symbols and version information
build:release-common --define release=true
build:release-common --define mimalloc=true
build:release-common --compilation_mode=opt
build:release-common --config=backtracesymbols
build:release-common --config=static-libs
Expand All @@ -107,6 +111,18 @@ build:untyped-blame --copt=-DTRACK_UNTYPED_BLAME_MODE
# harden: mark relocation sections read-only
build:release-linux --linkopt=-Wl,-z,relro,-z,now
build:release-linux --config=lto-linux --config=release-common
# Separate config for aarch64, so x86_64 can be differently optimized
build:release-linux-aarch64 --linkopt=-Wl,-z,relro,-z,now
build:release-linux-aarch64 --config=lto-linux --config=release-common

# It would be nice to move this back to release-common, but there is a build
# failure when using clang 15 on macOS to build GNU make via rules_foreign_cc:
# <https://github.com/bazelbuild/rules_foreign_cc/issues/1186>
# We only use rules_foreign_cc for mimalloc and we only use mimalloc in release
# builds, so I'm moving this here until we can figure out a better workaround,
# or a fix lands upstream.
build:release-linux --define mimalloc=true
build:release-linux-aarch64 --define mimalloc=true

# 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.
Expand All @@ -118,6 +134,7 @@ build:release-linux --config=lto-linux --config=release-common
# 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-aarch64 --copt=-march=armv8.1a

build:release-mac --config=release-common --platforms=@//tools/platforms:darwin_x86_64

Expand Down Expand Up @@ -214,10 +231,13 @@ build:ubsan --linkopt=-fsanitize=undefined --copt=-fno-sanitize-recover=undefine
build:ubsan --define unsanitized=false
build:ubsan --copt=-DHAS_SANITIZER

# Bazel links C++ files with $CC, not $CXX, this breaks UBSan
build:sanitize-linux --linkopt=external/llvm_toolchain_12_0_0/lib/clang/12.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
build:sanitize-linux --linkopt=external/llvm_toolchain_12_0_0/lib/clang/12.0.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a
build:sanitize-linux --linkopt=external/llvm_toolchain_12_0_0/lib/clang/12.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a
# TODO(jez) It's not clear whether we still need these tricks to get sanitizers to work,
# because we're using the toolchain's lld linker now.
# We could consider replacing this with something more typical.
# Original motivation: Bazel links C++ files with $CC, not $CXX, this breaks UBSan
build:sanitize-linux --linkopt=../../external/llvm_toolchain_15_0_7_llvm/lib/clang/15.0.7/lib/x86_64-unknown-linux-gnu/libclang_rt.asan_cxx.a
build:sanitize-linux --linkopt=../../external/llvm_toolchain_15_0_7_llvm/lib/clang/15.0.7/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_standalone_cxx.a
build:sanitize-linux --linkopt=../../external/llvm_toolchain_15_0_7_llvm/lib/clang/15.0.7/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_standalone.a
build:sanitize-linux --config=sanitize

build:sanitize-mac --config=sanitize
Expand Down Expand Up @@ -255,18 +275,13 @@ build:fuzz --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
##
## Webasm config. Please use either of those depending on your platform
##
build:webasm-linux --crosstool_top=//tools/toolchain/webasm-linux --config=webasm
build:webasm-darwin --crosstool_top=//tools/toolchain/webasm-darwin --config=webasm

# common webasm config
# Use --cpu as a differentiator.
build:webasm --cpu=webasm --spawn_strategy=local --genrule_strategy=local --copt=-Oz --linkopt=-Oz --copt=-DMDB_USE_ROBUST=0
build:webasm --copt=-Oz --linkopt=-Oz --copt=-DMDB_USE_ROBUST=0
build:webasm --define release=true
build:webasm --compilation_mode=opt
build:webasm --copt=-DNDEBUG --linkopt=-DNDEBUG # for some reason emscripten doesn't pass those when -O2\-Oz are specified
build:webasm --copt=--llvm-lto --copt=3 --linkopt=--llvm-lto --linkopt=3
# Specify a "sane" C++ toolchain for the host platform.
build:webasm --host_crosstool_top=@llvm_toolchain_12_0_0//:toolchain
# https://emscripten.org/docs/porting/exceptions.html#webassembly-exception-handling-based-support
build:webasm --features=exceptions --cxxopt=-fwasm-exceptions --linkopt=-fwasm-exceptions
# Blocked on https://github.com/emscripten-core/emscripten/issues/9780
build:webasm --copt=-fno-stack-protector

##
## Stripe's ci passes --config=ci, we need it to exist
Expand Down
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
61 changes: 61 additions & 0 deletions .buildkite/test-rbi-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -euo pipefail

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) platform="linux";;
Darwin*) platform="mac";;
*) exit 1
esac

export JOB_NAME=test-rbi-gen
source .buildkite/tools/setup-bazel.sh

err=0

echo "+++ running tests"

# `-c opt` is required, otherwise the tests are too slow
# forcedebug is really the ~only thing in `--config=dbg` we care about.
# must come after `-c opt` because `-c opt` will define NDEBUG on its own
test_args=(
"//test:end_to_end_rbi_test"
"//test:single_package_runner"
"-c"
"opt"
"--config=forcedebug"
"--spawn_strategy=local"
)

./bazel test \
--experimental_generate_json_trace_profile \
--profile=_out_/profile.json \
--test_summary=terse \
--test_output=errors \
"${test_args[@]}" || err=$?

if [ "$err" -ne 0 ]; then
echo "--- annotating build result"
failing_tests="$(mktemp)"

echo 'Run this command to run failing tests locally:' >> "$failing_tests"
echo >> "$failing_tests"
echo '```bash' >> "$failing_tests"
echo "./bazel test \\" >> "$failing_tests"

# Take the lines that start with target labels.
# Lines look like "//foo FAILED in 10s"
{ ./bazel test --test_summary=terse "${test_args[@]}" || true ; } | \
grep '^//' | \
sed -e 's/ .*/ \\/' | \
sed -e 's/^/ /' >> "$failing_tests"

# Put this last as an easy way to not have a `\` on the last line.
echo ' -c opt --config=forcedebug' >> "$failing_tests"
echo '```' >> "$failing_tests"

buildkite-agent annotate --context "test-rbi-gen.sh" --style error --append < "$failing_tests"

exit "$err"
fi
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.rbi linguist-language=Ruby
*.rbedited linguist-language=Ruby
*.rb diff=ruby
*.rbi diff=ruby
*.rbedited diff=ruby
*.md diff=markdown
test/**/*.out diff
test/cli/windows-line-endings/windows-line-endings.rb eol=crlf
Expand Down
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ gems/sorbet-static-and-runtime/Gemfile.lock
# Used by tools/scripts/ll-view.sh
/ll-view.out

compiler/IREmitter/Intrinsics/PayloadIntrinsics.c
compiler/IREmitter/Intrinsics/PayloadIntrinsics.formatted.c
compiler/IREmitter/Intrinsics/WrappedIntrinsics.h
compiler/IREmitter/Intrinsics/WrappedIntrinsics.formatted.h

# clangd caches data in this folder.
# clangd caches data in these folders
/.clangd
/.cache/clangd

# for YARD documentation
.yardoc/
doc/

# Sandbox folders
test/sandbox/*/*.log
test/sandbox/*/*.rb
test/sandbox/*/*.rbi
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.7
3.1.2
5 changes: 3 additions & 2 deletions .sorbet-buildkite/build-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ source .buildkite/tools/setup-bazel.sh
PATH=$PATH:$(pwd)
export PATH

./bazel build //emscripten:sorbet-wasm.tar --config=webasm-linux --strip=always
./bazel build //emscripten:sorbet-wasm.d --config=webasm

rm -rf _out_
mkdir -p _out_/webasm
cp bazel-bin/emscripten/sorbet-wasm.tar _out_/webasm/sorbet-wasm.tar
cp bazel-bin/emscripten/sorbet-wasm.d/sorbet-wasm.js _out_/webasm/
cp bazel-bin/emscripten/sorbet-wasm.d/sorbet-wasm.wasm _out_/webasm/
2 changes: 1 addition & 1 deletion .sorbet-buildkite/build-sorbet-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pushd gems/sorbet-runtime
echo "--- setup :ruby:"
eval "$(rbenv init -)"

runtime_versions=(2.7.7 3.1.2)
runtime_versions=(2.7.7 3.1.2 3.3.0)

for runtime_version in "${runtime_versions[@]}"; do
rbenv install --skip-existing "$runtime_version"
Expand Down
9 changes: 3 additions & 6 deletions .sorbet-buildkite/build-sorbet-static-and-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ pushd gems/sorbet-static-and-runtime
echo "--- setup :ruby:"
eval "$(rbenv init -)"

runtime_versions=(2.7.2 3.1.2)

for runtime_version in "${runtime_versions[@]}"; do
rbenv install --skip-existing "$runtime_version"
rbenv shell "$runtime_version"
done
# Uses the version in .ruby-version
rbenv rehash
ruby --version

echo "--- build"
git_commit_count=$(git rev-list --count HEAD)
Expand Down
12 changes: 6 additions & 6 deletions .sorbet-buildkite/build-static-release-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o errexit
echo "--- Dowloading artifacts"
rm -rf release
rm -rf _out_
buildkite-agent artifact download "_out_/**/*" .
buildkite-agent artifact download "_out_/**/*.gem" .

# Based on the output of build-static-release.sh
# _out_/gems/ should have the Linux & Mac sorbet-static gem
Expand All @@ -20,9 +20,7 @@ release_version="$prefix.${git_commit_count}"

rbenv install --skip-existing

# we pin to universal-darwin-18 but it shouldn't matter
# the specific version; we just want one mac binary
for platform in universal-darwin-18 x86_64-linux
for platform in universal-darwin x86_64-linux
do
gem unpack _out_/gems/sorbet-static-"${release_version}"-${platform}*.gem

Expand All @@ -31,8 +29,8 @@ do
mv sorbet-static-"${release_version}"-${platform}/libexec/sorbet gems/sorbet-static/libexec/linux.sorbet
;;

universal-darwin-18)
mv sorbet-static-"${release_version}"-${platform}*/libexec/sorbet gems/sorbet-static/libexec/mac.sorbet
universal-darwin)
mv sorbet-static-"${release_version}"-${platform}/libexec/sorbet gems/sorbet-static/libexec/mac.sorbet
;;
esac

Expand All @@ -48,4 +46,6 @@ gem build sorbet-static.gemspec

popd

rm -rf _out_
mkdir -p _out_/gems
mv gems/sorbet-static/sorbet-static-"${release_version}"-java.gem _out_/gems
20 changes: 9 additions & 11 deletions .sorbet-buildkite/build-static-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ processor_name="$(uname -m)"

platform="${kernel_name}-${processor_name}"
case "$platform" in
linux-x86_64|linux-aarch64)
linux-x86_64)
CONFIG_OPTS="--config=release-linux"
;;
linux-aarch64)
CONFIG_OPTS="--config=release-${platform}"
;;
darwin-x86_64|darwin-arm64)
CONFIG_OPTS="--config=release-mac"
command -v autoconf >/dev/null 2>&1 || brew install autoconf
Expand All @@ -37,13 +40,9 @@ git_commit_count=$(git rev-list --count HEAD)
release_version="0.5.${git_commit_count}"
sed -i.bak "s/0\\.0\\.0/${release_version}/" sorbet-static.gemspec
if [[ "darwin" == "$kernel_name" ]]; then
# Our binary should work on almost all OSes. The oldest v8 publishes is -14
# so I'm going with that for now.
for i in {14..22}; do
sed -i.bak "s/Gem::Platform::CURRENT/'universal-darwin-$i'/" sorbet-static.gemspec
gem build sorbet-static.gemspec
mv sorbet-static.gemspec.bak sorbet-static.gemspec
done
sed -i.bak "s/Gem::Platform::CURRENT/'universal-darwin'/" sorbet-static.gemspec
gem build sorbet-static.gemspec
mv sorbet-static.gemspec.bak sorbet-static.gemspec
else
gem build sorbet-static.gemspec
fi
Expand Down Expand Up @@ -75,8 +74,7 @@ rbenv exec gem uninstall --all --executables --ignore-dependencies sorbet sorbet
trap 'rbenv exec gem uninstall --all --executables --ignore-dependencies sorbet sorbet-static' EXIT

if [[ "darwin" == "$kernel_name" ]]; 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
rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-"universal-darwin".gem
else
rbenv exec gem install ../../gems/sorbet-static/sorbet-static-*-"$processor_name"-linux.gem
fi
Expand Down Expand Up @@ -108,7 +106,7 @@ rm -rf _out_
mkdir -p _out_/gems

mv gems/sorbet-static/sorbet-static-*.gem _out_/gems/
if [[ "$kernel_name" == "linux" ]]; then
if [[ "$platform" == "linux-x86_64" ]]; then
mv gems/sorbet/sorbet*.gem _out_/gems/
fi

Expand Down
Loading

0 comments on commit 9086c63

Please sign in to comment.