heguanhui opened a new issue, #63927:
URL: https://github.com/apache/doris/issues/63927
### Version
trunk (commit 4616202fc4)
### What's Wrong?
Building BE unit tests with TSAN (`-O1`) or RELEASE (`-O3`) optimization
levels causes linker errors:
```
undefined reference to 'doris::segment_v2::SegmentWriter::_is_mow()'
undefined reference to
'doris::segment_v2::SegmentWriter::_is_mow_with_cluster_key()'
undefined reference to 'doris::segment_v2::VerticalSegmentWriter::_is_mow()'
undefined reference to
'doris::segment_v2::VerticalSegmentWriter::_is_mow_with_cluster_key()'
```
The default ASAN build (`-O0`) does NOT exhibit this error because at `-O0`
the compiler ignores the `inline` keyword and exports the symbol.
### What You Expected?
BE unit tests should link successfully regardless of optimization level.
### How to Reproduce?
1. Build BE UT with TSAN or RELEASE mode:
```bash
BUILD_TYPE_UT=TSAN bash run-be-ut.sh --run
--filter=DeleteBitmapCalculatorTest.*
```
2. Observe linker errors for `_is_mow()` and `_is_mow_with_cluster_key()`.
### Root Cause
Commit 74aa0ca63a (`[fix](cluster key) cluster key support
vertical_segment_writer #38538`) defined `_is_mow()` and
`_is_mow_with_cluster_key()` with the `inline` keyword in `.cpp` files
(`segment_writer.cpp` and `vertical_segment_writer.cpp`).
At `-O1`/`-O3`, the compiler inlines these functions and does NOT export the
symbols. When commit 4616202fc4 introduced `TestSegmentWriter` (a friend
subclass) in `test_segment_writer.h` that calls these private methods from a
different translation unit, the linker cannot find the symbols.
The fix is to move the `inline` definitions from the `.cpp` files into the
header files (as class-internal inline definitions), so they are visible to all
translation units.
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]