From 2298c4e3eb4e4fe77f418e737979b2200c5d9f19 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 4 Mar 2024 10:25:58 +0200 Subject: [PATCH 1/4] Restore -Wall as the project default compile warning level --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cf9ec4c..d44e648a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,8 @@ if (Iconv_FOUND) add_compile_definitions(HAVE_ICONV) endif() +add_compile_options(-Wall) + add_subdirectory(src) add_subdirectory(doc) if (EXISTS po/popt.pot) From c8eee02863122fadb4621fee479a9f643c2b83d5 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 4 Mar 2024 10:29:00 +0200 Subject: [PATCH 2/4] Add build option to enable -Werror, use in CI --- CMakeLists.txt | 6 ++++++ ci/Dockerfile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d44e648a..bcd56373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ project(popt # Set soversion set(POPT_SOVERSION 0) +# Configurable stuff +option(ENABLE_WERROR "Stop build on warnings" OFF) + # Set up GNU conventions and standard FHS paths include(GNUInstallDirs) @@ -79,6 +82,9 @@ if (Iconv_FOUND) endif() add_compile_options(-Wall) +if (ENABLE_WERROR) + add_compile_options(-Werror) +endif() add_subdirectory(src) add_subdirectory(doc) diff --git a/ci/Dockerfile b/ci/Dockerfile index 9348e3c7..4dfd65cc 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -16,5 +16,5 @@ RUN dnf -y install \ COPY . . -RUN cmake -S . -B ./build +RUN cmake -S . -B ./build -DENABLE_WERROR=ON CMD cd build && ctest --output-on-failure --force-new-ctest-process From eccde4819ffd68358149e6c0431126f2e401eb97 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 4 Mar 2024 10:31:21 +0200 Subject: [PATCH 3/4] Bump CI to Fedora 39, 36 is getting a bit long in the tooth --- ci/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index 4dfd65cc..62968910 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/fedora:36 +FROM registry.fedoraproject.org/fedora:39 MAINTAINER rpm-maint@lists.rpm.org WORKDIR /srv/popt From 40ff6c97350d0ec734623fd47f87c0647ddfcf87 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 4 Mar 2024 10:43:52 +0200 Subject: [PATCH 4/4] Add options for building with address and undefined behavior sanitizers --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcd56373..67f0ff07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ set(POPT_SOVERSION 0) # Configurable stuff option(ENABLE_WERROR "Stop build on warnings" OFF) +option(ENABLE_ASAN "Enable address-sanitizer" OFF) +option(ENABLE_UBSAN "Enable undefined behavior-sanitizer" OFF) # Set up GNU conventions and standard FHS paths include(GNUInstallDirs) @@ -86,6 +88,20 @@ if (ENABLE_WERROR) add_compile_options(-Werror) endif() +# Sanitizers +if (ENABLE_ASAN) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) +endif() +if (ENABLE_UBSAN) + add_compile_options(-fsanitize=undefined) + add_link_options(-fsanitize=undefined) +endif() +if (ENABLE_ASAN OR ENABLE_UBSAN) + add_compile_options(-fno-omit-frame-pointer) +endif() + + add_subdirectory(src) add_subdirectory(doc) if (EXISTS po/popt.pot)