Skip to content

Commit

Permalink
build: bring abseil submodule back
Browse files Browse the repository at this point in the history
because of https://bugzilla.redhat.com/show_bug.cgi?id=2278689,
the rebuilt abseil package provided by fedora has different settings
than the ones if the tree is built with the sanitizer enabled. this
inconsistency leads to a crash.

to address this problem, we have to reinstate the abseil submodule, so
we can built it with the same compiler options with which we build the
tree.

in this change

* Revert "build: drop abseil submodule, replace with distribution abseil"
* update CMake building system with abseil header include settings
* bump up the abseil submodule to the latest LTS branch of abseil:
  lts_2024_01_16
* update scylla-gdb.py to adapt to the new structure of
  flat_hash_map

This reverts commit 8635d24.

Signed-off-by: Kefu Chai <[email protected]>

Closes scylladb#18511
  • Loading branch information
tchaikov authored and avikivity committed May 5, 2024
1 parent ea79191 commit 0b0e661
Show file tree
Hide file tree
Showing 23 changed files with 174 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
path = swagger-ui
url = ../scylla-swagger-ui
ignore = dirty
[submodule "abseil"]
path = abseil
url = ../abseil-cpp
[submodule "scylla-jmx"]
path = tools/jmx
url = ../scylla-jmx
Expand Down
31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ set(Seastar_EXCLUDE_APPS_FROM_ALL ON CACHE BOOL "" FORCE)
set(Seastar_EXCLUDE_TESTS_FROM_ALL ON CACHE BOOL "" FORCE)
set(Seastar_UNUSED_RESULT_ERROR ON CACHE BOOL "" FORCE)
add_subdirectory(seastar)
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)

find_package(Sanitizers QUIET)
set(sanitizer_cxx_flags
$<$<IN_LIST:$<CONFIG>,Debug;Sanitize>:$<TARGET_PROPERTY:Sanitizers::address,INTERFACE_COMPILE_OPTIONS>;$<TARGET_PROPERTY:Sanitizers::undefined_behavior,INTERFACE_COMPILE_OPTIONS>>)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(ABSL_GCC_FLAGS ${sanitizer_cxx_flags})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(ABSL_LLVM_FLAGS ${sanitizer_cxx_flags})
endif()
set(ABSL_DEFAULT_LINKOPTS
$<$<IN_LIST:$<CONFIG>,Debug;Sanitize>:$<TARGET_PROPERTY:Sanitizers::address,INTERFACE_LINK_LIBRARIES>;$<TARGET_PROPERTY:Sanitizers::undefined_behavior,INTERFACE_LINK_LIBRARIES>>)
add_subdirectory(abseil)
add_library(absl-headers INTERFACE)
target_include_directories(absl-headers INTERFACE
"${PROJECT_SOURCE_DIR}/abseil")
add_library(absl::headers ALIAS absl-headers)

# Exclude absl::strerror from the default "all" target since it's not
# used in Scylla build and, moreover, makes use of deprecated glibc APIs,
# such as sys_nerr, which are not exposed from "stdio.h" since glibc 2.32,
# which happens to be the case for recent Fedora distribution versions.
#
# Need to use the internal "absl_strerror" target name instead of namespaced
# variant because `set_target_properties` does not understand the latter form,
# unfortunately.
set_target_properties(absl_strerror PROPERTIES EXCLUDE_FROM_ALL TRUE)

