From c8f8d51dd2ed90fce0dd20fc8c54ffdea20a4eb4 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:42:55 +0100 Subject: [PATCH] Fix compilation on latest mac versions with external libraries (#2669) Fix also Performance job on ubuntu-latest/24.04: see similar fix in 957a05050. Close: #2412 --- .github/workflows/build.yml | 32 ++++----------------------- .github/workflows/build_scheduled.yml | 6 ++--- configure.ac | 22 ++++++++++++++++-- 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 766e7d3afd0..cfc2efa46bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,9 +76,8 @@ jobs: strategy: fail-fast: true matrix: - # macOS-latest == macos-14 on **ARM64**. Also macos-15 is on arm64 - # There are some issues with external dependencies on macOS-14/15. Disable it for the time being - os: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04", "macOS-13"] + # macos-14 and 15 are on **ARM64** + os: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04", "macOS-13", "macOS-14", "macOS-15"] gcrypt: ["--with-local-libgcrypt", ""] compiler: ["cc"] pcre: [""] @@ -131,25 +130,11 @@ jobs: nBPF: "" global_context: "--disable-global-context-support" - compiler: "cc" - os: macOS-13 + os: macOS-latest gcrypt: "" pcre: "--with-pcre2" maxminddb: "--with-maxminddb" - msan: "" # Disable sanitizer on macos - nBPF: "" - - compiler: "cc" - os: macos-14 - gcrypt: "" - pcre: "" - maxminddb: "" - msan: "" # Disable sanitizer on macos - nBPF: "" - - compiler: "cc" - os: macos-15 - gcrypt: "" - pcre: "" - maxminddb: "" - msan: "" # Disable sanitizer on macos + msan: "" nBPF: "" steps: - uses: actions/checkout@v4 @@ -215,18 +200,10 @@ jobs: run: | ./autogen.sh --enable-option-checking=fatal --enable-debug-messages ${{ matrix.gcrypt }} ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs ${{ matrix.global_context}} - name: Build nDPI - if: ${{ !startsWith(matrix.os, 'macos-14') && !startsWith(matrix.os, 'macos-15') }} run: | make -j all make -C example ndpiSimpleIntegration make -C rrdtool - - name: Build nDPI (MacOS M1) - if: startsWith(matrix.os, 'macos-14') || startsWith(matrix.os, 'macos-15') - run: | - make -j all - make -C example ndpiSimpleIntegration - # There are somes issues with librrd - # make -C rrdtool - name: Print nDPI long help run: | cd ./example && ./ndpiReader -H @@ -244,7 +221,6 @@ jobs: run: | NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_SKIP_PARALLEL_BAR=1 ./tests/do.sh - name: Test nDPI [UNIT] - if: ${{ !startsWith(matrix.os, 'macos-14') && !startsWith(matrix.os, 'macos-15') }} run: | ./tests/do-unit.sh - name: Test nDPI [DGA] diff --git a/.github/workflows/build_scheduled.yml b/.github/workflows/build_scheduled.yml index a295cdfedf2..52971b3be31 100644 --- a/.github/workflows/build_scheduled.yml +++ b/.github/workflows/build_scheduled.yml @@ -73,7 +73,6 @@ jobs: name: Performance (ubuntu-latest) runs-on: ubuntu-latest env: - GO111MODULE: on CFLAGS: -Werror steps: - uses: actions/checkout@v4 @@ -81,11 +80,10 @@ jobs: fetch-depth: 0 - name: Install Ubuntu Prerequisites run: | - sudo add-apt-repository ppa:longsleep/golang-backports sudo apt-get update sudo apt-get install libunwind-dev sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libpcap-dev parallel - sudo apt-get install golang-1.16-go libgoogle-perftools-dev graphviz + sudo apt-get install libgoogle-perftools-dev graphviz go install github.com/google/pprof@latest sudo ln -s ${HOME}/go/bin/pprof /usr/bin/pprof pprof -h @@ -122,7 +120,7 @@ jobs: - name: Install Ubuntu Prerequisites run: | sudo apt-get update - sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libjson-c libpcap-dev rrdtool librrd-dev parallel + sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libjson-c-dev libpcap-dev rrdtool librrd-dev parallel - name: Configure nDPI run: | ./autogen.sh --enable-option-checking=fatal --with-thread-sanitizer diff --git a/configure.ac b/configure.ac index 43c8a04fd48..f79f923f506 100644 --- a/configure.ac +++ b/configure.ac @@ -190,6 +190,26 @@ echo "Setting API version to ${NDPI_API_VERSION}" AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release]) AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change]) +NDPI_CFLAGS="-W -Wall -Wno-address-of-packed-member ${NDPI_CFLAGS}" + +dnl> MacOS brew.sh +HOMEBREW_DIR=/opt/homebrew +if test -d $HOMEBREW_DIR; then + # On latest macOS versions on M* archs, some (all?) libraries are not installed + # "system-wide" anymore. + NDPI_CFLAGS="${NDPI_CFLAGS} -I ${HOMEBREW_DIR}/include" + NDPI_LDFLAGS="${NDPI_LDFLAGS} -L ${HOMEBREW_DIR}/lib" + + # While updating NDPI_CFLAGS/NDPI_LDFLAGS is obvious, we need to update + # CFLAGS/LDFLAGS as well, because only these variables are used internally by + # autoconf to check for libraries. + # The core reason is likely that internally in our Makefiles we use + # NDPI_CFLAGS/NDPI_LDFLAGS instead of the standard CFLAGS/LDFLAGS + # See: 7c19de49047a5731f3107ff17854e9afe839cc61 for details + CFLAGS="${CFLAGS} -I ${HOMEBREW_DIR}/include" + LDFLAGS="${LDFLAGS} -L ${HOMEBREW_DIR}/lib" +fi + if ! test "${with_only_libndpi+set}" = set; then : dnl> used by json-c for unit tests PKG_CHECK_MODULES([JSONC], [json-c], [ @@ -226,8 +246,6 @@ AS_IF([test "x${enable_tls_sigs}" = "xyes"],[ HANDLE_TLS_SIGS="" ]) -NDPI_CFLAGS="-W -Wall -Wno-address-of-packed-member ${NDPI_CFLAGS}" - AS_IF([test "${with_lto_and_gold_linker+set}" = set], [ NDPI_CFLAGS="${NDPI_CFLAGS} -flto -fuse-ld=gold -Wno-unused-command-line-argument" NDPI_LDFLAGS="${NDPI_LDFLAGS} ${NDPI_CFLAGS}"