Skip to content

Commit

Permalink
build: Try to link in ASan runtime using linkopt a la Sorbet
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Jan 25, 2023
1 parent 54d627f commit e787eed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ build:dev --copt="-Wno-macro-redefined"
# -D_FORTIFY_SOURCE=1 by default. This is fixed by
# https://github.com/bazelbuild/bazel/pull/12772
# but I can't figure out how to use that, so hack it in for now.

build:dev-macos --config=dev
build:dev-macos --linkopt="external/llvm_toolchain_llvm/lib/clang/15.0.6/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"

build:dev-linux --config=dev
build:dev-linux --linkopt="external/llvm_toolchain_llvm/lib/clang/15.0.6/lib/linux/libclang_rt.asan_osx_dynamic.dylib"
10 changes: 6 additions & 4 deletions Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ but it will not be used for building the code in this project.)

```
# macOS
bazel build //... --spawn_strategy=local --config=dev
bazel build //... --spawn_strategy=local --config=dev-macos
# Linux
bazel build //... --config=dev
bazel build //... --config=dev-linux
```

(Later commands use `dev-macos` consistently for simplicity.)

The indexer binary will be placed at `bazel-bin/indexer/scip-clang`.

On macOS, `--spawn_strategy=local` provides a dramatic improvement
Expand All @@ -63,13 +65,13 @@ Consult `--help` for user-facing flags, and `--help-all` for both user-facing an
Run all tests:

```bash
bazel test //test --spawn_strategy=local --config=dev
bazel test //test --spawn_strategy=local --config=dev-macos
```

Update snapshot tests:

```bash
bazel test //update --spawn_strategy=local --config=dev
bazel test //update --spawn_strategy=local --config=dev-macos
```

## Formatting
Expand Down
8 changes: 7 additions & 1 deletion tools/regenerate-compdb.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash
bazel build //tools:compdb --spawn_strategy=local --config=dev

SUFFIX="linux"
if [ "$(uname)" == "Darwin" ]; then
SUFFIX="macos"
fi

bazel build //tools:compdb --spawn_strategy=local "--config=dev-$SUFFIX"

PROJECT_ROOT="$(dirname "${BASH_SOURCE[0]}")/.."

Expand Down

0 comments on commit e787eed

Please sign in to comment.