build: align minimum build dependencies with ndn-cxx

* Recommend gcc >= 7.4.0
 * Require clang >= 4.0, or Xcode >= 9.0 on macOS
 * Silence an ABI-related diagnostic message from gcc on armv7
 * Update Travis CI job matrix

Refs: #5087, #5106
Change-Id: I659aa617dad0ed7eb23967215c37586ef168d88c
This commit is contained in:
Davide Pesavento
2020-07-23 21:07:16 -04:00
parent 89edd8f3a9
commit 042dfb3ec5
12 changed files with 70 additions and 378 deletions
+1 -1
View File
@@ -25,6 +25,6 @@ if has OSX $NODE_LABELS; then
elif has Ubuntu $NODE_LABELS; then
sudo apt-get -qq update
sudo apt-get -qy install g++ pkg-config python3-minimal \
sudo apt-get -qy install build-essential pkg-config python3-minimal \
libboost-all-dev libssl-dev libsqlite3-dev
fi
+1 -5
View File
@@ -35,16 +35,12 @@ sudo rm -f /usr/local/lib{,64}/pkgconfig/libndn-cxx.pc
pushd ndn-cxx >/dev/null
if has Linux $NODE_LABELS && [[ $CXX != clang* && -z $DISABLE_ASAN ]]; then
# https://stackoverflow.com/a/47022141
ASAN="--with-sanitizer=address"
fi
if has CentOS-8 $NODE_LABELS; then
# https://bugzilla.redhat.com/show_bug.cgi?id=1721553
PCH="--without-pch"
fi
./waf --color=yes configure --disable-static --enable-shared --without-osx-keychain $ASAN $PCH
./waf --color=yes configure --disable-static --enable-shared --without-osx-keychain $PCH
./waf --color=yes build -j$WAF_JOBS
sudo_preserve_env PATH -- ./waf --color=yes install
+3 -21
View File
@@ -3,28 +3,8 @@ set -ex
# Prepare environment
rm -rf ~/.ndn
if has OSX $NODE_LABELS; then
security unlock-keychain -p named-data
fi
ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
BOOST_VERSION=$(python3 -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);")
ut_log_args() {
if (( BOOST_VERSION >= 106200 )); then
echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-${1:-report}.xml
else
if [[ -n $XUNIT ]]; then
echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \
--log_format2=XML --log_sink2=build/xunit-${1:-report}.xml
else
echo --log_level=test_suite
fi
fi
}
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
ASAN_OPTIONS="color=always"
ASAN_OPTIONS+=":check_initialization_order=1"
@@ -37,6 +17,8 @@ export ASAN_OPTIONS
export BOOST_TEST_BUILD_INFO=1
export BOOST_TEST_COLOR_OUTPUT=1
export BOOST_TEST_DETECT_MEMORY_LEAK=0
export BOOST_TEST_LOGGER=HRF,test_suite,stdout:XML,all,build/xunit-log.xml
# Run unit tests
./build/unit-tests $(ut_log_args)
./build/unit-tests
+6
View File
@@ -38,6 +38,12 @@ jobs:
- os: osx
osx_image: xcode11.3
env: # default compiler
- os: osx
osx_image: xcode11.6
env: # default compiler
- os: osx
osx_image: xcode12
env: # default compiler
allow_failures:
- arch: s390x # bug 4818
+34 -23
View File
@@ -1,10 +1,11 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import platform
from waflib import Configure, Logs, Utils
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
help='Compile in debugging mode with minimal optimizations (-Og)')
def configure(conf):
conf.start_msg('Checking C++ compiler version')
@@ -17,15 +18,21 @@ def configure(conf):
if cxx == 'gcc':
if ccver < (5, 3, 0):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 5.3.0.')
'The minimum supported gcc version is 7.4.0.')
elif ccver < (7, 4, 0):
warnmsg = ('Using a version of gcc older than 7.4.0 is not '
'officially supported and may result in build failures.')
conf.flags = GccFlags()
elif cxx == 'clang':
if ccver < (3, 6, 0):
if Utils.unversioned_sys_platform() == 'darwin' and ccver < (9, 0, 0):
errmsg = ('The version of Xcode you are using is too old.\n'
'The minimum supported Xcode version is 9.0.')
elif ccver < (4, 0, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 3.6.0.')
'The minimum supported clang version is 4.0.')
conf.flags = ClangFlags()
else:
warnmsg = 'Note: %s compiler is unsupported' % cxx
warnmsg = '%s compiler is unsupported' % cxx
conf.flags = CompilerFlags()
if errmsg:
@@ -33,7 +40,7 @@ def configure(conf):
conf.fatal(errmsg)
elif warnmsg:
conf.end_msg(ccverstr, color='YELLOW')
Logs.warn(warnmsg)
Logs.warn('WARNING: ' + warnmsg)
else:
conf.end_msg(ccverstr)
@@ -137,13 +144,14 @@ class GccBasicFlags(CompilerFlags):
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-O0',
'-Og', # gcc >= 4.8, clang >= 4.0
flags['CXXFLAGS'] += ['-Og',
'-g3',
'-pedantic',
'-Wall',
'-Wextra',
'-Werror',
'-Wcatch-value=2',
'-Wextra-semi',
'-Wnon-virtual-dtor',
'-Wno-error=deprecated-declarations', # Bug #3795
'-Wno-error=maybe-uninitialized', # Bug #1615
@@ -159,6 +167,8 @@ class GccBasicFlags(CompilerFlags):
'-pedantic',
'-Wall',
'-Wextra',
'-Wcatch-value=2',
'-Wextra-semi',
'-Wnon-virtual-dtor',
'-Wno-unused-parameter',
]
@@ -168,49 +178,50 @@ class GccBasicFlags(CompilerFlags):
class GccFlags(GccBasicFlags):
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fdiagnostics-color']
flags['CXXFLAGS'] += ['-fdiagnostics-color',
'-Wredundant-tags',
]
if platform.machine() == 'armv7l' and self.getCompilerVersion(conf) >= (7, 1, 0):
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags
def getOptimizedFlags(self, conf):
flags = super(GccFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fdiagnostics-color']
flags['CXXFLAGS'] += ['-fdiagnostics-color',
'-Wredundant-tags',
]
if platform.machine() == 'armv7l' and self.getCompilerVersion(conf) >= (7, 1, 0):
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
if Utils.unversioned_sys_platform() == 'darwin':
# Bug #4296
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
['-isystem', '/opt/local/include']] # for MacPorts
if Utils.unversioned_sys_platform() == 'freebsd':
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']] # Bug #4790
elif Utils.unversioned_sys_platform() == 'freebsd':
# Bug #4790
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
if version < (6, 0, 0):
if self.getCompilerVersion(conf) < (6, 0, 0):
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
return flags
def getOptimizedFlags(self, conf):
flags = super(ClangFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
if version < (6, 0, 0):
if self.getCompilerVersion(conf) < (6, 0, 0):
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
return flags
+2 -2
View File
@@ -98,7 +98,7 @@ Consumer::sendHelloInterest()
options.rttOptions.initialRto = m_syncInterestLifetime;
m_helloFetcher = SegmentFetcher::start(m_face, helloInterest,
ndn::security::v2::getAcceptAllValidator(), options);
ndn::security::getAcceptAllValidator(), options);
m_helloFetcher->afterSegmentValidated.connect([this] (const ndn::Data& data) {
if (data.getFinalBlock()) {
@@ -185,7 +185,7 @@ Consumer::sendSyncInterest()
options.rttOptions.initialRto = m_syncInterestLifetime;
m_syncFetcher = SegmentFetcher::start(m_face, syncInterest,
ndn::security::v2::getAcceptAllValidator(), options);
ndn::security::getAcceptAllValidator(), options);
m_syncFetcher->afterSegmentValidated.connect([this] (const ndn::Data& data) {
if (data.getFinalBlock()) {
+1 -1
View File
@@ -111,7 +111,7 @@ FullProducer::sendSyncInterest()
options.rttOptions.initialRto = m_syncInterestLifetime;
m_fetcher = SegmentFetcher::start(m_face, syncInterest,
ndn::security::v2::getAcceptAllValidator(), options);
ndn::security::getAcceptAllValidator(), options);
m_fetcher->onComplete.connect([this, syncInterest] (const ndn::ConstBufferPtr& bufferPtr) {
onSyncData(syncInterest, bufferPtr);
+2 -4
View File
@@ -55,8 +55,7 @@ public:
void
publish(const ndn::Name& interestName, const ndn::Name& dataName,
const ndn::Block& block, ndn::time::milliseconds freshness,
const ndn::security::SigningInfo& signingInfo =
ndn::security::v2::KeyChain::getDefaultSigningInfo());
const ndn::security::SigningInfo& signingInfo = ndn::security::SigningInfo());
/**
* @brief Put all the segments in memory.
@@ -70,8 +69,7 @@ public:
void
publish(const ndn::Name& interestName, const ndn::Name& dataName,
const std::shared_ptr<const ndn::Buffer>& buffer, ndn::time::milliseconds freshness,
const ndn::security::SigningInfo& signingInfo =
ndn::security::v2::KeyChain::getDefaultSigningInfo());
const ndn::security::SigningInfo& signingInfo = ndn::security::SigningInfo());
/**
* @brief Try to reply from memory, return false if we cannot find the segment.
-214
View File
@@ -1,214 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2020 Regents of the University of California.
*
* Based on work by Martin Ba (http://stackoverflow.com/a/26718189)
*
* This file is distributed under the Boost Software License, Version 1.0.
* (See http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
#define NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
#include <boost/version.hpp>
#if BOOST_VERSION >= 105900
#include <boost/test/unit_test_parameters.hpp>
#else
#include <boost/test/detail/unit_test_parameters.hpp>
#endif // BOOST_VERSION >= 105900
#include <boost/test/unit_test_log_formatter.hpp>
#include <boost/test/output/compiler_log_formatter.hpp>
#include <boost/test/output/xml_log_formatter.hpp>
namespace boost {
namespace unit_test {
namespace output {
/**
* @brief Log formatter for Boost.Test that outputs the logging to multiple formatters
*
* The log formatter is designed to output to one or multiple formatters at the same time. For
* example, one HRF formatter can output to the standard output, while XML formatter output to
* the file.
*
* Usage:
*
* // Call in init_unit_test_suite: (this will override the --log_format parameter)
* auto formatter = new boost::unit_test::output::multi_log_formatter; // same as already configured logger
*
* // Prepare and add additional logger(s)
* formatter.add(std::make_shared<boost::unit_test::output::xml_log_formatter>(),
* std::make_shared<std::ofstream>("out.xml"));
*
* boost::unit_test::unit_test_log.set_formatter(formatter);
*
* @note Calling `boost::unit_test::unit_test_log.set_stream(...)` will change the stream for
* the original logger.
*/
class multi_log_formatter : public unit_test_log_formatter
{
public:
/**
* @brief Create instance of the logger, based on the configured logger instance
*/
multi_log_formatter()
{
auto format =
#if BOOST_VERSION > 105900
runtime_config::get<output_format>(runtime_config::LOG_FORMAT);
#else
runtime_config::log_format();
#endif // BOOST_VERSION > 105900
switch (format) {
default:
#if BOOST_VERSION >= 105900
case OF_CLF:
#else
case CLF:
#endif // BOOST_VERSION >= 105900
m_loggers.push_back({std::make_shared<compiler_log_formatter>(), nullptr});
break;
#if BOOST_VERSION >= 105900
case OF_XML:
#else
case XML:
#endif // BOOST_VERSION >= 105900
m_loggers.push_back({std::make_shared<xml_log_formatter>(), nullptr});
break;
}
}
void
add(std::shared_ptr<unit_test_log_formatter> formatter, std::shared_ptr<std::ostream> os)
{
m_loggers.push_back({formatter, os});
}
// Formatter interface
void
log_start(std::ostream& os, counter_t test_cases_amount)
{
for (auto& l : m_loggers)
l.logger->log_start(l.os == nullptr ? os : *l.os, test_cases_amount);
}
void
log_finish(std::ostream& os)
{
for (auto& l : m_loggers)
l.logger->log_finish(l.os == nullptr ? os : *l.os);
}
void
log_build_info(std::ostream& os)
{
for (auto& l : m_loggers)
l.logger->log_build_info(l.os == nullptr ? os : *l.os);
}
void
test_unit_start(std::ostream& os, const test_unit& tu)
{
for (auto& l : m_loggers)
l.logger->test_unit_start(l.os == nullptr ? os : *l.os, tu);
}
void
test_unit_finish(std::ostream& os, const test_unit& tu, unsigned long elapsed)
{
for (auto& l : m_loggers)
l.logger->test_unit_finish(l.os == nullptr ? os : *l.os, tu, elapsed);
}
void
test_unit_skipped(std::ostream& os, const test_unit& tu)
{
for (auto& l : m_loggers)
l.logger->test_unit_skipped(l.os == nullptr ? os : *l.os, tu);
}
#if BOOST_VERSION >= 105900
void
log_exception_start(std::ostream& os, const log_checkpoint_data& lcd, const execution_exception& ex)
{
for (auto& l : m_loggers)
l.logger->log_exception_start(l.os == nullptr ? os : *l.os, lcd, ex);
}
void
log_exception_finish(std::ostream& os)
{
for (auto& l : m_loggers)
l.logger->log_exception_finish(l.os == nullptr ? os : *l.os);
}
#else
void
log_exception(std::ostream& os, const log_checkpoint_data& lcd, const execution_exception& ex)
{
for (auto& l : m_loggers)
l.logger->log_exception(l.os == nullptr ? os : *l.os, lcd, ex);
}
#endif // BOOST_VERSION >= 105900
void
log_entry_start(std::ostream& os, const log_entry_data& entry_data, log_entry_types let)
{
for (auto& l : m_loggers)
l.logger->log_entry_start(l.os == nullptr ? os : *l.os, entry_data, let);
}
void
log_entry_value(std::ostream& os, const_string value)
{
for (auto& l : m_loggers)
l.logger->log_entry_value(l.os == nullptr ? os : *l.os, value);
}
void
log_entry_finish(std::ostream& os)
{
for (auto& l : m_loggers)
l.logger->log_entry_finish(l.os == nullptr ? os : *l.os);
}
#if BOOST_VERSION >= 105900
void
entry_context_start(std::ostream& os, log_level level)
{
for (auto& l : m_loggers)
l.logger->entry_context_start(l.os == nullptr ? os : *l.os, level);
}
void
log_entry_context(std::ostream& os, const_string value)
{
for (auto& l : m_loggers)
l.logger->log_entry_context(l.os == nullptr ? os : *l.os, value);
}
void
entry_context_finish(std::ostream& os)
{
for (auto& l : m_loggers)
l.logger->entry_context_finish(l.os == nullptr ? os : *l.os);
}
#endif // BOOST_VERSION >= 105900
private:
struct LoggerInfo
{
std::shared_ptr<unit_test_log_formatter> logger;
std::shared_ptr<std::ostream> os;
};
std::vector<LoggerInfo> m_loggers;
};
} // namespace output
} // namespace unit_test
} // namespace boost
#endif // NDN_TESTS_BOOST_MULTI_LOG_FORMATTER_HPP
+1 -88
View File
@@ -24,91 +24,4 @@
*/
#define BOOST_TEST_MODULE PSync
#include <boost/version.hpp>
#if BOOST_VERSION >= 106200
// Boost.Test v3.3 (Boost 1.62) natively supports multi-logger output
#include "boost-test.hpp"
#else
#define BOOST_TEST_ALTERNATIVE_INIT_API
#define BOOST_TEST_NO_MAIN
#include "boost-test.hpp"
#include "boost-multi-log-formatter.hpp"
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/parsers.hpp>
#include <fstream>
#include <iostream>
static bool
init_tests()
{
init_unit_test();
namespace po = boost::program_options;
namespace ut = boost::unit_test;
po::options_description extraOptions;
std::string logger;
std::string outputFile = "-";
extraOptions.add_options()
("log_format2", po::value<std::string>(&logger), "Type of second log formatter: HRF or XML")
("log_sink2", po::value<std::string>(&outputFile)->default_value(outputFile), "Second log sink, - for stdout")
;
po::variables_map vm;
try {
po::store(po::command_line_parser(ut::framework::master_test_suite().argc,
ut::framework::master_test_suite().argv)
.options(extraOptions)
.run(),
vm);
po::notify(vm);
}
catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << "\n"
<< extraOptions << std::endl;
return false;
}
if (vm.count("log_format2") == 0) {
// second logger is not configured
return true;
}
std::shared_ptr<ut::unit_test_log_formatter> formatter;
if (logger == "XML") {
formatter = std::make_shared<ut::output::xml_log_formatter>();
}
else if (logger == "HRF") {
formatter = std::make_shared<ut::output::compiler_log_formatter>();
}
else {
std::cerr << "ERROR: only HRF or XML log formatter can be specified" << std::endl;
return false;
}
std::shared_ptr<std::ostream> output;
if (outputFile == "-") {
output = std::shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
}
else {
output = std::make_shared<std::ofstream>(outputFile.c_str());
}
auto multiFormatter = new ut::output::multi_log_formatter;
multiFormatter->add(formatter, output);
ut::unit_test_log.set_formatter(multiFormatter);
return true;
}
int
main(int argc, char* argv[])
{
return ::boost::unit_test::unit_test_main(&init_tests, argc, argv);
}
#endif // BOOST_VERSION >= 106200
#include "tests/boost-test.hpp"
+14 -15
View File
@@ -37,11 +37,11 @@ class SegmentPublisherFixture : public tests::UnitTestTimeFixture
{
public:
SegmentPublisherFixture()
: face(io, util::DummyClientFace::Options{true, true})
, publisher(face, keyChain)
, freshness(1000)
, numComplete(0)
, numRepliesFromStore(0)
: face(io, util::DummyClientFace::Options{true, true})
, publisher(face, keyChain)
, freshness(1000)
, numComplete(0)
, numRepliesFromStore(0)
{
face.setInterestFilter(InterestFilter("/hello/world"),
bind(&SegmentPublisherFixture::onInterest, this, _1, _2),
@@ -55,25 +55,24 @@ public:
}
}
~SegmentPublisherFixture() {
~SegmentPublisherFixture()
{
fetcher->stop();
}
void
expressInterest(const Interest& interest) {
fetcher = util::SegmentFetcher::start(face, interest, ndn::security::v2::getAcceptAllValidator());
fetcher->onComplete.connect([this] (ConstBufferPtr data) {
numComplete++;
});
fetcher->onError.connect([] (uint32_t errorCode, const std::string& msg) {
BOOST_CHECK(false);
});
expressInterest(const Interest& interest)
{
fetcher = util::SegmentFetcher::start(face, interest, ndn::security::getAcceptAllValidator());
fetcher->onComplete.connect([this] (auto&&...) { numComplete++; });
fetcher->onError.connect([] (auto&&...) { BOOST_CHECK(false); });
advanceClocks(ndn::time::milliseconds(10));
}
void
onInterest(const Name& prefix, const Interest& interest) {
onInterest(const Name& prefix, const Interest& interest)
{
if (publisher.replyFromStore(interest.getName())) {
numRepliesFromStore++;
return;
+5 -4
View File
@@ -15,9 +15,10 @@ int main() {{ boost::iostreams::{0}_compressor test; }}
COMPRESSION_SCHEMES = ['zlib', 'gzip', 'bzip2', 'lzma', 'zstd']
def options(opt):
opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs'])
opt.load(['default-compiler-flags', 'coverage', 'sanitizers',
'boost', 'doxygen', 'sphinx_build'],
opt.load(['compiler_cxx', 'gnu_dirs'])
opt.load(['default-compiler-flags',
'coverage', 'sanitizers', 'boost',
'doxygen', 'sphinx_build'],
tooldir=['.waf-tools'])
optgrp = opt.add_option_group('PSync Options')
@@ -31,7 +32,7 @@ def options(opt):
help='Build without {}'.format(scheme))
def configure(conf):
conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs',
conf.load(['compiler_cxx', 'gnu_dirs',
'default-compiler-flags', 'boost',
'doxygen', 'sphinx_build'])