Skip to content

Commit

Permalink
Merge branch 'main' into gsk/compile_in_1804_gcc9
Browse files Browse the repository at this point in the history
  • Loading branch information
guanshoukui committed Mar 5, 2024
2 parents f41e8a0 + 244c92a commit 873ebea
Show file tree
Hide file tree
Showing 65 changed files with 1,924 additions and 640 deletions.
52 changes: 52 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Must be first. Enables build:windows, build:linux, build:macos, build:freebsd, build:openbsd
build --enable_platform_specific_config
###############################################################################
# On Windows, provide: BAZEL_SH, and BAZEL_LLVM (if using clang-cl)
# On all platforms, provide: PYTHON3_BIN_PATH=python
###############################################################################
build --action_env=PATH
# For --compilation_mode=dbg, consider enabling checks in the standard library as well (below).
build --compilation_mode=opt
# FIXME(lingxuan.zlx) TEST CASE: test wide string crash since cxx abi off.
build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
# Using C++ 20 on all platforms.
build:linux --cxxopt="-std=c++20"
build:macos --cxxopt="-std=c++20"
build:clang-cl --cxxopt="-std=c++20"
build:gcc-cl --cxxopt="-std=c++20"
build:gcc-cl --cxxopt="-fcoroutines"
build:msvc-cl --cxxopt="/std:c++20"
build:windows --cxxopt="/std:c++20"
# This workaround is needed to prevent Bazel from compiling the same file twice (once PIC and once not).
build:linux --force_pic
build:macos --force_pic
build:clang-cl --compiler=clang-cl
build:msvc-cl --compiler=msvc-cl
# `LC_ALL` and `LANG` is needed for cpp worker tests, because they will call "ray start".
# If we don't add them, python's `click` library will raise an error.
build --action_env=LC_ALL
build --action_env=LANG
# Allow C++ worker tests to execute "ray start" with the correct version of Python.
build --action_env=VIRTUAL_ENV
build --action_env=PYENV_VIRTUAL_ENV
build --action_env=PYENV_VERSION
build --action_env=PYENV_SHELL
# This is needed for some core tests to run correctly
build:windows --enable_runfiles
build:linux --per_file_copt="-\\.(asm|S)$@-Werror"
build:macos --per_file_copt="-\\.(asm|S)$@-Werror"
build:clang-cl --per_file_copt="-\\.(asm|S)$@-Werror"
build:gcc-cl --per_file_copt="-\\.(asm|S)$@-Werror"
build:msvc-cl --per_file_copt="-\\.(asm|S)$@-WX"
# Ignore warnings for protobuf generated files and external projects.
build --per_file_copt="\\.pb\\.cc$@-w"
build --per_file_copt="-\\.(asm|S)$,external/.*@-w"
#build --per_file_copt="external/.*@-Wno-unused-result"
# Ignore minor warnings for host tools, which we generally can't control
build:clang-cl --host_copt="-Wno-inconsistent-missing-override"
build:clang-cl --host_copt="-Wno-microsoft-unqualified-friend"
# Ignore wchar_t -> char conversion warning on MSVC
build:msvc-cl --per_file_copt="external/boost/libs/regex/src/wc_regex_traits\\.cpp@-wd4244"
build --http_timeout_scaling=5.0
build --verbose_failures

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bazel
name: Bazel-Clang

on:
push:
Expand All @@ -22,8 +22,8 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: bazel build --action_env=CXX=clang++-17 --action_env=CC=clang-17 ...
run: bazel build --config=clang-cl --action_env=CXX=clang++-17 --action_env=CC=clang-17 ...

- name: Test
working-directory: ${{github.workspace}}
run: bazel test --action_env=CXX=clang++-17 --action_env=CC=clang-17 --test_output=errors ...
run: bazel test --config=clang-cl --action_env=CXX=clang++-17 --action_env=CC=clang-17 --test_output=errors ...
24 changes: 24 additions & 0 deletions .github/workflows/bazel_gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bazel-GCC

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2


- name: Build
working-directory: ${{github.workspace}}
run: bazel build --config=gcc-cl ...

- name: Test
working-directory: ${{github.workspace}}
run: bazel test --config=gcc-cl --test_output=errors ...
38 changes: 38 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Upload CodeCov Report

on: [ push, pull_request ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Install newer Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Configure
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=OFF -DYLT_ENABLE_SSL=ON \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17
- name: Build with ${{ matrix.compiler }}
run: cmake --build ${{github.workspace}}/build --config Debug -- -j

- name: Test
working-directory: ${{github.workspace}}/build
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.configuration }} -j 1 -V

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
37 changes: 25 additions & 12 deletions .github/workflows/linux_llvm_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Ubuntu 22.04 (llvm cov)

on:
pull_request_target:
branches: [ doc ]
workflow_dispatch:
branches:
- main
- fix_coverage

