Skip to content

Commit

Permalink
build: sync default CXXFLAGS and DEFINES with ndn-cxx
Browse files Browse the repository at this point in the history
Change-Id: I2e7916942e6f5e347e21949f4945af37573da5cc
  • Loading branch information
Pesa committed Jan 19, 2024
1 parent 9fa8ac3 commit 11c3638
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .jenkins.d/40-headers-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

CXX=${CXX:-g++}
STD=-std=c++17
CXXFLAGS="-O2 -Wall -Wno-unneeded-internal-declaration -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
CXXFLAGS="-O2 -Wall -Wno-unknown-warning-option -Wno-enum-constexpr-conversion -Wno-unused-const-variable $(pkg-config --cflags libndn-cxx $PCFILE)"
INCLUDEDIR="$(pkg-config --variable=includedir $PCFILE)"/$PROJ

echo "Using: $CXX $STD $CXXFLAGS"
Expand Down
15 changes: 14 additions & 1 deletion .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def getGeneralFlags(self, conf):

def getDebugFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}

def getOptimizedFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
Expand Down Expand Up @@ -175,6 +175,9 @@ def getDebugFlags(self, conf):
'-Wno-error=maybe-uninitialized', # Bug #1615
]
flags['LINKFLAGS'] += self.__linkFlags
# Enable assertions in libstdc++
# https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
flags['DEFINES'] += ['_GLIBCXX_ASSERTIONS=1']
return flags

def getOptimizedFlags(self, conf):
Expand Down Expand Up @@ -223,6 +226,9 @@ def getGeneralFlags(self, conf):
elif Utils.unversioned_sys_platform() == 'freebsd':
# Bug #4790
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
if self.getCompilerVersion(conf) >= (18, 0, 0):
# Bug #5300
flags['CXXFLAGS'] += ['-Wno-enum-constexpr-conversion']
return flags

__cxxFlags = [
Expand All @@ -233,6 +239,13 @@ def getGeneralFlags(self, conf):
def getDebugFlags(self, conf):
flags = super().getDebugFlags(conf)
flags['CXXFLAGS'] += self.__cxxFlags
# Enable assertions in libc++
if self.getCompilerVersion(conf) >= (18, 0, 0):
# https://libcxx.llvm.org/Hardening.html
flags['DEFINES'] += ['_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE']
elif self.getCompilerVersion(conf) >= (15, 0, 0):
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1']
return flags

def getOptimizedFlags(self, conf):
Expand Down
4 changes: 2 additions & 2 deletions src/logic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2023 University of California, Los Angeles
* Copyright (c) 2012-2024 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
Expand Down Expand Up @@ -594,7 +594,7 @@ Logic::sendSyncInterest()

m_pendingSyncInterestName = interestName;

#ifdef _DEBUG
#ifndef NDEBUG
printDigest(m_state.getRootDigest());
#endif

Expand Down

0 comments on commit 11c3638

Please sign in to comment.