Skip to content

Commit e1299ba

Browse files
morningmanclaude
andcommitted
[fix](build) Make ENABLE_UNITY_BUILD=OFF authoritative over CMAKE_UNITY_BUILD
Each pilot target set its UNITY_BUILD property inside `if (ENABLE_UNITY_BUILD)`, which is a one-way gate: OFF took the empty branch and left the property alone. CMake's own CMAKE_UNITY_BUILD initializes UNITY_BUILD when add_library runs, so a cache carrying CMAKE_UNITY_BUILD=ON kept the pilot targets unity-built while the build advertised the opposite. Normalize the option to a strict ON/OFF once and set the property unconditionally from it, so OFF is an explicit OFF. Normalizing also keeps an empty -DENABLE_UNITY_BUILD= (an unset variable forwarded by a script) from turning into a malformed set_target_properties call. Verified on this tree with `-DENABLE_UNITY_BUILD=OFF -DCMAKE_UNITY_BUILD=ON`: 28 unity TUs across the three pilot targets before, 0 after; the ordinary `-DENABLE_UNITY_BUILD=ON` configure still produces exactly the 6 advertised batches (InformationSchema 1, Service 1, Storage 4). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Gdfkk7RqgD5e3Uv7bTM3NV
1 parent 0dcc67c commit e1299ba

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎be/CMakeLists.txt‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ option(USE_JEMALLOC "Use jemalloc" ON)
8484
# builds. Turn OFF for precise per-file diagnostics, per-file tooling
8585
# (clang-tidy/coverage), or the finest-grained incremental rebuilds.
8686
option(ENABLE_UNITY_BUILD "Enable CMake unity builds for BE targets" ON)
87+
# Normalize to a strict ON/OFF. Every pilot target sets its UNITY_BUILD property
88+
# unconditionally from this value: OFF must be an explicit OFF, otherwise a
89+
# cache that also carries CMake's own CMAKE_UNITY_BUILD=ON leaves the property
90+
# ON (it initializes UNITY_BUILD at add_library time) and the escape hatch does
91+
# nothing.
92+
if (ENABLE_UNITY_BUILD)
93+
set(DORIS_UNITY_BUILD ON)
94+
else()
95+
set(DORIS_UNITY_BUILD OFF)
96+
endif()
8797
if (OS_MACOSX)
8898
set(GLIBC_COMPATIBILITY OFF)
8999
set(USE_LIBCPP ON)

‎be/src/information_schema/CMakeLists.txt‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@ pch_reuse(InformationSchema)
3131
# Batch size 0 merges all sources into a single unity TU (~10x faster than
3232
# compiling them individually). A new file whose file-scope symbols clash
3333
# inside the unity TU can opt out via SKIP_UNITY_BUILD_INCLUSION.
34-
if (ENABLE_UNITY_BUILD)
35-
set_target_properties(InformationSchema PROPERTIES UNITY_BUILD ON
36-
UNITY_BUILD_BATCH_SIZE 0)
37-
endif()
34+
set_target_properties(InformationSchema PROPERTIES UNITY_BUILD ${DORIS_UNITY_BUILD}
35+
UNITY_BUILD_BATCH_SIZE 0)

‎be/src/service/CMakeLists.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ list(APPEND SERVICE_UNITY_SKIP
4747
${CMAKE_CURRENT_SOURCE_DIR}/http/http_parser.cpp
4848
${CMAKE_CURRENT_SOURCE_DIR}/http/action/be_thread_stack_action.cpp)
4949
set_source_files_properties(${SERVICE_UNITY_SKIP} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
50-
if (ENABLE_UNITY_BUILD)
51-
set_target_properties(Service PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 0)
52-
endif()
50+
set_target_properties(Service PROPERTIES UNITY_BUILD ${DORIS_UNITY_BUILD}
51+
UNITY_BUILD_BATCH_SIZE 0)
5352

5453
if (${MAKE_TEST} STREQUAL "OFF" AND ${BUILD_BENCHMARK} STREQUAL "OFF")
5554
add_executable(doris_be

‎be/src/storage/CMakeLists.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,5 @@ list(APPEND STORAGE_UNITY_SKIP
6060
${CMAKE_CURRENT_SOURCE_DIR}/index/inverted/tokenizer/basic/basic_tokenizer.cpp
6161
${CMAKE_CURRENT_SOURCE_DIR}/index/zone_map/zone_map_index.cpp)
6262
set_source_files_properties(${STORAGE_UNITY_SKIP} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
63-
if (ENABLE_UNITY_BUILD)
64-
set_target_properties(Storage PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 32)
65-
endif()
63+
set_target_properties(Storage PROPERTIES UNITY_BUILD ${DORIS_UNITY_BUILD}
64+
UNITY_BUILD_BATCH_SIZE 32)

0 commit comments

Comments
 (0)