Skip to content

Commit

Permalink
Enable and fix additional build warnings (#655)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
NWilson authored Jan 10, 2025
1 parent 47a09b6 commit acb4b56
Show file tree
Hide file tree
Showing 17 changed files with 1,012 additions and 163 deletions.
82 changes: 67 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
permissions:
contents: read

env:
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
CFLAGS_MSVC: '/W3'
CFLAGS_SOLARIS_CC: '-errtags=yes -erroff=E_STATEMENT_NOT_REACHED'

jobs:
linux:
name: Linux
Expand All @@ -28,10 +33,10 @@ jobs:
run: ./autogen.sh

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

- name: Build
run: make -j3 CPPFLAGS='-Wall -Wextra -Werror'
run: make -j3

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

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

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

- name: Build
run: make -j3 CPPFLAGS='-Wall -Wextra -Werror'
run: make -j3

- name: Test (main test script)
run: ./RunTest
Expand Down Expand Up @@ -99,7 +104,7 @@ jobs:
submodules: true

- name: Configure
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
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

- name: Build
run: cd build && make -j3
Expand Down Expand Up @@ -127,7 +132,7 @@ jobs:
submodules: true

- name: Configure
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 }}
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 }}

- name: Build
run: cmake --build build --config Release
Expand Down Expand Up @@ -157,16 +162,37 @@ jobs:
- name: Build & test
uses: vmactions/freebsd-vm@debf37ca7b7fa40e19c542ef7ba30d6054a706a4 # v1.1.5
with:
envs: 'CFLAGS_GCC_STYLE'
usesh: true
prepare: |
pkg install -y cmake
run: |
set -e
./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32
make -j3 CPPFLAGS='-Wall -Wextra -Werror'
cp -rp . ../build-autoconf
cp -rp . ../build-cmake
echo "== Autoconf =="
cd ../build-autoconf
./configure CFLAGS="$CFLAGS_GCC_STYLE" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-Werror
make -j3
make check
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-freebsd
echo "== CMake =="
cd ../build-cmake
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
cd build
make -j3
ctest -j3 --output-on-failure
cmake --install . --prefix install-dir
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-freebsd
solaris:
name: Solaris
runs-on: ubuntu-24.04
Expand All @@ -191,6 +217,7 @@ jobs:
- name: Build & test
uses: vmactions/solaris-vm@a89b9438868c70db27e41625f0a5de6ff5e90809 # v1.1.0
with:
envs: 'CFLAGS_SOLARIS_CC'
usesh: true
# Seriously! Solaris is the only OS to actually ship without a C
# compiler, and not even to provide a simple download to get one!
Expand All @@ -203,22 +230,47 @@ jobs:
-k /root/pkg.oracle.com.key.pem \
-c /root/pkg.oracle.com.certificate.pem \
-G "*" -g https://pkg.oracle.com/solarisstudio/release solarisstudio
pkg install developer/build/make system/header
pkg install developer/build/make developer/build/cmake system/header
pkg install --accept developerstudio-126/cc
run: |
set -e
PATH=/opt/developerstudio12.6/bin:"$PATH"
export PATH
CC=cc
export CC
./configure --enable-jit --enable-pcre2-16 --enable-pcre2-32
make CPPFLAGS='-Wall -Wextra -Werror'
cp -rp . ../build-autoconf-32
cp -rp . ../build-autoconf-64
cp -rp . ../build-cmake-64
echo "== Autoconf, 32-bit =="
cd ../build-autoconf-32
./configure CC="cc -m32" CFLAGS="$CFLAGS_SOLARIS_CC" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-errwarn
make
make check
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-solaris
echo "== Autoconf, 64-bit =="
cd ../build-autoconf-64
./configure CC="cc -m64" CFLAGS="$CFLAGS_SOLARIS_CC" --enable-jit --enable-pcre2-16 --enable-pcre2-32 --enable-errwarn
make
make check
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
maint/RunManifestTest install-dir maint/manifest-makeinstall-solaris
echo "== CMake, 64-bit =="
cd ../build-cmake-64
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
cd build
make
ctest -j3 --output-on-failure
cmake --install . --prefix install-dir
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-solaris
distcheck:
name: Build & verify distribution
Expand Down
43 changes: 20 additions & 23 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

env:
CFLAGS_GCC_STYLE: '-Wall -Wextra -pedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings'
CFLAGS_MSVC: '/W3'

jobs:

canary:
Expand All @@ -30,7 +34,7 @@ jobs:
run: ./autogen.sh

- name: Configure
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
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

- name: Build
run: make -j3
Expand Down Expand Up @@ -65,7 +69,7 @@ jobs:
run: ./autogen.sh

- name: Configure
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
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

- name: Build
run: make -j3
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
submodules: true

- name: Configure
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
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

- name: Build
run: cd build && make -j3
Expand Down Expand Up @@ -123,7 +127,7 @@ jobs:
run: ./autogen.sh

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

