aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim.yurchuk@gmail.com>2023-09-05 20:33:14 +0300
committernkozlovskiy <nmk@ydb.tech>2023-09-05 20:53:37 +0300
commit7f49777e035ecdc4243dd39ee7b4891cb1297a4e (patch)
tree66c333ce1ae0e7dfd52bcdc5a203b4f26134bd33
parente44f767cdb56be8e8daafa4f844ab99a228affb0 (diff)
downloadydb-7f49777e035ecdc4243dd39ee7b4891cb1297a4e.tar.gz
Simplify cmake build
Simplify cmake build Pull Request resolved: #352
-rw-r--r--.github/actions/build/action.yml14
-rw-r--r--.github/prewarm/build.sh4
-rw-r--r--BUILD.md11
-rw-r--r--clang.toolchain11
4 files changed, 22 insertions, 18 deletions
diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
index 3ba0b7c31d..c3a56b3b95 100644
--- a/.github/actions/build/action.yml
+++ b/.github/actions/build/action.yml
@@ -26,10 +26,10 @@ runs:
export CC=/usr/bin/clang-14
export CC_FOR_BUILD=$CC
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \
+ -DCCACHE_PATH=/usr/local/bin/ccache \
-DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \
- -DCMAKE_CXX_FLAGS="-fsanitize=${{ inputs.sanitizer }} -g -gsplit-dwarf -gz -fno-omit-frame-pointer -UNDEBUG ${{ inputs.extra_compile_flags }}" \
- -DCMAKE_C_FLAGS="-fsanitize=${{ inputs.sanitizer }} -g -gsplit-dwarf -gz -fno-omit-frame-pointer -UNDEBUG ${{ inputs.extra_compile_flags }}" \
+ -DCMAKE_CXX_FLAGS="-fsanitize=${{ inputs.sanitizer }} -g -gsplit-dwarf -gz -fno-omit-frame-pointer ${{ inputs.extra_compile_flags }}" \
+ -DCMAKE_C_FLAGS="-fsanitize=${{ inputs.sanitizer }} -g -gsplit-dwarf -gz -fno-omit-frame-pointer ${{ inputs.extra_compile_flags }}" \
../ydb
- name: Configure
shell: bash
@@ -45,12 +45,10 @@ runs:
# FIXME: set DCMAKE_CXX_FLAGS_RELWITHDEBINFO and DCMAKE_CXX_FLAGS bacause of global_flags.cmake flags override.
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \
+ -DCCACHE_PATH=/usr/local/bin/ccache \
-DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \
- -DCMAKE_C_FLAGS="-O2 -UNDEBUG ${{ inputs.extra_compile_flags }}" \
- -DCMAKE_CXX_FLAGS="-O2 -UNDEBUG ${{ inputs.extra_compile_flags }}" \
- -DCMAKE_C_FLAGS_RELEASE="-O2 -UNDEBUG ${{ inputs.extra_compile_flags }}" \
- -DCMAKE_CXX_FLAGS_RELEASE="-O2 -UNDEBUG ${{ inputs.extra_compile_flags }}" \
+ -DCMAKE_C_FLAGS="${{ inputs.extra_compile_flags }}" \
+ -DCMAKE_CXX_FLAGS="${{ inputs.extra_compile_flags }}" \
../ydb
- name: Build
shell: bash
diff --git a/.github/prewarm/build.sh b/.github/prewarm/build.sh
index 2bc01d9896..8779edad0f 100644
--- a/.github/prewarm/build.sh
+++ b/.github/prewarm/build.sh
@@ -14,10 +14,8 @@ cd /ydbwork/build
echo "::group::cmake"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
--DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \
+-DCCACHE_PATH=/usr/local/bin/ccache \
-DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \
--DCMAKE_C_FLAGS_RELEASE="-O2 -UNDEBUG" \
--DCMAKE_CXX_FLAGS_RELEASE="-O2 -UNDEBUG" \
../ydb
echo "::endgroup::"
diff --git a/BUILD.md b/BUILD.md
index 9fa2561c8f..0e3547a8cf 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -87,9 +87,8 @@ Run cmake to generate build configuration:
```bash
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG" \
- -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \
- -DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain ../ydb
+ -DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \
+ ../ydb
```
@@ -127,14 +126,12 @@ With enabled Ccache, you can finish the compilation of all targets on supported
export CONAN_USER_HOME=~/ydbwork/build
```
-4. Genreate build configuration using `ccache`
+4. Generate build configuration using `ccache`
```bash
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \
+ -DCCACHE_PATH=/usr/local/bin/ccache \
-DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \
- -DCMAKE_C_FLAGS_RELEASE="-O2 -UNDEBUG" \
- -DCMAKE_CXX_FLAGS_RELEASE="-O2 -UNDEBUG" \
../ydb
```
diff --git a/clang.toolchain b/clang.toolchain
index b8ce37232d..71d241b34f 100644
--- a/clang.toolchain
+++ b/clang.toolchain
@@ -4,5 +4,16 @@ set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld -rdynamic")
set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld")
set(CMAKE_C_STANDARD_LIBRARIES "-lc -lm")
set(CMAKE_CXX_STANDARD_LIBRARIES "-lc -lm")
+if (CCACHE_PATH)
+ set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PATH}" CACHE STRING "C++ compiler launcher")
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PATH}" CACHE STRING "C compiler launcher")
+
+ # TODO: change ydb/.github/prewarm/build.sh in order to remove the difference with non-cache builds
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -UNDEBUG" CACHE STRING "C++ compiler flags")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -UNDEBUG" CACHE STRING "C compiler flags")
+else()
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -UNDEBUG" CACHE STRING "C++ compiler flags")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -UNDEBUG" CACHE STRING "C compiler flags")
+endif()
set(ENV{CC} clang-14)
set(ENV{CXX} clang++-14)