mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 15:05:53 +00:00
67
.github/scripts/strategy-matrix/generate.py
vendored
67
.github/scripts/strategy-matrix/generate.py
vendored
@@ -117,13 +117,6 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
if os['distro_name'] == 'windows' and not (build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'windows/amd64'):
|
if os['distro_name'] == 'windows' and not (build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'windows/amd64'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Add sanitizer flags
|
|
||||||
sanitizers_flags = 'undefined,float-divide-by-zero'
|
|
||||||
if os['compiler_name'] == 'gcc':
|
|
||||||
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow'
|
|
||||||
elif os['compiler_name'] == 'clang':
|
|
||||||
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow,unsigned-integer-overflow'
|
|
||||||
|
|
||||||
# Additional CMake arguments.
|
# Additional CMake arguments.
|
||||||
cmake_args = f'{cmake_args} -Dtests=ON -Dwerr=ON -Dxrpld=ON'
|
cmake_args = f'{cmake_args} -Dtests=ON -Dwerr=ON -Dxrpld=ON'
|
||||||
if not f'{os["compiler_name"]}-{os["compiler_version"]}' in ['gcc-12', 'clang-16']:
|
if not f'{os["compiler_name"]}-{os["compiler_version"]}' in ['gcc-12', 'clang-16']:
|
||||||
@@ -141,9 +134,9 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
cxx_flags = ''
|
cxx_flags = ''
|
||||||
# Enable code coverage for Debian Bookworm using GCC 15 in Debug and no
|
# Enable code coverage for Debian Bookworm using GCC 14 in Debug and no
|
||||||
# Unity on linux/amd64
|
# Unity on linux/amd64
|
||||||
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-15' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
|
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-14' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
|
||||||
cmake_args = f'-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 {cmake_args}'
|
cmake_args = f'-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 {cmake_args}'
|
||||||
cxx_flags = f'-O0 {cxx_flags}'
|
cxx_flags = f'-O0 {cxx_flags}'
|
||||||
|
|
||||||
@@ -163,25 +156,16 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
|
|
||||||
# Add the configuration to the list, with the most unique fields first,
|
# Add the configuration to the list, with the most unique fields first,
|
||||||
# so that they are easier to identify in the GitHub Actions UI, as long
|
# so that they are easier to identify in the GitHub Actions UI, as long
|
||||||
# names get truncated. Add Address and Thread (both coupled with UB) sanitizers when the distro is bookworm.
|
# names get truncated.
|
||||||
|
# Add Address and Thread (both coupled with UB) sanitizers when the distro is bookworm.
|
||||||
if os['distro_version'] == 'bookworm' and f'{os["compiler_name"]}-{os["compiler_version"]}' in {'gcc-15', 'clang-20'}:
|
if os['distro_version'] == 'bookworm' and f'{os["compiler_name"]}-{os["compiler_version"]}' in {'gcc-15', 'clang-20'}:
|
||||||
|
extra_warning_flags = ''
|
||||||
|
exe_linker_flags = ' -static-libubsan -static-libasan -static-libtsan'
|
||||||
|
shared_linker_flags = ' -static-libubsan -static-libasan -static-libtsan'
|
||||||
|
|
||||||
|
|
||||||
# Use medium code model to avoid relocation errors with large binaries
|
# Use medium code model to avoid relocation errors with large binaries
|
||||||
# Only for x86-64 (amd64) - ARM64 doesn't support -mcmodel=medium
|
# Only for x86-64 (amd64) - ARM64 doesn't support -mcmodel=medium
|
||||||
extra_warning_flags = ''
|
|
||||||
exe_linker_flags = ''
|
|
||||||
shared_linker_flags = ''
|
|
||||||
# Suppress false positive warnings in GCC with stringop-overflow
|
|
||||||
if os['compiler_name'] == 'gcc':
|
|
||||||
extra_warning_flags += ' -Wno-stringop-overflow'
|
|
||||||
# Somc functions are too complex and huge for gcc compiler to handle variable tracking.
|
|
||||||
# Hence disable it.
|
|
||||||
cxx_flags += " -fno-var-tracking-assignments"
|
|
||||||
# Disable mold linker - it's too strict about relocations with GCC runtime libs
|
|
||||||
# Use default linker (bfd/ld) which is more lenient with mixed code models
|
|
||||||
cmake_args += ' -Duse_mold=OFF -Duse_gold=OFF -Duse_lld=OFF'
|
|
||||||
exe_linker_flags += ' -static-libubsan -static-libasan -static-libtsan'
|
|
||||||
shared_linker_flags += ' -static-libubsan -static-libasan -static-libtsan'
|
|
||||||
|
|
||||||
if architecture['platform'] == 'linux/amd64' and os['compiler_name'] == 'gcc':
|
if architecture['platform'] == 'linux/amd64' and os['compiler_name'] == 'gcc':
|
||||||
# Add -mcmodel=large and -fPIC to both compiler AND linker flags
|
# Add -mcmodel=large and -fPIC to both compiler AND linker flags
|
||||||
# This is needed because sanitizers create very large binaries
|
# This is needed because sanitizers create very large binaries
|
||||||
@@ -191,16 +175,30 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
exe_linker_flags+=' -mcmodel=large -fPIC'
|
exe_linker_flags+=' -mcmodel=large -fPIC'
|
||||||
shared_linker_flags += ' -mcmodel=large -fPIC'
|
shared_linker_flags += ' -mcmodel=large -fPIC'
|
||||||
|
|
||||||
|
# Create default sanitizer flags
|
||||||
|
sanitizers_flags = 'undefined,float-divide-by-zero'
|
||||||
|
|
||||||
|
if os['compiler_name'] == 'gcc':
|
||||||
|
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow'
|
||||||
|
# Suppress false positive warnings in GCC with stringop-overflow
|
||||||
|
extra_warning_flags += ' -Wno-stringop-overflow'
|
||||||
|
# Disable mold, gold and lld linkers.
|
||||||
|
# Use default linker (bfd/ld) which is more lenient with mixed code models
|
||||||
|
cmake_args += ' -Duse_mold=OFF -Duse_gold=OFF -Duse_lld=OFF'
|
||||||
|
elif os['compiler_name'] == 'clang':
|
||||||
|
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow,unsigned-integer-overflow'
|
||||||
|
|
||||||
|
# Sanitizers recommend minimum of -O1 for reasonable performance
|
||||||
if "-O0" in cxx_flags:
|
if "-O0" in cxx_flags:
|
||||||
cxx_flags = cxx_flags.replace("-O0", "-O1")
|
cxx_flags = cxx_flags.replace("-O0", "-O1")
|
||||||
else:
|
else:
|
||||||
cxx_flags += " -O1"
|
cxx_flags += " -O1"
|
||||||
|
|
||||||
|
# First create config for asan
|
||||||
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=address,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}"'
|
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=address,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}"'
|
||||||
if exe_linker_flags:
|
# Add linker flags for Sanitizers
|
||||||
cmake_args_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{exe_linker_flags} -fsanitize=address,{sanitizers_flags}"'
|
cmake_args_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{exe_linker_flags} -fsanitize=address,{sanitizers_flags}"'
|
||||||
if shared_linker_flags:
|
cmake_args_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{shared_linker_flags} -fsanitize=address,{sanitizers_flags}"'
|
||||||
cmake_args_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{shared_linker_flags} -fsanitize=address,{sanitizers_flags}"'
|
|
||||||
|
|
||||||
# Add config with asan
|
# Add config with asan
|
||||||
configurations.append({
|
configurations.append({
|
||||||
@@ -212,9 +210,10 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
'os': os,
|
'os': os,
|
||||||
'architecture': architecture
|
'architecture': architecture
|
||||||
})
|
})
|
||||||
|
|
||||||
# Update configs for tsan
|
# Update configs for tsan
|
||||||
# gcc doesn't supports atomic_thread_fence with tsan. Suppress warnings.
|
# gcc doesn't supports atomic_thread_fence with tsan. Suppress warnings.
|
||||||
# Also tsan doesn't work well mcmode=large and bfd linker
|
# Also tsan doesn't work well with mcmode=large and bfd linker
|
||||||
if os['compiler_name'] == 'gcc':
|
if os['compiler_name'] == 'gcc':
|
||||||
extra_warning_flags += ' -Wno-tsan'
|
extra_warning_flags += ' -Wno-tsan'
|
||||||
cxx_flags = cxx_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
cxx_flags = cxx_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
||||||
@@ -222,11 +221,9 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
shared_linker_flags = shared_linker_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
shared_linker_flags = shared_linker_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
||||||
|
|
||||||
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=thread,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}"'
|
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=thread,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}"'
|
||||||
|
# Add linker flags for Sanitizers
|
||||||
if exe_linker_flags:
|
cmake_args_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{exe_linker_flags} -fsanitize=thread,{sanitizers_flags}"'
|
||||||
cmake_args_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{exe_linker_flags} -fsanitize=thread,{sanitizers_flags}"'
|
cmake_args_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{shared_linker_flags} -fsanitize=thread,{sanitizers_flags}"'
|
||||||
if shared_linker_flags:
|
|
||||||
cmake_args_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{shared_linker_flags} -fsanitize=thread,{sanitizers_flags}"'
|
|
||||||
|
|
||||||
configurations.append({
|
configurations.append({
|
||||||
'config_name': config_name+ "_tsan",
|
'config_name': config_name+ "_tsan",
|
||||||
|
|||||||
@@ -1,40 +1,50 @@
|
|||||||
include(./default)
|
include(./default)
|
||||||
|
{% set compiler, version, compiler_exe = detect_api.detect_default_compiler() %}
|
||||||
|
|
||||||
|
{% set default_sanitizer_flags = "undefined,float-divide-by-zero,signed-integer-overflow" %}
|
||||||
|
{% set sanitizers = os.getenv("SANITIZERS") %}
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
{% set sanitizers = os.getenv("SANITIZERS") %}
|
|
||||||
{% if sanitizers == "Address" or sanitizers == "Thread" %}
|
{% if sanitizers == "Address" or sanitizers == "Thread" %}
|
||||||
user.package:sanitizers={{ sanitizers }}
|
user.package:sanitizers={{ sanitizers }}
|
||||||
tools.info.package_ids:confs+=["user.package:sanitizers"]
|
tools.info.package_ids:confs+=["user.package:sanitizers"]
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
[conf]
|
[conf]
|
||||||
|
|
||||||
{% if compiler == "gcc" %}
|
{% if compiler == "gcc" %}
|
||||||
|
|
||||||
{% if sanitizers == "Address" %}
|
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~" -mcmodel=large -fPIC" %}
|
||||||
tools.build:cxxflags+=['-fsanitize=address,undefined,float-divide-by-zero,signed-integer-overflow
|
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~" -mcmodel=medium -fPIC" %}
|
||||||
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -Wno-stringop-overflow -mcmodel=medium -fPIC']
|
|
||||||
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
|
|
||||||
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
|
|
||||||
{% elif sanitizers == "Thread" %}
|
|
||||||
tools.build:cxxflags+=['-fsanitize=thread,undefined,float-divide-by-zero,signed-integer-overflow -fno-omit-frame-pointer
|
|
||||||
-fno-var-tracking-assignments
|
|
||||||
-O1 -Wno-stringop-overflow -Wno-tsan -mcmodel=medium -fPIC']
|
|
||||||
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
|
|
||||||
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% elif compiler == "clang" %}
|
|
||||||
|
|
||||||
{% if sanitizers == "Address" %}
|
{% if sanitizers == "Address" %}
|
||||||
tools.build:cxxflags+=['-fsanitize=address,undefined,float-divide-by-zero,signed-integer-overflow,unsigned-integer-overflow
|
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow']
|
||||||
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium -fPIC']
|
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
|
||||||
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
|
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
|
||||||
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
|
tools.cmake.cmaketoolchain:extra_variables={"use_mold": "OFF", "use_gold": "OFF", "use_lld": "OFF"}
|
||||||
|
|
||||||
{% elif sanitizers == "Thread" %}
|
{% elif sanitizers == "Thread" %}
|
||||||
tools.build:cxxflags+=['-fsanitize=thread,undefined,float-divide-by-zero,signed-integer-overflow,unsigned-integer-overflow
|
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow -Wno-tsan']
|
||||||
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium -fPIC']
|
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
|
||||||
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
|
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
|
||||||
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% elif compiler == "apple-clang" or compiler == "clang" %}
|
||||||
|
|
||||||
|
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~",unsigned-integer-overflow -fPIC" %}
|
||||||
|
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~",unsigned-integer-overflow -fPIC" %}
|
||||||
|
{% if sanitizers == "Address" %}
|
||||||
|
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1']
|
||||||
|
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
|
||||||
|
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
|
||||||
|
|
||||||
|
{% elif sanitizers == "Thread" %}
|
||||||
|
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1']
|
||||||
|
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
|
||||||
|
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user