Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```shell
sudo apt update
sudo apt install \
clang-15 \
clang-17 \
cmake \
curl \
flex \
Expand All @@ -18,8 +18,8 @@ sudo apt install \
libmpfr-dev \
libunwind-dev \
libyaml-dev \
lld-15 \
llvm-15-tools \
lld-17 \
llvm-17-tools \
maven \
openjdk-17-jdk \
pkg-config \
Expand All @@ -44,7 +44,7 @@ brew install \
jemalloc \
libffi
libyaml \
llvm@15 \
llvm@17 \
maven \
mpfr \
pkg-config \
Expand Down Expand Up @@ -81,20 +81,20 @@ add it your `env` (`.zshrc`, `.bashrc`, etc.), so that the Homebrew
installation of LLVM gets picked up correctly. We recommend adding it to
your shell profile.
```shell
export LLVM_DIR=$($(brew --prefix llvm@15)/bin/llvm-config --cmakedir)
export LLVM_DIR=$($(brew --prefix llvm@17)/bin/llvm-config --cmakedir)
```

If you don't usually use the `clang` from your Homebrew installation as
your default compiler, you can set the following CMake flg to use these
`clang` and `clang++`:
```shell
-DCMAKE_C_COMPILER="$(brew --prefix llvm@15)/bin/clang" \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm@15)/bin/clang++"
-DCMAKE_C_COMPILER="$(brew --prefix llvm@17)/bin/clang" \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm@17)/bin/clang++"
```
Once again, we recommend adding them and other llvm binaries to your
`PATH` in your shell profile:
```shell
export PATH="$(brew --prefix llvm@15)/bin:$PATH"
export PATH="$(brew --prefix llvm@17)/bin:$PATH"
```

Some tests rely on GNU Grep options, which are not available on macOS by
Expand Down
43 changes: 38 additions & 5 deletions scripts/clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,50 @@

set -euxo pipefail

LLVM_VERSION=15
BUILD_DIR=build

# Try to detect available LLVM version
if [[ "$OSTYPE" == "darwin"* ]]; then
clang_tidy="$(brew --prefix "llvm@${LLVM_VERSION}")/bin/clang-tidy"
driver="$(brew --prefix "llvm@${LLVM_VERSION}")/bin/run-clang-tidy"
# On macOS, try LLVM 17 first, then fall back to 15
for version in 17 15; do
if brew list "llvm@${version}" >/dev/null 2>&1; then
LLVM_VERSION=$version
clang_tidy="$(brew --prefix "llvm@${version}")/bin/clang-tidy"
driver="$(brew --prefix "llvm@${version}")/bin/run-clang-tidy"
break
fi
done
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
clang_tidy="clang-tidy-$LLVM_VERSION"
driver="run-clang-tidy-$LLVM_VERSION"
# On Linux, try different versions based on what's available
for version in 17 16 15 14; do
if command -v "clang-tidy-${version}" >/dev/null 2>&1 && command -v "run-clang-tidy-${version}" >/dev/null 2>&1; then
LLVM_VERSION=$version
clang_tidy="clang-tidy-${version}"
driver="run-clang-tidy-${version}"
break
fi
done

# Fallback to default clang-tidy if no versioned one is found
if [[ -z "${LLVM_VERSION:-}" ]]; then
if command -v clang-tidy >/dev/null 2>&1 && command -v run-clang-tidy >/dev/null 2>&1; then
LLVM_VERSION="default"
clang_tidy="clang-tidy"
driver="run-clang-tidy"
else
echo "Error: No clang-tidy installation found"
exit 1
fi
fi
fi

if [[ -z "${LLVM_VERSION:-}" ]]; then
echo "Error: No suitable LLVM/clang-tidy installation found"
exit 1
fi

echo "Using LLVM version: ${LLVM_VERSION}"

source_dirs=(
bindings
include
Expand Down