morningman opened a new pull request, #68520:
URL: https://github.com/apache/doris/pull/68520

   ## 上下文
   
   `run-be-ut.sh` 是 BE 单测的唯一入口。在一台 macOS 
机器上、从一个干净的工作树上首次运行它时,有两条独立的路径会直接失败,第三条路径会在编译阶段一个接一个地卡住,一共 7 个 TU 编不过 —— 而 Linux 
的 BE UT 一直是绿的。
   
   ## 问题与影响
   
   **1. 新工作树上 configure 直接失败(与平台无关)**
   
   `run-be-ut.sh` 只 init 了 5 个 submodule 中的 3 个,缺 `contrib/faiss` 和 
`contrib/openblas`。但 `be/CMakeLists.txt:1038` 无条件 
`add_subdirectory(be/src/storage/index/ann)`,而该目录的 
`cmake-protect/CMakeLists.txt:48/66` 又无条件 `add_subdirectory` 这两个 contrib:
   
   ```
   CMake Error at src/storage/index/ann/cmake-protect/CMakeLists.txt:48 
(add_subdirectory):
     The source directory .../contrib/openblas does not contain a 
CMakeLists.txt file.
   CMake Error at src/storage/index/ann/cmake-protect/CMakeLists.txt:66 
(add_subdirectory):
     The source directory .../contrib/faiss does not contain a CMakeLists.txt 
file.
   ```
   
   先跑过一次 `build.sh` 的树不会暴露这个问题(build.sh 会 init 这两个),所以它只在全新 clone / 新 worktree 
上出现。
   
   **2. macOS 上 7 个 test TU 编不过**
   
   `run-be-ut.sh` 调 ninja 时没有 `-k`,撞第一个就停。开发者只能改一个、重编一次、再撞下一个,**来回 7 
轮**,每轮代价是数十分钟的全量编译。7 个全部与本地改动无关,干净 master 一样复现。
   
   | # | TU | 报错 | 根因 |
   |---|---|---|---|
   | 1 | `exprs/function/function_map_inner_product_test.cpp` | 
`'faiss/impl/platform_macros.h' file not found` | `be/test/CMakeLists.txt` 的 
APPLE 分支用 `-Wl,-force_load,$<TARGET_FILE:vector_search_test>`,传的是**文件路径**,不携带 
usage requirements;其他平台用 `--whole-archive <target>`,列表里是 target,会传播 |
   | 2 | `exprs/function/function_format_round_test.cpp` | `ambiguous 
conversion from 'long' to 'Decimal64'`(11 处) | `Decimal64` = 
`Decimal<int64_t>`;Darwin 上构造参数是 `long long` 而字面量是 `long`,到各个整型/浮点构造函数都是同级转换 |
   | 3 | `storage/index/snii/bench/bkd_native_vs_clucene_bench_test.cpp` | 6 处 
`-Werror,-Wformat` | `uint64_t` 在 Darwin 是 `unsigned long long`、Linux 是 
`unsigned long` |
   | 4 | `storage/index/snii/bench/snii_vs_v3_benchmark_test.cpp` | `no member 
named 'posix_fadvise'`、`mincore` 参数类型 | `posix_fadvise`/`POSIX_FADV_DONTNEED` 在 
Darwin 不存在;`mincore(2)` 第三个参数 Darwin 是 `char*`、Linux 是 `unsigned char*` |
   | 5 | `storage/index/snii/bkd/bkd_corruption_test.cpp` | `deduced 
conflicting types ('size_type' vs 'uint64_t')` | initializer list 里混了 
`payload.size()`(size_t)和 `uint64_t` 字面量 |
   | 6 | `storage/index/snii/writer/spimi_locality_bench_test.cpp` | libc++ `no 
matching function for call to object of type 'key_equal'` | 
透明相等仿函数只定义了一个方向:libc++ 按 `(key, lookup)` 调用、libstdc++ 按 `(lookup, key)` |
   | 7 | `storage/segment/hierarchical_data_iterator_test.cpp` | 3 处 `no 
matching function for call to 'min'` | `kRows` 是 `size_t`、`current_ordinal` 是 
`ordinal_t`(`uint64_t`),Darwin 上是不同类型,`std::min` 推不出共同类型 |
   
   其中第 2 个是 2026-09-24 才合入的(#68397),正好落在上一次 macOS 全量排查之后。
   
   **为什么这些问题能长期存在**:`.github/workflows/be-ut-mac.yml` 名为 "BE UT (macOS)",但它跑的是 
`build.sh --be`,即 `-DMAKE_TEST=OFF` —— **`be/test` 下一个 TU 都不编**(workflow 里第 
123-126 行的注释也写明了这一点,它是 macOS 的 C++ 编译检查,不是测试构建)。Linux 的 BE UT 又全绿。于是"macOS + 
be/test"这个组合**没有任何 CI 覆盖**,只能靠开发者在 Mac 上手工跑 `run-be-ut.sh` 撞出来;而第 1 条(configure 
失败)和第 2 条(7 轮串行失败)恰好让这个手工路径的成本高到几乎不可行。
   
   ## 方案与好处
   
   **脚本侧**:`run-be-ut.sh` 的 `update_submodule` 列表补齐 `contrib/openblas` 与 
`contrib/faiss`,URL 与 `build.sh:941-942` 完全一致,并加注释说明这份列表必须与 build.sh 同步。
   
   **CMake 侧**:APPLE 分支在 force_load 之后显式链接 `ann_index`(它把 faiss 的 include 目录 
PUBLIC 导出)。这样 macOS 的编译与链接输入和其他平台**完全一致**,而不是给 macOS 打一个特例补丁。
   
   **代码侧**:6 个文件按各自根因做最小修改,全部使用仓库里已有的写法 —— 
`PRIu64`/`PRId64`(`decimal12.h`、`histogram.cpp`)、`int64_t(...)` 
包裹(`key_coder_test.cpp:392`、`jsonb_document_test.cpp:433`)、`#if 
defined(POSIX_FADV_DONTNEED)` 守卫。Linux 侧行为不变。
   
   改完之后 macOS 上 `run-be-ut.sh` 才真正是条可用的测试线;对 Linux 无任何影响。
   
   **需要注意的一次性代价**:APPLE 链接行开始传播 include 目录后,每个 test TU 的编译命令行都会变一次,因此 macOS 
上拉到这个改动后的第一次构建会重编 `be/test`(约 1230 个 TU),之后恢复增量。
   
   ## 类与调用图
   
   ```
   run-be-ut.sh
     └── update_submodule()  ← 补 contrib/openblas、contrib/faiss(与 build.sh 对齐)
           └── git submodule update --init --recursive
   
   be/CMakeLists.txt:1038  add_subdirectory(be/src/storage/index/ann)
     └── be/src/storage/index/ann/CMakeLists.txt:18  
add_subdirectory(cmake-protect)
           └── cmake-protect/CMakeLists.txt:48,66   
add_subdirectory(contrib/{openblas,faiss})
                 └── 目标 faiss ──(PUBLIC)──> 目标 ann_index ──(PUBLIC)──> be/test 
的 vector_search_test
                                                                             │
   be/test/CMakeLists.txt:170  if (APPLE)                                   │
     ├── 旧: -Wl,-force_load,<libvector_search_test.a 的路径>  ── 不传播 ──┘
     └── 新: 同上 + ann_index  ── 传播 faiss include dirs ──> 
function_map_inner_product_test.cpp
                                                              (所有 test TU 
的编译命令同时对齐到其他平台)
   ```
   


-- 
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]

Reply via email to