@@ -234,6 +234,8 @@ if (SPLIT_DEBUG_SYMBOLS)
234234    set (SPLIT_DEBUG_SYMBOLS_DIR "stripped"  CACHE  STRING  "A separate directory for stripped information" )
235235endif ()
236236
237+ option (BUILD_STRIPPED_BINARY "Build stripped binary (clickhouse-stripped)"  OFF )
238+ 
237239cmake_host_system_information (RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) # Not available under freebsd 
238240
239241
@@ -302,9 +304,8 @@ set (CMAKE_C_STANDARD_REQUIRED ON)
302304# See https://reviews.llvm.org/D112921 
303305set (CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}  -fsized-deallocation" )
304306
305- # falign-functions=32 prevents from random performance regressions with the code change. Thus, providing more stable 
306- # benchmarks. 
307- set (COMPILER_FLAGS "${COMPILER_FLAGS}  -falign-functions=32" )
307+ # falign-functions=64 prevents from random performance regressions with the code change. Thus, providing more stable benchmarks. 
308+ set (COMPILER_FLAGS "${COMPILER_FLAGS}  -falign-functions=64" )
308309
309310if  (ARCH_AMD64)
310311    # align branches within a 32-Byte boundary to avoid the potential performance loss when code layout change, 
@@ -381,6 +382,15 @@ elseif (ENABLE_THINLTO)
381382    message  (${RECONFIGURE_MESSAGE_LEVEL}  "Cannot enable ThinLTO" )
382383endif  ()
383384
385+ if (COMPILER_PIPE)
386+     set (MAX_COMPILER_MEMORY 2500)
387+ else ()
388+     set (MAX_COMPILER_MEMORY 1500)
389+ endif ()
390+ set (MAX_LINKER_MEMORY 5000)
391+ include (cmake/limit_jobs.cmake)
392+ 
393+ 
384394# Turns on all external libs like s3, kafka, ODBC, ... 
385395option (ENABLE_LIBRARIES "Enable all external libraries by default"  ON )
386396
@@ -402,15 +412,6 @@ endif ()
402412link_libraries (global -group)
403413target_link_libraries (global -group INTERFACE  $<TARGET_PROPERTY:global -libs,INTERFACE_LINK_LIBRARIES>)
404414
405- option  (ENABLE_GWP_ASAN "Enable Gwp-Asan"  OFF )
406- # We use mmap for allocations more heavily in debug builds, 
407- # but GWP-ASan also wants to use mmap frequently, 
408- # and due to a large number of memory mappings, 
409- # it does not work together well. 
410- # if ((NOT OS_LINUX AND NOT OS_ANDROID) OR (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")) 
411- #     set(ENABLE_GWP_ASAN OFF) 
412- # endif () 
413- 
414415option  (ENABLE_FIU "Enable Fiu"  ON )
415416
416417option (WERROR "Enable -Werror compiler option"  ON )
@@ -517,13 +518,32 @@ macro (clickhouse_add_executable target)
517518        add_executable  (${ARGV}  $<TARGET_OBJECTS:clickhouse_malloc>)
518519    endif  ()
519520
521+     # Wrap the malloc/free and other C-style functions with our own ones 
522+     # to inject memory tracking mechanism into them. 
523+     # Sanitizers have their own way of intercepting the 
524+     # allocations and deallocations, so we skip this step for them. 
525+     if  (NOT  (SANITIZE OR  SANITIZE_COVERAGE OR  OS_DARWIN OR  OS_FREEBSD))
526+         target_link_options (${target}  PRIVATE 
527+             "LINKER:--wrap=malloc" 
528+             "LINKER:--wrap=free" 
529+             "LINKER:--wrap=calloc" 
530+             "LINKER:--wrap=realloc" 
531+             "LINKER:--wrap=aligned_alloc" 
532+             "LINKER:--wrap=posix_memalign" 
533+             "LINKER:--wrap=valloc" 
534+             "LINKER:--wrap=memalign" 
535+             "LINKER:--wrap=reallocarray" 
536+         )
537+         if  (NOT  USE_MUSL)
538+             target_link_options (${target}  PRIVATE 
539+                 "LINKER:--wrap=pvalloc" 
540+             )
541+         endif ()
542+     endif ()
543+ 
520544    get_target_property  (type  ${target}  TYPE )
521545    if  (${type}  STREQUAL  EXECUTABLE)
522-         # Disabled if memory tracking is disabled 
523-         if  (TARGET  clickhouse_new_delete)
524-             # operator::new/delete for executables (MemoryTracker stuff) 
525-             target_link_libraries  (${target}  PRIVATE  clickhouse_new_delete)
526-         endif ()
546+         target_link_libraries  (${target}  PUBLIC  clickhouse_new_delete)
527547
528548        # In case of static jemalloc, because zone_register() is located in zone.c and 
529549        # is never used outside (it is declared as constructor) it is omitted 
@@ -595,6 +615,9 @@ option(CHECK_LARGE_OBJECT_SIZES "Check that there are no large object files afte
595615
596616add_subdirectory  (base)
597617add_subdirectory  (src)
618+ if  (LEXER_STANDALONE_BUILD)
619+     add_subdirectory (tests/lexer)
620+ endif  ()
598621add_subdirectory  (programs)
599622add_subdirectory  (utils)
600623
0 commit comments