Skip to content

Commit

Permalink
*: Fix build and readme in llvm17 (#9656)
Browse files Browse the repository at this point in the history
ref #6233

Fix README instruction for MacOS
Fix build unit test failure in LLVM17 + MacOS

Signed-off-by: Wish <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Co-authored-by: JaySon <[email protected]>
Co-authored-by: Liqi Geng <[email protected]>
  • Loading branch information
4 people authored Nov 20, 2024
1 parent 58bbc48 commit 6c86929
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ sudo ./llvm.sh 17 all
sudo apt install -y cmake ninja-build zlib1g-dev libcurl4-openssl-dev ccache
```

Then, expose the LLVM17 toolchain as the default one in order to use it later in compile:

```shell
export CC="/usr/bin/clang-17"
export CXX="/usr/bin/clang++-17"
```

**Note for Ubuntu 18.04 and Ubuntu 20.04:**

The default installed cmake may be not recent enough. You can install a newer cmake from the [Kitware APT Repository](https://apt.kitware.com):
Expand Down Expand Up @@ -125,9 +132,14 @@ xcode-select --install
brew install ninja cmake [email protected] ccache

brew install llvm@17
```

Then, expose the LLVM17 toolchain as the default one in order to use it later in compile:

# check llvm version
clang --version # should be 17.0.0 or higher
```shell
export PATH="$(brew --prefix)/opt/llvm@17/bin:$PATH"
export CC="$(brew --prefix)/opt/llvm@17/bin/clang"
export CXX="$(brew --prefix)/opt/llvm@17/bin/clang++"
```

</details>
Expand All @@ -148,34 +160,16 @@ To build TiFlash for development:
cmake --workflow --preset dev
```

Note: In Linux, usually you need to explicitly specify to use LLVM.

```shell
export CC="/usr/bin/clang-17"
export CXX="/usr/bin/clang++-17"
```

In MacOS, if you install llvm clang, you need to explicitly specify to use llvm clang.
Or if you don't like the preset:

Add the following lines to your shell environment, e.g. `~/.bash_profile`.
```shell
export PATH="$(brew --prefix)/opt/llvm/bin:$PATH"
export CC="$(brew --prefix)/opt/llvm/bin/clang"
export CXX="$(brew --prefix)/opt/llvm/bin/clang++"
```

Or use `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` to specify the compiler, like this:
```shell
# In the TiFlash repository root:
mkdir cmake-build-debug
cd cmake-build-debug

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

cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG
ninja tiflash
```

After building, you can get TiFlash binary in `dbms/src/Server/tiflash` in the `cmake-build-debug` directory.

### Build Options

TiFlash has several CMake build options to tweak for development purposes. These options SHOULD NOT be changed for production usage, as they may introduce unexpected build errors and unpredictable runtime behaviors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SegmentBitmapFilterTest : public SegmentTestBasic
SegmentTestBasic::writeSegment(SEG_ID, end - begin, begin);
if (unit.pack_size)
{
db_context->getSettingsRef().set("dt_segment_stable_pack_rows", *(unit.pack_size));
db_context->getSettingsRef().dt_segment_stable_pack_rows = *(unit.pack_size);
reloadDMContext();
ASSERT_EQ(dm_context->stable_pack_rows, *(unit.pack_size));
}
Expand Down

0 comments on commit 6c86929

Please sign in to comment.