# System libraries dependencies
find_package(Boost REQUIRED
Expand All @@ -66,7 +93,6 @@ target_link_libraries(Boost::regex
find_package(Lua REQUIRED)
find_package(ZLIB REQUIRED)
find_package(ICU COMPONENTS uc i18n REQUIRED)
find_package(absl COMPONENTS hash raw_hash_set REQUIRED)
find_package(fmt 9.0.0 REQUIRED)
find_package(libdeflate REQUIRED)
find_package(libxcrypt REQUIRED)
Expand Down Expand Up @@ -124,6 +150,8 @@ target_sources(scylla-main
target_link_libraries(scylla-main
PRIVATE
db
absl::headers
absl::btree
absl::hash
absl::raw_hash_set
Seastar::seastar
Expand Down Expand Up @@ -236,6 +264,7 @@ target_link_libraries(scylla PRIVATE

target_link_libraries(scylla PRIVATE
seastar
absl::headers
Boost::program_options)

target_include_directories(scylla PRIVATE
Expand Down
1 change: 1 addition & 0 deletions abseil
Submodule abseil added at d7aaad
3 changes: 2 additions & 1 deletion alternator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ target_link_libraries(alternator
cql3
idl
Seastar::seastar
xxHash::xxhash)
xxHash::xxhash
absl::headers)

check_headers(check-headers alternator
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
3 changes: 2 additions & 1 deletion api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ target_link_libraries(api
idl
wasmtime_bindings
Seastar::seastar
xxHash::xxhash)
xxHash::xxhash
absl::headers)

check_headers(check-headers api
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
1 change: 1 addition & 0 deletions auth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ target_link_libraries(scylla_auth
Seastar::seastar
xxHash::xxhash
PRIVATE
absl::headers
cql3
idl
wasmtime_bindings
Expand Down
1 change: 1 addition & 0 deletions cdc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_include_directories(cdc
${CMAKE_SOURCE_DIR})
target_link_libraries(cdc
PUBLIC
absl::headers
Seastar::seastar
xxHash::xxhash
PRIVATE
Expand Down
73 changes: 67 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def generate_compdb(compdb, ninja, buildfile, modes):
# build mode-specific compdbs
for mode in modes:
mode_out = outdir + '/' + mode
submodule_compdbs = [mode_out + '/' + submodule + '/' + compdb for submodule in ['seastar']]
submodule_compdbs = [mode_out + '/' + submodule + '/' + compdb for submodule in ['seastar', 'abseil']]
with open(mode_out + '/' + compdb, 'w+b') as combined_mode_specific_compdb:
subprocess.run(['./scripts/merge-compdb.py', outdir + '/' + mode,
ninja_compdb.name] + submodule_compdbs, stdout=combined_mode_specific_compdb)
Expand Down Expand Up @@ -1750,6 +1750,58 @@ def configure_seastar(build_dir, mode, mode_config):
subprocess.check_call(seastar_cmd, shell=False, cwd=cmake_dir)


def configure_abseil(build_dir, mode, mode_config):
# for sanitizer cflags
seastar_flags = query_seastar_flags(f'{outdir}/{mode}/seastar/seastar.pc',
mode_config['build_seastar_shared_libs'],
args.staticcxx)
seastar_cflags = seastar_flags['seastar_cflags']

abseil_build_dir = os.path.join(build_dir, mode, 'abseil')

abseil_cflags = seastar_cflags + ' ' + modes[mode]['cxx_ld_flags']
cmake_mode = mode_config['cmake_build_type']
abseil_cmake_args = [
'-DCMAKE_BUILD_TYPE={}'.format(cmake_mode),
'-DCMAKE_INSTALL_PREFIX={}'.format(build_dir + '/inst'), # just to avoid a warning from absl
'-DCMAKE_C_COMPILER={}'.format(args.cc),
'-DCMAKE_CXX_COMPILER={}'.format(args.cxx),
'-DCMAKE_CXX_FLAGS_{}={}'.format(cmake_mode.upper(), abseil_cflags),
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DCMAKE_CXX_STANDARD=20',
'-DABSL_PROPAGATE_CXX_STD=ON',
]

abseil_cmd = ['cmake', '-G', 'Ninja', real_relpath('abseil', abseil_build_dir)] + abseil_cmake_args

os.makedirs(abseil_build_dir, exist_ok=True)
subprocess.check_call(abseil_cmd, shell=False, cwd=abseil_build_dir)

abseil_libs = ['absl/' + lib for lib in [
'container/libabsl_hashtablez_sampler.a',
'container/libabsl_raw_hash_set.a',
'synchronization/libabsl_synchronization.a',
'synchronization/libabsl_graphcycles_internal.a',
'debugging/libabsl_stacktrace.a',
'debugging/libabsl_symbolize.a',
'debugging/libabsl_debugging_internal.a',
'debugging/libabsl_demangle_internal.a',
'time/libabsl_time.a',
'time/libabsl_time_zone.a',
'numeric/libabsl_int128.a',
'hash/libabsl_hash.a',
'hash/libabsl_city.a',
'hash/libabsl_low_level_hash.a',
'base/libabsl_malloc_internal.a',
'base/libabsl_spinlock_wait.a',
'base/libabsl_base.a',
'base/libabsl_raw_logging_internal.a',
'profiling/libabsl_exponential_biased.a',
'strings/libabsl_strings.a',
'strings/libabsl_strings_internal.a',
'base/libabsl_throw_delegate.a']]


def query_seastar_flags(pc_file, use_shared_libs, link_static_cxx=False):
if use_shared_libs:
opt = '--shared'
Expand All @@ -1769,9 +1821,7 @@ def query_seastar_flags(pc_file, use_shared_libs, link_static_cxx=False):
'seastar_testing_libs': testing_libs}

pkgs = ['libsystemd',
'jsoncpp',
'absl_raw_hash_set',
'absl_hash']
'jsoncpp']
# Lua can be provided by lua53 package on Debian-like
# systems and by Lua on others.
pkgs.append('lua53' if have_pkg('lua53') else 'lua')
Expand Down Expand Up @@ -2057,6 +2107,9 @@ def write_build_file(f,
if has_thrift:
local_libs += ' ' + maybe_static(args.staticthrift, '-lthrift')
local_libs += ' ' + maybe_static(args.staticboost, '-lboost_system')
objs.extend(['$builddir/' + mode + '/' + artifact for artifact in [
'abseil/' + x for x in abseil_libs
]])
if binary in tests:
if binary in pure_boost_tests:
local_libs += ' ' + maybe_static(args.staticboost, '-lboost_unit_test_framework')
Expand Down Expand Up @@ -2265,6 +2318,12 @@ def write_build_file(f,
f.write(f'build $builddir/{mode}/dist/tar/{scylla_product}-unified-package-{scylla_version}-{scylla_release}.tar.gz: copy $builddir/{mode}/dist/tar/{scylla_product}-unified-{scylla_version}-{scylla_release}.{arch}.tar.gz\n')
f.write(f'build $builddir/{mode}/dist/tar/{scylla_product}-unified-{arch}-package-{scylla_version}-{scylla_release}.tar.gz: copy $builddir/{mode}/dist/tar/{scylla_product}-unified-{scylla_version}-{scylla_release}.{arch}.tar.gz\n')

for lib in abseil_libs:
f.write('build $builddir/{mode}/abseil/{lib}: ninja $builddir/{mode}/abseil/build.ninja\n'.format(**locals()))
f.write(' pool = submodule_pool\n')
f.write(' subdir = $builddir/{mode}/abseil\n'.format(**locals()))
f.write(' target = {lib}\n'.format(**locals()))

checkheaders_mode = 'dev' if 'dev' in modes else modes.keys()[0]
f.write('build checkheaders: phony || {}\n'.format(' '.join(['$builddir/{}/{}.o'.format(checkheaders_mode, hh) for hh in headers])))

Expand Down Expand Up @@ -2394,7 +2453,7 @@ def write_build_file(f,
description = List configured modes
build mode_list: mode_list
default {modes_list}
''').format(modes_list=' '.join(default_modes), build_ninja_list=' '.join([f'{outdir}/{mode}/{dir}/build.ninja' for mode in build_modes for dir in ['seastar']]), **globals()))
''').format(modes_list=' '.join(default_modes), build_ninja_list=' '.join([f'{outdir}/{mode}/{dir}/build.ninja' for mode in build_modes for dir in ['seastar', 'abseil']]), **globals()))
unit_test_list = set(test for test in build_artifacts if test in set(tests))
f.write(textwrap.dedent('''\
rule unit_test_list
Expand Down Expand Up @@ -2438,11 +2497,14 @@ def create_build_system(args):
mode_config['per_src_extra_cxxflags']['release.cc'] = ' '.join(get_release_cxxflags(scylla_version, scylla_release))

if not args.dist_only:
global user_cflags, libs
# args.buildfile builds seastar with the rules of
# {outdir}/{mode}/seastar/build.ninja, and
# {outdir}/{mode}/seastar/seastar.pc is queried for building flags
for mode, mode_config in build_modes.items():
configure_seastar(outdir, mode, mode_config)
configure_abseil(outdir, mode, mode_config)
user_cflags += ' -isystem abseil'

for mode, mode_config in build_modes.items():
mode_config.update(query_seastar_flags(f'{outdir}/{mode}/seastar/seastar.pc',
Expand Down Expand Up @@ -2496,7 +2558,6 @@ def configure_using_cmake(args):
if args.staticboost:
settings['Boost_USE_STATIC_LIBS'] = 'ON'


source_dir = os.path.realpath(os.path.dirname(__file__))
build_dir = os.path.join(source_dir, 'build')

Expand Down
1 change: 1 addition & 0 deletions cql3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ target_link_libraries(cql3
idl
wasmtime_bindings
Seastar::seastar
absl::headers
xxHash::xxhash
ANTLR3::antlr3
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_link_libraries(db
mutation
Seastar::seastar
xxHash::xxhash
absl::headers
PRIVATE
data_dictionary
cql3)
Expand Down
3 changes: 2 additions & 1 deletion gms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ target_link_libraries(gms
Seastar::seastar
xxHash::xxhash
PRIVATE
db)
db
absl::headers)

check_headers(check-headers gms
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
3 changes: 3 additions & 0 deletions idl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ add_custom_target(idl-sources
DEPENDS ${idl_sources})
add_library(idl INTERFACE)
add_dependencies(idl idl-sources)
target_link_directories(idl
INTERFACE
absl::headers)
target_include_directories(idl
INTERFACE
${scylla_gen_build_dir})
Expand Down
2 changes: 0 additions & 2 deletions install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ debian_base_packages=(
libunistring-dev
libzstd-dev
libdeflate-dev
libabsl-dev
librapidxml-dev
libcrypto++-dev
libxxhash-dev
Expand All @@ -70,7 +69,6 @@ fedora_packages=(
snappy-devel
libdeflate-devel
systemd-devel
abseil-cpp-devel
cryptopp-devel
git
python
Expand Down
1 change: 1 addition & 0 deletions lang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_link_libraries(lang
Seastar::seastar
xxHash::xxhash
PRIVATE
absl::headers
${LUA_LIBRARIES})

check_headers(check-headers lang
Expand Down
1 change: 1 addition & 0 deletions message/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_link_libraries(message
PUBLIC
gms
Seastar::seastar
absl::headers
PRIVATE
idl)

Expand Down
4 changes: 3 additions & 1 deletion mutation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ target_link_libraries(mutation
PUBLIC
idl
Seastar::seastar
xxHash::xxhash)
xxHash::xxhash
PRIVATE
absl::headers)

check_headers(check-headers mutation
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
4 changes: 3 additions & 1 deletion raft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ target_include_directories(raft
target_link_libraries(raft
PUBLIC
Seastar::seastar
xxHash::xxhash)
xxHash::xxhash
PRIVATE
absl::headers)

check_headers(check-headers raft
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
2 changes: 2 additions & 0 deletions repair/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ target_sources(repair
table_check.cc)
target_include_directories(repair
PUBLIC
absl::headers
${CMAKE_SOURCE_DIR})
target_link_libraries(repair
PUBLIC
idl
absl::headers
Seastar::seastar
xxHash::xxhash)

Expand Down
1 change: 1 addition & 0 deletions replica/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_include_directories(replica
target_link_libraries(replica
PUBLIC
db
absl::headers
wasmtime_bindings
Seastar::seastar
xxHash::xxhash
Expand Down
3 changes: 2 additions & 1 deletion schema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ target_link_libraries(schema
cql3
idl
Seastar::seastar
xxHash::xxhash)
xxHash::xxhash
absl::headers)

check_headers(check-headers schema
GLOB_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/*.hh)
Loading

0 comments on commit 0b0e661

Please sign in to comment.