From 7f39babce4da43f2542dfef872a68c57eb55c0c4 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Tue, 9 Jul 2024 19:31:38 +0800 Subject: [PATCH] build: Introduce dev build for faster debugging --- .bazelrc | 5 ++++- .github/workflows/release-dry-run.yml | 6 +++--- .github/workflows/release-template.md | 5 ++--- .github/workflows/release.yml | 6 +++--- docs/scip-ruby/CONTRIBUTING.md | 22 +++++++++++----------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.bazelrc b/.bazelrc index 1ae5bca68..68adb0e90 100644 --- a/.bazelrc +++ b/.bazelrc @@ -68,10 +68,13 @@ build --cxxopt=-Wno-unqualified-std-cast-call --host_cxxopt=-Wno-unqualified-std ## ## debug configuration ## +build:dev --config=dbg --copt=-O1 + build:dbg --copt=-O0 build:dbg --compilation_mode=dbg build:dbg --config=debugsymbols + build:rubydbg --copt=-DRUBY_DEBUG --copt=-DVM_CHECK_MODE=1 --copt=-DTRANSIENT_HEAP_CHECK_MODE --copt=-DRGENGC_CHECK_MODE --copt=-DENC_DEBUG build:coverage --config=forcedebug @@ -136,7 +139,7 @@ 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_arm64 +build:release-mac --config=release-common --platforms=@//tools/platforms:darwin_x86_64 build:release-debug-linux --config=release-linux build:release-debug-linux --config=release-debug-common diff --git a/.github/workflows/release-dry-run.yml b/.github/workflows/release-dry-run.yml index 6ee749be0..fd4eba941 100644 --- a/.github/workflows/release-dry-run.yml +++ b/.github/workflows/release-dry-run.yml @@ -15,7 +15,7 @@ jobs: matrix: # Use macos-14 as macos-13 runner is only offered for x86_64 platform: ['ubuntu-20.04-16core-graph-team', 'macos-13-xlarge'] - config: ['debug', 'release'] + config: ['asserts', 'release'] runs-on: ${{ matrix.platform }} env: TAG: ${{ inputs.fakeTag }} @@ -52,7 +52,7 @@ jobs: run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" - name: ${{ format('🏗 Build ({0})', matrix.config) }} run: | - CONFIG="dbg" + CONFIG="dev" if [ "$CFG" == "release" ]; then CONFIG="release-${OS/darwin/mac}" fi @@ -63,7 +63,7 @@ jobs: CFG: ${{ matrix.config }} - name: ${{ format('🪄 Rename binary ({0})', matrix.config) }} run: | - SUFFIX="-debug" + SUFFIX="-asserts" if [ "$CFG" == "release" ]; then SUFFIX="" fi diff --git a/.github/workflows/release-template.md b/.github/workflows/release-template.md index 83b65103f..4d25e5274 100644 --- a/.github/workflows/release-template.md +++ b/.github/workflows/release-template.md @@ -9,9 +9,8 @@ bash -c 'curl -L "$RELEASE_URL/scip-ruby-$ARCH-$OS" -o scip-ruby' && \ chmod +x scip-ruby ``` -The `-debug*` binaries are meant for debugging issues (for example, if you run into a crash with `scip-ruby`), and are not recommended for general use. +The `-asserts*` binaries are meant for debugging issues (for example, if you run into a crash with `scip-ruby`), and are not recommended for general use. OS key: -- Darwin 20 ~ macOS 11 Big Sur -- Darwin 21 ~ macOS 12 Monterey - Darwin 22 ~ macOS 13 Ventura +- Darwin 23 ~ macOS 14 Sonoma diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f6d9a57d..748d6a038 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: platform: ['ubuntu-20.04', 'macos-12'] - config: ['debug', 'release'] + config: ['asserts', 'release'] runs-on: ${{ matrix.platform }} env: TAG: ${{ github.event.ref }} @@ -45,7 +45,7 @@ jobs: run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" - name: ${{ format('🏗 Build ({0})', matrix.config) }} run: | - CONFIG="dbg" + CONFIG="dev" if [ "$CFG" == "release" ]; then CONFIG="release-${OS/darwin/mac}" fi @@ -61,7 +61,7 @@ jobs: path: log - name: ${{ format('🪄 Rename binary ({0})', matrix.config) }} run: | - SUFFIX="-debug" + SUFFIX="-asserts" if [ "$CFG" == "release" ]; then SUFFIX="" fi diff --git a/docs/scip-ruby/CONTRIBUTING.md b/docs/scip-ruby/CONTRIBUTING.md index 9e5af13b4..8d64ae44f 100644 --- a/docs/scip-ruby/CONTRIBUTING.md +++ b/docs/scip-ruby/CONTRIBUTING.md @@ -110,7 +110,7 @@ see the [Design Decisions doc][]. ``` # Optionally replace 'dbg' with 'release-linux' or 'release-mac' -./bazel build //main:scip-ruby --config=dbg +./bazel build //main:scip-ruby --config=dev ``` The generated binary is located at `./bazel-bin/main/scip-ruby`. @@ -120,7 +120,7 @@ For more information about configurations, see the [Sorbet README](/sorbet-READM ### Building gems ```bash -./bazel build //gems/scip-ruby --config=dbg +./bazel build //gems/scip-ruby --config=dev ``` The generated gems are located in `./bazel-bin/gems/scip-ruby`. @@ -159,13 +159,13 @@ Here are some example test invocations: ``` # Run both snapshot tests and unit tests -./bazel test --config=dbg //test/scip +./bazel test --config=dev //test/scip # Run only unit tests -./bazel test --config=dbg //test/scip:unit_tests +./bazel test --config=dev //test/scip:unit_tests # Run a specific snapshot test, e.g. 'testdata/alias.rb' -./bazel test --config=dbg //test/scip:alias +./bazel test --config=dev //test/scip:alias ``` You can add `--test_output=errors` to see diffs for snapshot mismatches. @@ -174,10 +174,10 @@ Snapshot outputs can be easily updated: ``` # Update all snapshots -./bazel test --config=dbg //test/scip:update +./bazel test --config=dev //test/scip:update # Update snapshot for a single test -./bazel test --config=dbg //test/scip:update_alias +./bazel test --config=dev //test/scip:update_alias ``` Repo tests are kinda' broken right now; they're disabled @@ -189,7 +189,7 @@ Then run the tests using: ```bash # If Ruby was installed via asdf (recommended to avoid dependency on system Ruby on macOS) -./bazel test //test/scip/repos --config=dbg +./bazel test //test/scip/repos --config=dev ``` This may take a few minutes to run. @@ -262,7 +262,7 @@ Typically, I'll copy over the minimized code to the root and run: ```bash -./bazel build //main:scip-ruby --config=dbg && ./bazel-out/darwin_arm64-dbg/bin/main/scip-ruby tmp.rb -p cfg-text-loc --index-file /dev/null +./bazel build //main:scip-ruby --config=dev && ./bazel-out/darwin_arm64-dbg/bin/main/scip-ruby tmp.rb -p cfg-text-loc --index-file /dev/null ``` Alternately, it may be useful to create a `tmp.rb` @@ -271,9 +271,9 @@ file under the `test/scip/testdata/` directory ```bash # Check -./bazel test //test/scip:tmp --config=dbg +./bazel test //test/scip:tmp --config=dev # View output -./bazel test //test/scip:update_tmp --config=dbg && cat test/scip/testdata/tmp.snapshot.rb +./bazel test //test/scip:update_tmp --config=dev && cat test/scip/testdata/tmp.snapshot.rb ``` Having the [SCIP CLI](https://github.com/sourcegraph/scip) available