-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: add LLVM coverage support #8376
base: master
Are you sure you want to change the base?
cmake: add LLVM coverage support #8376
Conversation
If FLB_COVERAGE is on, FLB_COVERAGE_TYPE can be configured for the coverage type, which is one of: - gcov (default) - llvm Signed-off-by: Seigo Tanimura <[email protected]>
This allows llvm-profdata(1) to collect the test execution profiles. Signed-off-by: Seigo Tanimura <[email protected]>
Hi, I know little about this but how the coverage stuff helps to get this build on BSD? |
My ultimate goal is to address the build breakage on FreeBSD due to the use of The wrapper function of Although LLVM can emit the gcov coverage data somehow, that is merely a compatibility feature. It is better to support the LLVM-native coverage support to minimize the build prerequisites, as well as to avoid any problems that may happen in the compatibility feature only. The coverage part has been separated from the main fix because they change the different modules in Fluent Bit; the former changes the build system (hence tagged by The main |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR adds the coverage support to the platform with the LLVM/clang only, without GCC.
Background
This change is essential for FreeBSD as the Fluent Bit development platform. The
master
branch as of f8bd0ce does not build on FreeBSD 14.0-RELEASE because of thestrerror_r(3)
signature dependency on glibc. I am addressing this issue in parallel, in which the code coverage is required to prove the fix.New CMake Build Option(s)
FLB_COVERAGE_TYPE
gcov
: (default) gcov; native for GCC, compatible with LLVM/clang.llvm
: LLVM; native for LLVM/clang.FLB_COVERAGE
is required.Change(s) to
CMAKE_C_FLAGS
-fprofile-instr-generate -fcoverage-mapping
.These are the standard CFLAGS options to enable the code coverage profile instrumentation on LLVM/clang.
Change(s) to Test Execution Environment
LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR}/(testname).profraw
.runtime_shell
test can execute at most one test binary.Out of Scope
llvm-profdata
.llvm-cov
.Tested Environment
Testing
Before we can approve your change; please submit the following in a comment:
N/A
Example configuration file for the changeThis change does not add any new features to the Fluent Bit binary.
logs-fluent-bit-topic-llvm-coverage.zip
: The archive of the log files and sample LLVM coverage report.logs-fluent-bit-topic-llvm-coverage/
fluent-bit-cmake-topic-llvm-coverage-debian_x86_64_12_2.log
: Thecmake
log.env CC=clang-14 CXX=clang++-14 CPP=clang-cpp-14 LD=ld.lld RANLIB=llvm-ranlib-14 cmake -DFLB_COVERAGE=true -DFLB_COVERAGE_TYPE=llvm -DFLB_DEV=true -DFLB_VALGRIND=true -DFLB_TESTS_RUNTIME=true ..
fluent-bit-make-topic-llvm-coverage-debian_x86_64_12_2.log
: Themake
log.env CC=clang-14 CXX=clang++-14 CPP=clang-cpp-14 LD=ld.lld RANLIB=llvm-ranlib-14 make
fluent-bit-ctest-topic-llvm-coverage-debian_x86_64_12_2.log
: Thectest
log.ctest
flb-rt-out_td
: The test environment problem, I cannot make the valid test configuration.SIGTERM
.in_syslog_uds_dgram_plaintext_expect.sh
,in_syslog_uds_stream_plaintext_expect.sh
: These are known to stall for more than 5 minutes, found during the test rehearsal. The results afterSIGTERM
are both successful.fluent-bit-find-profraw-topic-llvm-coverage-debian_x86_64_12_2.log
: The LLVM profile files found afterctest
.find tests -type f -name '*.profraw'
fluent-bit-llvm-profdata-cov-topic-llvm-coverage-debian_x86_64_12_2.log
: The LLVM profile data collection and coverage report generation.llvm-cov-test-topic-llvm-coverage-debian_x86_64_12_2.tar.xz
: The LLVM coverage report in HTML.N/A
Attached Valgrind output that shows no leaks or memory corruption was foundThis change does not touch any C sources.
This change does not touch the packaging.
Documentation
Doc PR: installation: sources: Add FLB_COVERAGE and FLB_COVERAGE_TYPE. fluent-bit-docs#1289
Backporting
There is a fix depending on this PR. (pal: platform abstraction layer and strerror_r(3) wrapper #8390)
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.