Skip to content

Commit acb4b56

Browse files
authored
Enable and fix additional build warnings (#655)
Part of #651 * Use much stricter windows warnings (`/W3` rather than `/W1`). This requires quite a few fixes for all the sloppy places where we do implicit assignment of 64-bit values to 32-bit storage. * Use and test CMake build & install on FreeBSD and Solaris * Add 64 bit Solaris build (`cc -m64`) and fix existing Solaris warnings * Make compile flags used in CI consistent across platforms. Previously Mac & Linux were building with different warning flags. * Add `--enable-Werror` to `configure.ac`. This means that you can build with `-Werror` in a clean way. Previously, you had to hackily override the CPPFLAGS when calling `make` since you can't pass `-Werror` as a CFLAG into `./configure` (it messes with compiler feature detection).
1 parent 47a09b6 commit acb4b56

17 files changed

+1012
-163
lines changed

.github/workflows/build.yml

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
permissions:
1010
contents: read
1111

12+
env:
13+
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
14+
CFLAGS_MSVC: '/W3'
15+
CFLAGS_SOLARIS_CC: '-errtags=yes -erroff=E_STATEMENT_NOT_REACHED'
16+
1217
jobs:
1318
linux:
1419
name: Linux
@@ -28,10 +33,10 @@ jobs:
2833
run: ./autogen.sh
2934

3035
- name: Configure
31-
run: ./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-pcre2grep-libz --enable-pcre2grep-libbz2
36+
run: ./configure CFLAGS="$CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-pcre2grep-libz --enable-pcre2grep-libbz2 --enable-Werror
3237

3338
- name: Build
34-
run: make -j3 CPPFLAGS='-Wall -Wextra -Werror'
39+
run: make -j3
3540

3641
- name: Test (main test script)
3742
run: ./RunTest
@@ -56,7 +61,7 @@ jobs:
5661
container: alpine
5762
steps:
5863
- name: Setup
59-
run: apk add --no-cache automake autoconf gcc libtool make musl-dev git zlib zlib-dev bzip2 bzip2-dev #musl-locales
64+
run: apk add --no-cache automake autoconf gcc libtool make musl-dev git zlib zlib-dev bzip2 bzip2-dev
6065

6166
- name: Checkout
6267
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -67,10 +72,10 @@ jobs:
6772
run: ./autogen.sh
6873

6974
- name: Configure
70-
run: ./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-pcre2grep-libz --enable-pcre2grep-libbz2
75+
run: ./configure CFLAGS="$CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-pcre2grep-libz --enable-pcre2grep-libbz2 --enable-Werror
7176

7277
- name: Build
73-
run: make -j3 CPPFLAGS='-Wall -Wextra -Werror'
78+
run: make -j3
7479

7580
- name: Test (main test script)
7681
run: ./RunTest
@@ -99,7 +104,7 @@ jobs:
99104
submodules: true
100105

101106
- name: Configure
102-
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_SUPPORT_LIBZ=ON -DPCRE2_SUPPORT_LIBBZ2=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_C_FLAGS='-Wall -Wextra' -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
107+
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_SUPPORT_LIBZ=ON -DPCRE2_SUPPORT_LIBBZ2=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
103108

104109
- name: Build
105110
run: cd build && make -j3
@@ -127,7 +132,7 @@ jobs:
127132
submodules: true
128133

129134
- name: Configure
130-
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}
135+
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_C_FLAGS="$CFLAGS_MSVC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}
131136