jobs:
build:
Expand All @@ -19,37 +20,49 @@ jobs:
sudo apt-get install libssl-dev
sudo apt-get install llvm
- name: Install newer Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Run Coverage
run: |
ls
cp -r src/coro_rpc/tests/openssl_files .
ls
mkdir build && cd build
CC=clang CXX=clang++ cmake .. -DCOVERAGE_TEST=ON -DENABLE_SSL=ON
make -j test_rpc
export LLVM_PROFILE_FILE="test_rpc-%m.profraw"
./tests/test_rpc
llvm-profdata merge -sparse test_rpc-*.profraw -o test_rpc.profdata
llvm-cov show ./tests/test_rpc -instr-profile=test_rpc.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="async_simple|thirdparty|tests|asio|util|logging|struct_pack" -show-instantiations=false
CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DYLT_ENABLE_SSL=ON
make -j
export LLVM_PROFILE_FILE="test_ylt-%m.profraw"
cd output
cd tests
./coro_io_test
./coro_rpc_test
./easylog_test
./struct_pack_test
./struct_pack_test_with_optimize
llvm-profdata merge -sparse test_ylt-*.profraw -o test_ylt.profdata
llvm-cov show coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio|src" -show-instantiations=false
echo "Done!"
- name: Upload Coverage Results
uses: actions/upload-artifact@v3
with:
name: llvm-cov
path: ${{ github.workspace }}/.coverage_llvm_cov
path: ${{ github.workspace }}/build/.coverage_llvm_cov

- name: Create Code Coverage Report
working-directory: ${{github.workspace}}/build
working-directory: ${{github.workspace}}/build/output/tests
run: |
echo "Code Coverage Report" > tmp.log
echo "for detail, [goto summary](https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{github.run_id}}) download Artifacts `llvm-cov`" >> tmp.log
echo "\`\`\`" >> tmp.log
llvm-cov report ./tests/test_rpc -instr-profile=test_rpc.profdata -ignore-filename-regex="thirdparty|tests" -show-region-summary=false >> tmp.log
llvm-cov report coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio|src" -show-region-summary=false >> tmp.log
echo "\`\`\`" >> tmp.log
- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-file: '${{github.workspace}}/build/tmp.log'
body-file: '${{github.workspace}}/build/output/tests/tmp.log'
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
key: ${{ github.job }}-${{ matrix.mode}}-ssl( ${{ matrix.ssl}} )

- name: Configure CMake
run: OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON
run: OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu_clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Configure
run: |
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
run: |
CXX=clang++ CC=clang
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17\
-DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
- name: Build
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
-DBUILD_WITH_LIBCXX=${{matrix.libcxx}} \
-DENABLE_IO_URING=${{matrix.io_uring}} \
-DYLT_ENABLE_IO_URING=${{matrix.io_uring}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17\
-DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_PACK=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
CXX=g++ CC=gcc
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}}
- name: Build
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
run: |
CXX=g++ CC=gcc
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} \
-DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
CXX=g++ CC=gcc
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
-DENABLE_IO_URING=${{matrix.io_uring}} \
-DYLT_ENABLE_IO_URING=${{matrix.io_uring}} \
-DUSE_CCACHE=${{env.ccache}} \
-DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_PACK=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
key: ${{ github.job }}-${{ matrix.mode}}-ssl( ${{ matrix.ssl}} )-arch-${{ matrix.arch}}
- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON
run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON
- name: Build
run: cmake --build ${{github.workspace}}\build
- name: Test
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
with:
key: ${{ github.job }}-${{ matrix.mode}}-arch-${{ matrix.arch}}
- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON -DENABLE_CPP_20=OFF
run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON -DENABLE_CPP_20=OFF
- name: Build
run: cmake --build ${{github.workspace}}\build
- name: Test
Expand Down
90 changes: 86 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,95 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("//bazel:defs.bzl", "YA_BIN_COPT", "YA_LT_COPT")

package(default_visibility = ["//visibility:public"])

cc_library(
name = "ylt",
hdrs = glob([
"include/**",
"src/include/**"
srcs = glob([
"include/ylt/**/*.hpp",
"include/ylt/**/*.h",
"include/ylt/**/*.ipp",
"src/include/*.h",
]),
includes = ["include", "include/ylt/thirdparty","src/include"],
copts = YA_LT_COPT,
includes = [
"include",
"include/ylt",
"include/ylt/thirdparty",
"src/include",
],
linkopts = ["-lpthread"],
visibility = ["//visibility:public"],
)

# List one example for ylt tests.
cc_test(
name = "easylog_test",
srcs = [
"src/easylog/tests/main.cpp",
"src/easylog/tests/test_easylog.cpp",
],
copts = YA_BIN_COPT,
includes = [
"include",
"include/ylt/thirdparty",
"src/include",
],
deps = [":ylt"],
)

cc_binary(
name = "easylog_benchmark",
srcs = [
"src/easylog/benchmark/main.cpp",
],
copts = YA_BIN_COPT,
includes = [
"include",
"include/ylt/thirdparty",
"src/include",
],
deps = [":ylt"],
)

cc_binary(
name = "coro_http_example",
srcs = ["src/coro_http/examples/example.cpp"],
copts = YA_BIN_COPT,
includes = [
"include",
"include/ylt",
"include/ylt/thirdparty",
"src/include",
],
linkopts = ["-lpthread"],
deps = [":ylt"],
)

cc_binary(
name = "coro_http_channel",
srcs = ["src/coro_http/examples/channel.cpp"],
copts = YA_BIN_COPT,
includes = [
"include",
"include/ylt",
"include/ylt/thirdparty",
"src/include",
],
linkopts = ["-lpthread"],
deps = [":ylt"],
)

cc_binary(
name = "coro_http_chat_room",
srcs = ["src/coro_http/examples/chat_room.cpp"],
copts = YA_BIN_COPT,
includes = [
"include",
"include/ylt",
"include/ylt/thirdparty",
"src/include",
],
linkopts = ["-lpthread"],
deps = [":ylt"],
)
Loading

0 comments on commit 873ebea

Please sign in to comment.