Skip to content

Commit

Permalink
Fix compilation on latest mac versions with external libraries (#2669)
Browse files Browse the repository at this point in the history
Fix also Performance job on ubuntu-latest/24.04: see similar fix in
957a050.

Close: #2412
  • Loading branch information
IvanNardi authored Jan 15, 2025
1 parent 252be78 commit c8f8d51
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 34 deletions.
32 changes: 4 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [""]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build_scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,17 @@ jobs:
name: Performance (ubuntu-latest)
runs-on: ubuntu-latest
env:
GO111MODULE: on
CFLAGS: -Werror
steps:
- uses: actions/checkout@v4
with:
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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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], [
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit c8f8d51

Please sign in to comment.