132137
- name: Build
133138
run: cmake --build build --config Release
@@ -157,16 +162,37 @@ jobs:
157162
- name: Build & test
158163
uses: vmactions/freebsd-vm@debf37ca7b7fa40e19c542ef7ba30d6054a706a4 # v1.1.5
159164
with:
165+
envs: 'CFLAGS_GCC_STYLE'
160166
usesh: true
167+
prepare: |
168+
pkg install -y cmake
169+
161170
run: |
162171
set -e
163-
./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32
164-
make -j3 CPPFLAGS='-Wall -Wextra -Werror'
172+
173+
cp -rp . ../build-autoconf
174+
cp -rp . ../build-cmake
175+
176+
echo "== Autoconf =="
177+
cd ../build-autoconf
178+
179+
./configure CFLAGS="$CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-Werror
180+
make -j3
165181
make check
166182
167183
make install "DESTDIR=`pwd`/install-dir"
168184
maint/RunManifestTest install-dir maint/manifest-makeinstall-freebsd
169185
186+
echo "== CMake =="
187+
cd ../build-cmake
188+
189+
cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build
190+
cd build
191+
make -j3
192+
ctest -j3 --output-on-failure
193+
cmake --install . --prefix install-dir
194+
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-freebsd
195+
170196
solaris:
171197
name: Solaris
172198
runs-on: ubuntu-24.04
@@ -191,6 +217,7 @@ jobs:
191217
- name: Build & test
192218
uses: vmactions/solaris-vm@a89b9438868c70db27e41625f0a5de6ff5e90809 # v1.1.0
193219
with:
220+
envs: 'CFLAGS_SOLARIS_CC'
194221
usesh: true
195222
# Seriously! Solaris is the only OS to actually ship without a C
196223
# compiler, and not even to provide a simple download to get one!
@@ -203,22 +230,47 @@ jobs:
203230
-k /root/pkg.oracle.com.key.pem \
204231
-c /root/pkg.oracle.com.certificate.pem \
205232
-G "*" -g https://pkg.oracle.com/solarisstudio/release solarisstudio
206-
pkg install developer/build/make system/header
233+
pkg install developer/build/make developer/build/cmake system/header
207234
pkg install --accept developerstudio-126/cc
208235
209236
run: |
210237
set -e
211238
PATH=/opt/developerstudio12.6/bin:"$PATH"
212239
export PATH
213-
CC=cc
214-
export CC
215240
216-
./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32
217-
make CPPFLAGS='-Wall -Wextra -Werror'
241+
cp -rp . ../build-autoconf-32
242+
cp -rp . ../build-autoconf-64
243+
cp -rp . ../build-cmake-64
244+
245+
echo "== Autoconf, 32-bit =="
246+
cd ../build-autoconf-32
247+
248+
./configure CC="cc -m32" CFLAGS="$CFLAGS_SOLARIS_CC" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-errwarn
249+
make
250+
make check
251+
252+
make install "DESTDIR=`pwd`/install-dir"
253+
maint/RunManifestTest install-dir maint/manifest-makeinstall-solaris
254+
255+
echo "== Autoconf, 64-bit =="
256+
cd ../build-autoconf-64
257+
258+
./configure CC="cc -m64" CFLAGS="$CFLAGS_SOLARIS_CC" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-errwarn
259+
make
218260
make check
219261
220262
make install "DESTDIR=`pwd`/install-dir"
221-
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
263+
maint/RunManifestTest install-dir maint/manifest-makeinstall-solaris
264+
265+
echo "== CMake, 64-bit =="
266+
cd ../build-cmake-64
267+
268+
CC="cc -m64" cmake -DNCURSES_LIBRARY=termcap -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_SOLARIS_CC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build
269+
cd build
270+
make
271+
ctest -j3 --output-on-failure
272+
cmake --install . --prefix install-dir
273+
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-solaris
222274
223275
distcheck:
224276
name: Build & verify distribution

.github/workflows/dev.yml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
permissions:
1010
contents: read
1111

12+
env:
13+
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
14+
CFLAGS_MSVC: '/W3'
15+
1216
jobs:
1317

1418
canary:
@@ -30,7 +34,7 @@ jobs:
3034
run: ./autogen.sh
3135

3236
- name: Configure
33-
run: ./configure CC='gcc -fsanitize=undefined,address -fsanitize-undefined-trap-on-error' CFLAGS='-O0 -Wall -Wextra -Werror -Wno-error=unused-but-set-parameter' --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug --enable-pcre2test-libedit --with-link-size=4
37+
run: ./configure CC='gcc -fsanitize=undefined,address -fsanitize-undefined-trap-on-error' CFLAGS="-O0 $CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug --enable-Werror --enable-pcre2test-libedit --with-link-size=4
3438

3539
- name: Build
3640
run: make -j3
@@ -65,7 +69,7 @@ jobs:
6569
run: ./autogen.sh
6670

6771
- name: Configure
68-
run: ./configure CC='clang -fsanitize=undefined,address,integer -fno-sanitize-recover=undefined,integer -fno-sanitize=unsigned-integer-overflow,unsigned-shift-base,function' CFLAGS='${{ matrix.opt }} -Wall -Wextra -Werror -Wno-error=unused-but-set-parameter -Wno-error=deprecated-declarations -Wno-error=incompatible-library-redeclaration -Wno-error=incompatible-pointer-types-discards-qualifiers' --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug --with-link-size=3
72+
run: ./configure CC='clang -fsanitize=undefined,address,integer -fno-sanitize-recover=undefined,integer -fno-sanitize=unsigned-integer-overflow,unsigned-shift-base,function' CFLAGS="${{ matrix.opt }} $CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug --enable-Werror --with-link-size=3
6973

