Update default compilation flags
Synced from ndn-tools
Change-Id: I95e451f6978f473ad6f616277803464effffd3a7
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 629b8cf..bba2b1e 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -4,41 +4,63 @@
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
- help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
+ help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
def configure(conf):
- cxx = conf.env['CXX_NAME'] # CXX_NAME represents generic name of the compiler
- if cxx == 'gcc':
- flags = GccFlags()
- elif cxx == 'clang':
- flags = ClangFlags()
- else:
- flags = CompilerFlags()
- Logs.warn('The code has not yet been tested with %s compiler' % cxx)
+ conf.start_msg('Checking C++ compiler version')
- areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+ cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
+ ccver = tuple(int(i) for i in conf.env['CC_VERSION'])
+ errmsg = ''
+ warnmsg = ''
+ if cxx == 'gcc':
+ if ccver < (4, 8, 2):
+ errmsg = ('The version of gcc you are using is too old.\n'
+ 'The minimum supported gcc version is 4.8.2.')
+ conf.flags = GccFlags()
+ elif cxx == 'clang':
+ if ccver < (3, 4, 0):
+ errmsg = ('The version of clang you are using is too old.\n'
+ 'The minimum supported clang version is 3.4.0.')
+ conf.flags = ClangFlags()
+ else:
+ warnmsg = 'Note: %s compiler is unsupported' % cxx
+ conf.flags = CompilerFlags()
+
+ if errmsg:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
+ conf.fatal(errmsg)
+ elif warnmsg:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
+ Logs.warn(warnmsg)
+ else:
+ conf.end_msg('.'.join(conf.env['CC_VERSION']))
+
+ conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
# General flags are always applied (e.g., selecting C++11 mode)
- generalFlags = flags.getGeneralFlags(conf)
+ generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']
+@Configure.conf
+def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
# corresponding environment variables are not set.
# DEFINES are always applied.
if conf.options.debug:
- extraFlags = flags.getDebugFlags(conf)
- if areCustomCxxflagsPresent:
+ extraFlags = conf.flags.getDebugFlags(conf)
+ if conf.areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
- extraFlags = flags.getOptimizedFlags(conf)
+ extraFlags = conf.flags.getOptimizedFlags(conf)
- if not areCustomCxxflagsPresent:
+ if not conf.areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
@@ -55,9 +77,10 @@
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
- for flag in cxxflags:
- if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
- supportedFlags += [flag]
+ for flags in cxxflags:
+ flags = Utils.to_list(flags)
+ if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
+ supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('CXXFLAGS', supportedFlags)
@@ -73,9 +96,10 @@
self.start_msg('Checking supported LINKFLAGS')
supportedFlags = []
- for flag in linkflags:
- if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
- supportedFlags += [flag]
+ for flags in linkflags:
+ flags = Utils.to_list(flags)
+ if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
+ supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('LINKFLAGS', supportedFlags)
@@ -98,19 +122,26 @@
"""
This class defines basic flags that work for both gcc and clang compilers
"""
+ def getGeneralFlags(self, conf):
+ flags = super(GccBasicFlags, self).getGeneralFlags(conf)
+ flags['CXXFLAGS'] += ['-std=c++11']
+ return flags
+
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-O0',
+ '-Og', # gcc >= 4.8, clang >= 4.0
'-g3',
'-pedantic',
'-Wall',
'-Wextra',
'-Werror',
- '-Wno-unused-parameter',
- '-Wno-error=maybe-uninitialized', # Bug #1615
+ '-Wnon-virtual-dtor',
'-Wno-error=deprecated-declarations', # Bug #3795
- '-Wno-error=unused-local-typedefs',
+ '-Wno-error=maybe-uninitialized', # Bug #1615
+ '-Wno-unused-parameter',
]
+ flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
return flags
def getOptimizedFlags(self, conf):
@@ -120,30 +151,19 @@
'-pedantic',
'-Wall',
'-Wextra',
+ '-Wnon-virtual-dtor',
'-Wno-unused-parameter',
]
+ flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
return flags
class GccFlags(GccBasicFlags):
- def getGeneralFlags(self, conf):
- flags = super(GccFlags, self).getGeneralFlags(conf)
- version = tuple(int(i) for i in conf.env['CC_VERSION'])
- if version < (4, 8, 2):
- conf.fatal('The version of gcc you are using (%s) is too old.\n' %
- '.'.join(conf.env['CC_VERSION']) +
- 'The minimum supported gcc version is 4.8.2.')
- else:
- flags['CXXFLAGS'] += ['-std=c++11']
- return flags
-
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
- flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
- '-fdiagnostics-color', # gcc >= 4.9
- ]
+ flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
def getOptimizedFlags(self, conf):
@@ -157,26 +177,36 @@
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
- flags['CXXFLAGS'] += ['-std=c++11']
- if Utils.unversioned_sys_platform() == 'darwin':
- flags['CXXFLAGS'] += ['-stdlib=libc++']
- flags['LINKFLAGS'] += ['-stdlib=libc++']
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if Utils.unversioned_sys_platform() == 'darwin' and version >= (9, 0, 0): # Bug #4296
+ flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
+ ['-isystem', '/opt/local/include']] # for MacPorts
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
- '-Wno-unused-local-typedef', # Bugs #2657 and #3209
- '-Wno-error=unneeded-internal-declaration', # Bug #1588
+ '-Wextra-semi',
+ '-Wundefined-func-template',
'-Wno-error=deprecated-register',
- '-Wno-error=keyword-macro', # Bug #3235
'-Wno-error=infinite-recursion', # Bug #3358
+ '-Wno-error=keyword-macro', # Bug #3235
+ '-Wno-error=unneeded-internal-declaration', # Bug #1588
+ '-Wno-unused-local-typedef', # Bugs #2657 and #3209
]
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
+ flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
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 = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
+ flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
return flags
diff --git a/src/ca-storage.cpp b/src/ca-storage.cpp
index 3f8aeb5..ebe5c98 100644
--- a/src/ca-storage.cpp
+++ b/src/ca-storage.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -23,6 +23,8 @@
namespace ndn {
namespace ndncert {
+CaStorage::~CaStorage() = default;
+
unique_ptr<CaStorage>
CaStorage::createCaStorage(const std::string& caStorageType)
{
diff --git a/src/ca-storage.hpp b/src/ca-storage.hpp
index 0a85f6c..ab5e38d 100644
--- a/src/ca-storage.hpp
+++ b/src/ca-storage.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -38,8 +38,10 @@
using std::runtime_error::runtime_error;
};
-public:
- // certificate request related
+ virtual
+ ~CaStorage();
+
+public: // certificate request related
virtual CertificateRequest
getRequest(const std::string& requestId) = 0;
@@ -58,7 +60,7 @@
virtual std::list<CertificateRequest>
listAllRequests(const Name& caName) = 0;
- // certificate related
+public: // certificate related
virtual security::v2::Certificate
getCertificate(const std::string& certId) = 0;
@@ -77,7 +79,7 @@
virtual std::list<security::v2::Certificate>
listAllIssuedCertificates(const Name& caName) = 0;
-public:
+public: // factory
template<class CaStorageType>
static void
registerCaStorage(const std::string& caStorageType = CaStorageType::STORAGE_TYPE)
diff --git a/src/challenge-module.cpp b/src/challenge-module.cpp
index 224a30c..c1f3432 100644
--- a/src/challenge-module.cpp
+++ b/src/challenge-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -37,6 +37,8 @@
{
}
+ChallengeModule::~ChallengeModule() = default;
+
unique_ptr<ChallengeModule>
ChallengeModule::createChallengeModule(const std::string& canonicalName)
{
diff --git a/src/challenge-module.hpp b/src/challenge-module.hpp
index af0d40b..b2d39ad 100644
--- a/src/challenge-module.hpp
+++ b/src/challenge-module.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -44,8 +44,12 @@
};
public:
+ explicit
ChallengeModule(const std::string& uniqueType);
+ virtual
+ ~ChallengeModule();
+
template<class ChallengeType>
static void
registerChallengeModule(const std::string& typeName)
diff --git a/src/client-module.cpp b/src/client-module.cpp
index e4162d2..0d98d90 100644
--- a/src/client-module.cpp
+++ b/src/client-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -38,6 +38,8 @@
{
}
+ClientModule::~ClientModule() = default;
+
void
ClientModule::requestCaTrustAnchor(const Name& caName, const DataCallback& trustAnchorCallback,
const ErrorCallback& errorCallback)
diff --git a/src/client-module.hpp b/src/client-module.hpp
index e285ce2..df2a43a 100644
--- a/src/client-module.hpp
+++ b/src/client-module.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2017, Regents of the University of California.
+ * Copyright (c) 2017-2018, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -64,9 +64,11 @@
using ErrorCallback = function<void (const std::string&)>;
public:
- explicit
ClientModule(Face& face, security::v2::KeyChain& keyChain, size_t retryTimes = 2);
+ virtual
+ ~ClientModule();
+
ClientConfig&
getClientConf()
{
@@ -176,7 +178,6 @@
virtual void
onNack(const Interest& interest, const lp::Nack& nack, const ErrorCallback& errorCallback);
-
protected:
ClientConfig m_config;
Face& m_face;
diff --git a/wscript b/wscript
index 438b03f..8cb55dc 100644
--- a/wscript
+++ b/wscript
@@ -1,8 +1,8 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION = "0.1.0"
APPNAME = "ndncert"
-BUGREPORT = "http://redmine.named-data.net/projects/ndncert"
-GIT_TAG_PREFIX = "ndncert"
+BUGREPORT = "https://redmine.named-data.net/projects/ndncert"
+GIT_TAG_PREFIX = "ndncert-"
from waflib import Logs, Utils, Context
import os
@@ -11,11 +11,12 @@
opt.load(['compiler_cxx', 'gnu_dirs'])
opt.load(['boost', 'default-compiler-flags', 'sqlite3',
'coverage', 'sanitizers',
- 'doxygen', 'sphinx_build'], tooldir=['.waf-tools'])
+ 'doxygen', 'sphinx_build'],
+ tooldir=['.waf-tools'])
- syncopt = opt.add_option_group ("ndncert options")
- syncopt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
- help='''build unit tests''')
+ certopt = opt.add_option_group("ndncert options")
+ certopt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
+ help='''Build unit tests''')
def configure(conf):
conf.load(['compiler_cxx', 'gnu_dirs',
@@ -23,8 +24,7 @@
'doxygen', 'sphinx_build'])
if 'PKG_CONFIG_PATH' not in os.environ:
- os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
-
+ os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
uselib_store='NDN_CXX', mandatory=True)
@@ -40,10 +40,12 @@
if conf.env.BOOST_VERSION_NUMBER < 105400:
Logs.error("Minimum required boost version is 1.54.0")
Logs.error("Please upgrade your distribution or install custom boost libraries" +
- " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
+ " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
return
- # Loading "late" to prevent tests to be compiled with profiling flags
+ conf.check_compiler_flags()
+
+ # Loading "late" to prevent tests from being compiled with profiling flags
conf.load('coverage')
conf.load('sanitizers')
@@ -70,7 +72,6 @@
)
bld.recurse('tools')
-
bld.recurse('tests')
bld.install_files(
@@ -88,9 +89,7 @@
)
bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample")
-
bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample")
-
bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample")
bld(features="subst",