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

Compilation error with MSYS2 CLANG{64,32} environments #3851

Closed
k-takata opened this issue Nov 21, 2023 · 16 comments
Closed

Compilation error with MSYS2 CLANG{64,32} environments #3851

k-takata opened this issue Nov 21, 2023 · 16 comments
Assignees

Comments

@k-takata
Copy link
Member

https://github.com/universal-ctags/ctags-win32/actions/runs/6924537331/job/18833909212
https://github.com/universal-ctags/ctags-win32/actions/runs/6924537331/job/18833909365

main/lxpath.c:166:3: error: call to undeclared function 'xmlLineNumbersDefault'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  166 |                 xmlLineNumbersDefault (1);
      |                 ^
main/lxpath.c:167:9: error: call to undeclared function 'xmlParseMemory'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  167 |                 doc = xmlParseMemory((const char*)data, size);
      |                       ^
main/lxpath.c:167:7: error: incompatible integer to pointer conversion assigning to 'xmlDocPtr' (aka 'struct _xmlDoc *') from 'int' [-Wint-conversion]
  167 |                 doc = xmlParseMemory((const char*)data, size);
      |                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.

It seems that xmlLineNumbersDefault and xmlParseMemory are deprecated.
https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html
(Not sure why these errors don't occur with MSYS2 MINGW{32,64} environments, though. Both use libxml2-2.12.0.)

@k-takata
Copy link
Member Author

These error didn't occur when libxml2-2.11.6 was used:
https://github.com/universal-ctags/ctags-win32/actions/runs/6911068107/job/18805112817

@k-takata
Copy link
Member Author

It seems that MINGW{32,64} have another errors with libxml2-2.12.0.

MINGW64:
https://github.com/universal-ctags/ctags-win32/actions/runs/6917682193/job/18819132209

	--- ./Tmain/selector-xml-root-elelement.d/stdout-expected.txt	2023-11-19 01:59:33.486877700 +0000
	+++ D:/a/ctags-win32/ctags-win32/ctags/Tmain/selector-xml-root-elelement.d/stdout-actual.txt	2023-11-19 02:05:51.950974900 +0000
	@@ -1 +0,0 @@
	-input.xml: DBusIntrospect

MINGW32:
https://github.com/universal-ctags/ctags-win32/actions/runs/6917682193/job/18819132302

	--- ./Units/parser-ant.r/xpath-based.d/expected.tags	2023-11-19 01:59:28.699355000 +0000
	+++ D:/a/ctags-win32/ctags-win32/ctags/Units/parser-ant.r/xpath-based.d/FILTERED.tmp	2023-11-19 02:06:00.988167700 +0000
	@@ -4,4 +4,4 @@
	-clean	input.xml	/^  <target name="clean" depends="init">$/;"	t	language:Ant	project:MyProject	roles:def
	-compile_something	input.xml	/^  <target name="compile_something" depends="init">$/;"	t	language:Ant	project:MyProject	roles:def
	-deploy	input.xml	/^    <target name="deploy" depends="compile_something, generate_h_from_java">$/;"	t	language:Ant	project:MyProject	roles:def
	-generate_h_from_java	input.xml	/^  <target name="generate_h_from_java" depends="compile_something">$/;"	t	language:Ant	project:MyProject	roles:def
	+clean	input.xml	/^$/;"	t	language:Ant	project:MyProject	roles:def
	+compile_something	input.xml	/^  <\/target>$/;"	t	language:Ant	project:MyProject	roles:def
	+deploy	input.xml	/^      link="http:\/\/java.sun.com\/j2se\/1.4.1\/docs\/api\/"$/;"	t	language:Ant	project:MyProject	roles:def
	+generate_h_from_java	input.xml	/^$/;"	t	language:Ant	project:MyProject	roles:def
	@@ -9 +9 @@
	-javadoc	input.xml	/^  <target name="javadoc">$/;"	t	language:Ant	project:MyProject	roles:def
	+javadoc	input.xml	/^  <\/target-->$/;"	t	language:Ant	project:MyProject	roles:def

@masatake masatake self-assigned this Nov 21, 2023
@leleliu008
Copy link
Member

leleliu008 commented Nov 21, 2023

lixml2-2.12.0 in MSYS2 was built with --with-legacy comfigure option, so it should be compatible with the older versions.

Reference: msys2/MSYS2-packages@d8c83a4

the real cause is that xmlLineNumbersDefault and xmlParseMemory functions are declared in libxml/parser.h, which in turn was not included in main/lxpath.c

diff --git a/main/lxpath.c b/main/lxpath.c
index 42e4a40e..275491a3 100644
--- a/main/lxpath.c
+++ b/main/lxpath.c
@@ -20,6 +20,7 @@
 #include "xtag.h"
 
 #ifdef HAVE_LIBXML
+#include <libxml/parser.h>
 #include <libxml/xpath.h>
 #include <libxml/tree.h>
 

@masatake
Copy link
Member

@k-takata #3852 may fix this issue.
Could you try the latest master branch?
If the issue is still reproduced, please reopen this issue.

@k-takata
Copy link
Member Author

I will check it in tomorrow's daily build.

@k-takata
Copy link
Member Author

k-takata commented Nov 22, 2023

@k-takata k-takata reopened this Nov 22, 2023
@masatake
Copy link
Member

@k-takata Thank you. I'll look into this.

@leleliu008
Copy link
Member

libxml/parser.h should be included in main/selectors.c too.

@masatake
Copy link
Member

In my understanding, @leleliu008 fixed the issue about the building.
The rest issue is about the test failures.

We must catch up on the newer API of libxml2. I'll work on this topic.

@k-takata
Copy link
Member Author

Now the build error has been fixed.
However, as you expected, it is still failing.
https://github.com/universal-ctags/ctags-win32/actions/runs/6964711106

@masatake
Copy link
Member

@k-takata Thank you. I'll work on fixing the failure at #3858.
Looks mysterious.

@masatake
Copy link
Member

masatake commented Nov 25, 2023

The error was reproduced with libxml2-2.12.1 + fedora:latest container.

[root@3baa1bab8976 ctags]# LD_LIBRARY_PATH=/usr/local/lib  ./ctags -o - --fields=+n Units/parser-ant.r/xpath-based.d/input.xml  | ./readtags -et - javadoc
javadoc Units/parser-ant.r/xpath-based.d/input.xml      /^  <\/target-->$/;"    kind:t  project:MyProject
[root@3baa1bab8976 ctags]# LD_LIBRARY_PATH= ./ctags -o - --fields=+n Units/parser-ant.r/xpath-based.d/input.xml  | ./readtags -et - javadoc
javadoc Units/parser-ant.r/xpath-based.d/input.xml      /^  <target name="javadoc">$/;" kind:t  project:MyProject

libxml2-2.10.4 is installed as a package in 'fedora:latest' container.

@masatake
Copy link
Member

Git-bisect reported the following commit of libxml2 causes this issue:

[root@3baa1bab8976 libxml2]# git bisect good                                                                                                                                
cb927e851959219da1fec49d1cf088aac5579949 is the first bad commit                                                                                                            
commit cb927e851959219da1fec49d1cf088aac5579949                                       
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Date:   Mon Sep 25 14:35:43 2023 +0200

    parser: Don't skip CR in xmlCurrentChar 
     
    Skip over carriage returns later in xmlNextChar.

 parserInternals.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

https://gitlab.gnome.org/GNOME/libxml2/-/commit/cb927e851959219da1fec49d1cf088aac5579949

@masatake
Copy link
Member

masatake commented Nov 25, 2023

The commit cb927e851959219da1fec49d1cf088aac5579949 is small, but many commits have been added after the commit. So, I could not fix the bug in HEAD.

I reported the issue to https://gitlab.gnome.org/GNOME/libxml2/-/issues/628 with minimum reproducer. If I could fix the bug, we would have to add code to ctags not to use a broken version of libxml2.

On the platform using configure for building ctags, AC_TRY_RUN with the minimum reproducer in configure can be used to decide whether we should link libxml-2.0 to ctags or not.

@masatake
Copy link
Member

masatake commented Nov 26, 2023

It seems that the bug is fixed in https://gitlab.gnome.org/GNOME/libxml2/-/commit/43b511fa714df875dc4f40d108061eede0d4d76b.

(Added) I verified that the test case is passed with the libxml2 with the commit.

@masatake
Copy link
Member

masatake commented Dec 6, 2023

Close via #3858.

As I reported, a bug in libxml2 caused the failure of the test case.
It was fixed in the upstream project.

I added code detecting the bug of libxml2 to configure.ac. The code doesn't link libxml2 to ctags if the code detects the bug.

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

No branches or pull requests

3 participants