Skip to content

build: Turn compiler warnings into errors only for our code#60

Merged
jrohel merged 1 commit intorpm-software-management:mainfrom
ppisar:no_werror_for_swig
Feb 2, 2026
Merged

build: Turn compiler warnings into errors only for our code#60
jrohel merged 1 commit intorpm-software-management:mainfrom
ppisar:no_werror_for_swig

Conversation

@ppisar
Copy link
Copy Markdown
Contributor

@ppisar ppisar commented Jan 30, 2026

Building with GCC 16 failed on i686 architecture:

/builddir/build/BUILD/libpkgmanifest-0.5.9-build/libpkgmanifest-0.5.9/redhat-linux-build/bindings/python/libpkgmanifest/CMakeFiles/python3_common.dir/commonPYTHON_wrap.cxx: In function ‘void SWIG_TypeClientData(swig_type_info*, void*)’:
/builddir/build/BUILD/libpkgmanifest-0.5.9-build/libpkgmanifest-0.5.9/redhat-linux-build/bindings/python/libpkgmanifest/CMakeFiles/python3_common.dir/commonPYTHON_wrap.cxx:692:37: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  692 |     for (cast = head; (cast - head) <= head->value; cast++) {
  |                       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~

The cause is a bug in Swig-4.4.1 swig/swig#3323. The bug is triggered by adding -Wextra -Werror to all compiler invocation, stricter GCC, and building on 32-bit platforms where a ptrdiff_t type has the same rank as the int type.

This patch works around the compiler warning by only applying the -Werror option to code we maintain. Particullary, not applying to Swig-generated code. In my opinion, this is more sustainable approach than adding -Wno-warn-... exceptions to bindings/CMakeLists.txt whenever the C++ compiler or Swig changes.

Resolve: https://bugzilla.redhat.com/show_bug.cgi?id=2434767

A Fedora scratch build applying this fix https://koji.fedoraproject.org/koji/taskinfo?taskID=141685236.

Building with GCC 16 failed on i686 architecture:

    /builddir/build/BUILD/libpkgmanifest-0.5.9-build/libpkgmanifest-0.5.9/redhat-linux-build/bindings/python/libpkgmanifest/CMakeFiles/python3_common.dir/commonPYTHON_wrap.cxx: In function ‘void SWIG_TypeClientData(swig_type_info*, void*)’:
    /builddir/build/BUILD/libpkgmanifest-0.5.9-build/libpkgmanifest-0.5.9/redhat-linux-build/bindings/python/libpkgmanifest/CMakeFiles/python3_common.dir/commonPYTHON_wrap.cxx:692:37: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
      692 |     for (cast = head; (cast - head) <= head->value; cast++) {
	  |                       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~

The cause is a bug in Swig-4.4.1 <swig/swig#3323>.
The bug is triggered by adding -Wextra -Werror to all compiler invocation,
stricter GCC, and building on 32-bit platforms where a ptrdiff_t type
has the same rank as the int type.

This patch works around the compiler warning by only applying the
-Werror option to code we maintain. Particullary, not applying to
Swig-generated code. In my opinion, this is more sustainable approach
than adding -Wno-warn-... exceptions to bindings/CMakeLists.txt
whenever the C++ compiler or Swig changes.

Resolve: https://bugzilla.redhat.com/show_bug.cgi?id=2434767
@ppisar ppisar requested a review from a team as a code owner January 30, 2026 09:49
@ppisar ppisar requested review from dcantrell and fhbash January 30, 2026 09:49
@ppisar
Copy link
Copy Markdown
Contributor Author

ppisar commented Jan 30, 2026

The unrelated failure of Code Coverage CI task is addressed in #61.

Copy link
Copy Markdown

@fhbash fhbash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jrohel
Copy link
Copy Markdown

jrohel commented Feb 2, 2026

LGTM

@jrohel jrohel self-assigned this Feb 2, 2026
@jrohel jrohel merged commit 85950e7 into rpm-software-management:main Feb 2, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants