Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » 2022.3rc5
Re: 2022.3rc5 [message #59568 is a reply to message #59567] Tue, 07 February 2023 00:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Mon, 06 February 2023 23:34
Hello Mirek,

It didn't work but I've got a more detailed error -instead of plain nullptr- by using clang_parseTranslationUnit2() function, which returns an enum, defined in CxErrorCode.h):

 /**
  * An AST deserialization error has occurred.
  */
 CXError_ASTReadError = 4


I'll dig deeper, but if this gives you any hints, please let me know.

Best regards,
Oblivion


https://groups.google.com/g/llvm-dev/c/Jh0bUJz7PHw?pli=1

Based on this, maybe you could try to pass the filename instead of "nullptr" in the call and remove it from commandline? Not the same error, but could be related.

Re: 2022.3rc5 [message #59576 is a reply to message #59568] Wed, 08 February 2023 17:55 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Hello Mirek,

I've stripped the code, and wrote the below test:

struct Clang {

	CXIndex index = nullptr;
	CXTranslationUnit tu = nullptr;

	Clang()
	{
		MemoryIgnoreLeaksBlock __;
		index = clang_createIndex(0, 0);
	}

	void Parse()
	{
		Vector<const char*> args = {
			"-std=c++14",
			"-xc++",
			"-I/usr/include/llvm",
			"-I/usr/include/c++",
			"-I/usr/include/c++/12.2.1",
			"-I/usr/include/c++/12.2.1/x86_64-pc-linux-gnu",
			"-I/usr/include/c++/12.2.1/backward",
			"-I/usr/lib/clang/15.0.7/include",
			"-I/usr/include"
			"-I/usr/local/include",
		};

		tu = clang_parseTranslationUnit(
						index,
						"/home/user/test.cpp",
                        args,
                        args.GetCount(),
                        nullptr,
                        0,
                        CXTranslationUnit_None
                 );
	}

	~Clang()
	{
		MemoryIgnoreLeaksBlock __;
		if(tu) clang_disposeTranslationUnit(tu);
		clang_disposeIndex(index);
	}

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT);
	Clang().Parse();
}


