From 01eb8157f961951031b318dbbceb0059a6705ac2 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Sun, 28 Jan 2024 16:00:04 -0500 Subject: [PATCH 1/3] build: sync default CXXFLAGS and DEFINES with ndn-cxx --- .jenkins.d/40-headers-check.sh | 2 +- .waf-tools/default-compiler-flags.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.jenkins.d/40-headers-check.sh b/.jenkins.d/40-headers-check.sh index 4723a3f..92843ee 100755 --- a/.jenkins.d/40-headers-check.sh +++ b/.jenkins.d/40-headers-check.sh @@ -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" diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py index bee5072..6869097 100644 --- a/.waf-tools/default-compiler-flags.py +++ b/.waf-tools/default-compiler-flags.py @@ -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""" @@ -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): @@ -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 = [ @@ -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): From ea436a48cedd73e5ab6e661c6c75922c08c462a0 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Fri, 9 Feb 2024 21:03:32 -0500 Subject: [PATCH 2/3] ci: minimize installed libboost packages --- .jenkins.d/00-deps.sh | 25 ++++++++++++++++++++----- .jenkins.d/01-ndn-cxx.sh | 6 +++--- .jenkins.d/10-build.sh | 6 +++--- .jenkins.d/20-tests.sh | 3 ++- .jenkins.d/40-headers-check.sh | 2 +- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh index b78b899..95d5eac 100755 --- a/.jenkins.d/00-deps.sh +++ b/.jenkins.d/00-deps.sh @@ -1,8 +1,23 @@ #!/usr/bin/env bash set -eo pipefail -APT_PKGS=(build-essential pkg-config python3-minimal - libboost-all-dev libssl-dev libsqlite3-dev) +APT_PKGS=( + build-essential + libboost-chrono-dev + libboost-date-time-dev + libboost-dev + libboost-filesystem-dev + libboost-iostreams-dev + libboost-log-dev + libboost-program-options-dev + libboost-stacktrace-dev + libboost-test-dev + libboost-thread-dev + libsqlite3-dev + libssl-dev + pkg-config + python3-minimal +) FORMULAE=(boost openssl pkg-config) PIP_PKGS=() case $JOB_NAME in @@ -25,10 +40,10 @@ if [[ $ID == macos ]]; then brew update brew install --formula "${FORMULAE[@]}" elif [[ $ID_LIKE == *debian* ]]; then - sudo apt-get -qq update - sudo apt-get -qy install "${APT_PKGS[@]}" + sudo apt-get update -qq + sudo apt-get install -qy --no-install-recommends "${APT_PKGS[@]}" elif [[ $ID_LIKE == *fedora* ]]; then - sudo dnf -y install gcc-c++ libasan lld pkgconf-pkg-config python3 \ + sudo dnf install -y gcc-c++ libasan lld pkgconf-pkg-config python3 \ boost-devel openssl-devel sqlite-devel fi diff --git a/.jenkins.d/01-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh index 91ebefd..6c7fb22 100755 --- a/.jenkins.d/01-ndn-cxx.sh +++ b/.jenkins.d/01-ndn-cxx.sh @@ -42,9 +42,9 @@ sudo ./waf --color=yes install popd >/dev/null popd >/dev/null -if [[ $ID_LIKE == *fedora* ]]; then - sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64 -fi if [[ $ID_LIKE == *linux* ]]; then + if [[ $(uname -m) == x86_64 && -d /usr/lib64 ]]; then + sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64 + fi sudo ldconfig fi diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh index 5fd152d..e24772f 100755 --- a/.jenkins.d/10-build.sh +++ b/.jenkins.d/10-build.sh @@ -35,9 +35,9 @@ fi # Install sudo ./waf --color=yes install -if [[ $ID_LIKE == *fedora* ]]; then - sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64 -fi if [[ $ID_LIKE == *linux* ]]; then + if [[ $(uname -m) == x86_64 && -d /usr/lib64 ]]; then + sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64 + fi sudo ldconfig fi diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh index ab14284..ea5f998 100755 --- a/.jenkins.d/20-tests.sh +++ b/.jenkins.d/20-tests.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash set -eo pipefail +# https://github.com/google/sanitizers/wiki/SanitizerCommonFlags # https://github.com/google/sanitizers/wiki/AddressSanitizerFlags ASAN_OPTIONS="color=always" +ASAN_OPTIONS+=":strip_path_prefix=${PWD}/" ASAN_OPTIONS+=":check_initialization_order=1" ASAN_OPTIONS+=":detect_stack_use_after_return=1" ASAN_OPTIONS+=":strict_init_order=1" ASAN_OPTIONS+=":strict_string_checks=1" ASAN_OPTIONS+=":detect_invalid_pointer_pairs=2" -ASAN_OPTIONS+=":strip_path_prefix=${PWD}/" export ASAN_OPTIONS # https://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/runtime_config/summary.html diff --git a/.jenkins.d/40-headers-check.sh b/.jenkins.d/40-headers-check.sh index 92843ee..5334610 100755 --- a/.jenkins.d/40-headers-check.sh +++ b/.jenkins.d/40-headers-check.sh @@ -11,7 +11,7 @@ if [[ -n $DISABLE_HEADERS_CHECK ]]; then exit 0 fi -if [[ $ID_LIKE == *fedora* ]]; then +if [[ $ID_LIKE == *linux* && -d /usr/local/lib64/pkgconfig ]]; then export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig fi From 5ab3b6e23b55cd44e888b1df8b9bbc68c8a2f67d Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Mon, 19 Feb 2024 02:32:02 -0500 Subject: [PATCH 3/3] Add .editorconfig --- .editorconfig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..624ad9b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +[*.{cpp,hpp}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[{*.{py,sh},.jenkins,wscript}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +indent_style = space +trim_trailing_whitespace = false + +[*.rst] +indent_style = space +trim_trailing_whitespace = true + +[*.{yaml,yml}] +indent_style = space +indent_size = 2