mate-desktop / eom

An image viewer for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
57 stars 32 forks source link

fix building with new libxml 2.12.0 #343

Closed kloczek closed 11 months ago

kloczek commented 11 months ago

Added include <libxml/xmlsave.h> to allow build with libxml 2.12.0.

This PR fixes buid issue with libxml 2.12.0

make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/eom-1.27.1/cut-n-paste/toolbar-editor'
  CC       libtoolbareditor_la-egg-toolbars-model.lo
egg-toolbars-model.c: In function 'egg_toolbars_model_to_xml':
egg-toolbars-model.c:78:3: error: 'xmlIndentTreeOutput' undeclared (first use in this function)
   78 |   xmlIndentTreeOutput = TRUE;
      |   ^~~~~~~~~~~~~~~~~~~
egg-toolbars-model.c:78:3: note: each undeclared identifier is reported only once for each function it appears in
egg-toolbars-model.c: In function 'egg_toolbars_model_load_toolbars':
egg-toolbars-model.c:591:9: warning: implicit declaration of function 'xmlParseFile'; did you mean 'xmlSaveFile'? [-Wimplicit-function-declaration]
  591 |   doc = xmlParseFile (xml_file);
      |         ^~~~~~~~~~~~
      |         xmlSaveFile
egg-toolbars-model.c:591:7: warning: assignment to 'xmlDocPtr' {aka 'struct _xmlDoc *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
  591 |   doc = xmlParseFile (xml_file);
      |       ^
egg-toolbars-model.c: In function 'egg_toolbars_model_load_names':
egg-toolbars-model.c:655:7: warning: assignment to 'xmlDocPtr' {aka 'struct _xmlDoc *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
  655 |   doc = xmlParseFile (xml_file);
      |       ^
make[4]: *** [Makefile:574: libtoolbareditor_la-egg-toolbars-model.lo] Error 1
raveit65 commented 11 months ago

Fedora 39 CI build failed because of new libpeas-2 which comes with API and ABI changes and and removal of the GTK interfaces. See libpeas migration guide https://gitlab.gnome.org/GNOME/libpeas/-/commit/80ccc392922289f69d5a705f808e25818ceae1a9 Of cause i can't build eom for stable fedora 39 anymore :/

Debian CI use libxml2-dev/testing,now 2.9.14+dfsg-1.3 amd64 see https://app.travis-ci.com/github/mate-desktop/eom/jobs/613603820#L389

In result i have no idea to test this PR at the moment.

@mate-desktop/core-team Any ideas?

cwendling commented 11 months ago

Short of building from source, I don't know.

However, the change look roughly OK, but does it fix the implicit declaration of function 'xmlParseFile' issue? It's not a hard error here, but it's a terrible thing to let pass (I myself always build with -Werror-implicit-function-delcaration because of this silly C89 feature). IIUC, you'd have to include libxml/parser.h.

Also, I'd actually include libxml/globals.h instead of libxml/xmlsave.h for getting xmlIndentTreeOutput, as it's here it is in pre-2.12, and it's supported by 2.12 as well.

Note: I did not build with libxml2 2.12, I just looked at the new sources.

kloczek commented 11 months ago

However, the change look roughly OK, but does it fix the implicit declaration of function 'xmlParseFile' issue? It's not a hard error here, but it's a terrible thing to let pass (I myself always build with -Werror-implicit-function-delcaration because of this silly C89 feature). IIUC, you'd have to include libxml/parser.h.

Please never do such things if you don't want to shoot in your own foot.

cwendling commented 11 months ago

Please never do such things if you don't want to shoot in your own foot.

@kloczek what to you mean? Never do what?

raveit65 commented 11 months ago

I tested your commit with eom rpm in fedora-rawhide which comes with libxml2-devel-2.12.0-1.fc40.x86_64. Compiling fails with

currency-manager.c: In function ‘load_ecb_rates’:
currency-manager.c:484:5: error: implicit declaration of function ‘xmlInitParser’ [-Werror=implicit-function-declaration]
484 |     xmlInitParser();
|     ^~~~~~~~~~~~~
currency-manager.c:486:16: error: implicit declaration of function ‘xmlReadFile’ [-Werror=implicit-function-declaration]
486 |     document = xmlReadFile(filename, NULL, 0);
|                ^~~~~~~~~~~
currency-manager.c:486:14: warning: assignment to ‘xmlDocPtr’ {aka ‘struct _xmlDoc *’} from ‘int’ makes pointerfrom integer without a cast [-Wint-conversion]
486 |     document = xmlReadFile(filename, NULL, 0);
|              ^
gcc -DHAVE_CONFIG_H -I. -I..  -DLOCALE_DIR=\""/usr/share/locale"\" -Wall -Wmissing-prototypes -I/usr/include/pango-1.0 -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/atk-1.0 -I/usr/include/libxml2 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/at-spi2-atk/2.0 -I/usr/include/cloudproviders -I/usr/include/webp -I/usr/include/at-spi-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/blkid -I/usr/include/pixman-1 -I/usr/include/libmount -I/usr/include/fribidi -I/usr/include/libpng16 -I/usr/include/sysprof-6 -pthread   -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64   -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -c -o mp-trigonometric.o mp-trigonometric.c
currency-manager.c:524:5: error: implicit declaration of function ‘xmlCleanupParser’ [-Werror=implicit-function-declaration]
524 |     xmlCleanupParser();
|     ^~~~~~~~~~~~~~~~

Sadly, i wasn't able to add -Werror=implicit-function-declaration or -Wimplicit-function-declaration when compiling locally with autotools to reproduce this warning. Using CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wimplicit-function-declaration -Werror=implicit-int' ./autogen.sh doesn't have any effect in fedora 38/39.

raveit65 commented 11 months ago

CI is fixed https://github.com/mate-desktop/eom/commit/768f2bbd2a11d2d4c88a512dff9df6342bdc40b7 You can rebase branch. But fedora39 use libxml-2.10.4-3.fc39. So, this doesn't test your PR.

kloczek commented 11 months ago

@kloczek what to you mean? Never do what?

This is not place to explain that. it is set of very good reasons to not ignore such warnings.

cwendling commented 11 months ago

it is set of very good reasons to not ignore such warnings.

What I wrote is that you should treat implicit function declaration as an error, definitely not ignore it.

kloczek commented 11 months ago

What I wrote is that you should treat implicit function declaration as an error, definitely not ignore it.

OK. Sorry my fault .. misunderstanding.

raveit65 commented 11 months ago

Cool, with the new rebase branch with master suggestion button we can rebase PR for our self now ;) grafik

lukefromdc commented 11 months ago

We have libxml2.9 in Debian Unstable right now

cwendling commented 11 months ago

OK so I just tested this with 2.12.0.

With the current state of this PR, I still get this:

egg-toolbars-model.c: In function ‘egg_toolbars_model_load_toolbars’:
egg-toolbars-model.c:592:9: warning: implicit declaration of function ‘xmlParseFile’; did you mean ‘xmlSaveFile’? [-Wimplicit-function-declaration]
  592 |   doc = xmlParseFile (xml_file);
      |         ^~~~~~~~~~~~
      |         xmlSaveFile
egg-toolbars-model.c:592:7: warning: assignment to ‘xmlDocPtr’ {aka ‘struct _xmlDoc *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  592 |   doc = xmlParseFile (xml_file);
      |       ^
egg-toolbars-model.c: In function ‘egg_toolbars_model_load_names’:
egg-toolbars-model.c:656:7: warning: assignment to ‘xmlDocPtr’ {aka ‘struct _xmlDoc *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  656 |   doc = xmlParseFile (xml_file);
      |       ^

which is not good.

With my suggestion though all warnings are gone (for me), and it builds fine with both 2.9.14 and 2.12.0.