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 » Developing U++ » U++ Developers corner » Clang / lld  () 1 Vote
Clang / lld [message #51614] Fri, 19 April 2019 22:50 Go to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mirek wrote on Sat, 13 April 2019 07:07
These are things I would like to have solved, but do not have resources to:

- Fix uldar - old U++ linker for mingw by Tomas Rylek, that is superfast (compared to ld.exe supplied with mingw), but unfortunately stopped working around mingw 2012 version. This would make mingw much more attractive for us (well, there is still that poor TLS handling, but maybe that will get solved over time too).

I personally would take a look at LLD first. Gold linker is supposed to be several times faster than ld, but it doesn't support PE/COFF. LLD is supposed to be several times faster than the gold linker, and it supports PE/COFF. So, there is no need to reinvent the wheel.


Regards,
Novo

[Updated on: Wed, 24 April 2019 10:56] by Moderator

Report message to a moderator

Re: Possible new package or overhaul proposals for U++ in 2019 [message #51617 is a reply to message #51614] Sat, 20 April 2019 00:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Fri, 19 April 2019 22:50
mirek wrote on Sat, 13 April 2019 07:07
These are things I would like to have solved, but do not have resources to:

- Fix uldar - old U++ linker for mingw by Tomas Rylek, that is superfast (compared to ld.exe supplied with mingw), but unfortunately stopped working around mingw 2012 version. This would make mingw much more attractive for us (well, there is still that poor TLS handling, but maybe that will get solved over time too).

I personally would take a look at LLD first. Gold linker is supposed to be several times faster than ld, but it doesn't support PE/COFF. LLD is supposed to be several times faster than the gold linker, and it supports PE/COFF. So, there is no need to reinvent the wheel.


Absolutely! Anyway, the goal is to integrate it with mingw. Will that be possible?

[Updated on: Sat, 20 April 2019 01:01]

Report message to a moderator

Re: Possible new package or overhaul proposals for U++ in 2019 [message #51619 is a reply to message #51617] Sat, 20 April 2019 01:05 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mirek wrote on Fri, 19 April 2019 18:56
Absolutely! Anyway, the goal is to integrate it with mingw. Will that be possible?

I think, yes, this should be possible. I'll try to do that.


Regards,
Novo
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51656 is a reply to message #51619] Tue, 23 April 2019 16:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 20 April 2019 01:05
mirek wrote on Fri, 19 April 2019 18:56
Absolutely! Anyway, the goal is to integrate it with mingw. Will that be possible?

I think, yes, this should be possible. I'll try to do that.


I was going through web investigating this and just to clarify: Even better would be using clang and its linker...

It looks like it should be possible to combine mingw libraries with clang toolchain...

I am really surprised that something like that is not already somewhere for download.

Mirek

[Updated on: Tue, 23 April 2019 16:39]

Report message to a moderator

Re: Possible new package or overhaul proposals for U++ in 2019 [message #51657 is a reply to message #51656] Tue, 23 April 2019 17:29 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mirek wrote on Tue, 23 April 2019 10:38

I was going through web investigating this and just to clarify: Even better would be using clang and its linker...

It looks like it should be possible to combine mingw libraries with clang toolchain...

I am really surprised that something like that is not already somewhere for download.

Mirek

AFAIK, no one is allowed to distribute mingw. That is the problem ...
clang can be combined with Microsoft SDK as well ... In this case it is called clang-cl ...
I'll try to check clang with mingw later. I need to work on my own stuff now ...


Regards,
Novo
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51663 is a reply to message #51657] Wed, 24 April 2019 09:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Tue, 23 April 2019 17:29
mirek wrote on Tue, 23 April 2019 10:38

I was going through web investigating this and just to clarify: Even better would be using clang and its linker...

It looks like it should be possible to combine mingw libraries with clang toolchain...

I am really surprised that something like that is not already somewhere for download.

Mirek

AFAIK, no one is allowed to distribute mingw. That is the problem ...


Nonsense. Mingw (those parts except the GNU compiler) is public domain.

Quote:

clang can be combined with Microsoft SDK as well ... In this case it is called clang-cl ...
I'll try to check clang with mingw later. I need to work on my own stuff now ...


OK, so I have tried... Clang 8.0.0. does not seem to work with mingw.

However, 7.0.0 does, after fixing some issues here and there, with ld.exe. That would be more than enough, 7.0.0 is late 2018 release.

The only problem is that I am so far unable to make ldd.exe work. I am able to compile with "-fuse-ld=lld" and everything seems fine, unfortunately resulting .exe just crashes. So it all leads to nowhere - complete recompile of GUI app is 12 seconds for clang and 17 seconds for that damned slow ld.exe to link results....

I am attaching .bm....

Maybe it would be better to try in Microsoft SDK mode? Perhaps mingw Win32 libraries and headers would import to clang-cl?
  • Attachment: CLANG.bm
    (Size: 1.12KB, Downloaded 201 times)
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51664 is a reply to message #51663] Wed, 24 April 2019 09:50 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
A couple of years ago I did manage to compile normal C++ with windows precompiled clang and Windows SDK.

It had a few bugs though, mainly the feature you use in U++ to check for leaks, did not work.
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51667 is a reply to message #51664] Wed, 24 April 2019 10:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 24 April 2019 09:50
A couple of years ago I did manage to compile normal C++ with windows precompiled clang and Windows SDK.


Yeah, thats simple. I can compile with mingw SDK as well. The only problem is that damned linker, which is the whole point of trying.

If it had a faster linker, "mingw" version would be 1000% more attractive. Hell, I might even use it on windows for production development...

Mirek
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51668 is a reply to message #51667] Wed, 24 April 2019 10:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have tried to ask here:

https://stackoverflow.com/questions/55825807/using-llvm-link er-lld-with-mingw
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51675 is a reply to message #51668] Wed, 24 April 2019 14:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have tried snapshot of clang 9.0.0 and it actually works!

Interestingly, even those TLS variables are properly optimized (unlike mingw gcc). Linking GUI app now takes 0.2s.

There are some problems with TLS variables in inline code, but fixing those is possible. Also, <float.h> needed a bit of fixing.

The only problem seems to be that clang is 1.5GB beast. I hope it will be possible to prune it a bit...

Mirek
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51676 is a reply to message #51675] Thu, 25 April 2019 07:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Even better: I have tried to simply replace ld.exe in mingw with clang's (9.0.0) lld.exe and everything works!

Here are times:

with original ld.exe

C:\upp\out\examples\MINGWx64.Debug.Debug_Full.Gui\AddressBoo k.exe (39524957 B) linked in (0:19.68)


with lld.exe

C:\upp\out\examples\MINGWx64.Debug.Debug_Full.Gui\AddressBoo k.exe (36620800 B) linked in (0:00.27)

Thank you Novo for pointing me in the right direction. This is really significant step ahead!
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51685 is a reply to message #51676] Thu, 25 April 2019 16:14 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mirek wrote on Thu, 25 April 2019 01:57
Even better: I have tried to simply replace ld.exe in mingw with clang's (9.0.0) lld.exe and everything works!

Here are times:

with original ld.exe

C:\upp\out\examples\MINGWx64.Debug.Debug_Full.Gui\AddressBoo k.exe (39524957 B) linked in (0:19.68)


with lld.exe

C:\upp\out\examples\MINGWx64.Debug.Debug_Full.Gui\AddressBoo k.exe (36620800 B) linked in (0:00.27)

Thank you Novo for pointing me in the right direction. This is really significant step ahead!

No problem.
I'm glad to help.


Regards,
Novo
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51725 is a reply to message #51685] Fri, 03 May 2019 10:27 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I upgraded to 13076 and there is no lld.exe inside.

Did you replace the executable with the same name or is this not included for testing yet?
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51727 is a reply to message #51725] Fri, 03 May 2019 11:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 03 May 2019 10:27
I upgraded to 13076 and there is no lld.exe inside.

Did you replace the executable with the same name or is this not included for testing yet?


Yes, it is renamed to ld.exe.

You can easily detect its presence by mingw link times... Smile

Mirek
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51728 is a reply to message #51727] Fri, 03 May 2019 15:11 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
mirek wrote on Fri, 03 May 2019 12:50
cbpporter wrote on Fri, 03 May 2019 10:27
I upgraded to 13076 and there is no lld.exe inside.

Did you replace the executable with the same name or is this not included for testing yet?


Yes, it is renamed to ld.exe.

You can easily detect its presence by mingw link times... Smile

Mirek

Thanks!

Next, we need to use clang to compile Smile.
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51729 is a reply to message #51728] Fri, 03 May 2019 17:49 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
cbpporter wrote on Fri, 03 May 2019 09:11

Next, we need to use clang to compile Smile.

I personally would recommend to be careful with clang. I always thought that clang on Linux is the best C++ compiler ever, but a few days ago I've ported my old app written for msvc to clang and got very unpleasant results. The app itself is big and complicated, written in 99.99% C++98 (keyword "auto" is used only once), but it has a lot of CRTP, static visitors and similar stuff. Now the app won't compile with GCC and MSVC, and it is crashing in the places where it used to work before.

IMHO, ideally, U++ should be tested against GCC, MSVC, and Clang.


Regards,
Novo
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51730 is a reply to message #51728] Sat, 04 May 2019 08:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 03 May 2019 15:11
mirek wrote on Fri, 03 May 2019 12:50
cbpporter wrote on Fri, 03 May 2019 10:27
I upgraded to 13076 and there is no lld.exe inside.

Did you replace the executable with the same name or is this not included for testing yet?


Yes, it is renamed to ld.exe.

You can easily detect its presence by mingw link times... Smile

Mirek

Thanks!

Next, we need to use clang to compile Smile.


Interestingly, from my tests, mingw / lld might be now ideal combo for Win. Clang is not faster compiler and does not produce better code than GCC 8. It even now seems that mingw/lld might be slightly better than Visual C++. The produced code seems a little bit more refined, link times are virtually zero while Visual C++ linker is fast, but still takes a couple of seconds to link large app (like theide). Compile times are about 2x worse, but in normal development cycle link times might be more important.

The only problem with mingw was horrible TLS implementation, but I have now workaround for that for the next release.

Mirek
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51738 is a reply to message #51730] Fri, 10 May 2019 11:49 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

Does MinGW support linking against external binary libraries created with MSVC?

Also, are structs binary compatible with MSVC?

Best regards,

Tom
Re: Possible new package or overhaul proposals for U++ in 2019 [message #51743 is a reply to message #51738] Sat, 11 May 2019 16:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 10 May 2019 11:49
Hi,

Does MinGW support linking against external binary libraries created with MSVC?


I guess it depends on a lot of things, but generally, yes. Funny part is that whereas you need import library for MSC, mingw links directly .dll Smile

Also, are structs binary compatible with MSVC?

Quote:

Best regards,


As far as I can tell, yes.

[Updated on: Sat, 11 May 2019 16:05]

Report message to a moderator

Re: Possible new package or overhaul proposals for U++ in 2019 [message #51744 is a reply to message #51743] Sat, 11 May 2019 19:29 Go to previous messageGo to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
On compatibility of Clang with MSVC: MSVC compatibility
On C++ ABI compatibility in general: C++ binary compatible API (ABI)


Regards,
Novo
Previous Topic: Two new nasty GCC warnings that I am going to disable
Next Topic: Example websocket SSL
Goto Forum:
  


Current Time: Thu Mar 28 09:36:52 CET 2024

Total time taken to generate the page: 0.02176 seconds