Skip to content

Commit 8cad464

Browse files
committed
Build system: minor fixes about flag compilation and example dependencies
- always use `-Wextra` compilation flag; it was already used in CI - always compile `ndpiSimpleIntegration` when building examples - don't mess with optimization flags: `CFLAGS` default value is "-g -O2" and the user can change it
1 parent 4096d75 commit 8cad464

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Python Bindings (ubuntu-latest)
1515
runs-on: ubuntu-latest
1616
env:
17-
CFLAGS: -Wextra -Werror
17+
CFLAGS: -Werror
1818
steps:
1919
- uses: actions/checkout@v4
2020
with:
@@ -72,7 +72,7 @@ jobs:
7272
runs-on: ${{ matrix.os }}
7373
env:
7474
CC: ${{ matrix.compiler }}
75-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
75+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS ${{ matrix.cflags }}
7676
strategy:
7777
fail-fast: true
7878
matrix:
@@ -84,31 +84,36 @@ jobs:
8484
msan: [""]
8585
nBPF: [""]
8686
global_context: [""] # Enable by default
87+
cflags: ["-g -O2"] # Default value if you do not specify CFLAGS variable
8788
include:
8889
- compiler: "gcc-4.9" # "Oldest" gcc easily available. To simulate RHEL7
8990
os: ubuntu-22.04
9091
pcre: "--with-pcre2"
9192
maxminddb: "--with-maxminddb"
9293
msan: "--with-sanitizer"
9394
nBPF: ""
95+
cflags: ["-O0"]
9496
- compiler: "gcc-14" # "Newest" gcc easily available
9597
os: ubuntu-24.04
9698
pcre: "--with-pcre2"
9799
maxminddb: "--with-maxminddb"
98100
msan: "--with-sanitizer"
99101
nBPF: ""
102+
cflags: ["-O2"]
100103
- compiler: "clang-12" # "Oldest" clang easily available
101104
os: ubuntu-22.04
102105
pcre: "--with-pcre2"
103106
maxminddb: "--with-maxminddb"
104107
msan: "--with-sanitizer"
105108
nBPF: ""
109+
cflags: ["-Os"]
106110
- compiler: "clang-18" # "Newest" clang easily available. See also below...
107111
os: ubuntu-24.04
108112
pcre: "--with-pcre2"
109113
maxminddb: "--with-maxminddb"
110114
msan: "--with-sanitizer"
111115
nBPF: ""
116+
cflags: ["-O3"]
112117
- compiler: "cc"
113118
os: ubuntu-latest
114119
pcre: "--with-pcre2"
@@ -241,7 +246,7 @@ jobs:
241246
runs-on: ubuntu-24.04
242247
env:
243248
CC: ${{ matrix.compiler }}
244-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
249+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
245250
strategy:
246251
fail-fast: true
247252
matrix:
@@ -277,7 +282,7 @@ jobs:
277282
name: ${{ matrix.os }} (msys2)
278283
runs-on: ${{ matrix.os }}
279284
env:
280-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
285+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS -O2
281286
strategy:
282287
fail-fast: true
283288
matrix:
@@ -311,7 +316,7 @@ jobs:
311316
name: Out-of-tree builds
312317
runs-on: ubuntu-latest
313318
env:
314-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
319+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
315320
steps:
316321
- uses: actions/checkout@v4
317322
with:

.github/workflows/build_docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: Ubuntu ${{ matrix.arch }}
1919
runs-on: ubuntu-latest
2020
env:
21-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
21+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
2222
# Idea to have significant faster tests while pushing/merging: test all pcaps only on schedule runs; otherwise tests only the pcaps updated/added recently
2323
NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS: ${{ (github.event_name == 'schedule') && '0' || '1' }}
2424
strategy:

.github/workflows/build_masan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-22.04 # TODO: some issues with masan/clang/ubuntu-24.04
2121
env:
2222
CC: clang
23-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
23+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
2424
# Idea to have significant faster tests while pushing/merging: test all pcaps only on schedule runs; otherwise tests only the pcaps updated/added recently
2525
NDPI_TEST_ONLY_RECENTLY_UPDATED_PCAPS: ${{ (github.event_name == 'schedule') && '0' || '1' }}
2626
steps:

