Skip to content

Commit fad1264

Browse files
committed
build: sync default CXXFLAGS and DEFINES with ndn-cxx
Change-Id: Ibbee6527a8dca6e8d92c4524a9ca9923ac7c4a2d
1 parent efdb872 commit fad1264

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.jenkins.d/40-headers-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fi
1717

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

2323
echo "Using: $CXX $STD $CXXFLAGS"

.waf-tools/default-compiler-flags.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def getGeneralFlags(self, conf):
136136

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

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

180183
def getOptimizedFlags(self, conf):
@@ -223,6 +226,9 @@ def getGeneralFlags(self, conf):
223226
elif Utils.unversioned_sys_platform() == 'freebsd':
224227
# Bug #4790
225228
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
229+
if self.getCompilerVersion(conf) >= (18, 0, 0):
230+
# Bug #5300
231+
flags['CXXFLAGS'] += ['-Wno-enum-constexpr-conversion']
226232
return flags
227233

228234
__cxxFlags = [
@@ -233,6 +239,13 @@ def getGeneralFlags(self, conf):
233239
def getDebugFlags(self, conf):
234240
flags = super().getDebugFlags(conf)
235241
flags['CXXFLAGS'] += self.__cxxFlags
242+
# Enable assertions in libc++
243+
if self.getCompilerVersion(conf) >= (18, 0, 0):
244+
# https://libcxx.llvm.org/Hardening.html
245+
flags['DEFINES'] += ['_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE']
246+
elif self.getCompilerVersion(conf) >= (15, 0, 0):
247+
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
248+
flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1']
236249
return flags
237250

238251
def getOptimizedFlags(self, conf):

0 commit comments

Comments
 (0)