This works. clang_parseTranslationUnit() returns a translation unit handle every single time. (And the handle can be successfully used to traverse the AST.


However, the same code applied to TheIDE's Clang::Parse() method, with hard coded paths as is above,
clang_parseTranslationUnit() still fails to return a translation unit every single time.

I've tried both dynamic loading and static linking (LCLANG), tested both the above code & TheIDe on Linux 6.1.9/Clang 14 & 15

At this point I am almost sure that this is not a user-side problem, because I have installed vanilla ArchLinux on both a real hardware and on a VM (on windows machine), yet I get the same failure... Could this be a process env issue? Any ideas?


Best regards,
Oblivion





[Updated on: Wed, 08 February 2023 17:57]

Report message to a moderator

Re: 2022.3rc5 [message #59577 is a reply to message #59576] Wed, 08 February 2023 20:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Wed, 08 February 2023 17:55
Hello Mirek,
However, the same code applied to TheIDE's Clang::Parse() method, with hard coded paths as is above,
clang_parseTranslationUnit() still fails to return a translation unit every single time.


Just idea: Try to put it at the start of theide's GUI_APP_MAIN. If it works there, it must be something between that point and Clang::Parse. If not, it some linking or global constructor problem (or something like that).

Mirek
Re: 2022.3rc5 [message #59578 is a reply to message #59577] Wed, 08 February 2023 20:33 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Hello Mirek,

You're right,
I've just got an interesting result:

CONSOLE_APP_MAIN = clang_parseTranslationUnit() = OK
GUI_APP_MAIN = clang_parseTranslationUnit() = fails


Best regards,
Oblivion





Re: 2022.3rc5 [message #59579 is a reply to message #59410] Wed, 08 February 2023 20:50 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
I think we're getting somewhere:

It appears to be a GTK::GUI_APP_MAIN related problem, as clangd snippet seems to work fine with NOGTK flag.

edit: Yes, I can confirm this.TheIde (NOGTK) with clangd runs just fine!

Best regards,
Oblivion


[Updated on: Wed, 08 February 2023 22:44]

Report message to a moderator

Re: 2022.3rc5 [message #59581 is a reply to message #59577] Thu, 09 February 2023 17:41 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
HEllo Mirek,

The culprit seems to be gtk_init() function in InitGtkApp() function, line: 69.
If I call the clangd before that point, the parser works.


Best regards,
Oblivion



Re: 2022.3rc5 [message #59582 is a reply to message #59581] Thu, 09 February 2023 19:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Thu, 09 February 2023 17:41
HEllo Mirek,

The culprit seems to be gtk_init() function in InitGtkApp() function, line: 69.
If I call the clangd before that point, the parser works.


Best regards,
Oblivion



Cool but we definitely need to call it, right? Smile

Maybe it alters argv/environment?

Or maybe something with threads?
Re: 2022.3rc5 [message #59584 is a reply to message #59410] Thu, 09 February 2023 21:05 Go to previous messageGo to next message
Silvan is currently offline  Silvan
Messages: 56
Registered: December 2014
Location: Trento (IT)
Member
maybe it is not related but I found a problem in the parser: https://www.ultimatepp.org/forums/index.php?t=msg&th=120 25&start=0&
In short: parser give error in theide but build normally.
It depend on the machine theide is running, just after unpacking.

Bye
Re: 2022.3rc5 [message #59586 is a reply to message #59582] Thu, 09 February 2023 23:20 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Razz
I found the problem. It is env/LC_CTYPE variable.

My locale is set to tr_TR.UTF-8
For now, clangd doesn't seem to like it.
Changing LC_CTYPE to en_US did the trick for me, on all ArchLinux installations...

I am not entirely familiar with clangd's behaviour (yet) but if it requires LC_CTYPE to be ASCII en_xx values, maybe TheIDE should ensure that it is.


Best regards,
Oblivion


Re: 2022.3rc5 [message #59587 is a reply to message #59586] Fri, 10 February 2023 08:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Thu, 09 February 2023 23:20
Razz
I found the problem. It is env/LC_CTYPE variable.

My locale is set to tr_TR.UTF-8
For now, clangd doesn't seem to like it.
Changing LC_CTYPE to en_US did the trick for me, on all ArchLinux installations...

I am not entirely familiar with clangd's behaviour (yet) but if it requires LC_CTYPE to be ASCII en_xx values, maybe TheIDE should ensure that it is.


Best regards,
Oblivion


Tried something like putting something like this at the start of theide GUI_APP_MAIN?

GUI_APP_MAIN {
#ifdef PLATFORM_POSIX
SetEnv("LC_TYPE", "en_US.UTF8")
#endif
Re: 2022.3rc5 [message #59593 is a reply to message #59587] Fri, 10 February 2023 21:45 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Quote:
Tried something like putting something like this at the start of theide GUI_APP_MAIN?

GUI_APP_MAIN {
#ifdef PLATFORM_POSIX
SetEnv("LC_TYPE", "en_US.UTF8")
#endif


I've already tried this, but it doesn't work. Also, after thinking about it, I am not sure this is a good idea. LC_CTYPE variable should be set by OS user, not by TheIDE. (Unless there is a clang specific config option to set). In the meantime I'll use the desktop file to set it for TheIDE...

Best regards,
Oblivion


Re: 2022.3rc5 [message #59594 is a reply to message #59593] Fri, 10 February 2023 23:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Fri, 10 February 2023 21:45
Quote:
Tried something like putting something like this at the start of theide GUI_APP_MAIN?

GUI_APP_MAIN {
#ifdef PLATFORM_POSIX
SetEnv("LC_TYPE", "en_US.UTF8")
#endif


I've already tried this, but it doesn't work. Also, after thinking about it, I am not sure this is a good idea. LC_CTYPE variable should be set by OS user, not by TheIDE. (Unless there is a clang specific config option to set). In the meantime I'll use the desktop file to set it for TheIDE...

Best regards,
Oblivion


U++ does not care about LC_TYPE, so does not TheIDE. If anything, TheIDE needs it en_us utf8...

Global constructor then (INITBLOCK) then?

Mirek
Re: 2022.3rc5 [message #59595 is a reply to message #59594] Sat, 11 February 2023 07:48 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Quote:
Global constructor then (INITBLOCK) then?


Yes,

INITBLOCK {
	SetEnv("LC_CTYPE", "en_US.UTF-8");
}


This works.

Best regards,
Oblivion


Re: 2022.3rc5 [message #59602 is a reply to message #59595] Mon, 13 February 2023 11:21 Go to previous messageGo to next message
Silvan is currently offline  Silvan
Messages: 56
Registered: December 2014
Location: Trento (IT)
Member
Hi Oblivion,
I experienced a similar problem with the parser under Windows 10,
I tried to find out wicht enviromental variable could affect the behaviour of the ide, but with no success.
Have you an idea of the correspondent under windows of LC_CTYPE?
Thank you for any help,
Silvan
Re: 2022.3rc5 [message #59626 is a reply to message #59595] Sun, 19 February 2023 10:06 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Sat, 11 February 2023 07:48
Quote:
Global constructor then (INITBLOCK) then?


Yes,

INITBLOCK {
	SetEnv("LC_CTYPE", "en_US.UTF-8");
}


This works.

Best regards,
Oblivion


It is now in master then...

Mirek
Previous Topic: ide insert data/timestep/GUID
Next Topic: clang-format integration
Goto Forum:
  


Current Time: Thu Apr 18 14:48:24 CEST 2024

Total time taken to generate the page: 0.03254 seconds