.github/workflows/build_scheduled.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
name: Thread Sanitizer (ubuntu-latest)
113113
runs-on: ubuntu-latest
114114
env:
115-
CFLAGS: -Wextra -Werror
115+
CFLAGS: -Werror
116116
steps:
117117
- uses: actions/checkout@v4
118118
with:
@@ -137,7 +137,7 @@ jobs:
137137
name: Local gcrypt on ${{ matrix.os }}
138138
runs-on: ${{ matrix.os }}
139139
env:
140-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
140+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
141141
strategy:
142142
fail-fast: true
143143
matrix:
@@ -175,7 +175,7 @@ jobs:
175175
name: Local gcrypt on ${{ matrix.os }} (msys2)
176176
runs-on: ${{ matrix.os }}
177177
env:
178-
CFLAGS: -Wextra -Werror -DNDPI_EXTENDED_SANITY_CHECKS
178+
CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS
179179
strategy:
180180
fail-fast: true
181181
matrix:

configure.ac

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ AS_IF([test "${with_thread_sanitizer+set}" = set -a "${with_memory_sanitizer+set
5757
])
5858
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[
5959
NDPI_CFLAGS="${NDPI_CFLAGS} -O0 -g3"
60-
],[
61-
dnl> Oss-fuzz doesn't really like any optimizaton flags don't set by itself
62-
AS_IF([test "x$enable_fuzztargets" != "xyes"], [NDPI_CFLAGS="${NDPI_CFLAGS} -O2"])
6360
])
6461
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[
6562
AS_IF([test "x$enable_gprof" = "xyes"], [
@@ -254,7 +251,7 @@ echo "Setting API version to ${NDPI_API_VERSION}"
254251
AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release])
255252
AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
256253

257-
NDPI_CFLAGS="-W -Wall -Wno-address-of-packed-member ${NDPI_CFLAGS}"
254+
NDPI_CFLAGS="-W -Wall -Wextra -Wno-address-of-packed-member ${NDPI_CFLAGS}"
258255

259256
dnl> MacOS brew.sh
260257
HOMEBREW_DIR=/opt/homebrew

example/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ endif
5454

5555
AM_CFLAGS+=-pthread
5656

57-
all: ndpiReader$(EXE_SUFFIX) @DPDK_TARGET@
57+
all: ndpiReader$(EXE_SUFFIX) ndpiSimpleIntegration$(EXE_SUFFIX) @DPDK_TARGET@
5858

5959
EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c
6060
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(notdir $(wildcard $(srcdir)/*.c)))

src/lib/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CFLAGS_ndpi_bitmap.c := -Wno-unused-function
3737
CFLAGS_ndpi_bitmap64_fuse.c := -Wno-unused-function
3838
CFLAGS_gcrypt_light.c := -Wno-unused-function -Wno-unused-parameter
3939
CFLAGS_ahocorasick.c := -Wno-unused-function -Wno-unused-parameter
40-
CFLAGS_roaring.c := -Wno-unused-function -Wno-attributes
40+
CFLAGS_roaring.c := -Wno-unused-function -Wno-attributes -Wno-missing-braces -Wno-missing-field-initializers
4141
# Use AM_LDFLAGS for package flags, never modify user's LDFLAGS
4242
AM_LDFLAGS = @NDPI_LDFLAGS@
4343
LIBS = @ADDITIONAL_LIBS@ @LIBS@ @GPROF_LIBS@

utils/check_symbols.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ for line in $(nm -P -u "${NDPI_LIB}"); do
2828
'printf'|'fprintf') SKIP=1 ;;
2929
esac
3030
;;
31+
'[ndpi_analyze.o]'|'[ndpi_cache.o]'|'[ndpi_config.o]')
32+
case "${FOUND_SYMBOL}" in
33+
'fprintf') SKIP=1 ;;
34+
esac
35+
;;
3136
'[ahocorasick.o]')
3237
case "${FOUND_SYMBOL}" in
3338
'fprintf') SKIP=1 ;;

0 commit comments

Comments
 (0)