Skip to content

Commit acd75b8

Browse files
build: use llvm@17 in darwin
Signed-off-by: Lloyd-Pottiger <[email protected]>
1 parent 993d8c7 commit acd75b8

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ And the following operating systems:
3737
The following packages are required:
3838

3939
- CMake 3.23.0+
40-
- Clang 17.0.0+ under Linux or AppleClang 14.0.0+ under MacOS
40+
- Clang 17.0.0+
4141
- Rust
4242
- Python 3.0+
4343
- Ninja-Build or GNU Make
@@ -123,11 +123,7 @@ xcode-select --install
123123

124124
# Install other dependencies
125125
brew install ninja cmake [email protected] ccache
126-
```
127-
128-
If your MacOS is higher or equal to 13.0 (Ventura), it should work out of the box because by default Xcode 14.3 provides Apple clang 14.0.0. But if your MacOS is lower than 13.0, you should install llvm clang manually.
129126

130-
```shell
131127
brew install llvm@17
132128

133129
# check llvm version
@@ -163,17 +159,17 @@ In MacOS, if you install llvm clang, you need to explicitly specify to use llvm
163159

164160
Add the following lines to your shell environment, e.g. `~/.bash_profile`.
165161
```shell
166-
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
167-
export CC="/opt/homebrew/opt/llvm/bin/clang"
168-
export CXX="/opt/homebrew/opt/llvm/bin/clang++"
162+
export PATH="$(brew --prefix)/opt/llvm/bin:$PATH"
163+
export CC="$(brew --prefix)/opt/llvm/bin/clang"
164+
export CXX="$(brew --prefix)/opt/llvm/bin/clang++"
169165
```
170166

171167
Or use `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` to specify the compiler, like this:
172168
```shell
173169
mkdir cmake-build-debug
174170
cd cmake-build-debug
175171

176-
cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++
172+
cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER="$(brew --prefix)/opt/llvm/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix)/opt/llvm/bin/clang++"
177173

178174
ninja tiflash
179175
```

release-darwin/build/build-release.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ if [ -d "$install_dir" ]; then rm -rf "${install_dir:?}"/*; else mkdir -p "$inst
3232
build_dir="$SRCPATH/release-darwin/build-release"
3333
rm -rf $build_dir && mkdir -p $build_dir && cd $build_dir
3434

35+
# use llvm@17
36+
export PATH="$(brew --prefix)/opt/llvm@17/bin:$PATH"
37+
export CC="$(brew --prefix)/opt/llvm@17/bin/clang"
38+
export CXX="$(brew --prefix)/opt/llvm@17/bin/clang++"
39+
3540
cmake "$SRCPATH" \
3641
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
3742
-DUSE_INTERNAL_SSL_LIBRARY=ON \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Copyright 2023 PingCAP, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -ueox pipefail
17+
18+
brew install llvm@17

0 commit comments

Comments
 (0)