Skip to content

Commit

Permalink
Add support for building with sanitizers
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura committed Oct 6, 2023
1 parent b9273de commit 0012803
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ if (WITH_ZSTD)
SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DWITH_ZSTD")
endif()

if (WITH_SANITIZERS)
message(WARNING "Building with sanitizers enabled!")
add_compile_options(-fsanitize=address -fsanitize=undefined -fsanitize=leak)
link_libraries(asan ubsan)
endif()

# Threaded XZ Compression
# Note: This option is disabled by default, because Createrepo_c
# parallelize a lot of tasks (including compression) by default, this
Expand Down
11 changes: 10 additions & 1 deletion createrepo_c.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
%bcond_with legacy_hashes
%endif

%bcond_with sanitizers

Summary: Creates a common metadata repository
Name: createrepo_c
Version: 1.0.0
Expand Down Expand Up @@ -77,6 +79,12 @@ BuildRequires: drpm-devel >= 0.4.0
BuildRequires: pkgconfig(libzstd)
%endif

%if %{with sanitizers}
BuildRequires: libasan
BuildRequires: liblsan
BuildRequires: libubsan
%endif

%if 0%{?fedora} || 0%{?rhel} > 7
Obsoletes: createrepo < 0.11.0
Provides: createrepo = %{version}-%{release}
Expand Down Expand Up @@ -127,7 +135,8 @@ pushd build-py3
-DWITH_LIBMODULEMD=%{?with_libmodulemd:ON}%{!?with_libmodulemd:OFF} \
-DWITH_LEGACY_HASHES=%{?with_legacy_hashes:ON}%{!?with_legacy_hashes:OFF} \
-DENABLE_DRPM=%{?with_drpm:ON}%{!?with_drpm:OFF} \
-DWITH_ZSTD=%{?with_zstd:ON}%{!?with_zstd:OFF}
-DWITH_ZSTD=%{?with_zstd:ON}%{!?with_zstd:OFF} \
-DWITH_SANITIZERS=%{?with_sanitizers:ON}%{!?with_sanitizers:OFF}
make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}"
# Build C documentation
make doc-c
Expand Down

0 comments on commit 0012803

Please sign in to comment.