Files
scylladb/cql3/CMakeLists.txt
Avi Kivity 4a9fdb17f0 build: cmake: fix -fno-sanitize-address-use-after-scope for CQL parser
The CMake build had -fsanitize-address-use-after-scope (enable) when
it should have been -fno-sanitize-address-use-after-scope (disable).

The comment on lines 24-25 of cql3/CMakeLists.txt explains the intent:
the use-after-scope sanitizer uses too much stack space on CqlParser
and overflows the stack. The Python-ninja path in configure.py:2801-2802
correctly had -fno-sanitize-address-use-after-scope.

Found by black-box comparison of compiler flags between the Python-ninja
and CMake build paths (ninja -nv output, debug mode, CqlParser.o):

  Python-ninja: -fno-sanitize-address-use-after-scope  (correct: disable)
  CMake:        -fsanitize-address-use-after-scope      (wrong: enable)

Closes scylladb/scylladb#29439
2026-04-14 14:48:52 +03:00

151 lines
4.7 KiB
CMake

include(generate_cql_grammar)
find_package(ANTLR3 REQUIRED)
generate_cql_grammar(
GRAMMAR Cql.g
SOURCES cql_grammar_srcs)
set_source_files_properties(${cql_grammar_srcs}
PROPERTIES
COMPILE_OPTIONS "-Wno-uninitialized;-Wno-parentheses-equality")
set(cql_parser_srcs ${cql_grammar_srcs})
list(FILTER cql_parser_srcs INCLUDE REGEX "Parser.cpp$")
set(unoptimized_modes "Coverage,Debug,Sanitize")
set(sanitized_modes "Debug,Sanitize")
set_property(
SOURCE ${cql_parser_srcs}
APPEND
PROPERTY COMPILE_OPTIONS
# Unoptimized parsers end up using huge amounts of stack space and
# overflowing their stack
$<$<CONFIG:${unoptimized_modes}>:-O1>
# use-after-scope sanitizer also uses large amount of stack space
# and overflows the stack of CqlParser
$<$<CONFIG:${sanitized_modes}>:-fno-sanitize-address-use-after-scope>)
add_library(cql3 STATIC)
target_sources(cql3
PRIVATE
attributes.cc
cf_name.cc
cql3_type.cc
description.cc
operation.cc
index_name.cc
keyspace_element_name.cc
lists.cc
sets.cc
maps.cc
values.cc
expr/expression.cc
expr/restrictions.cc
expr/prepare_expr.cc
functions/user_function.cc
functions/functions.cc
functions/aggregate_fcts.cc
functions/castas_fcts.cc
functions/error_injection_fcts.cc
statements/strong_consistency/select_statement.cc
statements/strong_consistency/modification_statement.cc
statements/strong_consistency/statement_helpers.cc
functions/vector_similarity_fcts.cc
statements/cf_prop_defs.cc
statements/cf_statement.cc
statements/authentication_statement.cc
statements/create_keyspace_statement.cc
statements/create_table_statement.cc
statements/create_view_statement.cc
statements/create_type_statement.cc
statements/create_function_statement.cc
statements/create_aggregate_statement.cc
statements/drop_index_statement.cc
statements/drop_keyspace_statement.cc
statements/drop_table_statement.cc
statements/drop_view_statement.cc
statements/drop_type_statement.cc
statements/drop_function_statement.cc
statements/drop_aggregate_statement.cc
statements/schema_altering_statement.cc
statements/ks_prop_defs.cc
statements/function_statement.cc
statements/modification_statement.cc
statements/cas_request.cc
statements/raw/parsed_statement.cc
statements/property_definitions.cc
statements/update_statement.cc
statements/broadcast_modification_statement.cc
statements/broadcast_select_statement.cc
statements/delete_statement.cc
statements/prune_materialized_view_statement.cc
statements/batch_statement.cc
statements/select_statement.cc
statements/use_statement.cc
statements/index_prop_defs.cc
statements/index_target.cc
statements/create_index_statement.cc
statements/truncate_statement.cc
statements/alter_table_statement.cc
statements/alter_view_statement.cc
statements/list_users_statement.cc
statements/authorization_statement.cc
statements/permission_altering_statement.cc
statements/list_permissions_statement.cc
statements/grant_statement.cc
statements/revoke_statement.cc
statements/alter_type_statement.cc
statements/alter_keyspace_statement.cc
statements/role-management-statements.cc
statements/service_level_statement.cc
statements/create_service_level_statement.cc
statements/alter_service_level_statement.cc
statements/sl_prop_defs.cc
statements/drop_service_level_statement.cc
statements/attach_service_level_statement.cc
statements/detach_service_level_statement.cc
statements/list_service_level_statement.cc
statements/list_service_level_attachments_statement.cc
statements/list_effective_service_level_statement.cc
statements/describe_statement.cc
statements/view_prop_defs.cc
update_parameters.cc
util.cc
ut_name.cc
role_name.cc
column_identifier.cc
column_specification.cc
constants.cc
query_processor.cc
query_options.cc
user_types.cc
untyped_result_set.cc
selection/selectable.cc
selection/selection.cc
selection/selector.cc
restrictions/statement_restrictions.cc
result_set.cc
prepare_context.cc
${cql_grammar_srcs})
target_include_directories(cql3
PUBLIC
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR})
target_link_libraries(cql3
PUBLIC
idl
wasmtime_bindings
Seastar::seastar
absl::headers
xxHash::xxhash
ANTLR3::antlr3
PRIVATE
lang
transport)
if (Scylla_USE_PRECOMPILED_HEADER_USE)
target_precompile_headers(cql3 REUSE_FROM scylla-precompiled-header)
endif()
check_headers(check-headers cql3
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)