2021-06-22 05:07:10 +08:00
|
|
|
#!/usr/bin/env python3
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
from itertools import combinations, chain
|
|
|
|
from enum import Enum, auto
|
|
|
|
|
|
|
|
|
|
|
|
LINUX = 'linux'
|
|
|
|
OSX = 'osx'
|
2021-12-22 08:15:14 +08:00
|
|
|
WINDOWS = 'windows'
|
2022-01-07 11:31:09 +08:00
|
|
|
FREEBSD = 'freebsd'
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
AMD64 = 'amd64'
|
|
|
|
ARM64 = 'arm64'
|
|
|
|
PPC64LE = 'ppc64le'
|
|
|
|
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
TRAVIS_TEMPLATE = """\
|
2021-10-14 03:35:52 +08:00
|
|
|
# This config file is generated by ./scripts/gen_travis.py.
|
|
|
|
# Do not edit by hand.
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
# We use 'minimal', because 'generic' makes Windows VMs hang at startup. Also
|
|
|
|
# the software provided by 'generic' is simply not needed for our tests.
|
|
|
|
# Differences are explained here:
|
|
|
|
# https://docs.travis-ci.com/user/languages/minimal-and-generic/
|
|
|
|
language: minimal
|
2023-08-05 05:22:35 +08:00
|
|
|
dist: jammy
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
jobs:
|
2017-01-26 04:58:50 +08:00
|
|
|
include:
|
2021-10-14 03:35:52 +08:00
|
|
|
{jobs}
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
before_install:
|
|
|
|
- |-
|
|
|
|
if test -f "./scripts/$TRAVIS_OS_NAME/before_install.sh"; then
|
|
|
|
source ./scripts/$TRAVIS_OS_NAME/before_install.sh
|
|
|
|
fi
|
|
|
|
|
2017-01-26 04:58:50 +08:00
|
|
|
before_script:
|
2021-12-22 08:15:14 +08:00
|
|
|
- |-
|
|
|
|
if test -f "./scripts/$TRAVIS_OS_NAME/before_script.sh"; then
|
|
|
|
source ./scripts/$TRAVIS_OS_NAME/before_script.sh
|
|
|
|
else
|
|
|
|
scripts/gen_travis.py > travis_script && diff .travis.yml travis_script
|
|
|
|
autoconf
|
|
|
|
# If COMPILER_FLAGS are not empty, add them to CC and CXX
|
|
|
|
./configure ${{COMPILER_FLAGS:+ CC="$CC $COMPILER_FLAGS" \
|
2021-10-14 03:35:52 +08:00
|
|
|
CXX="$CXX $COMPILER_FLAGS"}} $CONFIGURE_FLAGS
|
2021-12-22 08:15:14 +08:00
|
|
|
make -j3
|
|
|
|
make -j3 tests
|
|
|
|
fi
|
2017-01-26 04:58:50 +08:00
|
|
|
|
|
|
|
script:
|
2021-12-22 08:15:14 +08:00
|
|
|
- |-
|
|
|
|
if test -f "./scripts/$TRAVIS_OS_NAME/script.sh"; then
|
|
|
|
source ./scripts/$TRAVIS_OS_NAME/script.sh
|
|
|
|
else
|
|
|
|
make check
|
|
|
|
fi
|
2017-01-26 04:58:50 +08:00
|
|
|
"""
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
class Option(object):
|
|
|
|
class Type:
|
|
|
|
COMPILER = auto()
|
|
|
|
COMPILER_FLAG = auto()
|
|
|
|
CONFIGURE_FLAG = auto()
|
|
|
|
MALLOC_CONF = auto()
|
2021-12-22 08:15:14 +08:00
|
|
|
FEATURE = auto()
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
def __init__(self, type, value):
|
|
|
|
self.type = type
|
|
|
|
self.value = value
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def as_compiler(value):
|
|
|
|
return Option(Option.Type.COMPILER, value)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def as_compiler_flag(value):
|
|
|
|
return Option(Option.Type.COMPILER_FLAG, value)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def as_configure_flag(value):
|
|
|
|
return Option(Option.Type.CONFIGURE_FLAG, value)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def as_malloc_conf(value):
|
|
|
|
return Option(Option.Type.MALLOC_CONF, value)
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
@staticmethod
|
|
|
|
def as_feature(value):
|
|
|
|
return Option(Option.Type.FEATURE, value)
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
def __eq__(self, obj):
|
|
|
|
return (isinstance(obj, Option) and obj.type == self.type
|
|
|
|
and obj.value == self.value)
|
|
|
|
|
|
|
|
|
2017-01-26 04:58:50 +08:00
|
|
|
# The 'default' configuration is gcc, on linux, with no compiler or configure
|
|
|
|
# flags. We also test with clang, -m32, --enable-debug, --enable-prof,
|
2017-04-21 08:21:37 +08:00
|
|
|
# --disable-stats, and --with-malloc-conf=tcache:false. To avoid abusing
|
|
|
|
# travis though, we don't test all 2**7 = 128 possible combinations of these;
|
|
|
|
# instead, we only test combinations of up to 2 'unusual' settings, under the
|
|
|
|
# hope that bugs involving interactions of such settings are rare.
|
2017-01-26 04:58:50 +08:00
|
|
|
MAX_UNUSUAL_OPTIONS = 2
|
|
|
|
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
GCC = Option.as_compiler('CC=gcc CXX=g++')
|
|
|
|
CLANG = Option.as_compiler('CC=clang CXX=clang++')
|
2021-12-22 08:15:14 +08:00
|
|
|
CL = Option.as_compiler('CC=cl.exe CXX=cl.exe')
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
compilers_unusual = [CLANG,]
|
|
|
|
|
2020-09-11 16:07:10 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
CROSS_COMPILE_32BIT = Option.as_feature('CROSS_COMPILE_32BIT')
|
|
|
|
feature_unusuals = [CROSS_COMPILE_32BIT]
|
2017-01-26 04:58:50 +08:00
|
|
|
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
configure_flag_unusuals = [Option.as_configure_flag(opt) for opt in (
|
2017-04-21 08:21:37 +08:00
|
|
|
'--enable-debug',
|
|
|
|
'--enable-prof',
|
|
|
|
'--disable-stats',
|
2019-02-07 05:36:56 +08:00
|
|
|
'--disable-libdl',
|
2019-03-23 08:08:53 +08:00
|
|
|
'--enable-opt-safety-checks',
|
2019-09-12 01:31:30 +08:00
|
|
|
'--with-lg-page=16',
|
2021-10-14 03:35:52 +08:00
|
|
|
)]
|
2017-05-23 08:15:57 +08:00
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
malloc_conf_unusuals = [Option.as_malloc_conf(opt) for opt in (
|
2017-05-23 08:15:57 +08:00
|
|
|
'tcache:false',
|
|
|
|
'dss:primary',
|
2017-05-24 01:53:36 +08:00
|
|
|
'percpu_arena:percpu',
|
2017-06-01 02:56:31 +08:00
|
|
|
'background_thread:true',
|
2021-10-14 03:35:52 +08:00
|
|
|
)]
|
|
|
|
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
all_unusuals = (compilers_unusual + feature_unusuals
|
2021-10-14 03:35:52 +08:00
|
|
|
+ configure_flag_unusuals + malloc_conf_unusuals)
|
2017-01-26 04:58:50 +08:00
|
|
|
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
def get_extra_cflags(os, compiler):
|
2022-01-07 11:31:09 +08:00
|
|
|
if os == FREEBSD:
|
|
|
|
return []
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
if os == WINDOWS:
|
|
|
|
# For non-CL compilers under Windows (for now it's only MinGW-GCC),
|
|
|
|
# -fcommon needs to be specified to correctly handle multiple
|
|
|
|
# 'malloc_conf' symbols and such, which are declared weak under Linux.
|
|
|
|
# Weak symbols don't work with MinGW-GCC.
|
|
|
|
if compiler != CL.value:
|
|
|
|
return ['-fcommon']
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
# We get some spurious errors when -Warray-bounds is enabled.
|
|
|
|
extra_cflags = ['-Werror', '-Wno-array-bounds']
|
|
|
|
if compiler == CLANG.value or os == OSX:
|
|
|
|
extra_cflags += [
|
2021-12-22 08:15:14 +08:00
|
|
|
'-Wno-unknown-warning-option',
|
|
|
|
'-Wno-ignored-attributes'
|
|
|
|
]
|
2021-10-14 03:35:52 +08:00
|
|
|
if os == OSX:
|
|
|
|
extra_cflags += [
|
2021-12-22 08:15:14 +08:00
|
|
|
'-Wno-deprecated-declarations',
|
|
|
|
]
|
2021-10-14 03:35:52 +08:00
|
|
|
return extra_cflags
|
|
|
|
|
|
|
|
|
2018-07-10 20:41:20 +08:00
|
|
|
# Formats a job from a combination of flags
|
2021-10-14 03:35:52 +08:00
|
|
|
def format_job(os, arch, combination):
|
2021-12-22 08:15:14 +08:00
|
|
|
compilers = [x.value for x in combination if x.type == Option.Type.COMPILER]
|
|
|
|
assert(len(compilers) <= 1)
|
2021-10-14 03:35:52 +08:00
|
|
|
compiler_flags = [x.value for x in combination if x.type == Option.Type.COMPILER_FLAG]
|
|
|
|
configure_flags = [x.value for x in combination if x.type == Option.Type.CONFIGURE_FLAG]
|
|
|
|
malloc_conf = [x.value for x in combination if x.type == Option.Type.MALLOC_CONF]
|
2021-12-22 08:15:14 +08:00
|
|
|
features = [x.value for x in combination if x.type == Option.Type.FEATURE]
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
if len(malloc_conf) > 0:
|
|
|
|
configure_flags.append('--with-malloc-conf=' + ','.join(malloc_conf))
|
2017-01-26 04:58:50 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
if not compilers:
|
|
|
|
compiler = GCC.value
|
|
|
|
else:
|
|
|
|
compiler = compilers[0]
|
2020-09-11 16:07:10 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
extra_environment_vars = ''
|
|
|
|
cross_compile = CROSS_COMPILE_32BIT.value in features
|
|
|
|
if os == LINUX and cross_compile:
|
|
|
|
compiler_flags.append('-m32')
|
|
|
|
|
|
|
|
features_str = ' '.join([' {}=yes'.format(feature) for feature in features])
|
|
|
|
|
|
|
|
stringify = lambda arr, name: ' {}="{}"'.format(name, ' '.join(arr)) if arr else ''
|
|
|
|
env_string = '{}{}{}{}{}{}'.format(
|
2021-10-14 03:35:52 +08:00
|
|
|
compiler,
|
2021-12-22 08:15:14 +08:00
|
|
|
features_str,
|
|
|
|
stringify(compiler_flags, 'COMPILER_FLAGS'),
|
|
|
|
stringify(configure_flags, 'CONFIGURE_FLAGS'),
|
|
|
|
stringify(get_extra_cflags(os, compiler), 'EXTRA_CFLAGS'),
|
|
|
|
extra_environment_vars)
|
2020-09-11 16:07:10 +08:00
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
job = ' - os: {}\n'.format(os)
|
|
|
|
job += ' arch: {}\n'.format(arch)
|
2021-10-14 03:35:52 +08:00
|
|
|
job += ' env: {}'.format(env_string)
|
2018-07-10 20:41:20 +08:00
|
|
|
return job
|
|
|
|
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
def generate_unusual_combinations(unusuals, max_unusual_opts):
|
2021-10-14 03:35:52 +08:00
|
|
|
"""
|
|
|
|
Generates different combinations of non-standard compilers, compiler flags,
|
|
|
|
configure flags and malloc_conf settings.
|
|
|
|
|
|
|
|
@param max_unusual_opts: Limit of unusual options per combination.
|
|
|
|
"""
|
|
|
|
return chain.from_iterable(
|
2021-12-22 08:15:14 +08:00
|
|
|
[combinations(unusuals, i) for i in range(max_unusual_opts + 1)])
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
def included(combination, exclude):
|
|
|
|
"""
|
|
|
|
Checks if the combination of options should be included in the Travis
|
|
|
|
testing matrix.
|
2021-12-22 08:15:14 +08:00
|
|
|
|
|
|
|
@param exclude: A list of options to be avoided.
|
2021-10-14 03:35:52 +08:00
|
|
|
"""
|
|
|
|
return not any(excluded in combination for excluded in exclude)
|
|
|
|
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
def generate_jobs(os, arch, exclude, max_unusual_opts, unusuals=all_unusuals):
|
2021-10-14 03:35:52 +08:00
|
|
|
jobs = []
|
2021-12-22 08:15:14 +08:00
|
|
|
for combination in generate_unusual_combinations(unusuals, max_unusual_opts):
|
2021-10-14 03:35:52 +08:00
|
|
|
if included(combination, exclude):
|
|
|
|
jobs.append(format_job(os, arch, combination))
|
|
|
|
return '\n'.join(jobs)
|
|
|
|
|
|
|
|
|
|
|
|
def generate_linux(arch):
|
|
|
|
os = LINUX
|
|
|
|
|
|
|
|
# Only generate 2 unusual options for AMD64 to reduce matrix size
|
|
|
|
max_unusual_opts = MAX_UNUSUAL_OPTIONS if arch == AMD64 else 1
|
|
|
|
|
|
|
|
exclude = []
|
|
|
|
if arch == PPC64LE:
|
|
|
|
# Avoid 32 bit builds and clang on PowerPC
|
2021-12-22 08:15:14 +08:00
|
|
|
exclude = (CROSS_COMPILE_32BIT, CLANG,)
|
2021-10-14 03:35:52 +08:00
|
|
|
|
|
|
|
return generate_jobs(os, arch, exclude, max_unusual_opts)
|
|
|
|
|
|
|
|
|
|
|
|
def generate_macos(arch):
|
|
|
|
os = OSX
|
|
|
|
|
|
|
|
max_unusual_opts = 1
|
|
|
|
|
|
|
|
exclude = ([Option.as_malloc_conf(opt) for opt in (
|
|
|
|
'dss:primary',
|
|
|
|
'background_thread:true')] +
|
|
|
|
[Option.as_configure_flag('--enable-prof')] +
|
|
|
|
[CLANG,])
|
|
|
|
|
|
|
|
return generate_jobs(os, arch, exclude, max_unusual_opts)
|
|
|
|
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
def generate_windows(arch):
|
|
|
|
os = WINDOWS
|
|
|
|
|
|
|
|
max_unusual_opts = 3
|
|
|
|
unusuals = (
|
|
|
|
Option.as_configure_flag('--enable-debug'),
|
|
|
|
CL,
|
|
|
|
CROSS_COMPILE_32BIT,
|
|
|
|
)
|
|
|
|
return generate_jobs(os, arch, (), max_unusual_opts, unusuals)
|
|
|
|
|
|
|
|
|
2022-01-07 11:31:09 +08:00
|
|
|
def generate_freebsd(arch):
|
|
|
|
os = FREEBSD
|
|
|
|
|
|
|
|
max_unusual_opts = 4
|
|
|
|
unusuals = (
|
|
|
|
Option.as_configure_flag('--enable-debug'),
|
|
|
|
Option.as_configure_flag('--enable-prof --enable-prof-libunwind'),
|
|
|
|
Option.as_configure_flag('--with-lg-page=16 --with-malloc-conf=tcache:false'),
|
|
|
|
CROSS_COMPILE_32BIT,
|
|
|
|
)
|
|
|
|
return generate_jobs(os, arch, (), max_unusual_opts, unusuals)
|
|
|
|
|
|
|
|
|
2021-12-22 08:15:14 +08:00
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
def get_manual_jobs():
|
|
|
|
return """\
|
2018-07-10 19:58:37 +08:00
|
|
|
# Development build
|
2018-07-10 20:41:20 +08:00
|
|
|
- os: linux
|
2021-10-14 03:35:52 +08:00
|
|
|
env: CC=gcc CXX=g++ CONFIGURE_FLAGS="--enable-debug \
|
|
|
|
--disable-cache-oblivious --enable-stats --enable-log --enable-prof" \
|
|
|
|
EXTRA_CFLAGS="-Werror -Wno-array-bounds"
|
2018-07-11 21:11:53 +08:00
|
|
|
# --enable-expermental-smallocx:
|
|
|
|
- os: linux
|
2021-10-14 03:35:52 +08:00
|
|
|
env: CC=gcc CXX=g++ CONFIGURE_FLAGS="--enable-debug \
|
|
|
|
--enable-experimental-smallocx --enable-stats --enable-prof" \
|
|
|
|
EXTRA_CFLAGS="-Werror -Wno-array-bounds"
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
jobs = '\n'.join((
|
2022-03-22 06:11:34 +08:00
|
|
|
generate_windows(AMD64),
|
|
|
|
|
|
|
|
generate_freebsd(AMD64),
|
|
|
|
|
2021-10-14 03:35:52 +08:00
|
|
|
generate_linux(AMD64),
|
|
|
|
generate_linux(PPC64LE),
|
|
|
|
|
|
|
|
generate_macos(AMD64),
|
2021-12-22 08:15:14 +08:00
|
|
|
|
2022-03-22 06:11:34 +08:00
|
|
|
get_manual_jobs(),
|
2021-10-14 03:35:52 +08:00
|
|
|
))
|
|
|
|
|
|
|
|
print(TRAVIS_TEMPLATE.format(jobs=jobs))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|