Skip to content

Commit da2223f

Browse files
lucylqGithub Executorch
andauthored
Export ET_LOG_ENABLED=0 as PUBLIC compile definition on cmake targets (#17907)
The executorch and executorch_core cmake targets did not propagate ET_LOG_ENABLED=0 to consumers via INTERFACE_COMPILE_DEFINITIONS. This caused inline/template functions from headers (e.g. MemoryAllocator::allocate, Result<T>::CheckOk) to be instantiated with logging enabled in consumer TUs, pulling in format strings, et_pal_emit_log_message, and the full POSIX logging stack (fprintf, chrono). Adding ET_LOG_ENABLED=0 as a PUBLIC definition ensures consumers compile header code with the same logging state as the library. Reduces stripped size_test by 4,096 bytes and stripped size_test_all_ops by 8,192 bytes. --------- Co-authored-by: Github Executorch <github_executorch@arm.com>
1 parent 4e8bcd3 commit da2223f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ target_include_directories(
494494
target_compile_definitions(
495495
executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
496496
)
497+
if(NOT EXECUTORCH_ENABLE_LOGGING)
498+
target_compile_definitions(executorch_core PUBLIC ET_LOG_ENABLED=0)
499+
endif()
497500
target_compile_options(executorch_core PUBLIC ${_common_compile_options})
498501
if(MAX_KERNEL_NUM)
499502
target_compile_definitions(
@@ -542,6 +545,9 @@ add_library(executorch ${_executorch__srcs})
542545
target_link_libraries(executorch PRIVATE executorch_core)
543546
target_include_directories(executorch PUBLIC ${_common_include_directories})
544547
target_compile_definitions(executorch PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
548+
if(NOT EXECUTORCH_ENABLE_LOGGING)
549+
target_compile_definitions(executorch PUBLIC ET_LOG_ENABLED=0)
550+
endif()
545551
target_compile_options(executorch PUBLIC ${_common_compile_options})
546552
executorch_target_link_options_shared_lib(executorch)
547553

0 commit comments

Comments
 (0)