- name: Build
run: make -j3
Expand Down Expand Up @@ -168,7 +172,7 @@ jobs:
- name: Configure
run: |
cmake --version | grep "version ${CMAKE_VER}" || (echo "CMake version mismatch" && exit 1)
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
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
- name: Build
run: ninja -C build
Expand All @@ -193,7 +197,7 @@ jobs:
submodules: true

- name: Configure
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
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

- name: Build
run: cmake --build build --config RelWithDebInfo
Expand All @@ -212,7 +216,7 @@ jobs:
submodules: true

- name: Configure
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
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

- name: Build
run: cmake --build build --config Debug
Expand Down Expand Up @@ -246,27 +250,13 @@ jobs:
runs-on: ubuntu-24.04
container: perl:devel
steps:
- name: Setup
run: |
apt-get -qq update
apt-get -qq install cmake ninja-build
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: yes

- name: Configure
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

- name: Build
run: ninja -C build

- name: Test
run: |
cd build
ctest -j3 --output-on-failure
cd ..
perl -v
maint/RunPerlTest
Expand All @@ -276,14 +266,21 @@ jobs:
# functions or macros which collide.
name: CMake unity build
runs-on: ubuntu-24.04
env:
# Disallowing shadowing would be very spammy for unity builds, because the
# same variable name can be used in multiple files.
# We disable format truncation/overflow because the heuristics used for
# these warnings are not very good, and are apparently affected by the
# inliner, which is used much less aggressively in unity builds.
CFLAGS_UNITY: "-Wno-shadow -Wno-format-truncation -Wno-format-overflow"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true

- name: Configure
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
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

- name: Build
run: cd build && make -j3
Expand Down Expand Up @@ -324,7 +321,7 @@ jobs:

- name: Configure
shell: msys2 {0}
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
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

- name: Build
shell: msys2 {0}
Expand Down
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

set(CMAKE_C_VISIBILITY_PRESET hidden)
cmake_policy(SET CMP0063 NEW)

# Set policy CMP0026 to avoid warnings for the use of LOCATION in
# GET_TARGET_PROPERTY. This should no longer be required.
# CMAKE_POLICY(SET CMP0026 OLD)

# With a recent cmake, you can provide a rootdir to look for non
# standard installed library dependencies, but to do so, the policy
# needs to be set to new (by uncommenting the following)
# CMAKE_POLICY(SET CMP0074 NEW)
# The following policies have been set in the PCRE2 CMake file in the past.
# Since we specify a minimum of CMake 3.15, these are no longer required.
# cmake_policy(SET CMP0063 NEW)
# cmake_policy(SET CMP0026 OLD)
# cmake_policy(SET CMP0074 NEW)

# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
# on the command line.
Expand Down Expand Up @@ -175,7 +171,7 @@ check_c_source_compiles(
)

set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "XL")
if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "XL" AND NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
endif()

Expand Down
4 changes: 2 additions & 2 deletions config-cmake.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define PCRE2GREP_BUFSIZE @PCRE2GREP_BUFSIZE@
#define PCRE2GREP_MAX_BUFSIZE @PCRE2GREP_MAX_BUFSIZE@

#define MAX_NAME_SIZE 128
#define MAX_NAME_COUNT 10000
#define MAX_NAME_SIZE 128
#define MAX_NAME_COUNT 10000

/* end config.h for CMake builds */
23 changes: 21 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ AC_ARG_ENABLE(percent-zt,
[disable the use of z and t formatting modifiers]),
, enable_percent_zt=auto)

# Handle --enable-Werror/errwarn
AC_ARG_ENABLE(Werror,
AS_HELP_STRING([--enable-Werror],
[Add -Werror to CFLAGS (GCC/Clang style); if -Werror is passed to ./configure via CFLAGS it interferes with feature detection]),
, enable_Werror=no)
AC_ARG_ENABLE(errwarn,
AS_HELP_STRING([--enable-errwarn],
[Add -errwarn=%all to CFLAGS (Sun cc style)]),
, enable_errwarn=no)

# Set the default value for pcre2-8
if test "x$enable_pcre2_8" = "xunset"
then
Expand Down Expand Up @@ -659,9 +669,9 @@ if test "$enable_pcre2test_libreadline" = "yes"; then
[unset ac_cv_lib_readline_readline;
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
[unset ac_cv_lib_readline_readline;
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
[unset ac_cv_lib_readline_readline;
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
[LIBREADLINE=""],
[-ltermcap])],
[-lncursesw])],
Expand Down Expand Up @@ -1145,6 +1155,15 @@ AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
# creating it was changed by reconfiguration.
AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])

# Handle --enable-Werror/errwarn. This must come last, so that we don't mess
# with any of the library-detection tests (or similar).
if test "X$enable_Werror" = Xyes; then
CFLAGS="$CFLAGS -Werror"
fi
if test "X$enable_errwarn" = Xyes; then
CFLAGS="$CFLAGS -errwarn=%all"
fi

AC_OUTPUT

# --disable-stack-for-recursion is obsolete and has no effect.
Expand Down
Loading

0 comments on commit acb4b56

Please sign in to comment.