Skip to content

Commit e47ac67

Browse files
build: use llvm@17 in darwin (#9572)
ref #6233 build: use llvm@17 in darwin Signed-off-by: Lloyd-Pottiger <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
1 parent f53cb29 commit e47ac67

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
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
```

dbms/src/Storages/DeltaMerge/ColumnFile/ColumnFileSetWithVectorIndexInputStream.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ Block ColumnFileSetWithVectorIndexInputStream::readImpl(FilterPtr & res_filter)
161161
// read vector type column by vector index
162162
auto tiny_reader = tiny_readers[current_file_index];
163163
auto vec_column = vec_cd.type->createColumn();
164-
const std::span<const VectorIndexViewer::SearchResult> file_selected_rows{
165-
&*selected_row_begin,
166-
static_cast<size_t>(std::distance(selected_row_begin, selected_row_end))};
164+
const std::span file_selected_rows{selected_row_begin, selected_row_end};
167165
tiny_reader->read(vec_column, file_selected_rows, /* rowid_start_offset= */ read_rows, file_rows);
168166
assert(vec_column->size() == file_rows);
169167

dbms/src/Storages/DeltaMerge/File/DMFileWithVectorIndexBlockInputStream.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ std::tuple<Block, size_t> DMFileWithVectorIndexBlockInputStream::readByIndexRead
170170

171171
auto begin = std::lower_bound(sorted_results.cbegin(), sorted_results.cend(), block_start_row_id);
172172
auto end = std::lower_bound(begin, sorted_results.cend(), index_reader_next_row_id);
173-
const std::span<const VectorIndexViewer::Key> block_selected_rows{
174-
&*begin,
175-
static_cast<size_t>(std::distance(begin, end))};
173+
const std::span block_selected_rows{begin, end};
176174
vec_index_reader->read(vec_column, block_selected_rows, block_start_row_id, read_rows);
177175

178176
block.insert(ColumnWithTypeAndName{std::move(vec_column), vec_cd.type, vec_cd.name, vec_cd.id});
@@ -200,9 +198,7 @@ std::tuple<Block, size_t> DMFileWithVectorIndexBlockInputStream::readByFollowing
200198
// Then read from vector index for the same pack.
201199
auto begin = std::lower_bound(sorted_results.cbegin(), sorted_results.cend(), block_others.startOffset());
202200
auto end = std::lower_bound(begin, sorted_results.cend(), block_others.startOffset() + read_rows);
203-
const std::span<const VectorIndexViewer::Key> block_selected_rows{
204-
&*begin,
205-
static_cast<size_t>(std::distance(begin, end))};
201+
const std::span block_selected_rows{begin, end};
206202
vec_index_reader->read(vec_column, block_selected_rows, block_others.startOffset(), read_rows);
207203

208204
// Re-assemble block using the same layout as header.

dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ std::vector<VectorIndexViewer::SearchResult> VectorIndexHNSWViewer::searchWithDi
343343
{
344344
const auto rowid = result[i].member.key;
345345
if (valid_rows[rowid])
346-
search_results.push_back({rowid, result[i].distance});
346+
search_results.emplace_back(rowid, result[i].distance);
347347
}
348348
return search_results;
349349
}

release-darwin/build/build-release.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ 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" \
41+
-GNinja \
3642
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
3743
-DUSE_INTERNAL_SSL_LIBRARY=ON \
3844
-Wno-dev \
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 ninja
19+
brew install llvm@17

0 commit comments

Comments
 (0)