Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation failure due to -Werror flag #4777

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Thor-x86
Copy link

@Thor-x86 Thor-x86 commented Dec 19, 2023

This is an attempt to get this commands working for building the cyrus-imapd:

autoreconf -i
./configure CFLAGS="-W -Wno-unused-parameter -g -O0 -Wall -Wextra -Werror -fPIC --std=gnu99"   \
    --enable-srs --enable-afs --enable-autocreate --enable-idled --enable-nntp --enable-murder \
    --enable-http --enable-calalarmd --enable-jmap --enable-xapian --enable-replication        \
    --enable-backup --enable-cmulocal --enable-oldsievename --enable-unit-tests                \
    --enable-cyrusdb-benchmarks
make lex-fix
cd perl/annotator; perl Makefile.PL
cd ../imap; perl Makefile.PL
cd ../sieve/managesieve; perl Makefile.PL
cd ../../..
make -j8
make check

Without error caused by warning and -Werror flag. Also notes that currently I'm working with upstream's latest stable version of toolchains and dependencies. Thus, the fix might not quite relevant on Debian but definitely needed in rolling release distributions like Arch.

Attempt to fix error message:
imap/http_dav.c: In function ‘parse_xml_body’:
imap/http_dav.c:3819:33: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
 3819 |         xmlErrorPtr err = xmlCtxtGetLastError(txn->conn->xml);
      |

Signed-off-by: Athaariq Ardhiansyah <[email protected]>
Attempt to fix error message:
/mnt/img/athaariq/cyrus-imapd/docsrc/imap/concepts/deployment/storage.rst:973: WARNING: duplicate term description of MTBF, other instance in glossary
/mnt/img/athaariq/cyrus-imapd/docsrc/imap/concepts/deployment/storage.rst:977: WARNING: duplicate term description of HBA, other instance in glossary
/mnt/img/athaariq/cyrus-imapd/docsrc/imap/concepts/features/server-aggregation.rst:392: WARNING: duplicate term description of frontend, other instance in glossary
/mnt/img/athaariq/cyrus-imapd/docsrc/imap/concepts/features/server-aggregation.rst:397: WARNING: duplicate term description of backend, other instance in glossary

Signed-off-by: Athaariq Ardhiansyah <[email protected]>
Copy link
Author

@Thor-x86 Thor-x86 left a comment

Choose a reason for hiding this comment

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

LGTM, CUnit and Cassandane shows no problem.

@elliefm
Copy link
Contributor

elliefm commented Dec 20, 2023

cd perl/annotator; perl Makefile.PL
cd ../imap; perl Makefile.PL
cd ../sieve/managesieve; perl Makefile.PL
cd ../../..

These steps shouldn't be necessary, the top level make takes care of all that

Copy link
Contributor

@elliefm elliefm left a comment

Choose a reason for hiding this comment

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

Thanks. I appreciate the enthusiasm for cleaning up the documentation warnings, but most of your proposed changes make things worse. I've addressed each with individual comments.

The documentation warnings are not what's causing your build to fail. -Werror only applies to the C compiler, not to sphinx-build.

It looks like your build fails because of the const warning from http_dav.c. I've asked Ken to have a closer look at this one, because if the object returned by the libxml call is const (or is const in newer versions of libxml), the way we use it might be unsafe.

docsrc/conf.py Outdated Show resolved Hide resolved
docsrc/conf.py Outdated Show resolved Hide resolved
docsrc/imap/download/release-notes/3.3/index.rst Outdated Show resolved Hide resolved
docsrc/conf.py Outdated Show resolved Hide resolved
docsrc/imap/download/release-notes/index.rst Outdated Show resolved Hide resolved
xmlErrorPtr err = xmlCtxtGetLastError(txn->conn->xml);
const xmlError *err = xmlCtxtGetLastError(txn->conn->xml);
Copy link
Contributor

Choose a reason for hiding this comment

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

@ksmurchison can you have a look at this one please, I'm not familiar with the XML library.

In particular, a few lines later we save err->message in txn->error.desc. That might not be safe if we don't have lifetime ownership of the err object, which the constness might imply.

Since we aren't getting this warning/error outselves, perhaps this is an API change in the XML library that we haven't stumbled upon yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding const seems correct as that is what the API specifies. Since we're getting the error from the XML parser context, and there is a xmlCtxtResetLastError() function, I assume its safe to reference the error until we free the parser context.

Copy link
Author

Choose a reason for hiding this comment

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

As an information, the Arch distribution uses libxml2 v2.12.3. I see the changes at libxml2 GitLab repository which related to this issue. This is what maintainer's say:

This is a slight break of the API, but users really shouldn't modify the global error struct. The goal is to make xmlLastError use static buffers for its strings eventually. This should warn people if they're abusing the struct.

Copy link
Author

Choose a reason for hiding this comment

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

Adding const seems correct as that is what the API specifies. Since we're getting the error from the XML parser context, and there is a xmlCtxtResetLastError() function, I assume its safe to reference the error until we free the parser context.

Alright, thanks for the clarification. Is there anything I can do?

docsrc/imap/reference/admin/sop/deleting.rst Outdated Show resolved Hide resolved
docsrc/imap/reference/admin/sop/deleting.rst Outdated Show resolved Hide resolved
docsrc/imap/concepts/deployment/storage.rst Show resolved Hide resolved
@Thor-x86
Copy link
Author

Drop commit requests are fulfilled, please take a look

These steps shouldn't be necessary, the top level make takes care of all that

I tried, but it yells "No build target" error. There is no explanation or verbose message about the problem unfortunately, so I have to do that manually.

The documentation warnings are not what's causing your build to fail. -Werror only applies to the C compiler, not to sphinx-build.

The commit 6a9d617 went first, but -Werror causes GNU Make complaining on Sphinx. So the compilation process refused to carry on. Initially I thought -Werror only for C/C++ not the other stuffs. Re-clone and applying changes again still results the same error. Perhaps I missed something on configuration step?

Copy link
Author

@Thor-x86 Thor-x86 left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes and ran the CUnit again. @elliefm let me know if you agree with modification on imap/http_dav.c. Thanks

@pgnd
Copy link

pgnd commented Jan 26, 2024

can this get a review/merge?
currently, still causing build fails with sphinx-build enabled ...

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.

None yet

4 participants