7074
- name: Build
7175
run: make -j3
@@ -95,7 +99,7 @@ jobs:
9599
submodules: true
96100

97101
- name: Configure
98-
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
102+
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
99103

100104
- name: Build
101105
run: cd build && make -j3
@@ -123,7 +127,7 @@ jobs:
123127
run: ./autogen.sh
124128

125129
- name: Configure
126-
run: ./configure CFLAGS='-Os -Wall -Wextra -Werror -Wno-error=unused-but-set-parameter' --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug
130+
run: ./configure CFLAGS="-Os $CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug --enable-Werror
127131

128132
- name: Build
129133
run: make -j3
@@ -168,7 +172,7 @@ jobs:
168172
- name: Configure
169173
run: |
170174
cmake --version | grep "version ${CMAKE_VER}" || (echo "CMake version mismatch" && exit 1)
171-
CC='clang' CFLAGS='-fsanitize=undefined,address,integer -fno-sanitize-recover=undefined,integer -fno-sanitize=unsigned-shift-base,function -pedantic -Wall -Wextra -Wpedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Werror -Wno-error=incompatible-pointer-types-discards-qualifiers' cmake -G Ninja -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DPCRE2_SUPPORT_LIBREADLINE=ON -DCMAKE_BUILD_TYPE=MinSizeRel -B build
175+
CC='clang' cmake -G Ninja -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DPCRE2_SUPPORT_LIBREADLINE=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=MinSizeRel -B build
172176
173177
- name: Build
174178
run: ninja -C build
@@ -193,7 +197,7 @@ jobs:
193197
submodules: true
194198

195199
- name: Configure
196-
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2GREP_SUPPORT_CALLOUT_FORK=OFF -DPCRE2_DEBUG=ON -DPCRE2_NEWLINE=ANYCRLF -DPCRE2_STATIC_PIC=ON -DPCRE2_STATIC_RUNTIME=ON -DPCRE2_SUPPORT_BSR_ANYCRLF=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A Win32
200+
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2GREP_SUPPORT_CALLOUT_FORK=OFF -DPCRE2_DEBUG=ON -DPCRE2_NEWLINE=ANYCRLF -DPCRE2_STATIC_PIC=ON -DPCRE2_STATIC_RUNTIME=ON -DPCRE2_SUPPORT_BSR_ANYCRLF=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DCMAKE_C_FLAGS="$CFLAGS_MSVC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A Win32
197201

198202
- name: Build
199203
run: cmake --build build --config RelWithDebInfo
@@ -212,7 +216,7 @@ jobs:
212216
submodules: true
213217

214218
- name: Configure
215-
run: cmake -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A x64
219+
run: cmake -DPCRE2_SUPPORT_JIT=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCMAKE_C_FLAGS="$CFLAGS_MSVC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A x64
216220

217221
- name: Build
218222
run: cmake --build build --config Debug
@@ -246,27 +250,13 @@ jobs:
246250
runs-on: ubuntu-24.04
247251
container: perl:devel
248252
steps:
249-
- name: Setup
250-
run: |
251-
apt-get -qq update
252-
apt-get -qq install cmake ninja-build
253-
254253
- name: Checkout
255254
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
256255
with:
257256
submodules: yes
258257

259-
- name: Configure
260-
run: cmake -G Ninja -B build -DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_NEVER_BACKSLASH_C=ON -DPCRE2_DEBUG=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
261-
262-
- name: Build
263-
run: ninja -C build
264-
265258
- name: Test
266259
run: |
267-
cd build
268-
ctest -j3 --output-on-failure
269-
cd ..
270260
perl -v
271261
maint/RunPerlTest
272262
@@ -276,14 +266,21 @@ jobs:
276266
# functions or macros which collide.
277267
name: CMake unity build
278268
runs-on: ubuntu-24.04
269+
env:
270+
# Disallowing shadowing would be very spammy for unity builds, because the
271+
# same variable name can be used in multiple files.
272+
# We disable format truncation/overflow because the heuristics used for
273+
# these warnings are not very good, and are apparently affected by the
274+
# inliner, which is used much less aggressively in unity builds.
275+
CFLAGS_UNITY: "-Wno-shadow -Wno-format-truncation -Wno-format-overflow"
279276
steps:
280277
- name: Checkout
281278
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
282279
with:
283280
submodules: true
284281

285282
- name: Configure
286-
run: cmake -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=0 -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
283+
run: cmake -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=0 -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE $CFLAGS_UNITY" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
287284

288285
- name: Build
289286
run: cd build && make -j3
@@ -324,7 +321,7 @@ jobs:
324321

325322
- name: Configure
326323
shell: msys2 {0}
327-
run: cmake -G Ninja -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
324+
run: cmake -G Ninja -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE -Wno-format-truncation -Wno-format-overflow" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
328325

329326
- name: Build
330327
shell: msys2 {0}

CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,12 @@ set(CMAKE_C_STANDARD 99)
118118
set(CMAKE_C_STANDARD_REQUIRED TRUE)
119119

120120
set(CMAKE_C_VISIBILITY_PRESET hidden)
121-
cmake_policy(SET CMP0063 NEW)
122121

123-
# Set policy CMP0026 to avoid warnings for the use of LOCATION in
124-
# GET_TARGET_PROPERTY. This should no longer be required.
125-
# CMAKE_POLICY(SET CMP0026 OLD)
126-
127-
# With a recent cmake, you can provide a rootdir to look for non
128-
# standard installed library dependencies, but to do so, the policy
129-
# needs to be set to new (by uncommenting the following)
130-
# CMAKE_POLICY(SET CMP0074 NEW)
122+
# The following policies have been set in the PCRE2 CMake file in the past.
123+
# Since we specify a minimum of CMake 3.15, these are no longer required.
124+
# cmake_policy(SET CMP0063 NEW)
125+
# cmake_policy(SET CMP0026 OLD)
126+
# cmake_policy(SET CMP0074 NEW)
131127

132128
# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
133129
# on the command line.
@@ -175,7 +171,7 @@ check_c_source_compiles(
175171
)
176172

177173
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
178-
if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "XL")
174+
if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "XL" AND NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro")
179175
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
180176
endif()
181177

config-cmake.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define PCRE2GREP_BUFSIZE @PCRE2GREP_BUFSIZE@
5353
#define PCRE2GREP_MAX_BUFSIZE @PCRE2GREP_MAX_BUFSIZE@
5454

55-
#define MAX_NAME_SIZE 128
56-
#define MAX_NAME_COUNT 10000
55+
#define MAX_NAME_SIZE 128
56+
#define MAX_NAME_COUNT 10000
5757

5858
/* end config.h for CMake builds */

configure.ac

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,16 @@ AC_ARG_ENABLE(percent-zt,
448448
[disable the use of z and t formatting modifiers]),
449449
, enable_percent_zt=auto)
450450

451+
# Handle --enable-Werror/errwarn
452+
AC_ARG_ENABLE(Werror,
453+
AS_HELP_STRING([--enable-Werror],
454+
[Add -Werror to CFLAGS (GCC/Clang style); if -Werror is passed to ./configure via CFLAGS it interferes with feature detection]),
455+
, enable_Werror=no)
456+
AC_ARG_ENABLE(errwarn,
457+
AS_HELP_STRING([--enable-errwarn],
458+
[Add -errwarn=%all to CFLAGS (Sun cc style)]),
459+
, enable_errwarn=no)
460+
451461
# Set the default value for pcre2-8
452462
if test "x$enable_pcre2_8" = "xunset"
453463
then
@@ -659,9 +669,9 @@ if test "$enable_pcre2test_libreadline" = "yes"; then
659669
[unset ac_cv_lib_readline_readline;
660670
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
661671
[unset ac_cv_lib_readline_readline;
662-
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
672+
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
663673
[unset ac_cv_lib_readline_readline;
664-
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
674+
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
665675
[LIBREADLINE=""],
666676
[-ltermcap])],
667677
[-lncursesw])],
@@ -1145,6 +1155,15 @@ AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
11451155
# creating it was changed by reconfiguration.
11461156
AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])
11471157

1158+
# Handle --enable-Werror/errwarn. This must come last, so that we don't mess
1159+
# with any of the library-detection tests (or similar).
1160+
if test "X$enable_Werror" = Xyes; then
1161+
CFLAGS="$CFLAGS -Werror"
1162+
fi
1163+
if test "X$enable_errwarn" = Xyes; then
1164+
CFLAGS="$CFLAGS -errwarn=%all"
1165+
fi
1166+
11481167
AC_OUTPUT
11491168

11501169
# --disable-stack-for-recursion is obsolete and has no effect.

0 commit comments

Comments
 (0)