Skip to content

Commit

Permalink
build: Introduce dev build for faster debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Jul 9, 2024
1 parent 523faea commit 7f39bab
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions docs/scip-ruby/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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`
Expand All @@ -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
Expand Down

0 comments on commit 7f39bab

Please sign in to comment.