Author Topic: Clang based CC, new CC interface  (Read 39357 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: Clang based CC, new CC interface
« Reply #15 on: January 16, 2014, 10:26:17 pm »
You got a working Clang on Windows? How so?
I downloaded Clang for Windows form here, installed it, added the proper paths to the project file, and it just worked (which did actually surprise me).  Windows .cbp is now committed.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Clang based CC, new CC interface
« Reply #16 on: January 17, 2014, 11:33:48 am »
Oh wow... last time I checked, that page had something "Windows support is troublesome, but we have a 3.2 experimental build for MSVC only". I had tried their "build from source" instructions (using MinGW, but that failed miserably).

Great, I'll have a look, thank you :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Clang based CC, new CC interface
« Reply #17 on: January 17, 2014, 11:42:15 am »
That doesn't seem to have anything like WinAPI headers (or libs) or even C++SL, need to copy those over from MinGW?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 4998
Re: Clang based CC, new CC interface
« Reply #18 on: January 17, 2014, 01:10:33 pm »
as for linux, distros have clang, but for a modern C++ developer  :P , you want to use C++11, and then the problem starts, you need their new libc++ library implementation.
As far as i know still hard or impossible to have that on linux, unless someones can tell me otherwise (an the how ) ...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: Clang based CC, new CC interface
« Reply #19 on: January 17, 2014, 01:50:37 pm »
That doesn't seem to have anything like WinAPI headers (or libs) or even C++SL, need to copy those over from MinGW?
I've seen that, too - in fact I am monitoring this site. The thing is, you can and have to adjust the compiler config to make use of another compiler that provides those API. If I am not mistaken, this works well with that release for VC, but I doubt it will work reliable for MinGW. What I did was compiling clang itself using MinGW (based on Makefiles created for Code::Blocks using cmake) which ensure ABI compatibility with that compiler. Then you can adjust the compiler settings so they point to exactly this MinGW distribution - and have to add very low-level include folders so it actually FINDS the references. This depends on the standard used, so its really fiddling with settings.

Well - that's how far I came. Compiling a very basic app works, but I am far from compiling anything else than that. At linking time you'll see that (i.e.) wxWidgets needs better to be compiled with clang before, too. And so on...

Still a never-ending story. I'm afraid its still no prime time on Windows, yet. :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Clang based CC, new CC interface
« Reply #20 on: January 17, 2014, 03:56:28 pm »
The way this download page looks, there should actually be C++ standard library somewhere. It starts with "sources", and among these is LibC++, which I assume is CLang's equivalent of glibc++. But I can't find it anywhere in the installed compiler. Be nice if they had something like "install instructions", hehehe...

So basically CLang seems to work, as long as you don't try anything like #include <algorithm> or #include <vector>. It compiles and links int main() { return 0; } lightning fast, too  :P. If only it worked for anything else as well...

Well, maybe in 3-4 months. They do seem to be working on getting something usable together.

Quote
What I did was compiling clang itself using MinGW
Sadly, wasting days and days on compiling compilers to no avail is something I can't afford any more :(
For me, it really has to work by unpacking a .tar.gz or a .zip file, or by double-clicking an installer.

(Or, in the most extreme case, a script that I need to run unattended (and leave the computer on over night) to do a fully automatic build. But that one had better work without guessing and trying afterwards.)
« Last Edit: January 17, 2014, 04:01:02 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: Clang based CC, new CC interface
« Reply #21 on: January 17, 2014, 04:52:44 pm »
So basically CLang seems to work, as long as you don't try anything like #include <algorithm> or #include <vector>. It compiles and links int main() { return 0; } lightning fast, too  :P. If only it worked for anything else as well...
That basically summarises my experience except hat I provided a C library through MinGW but the linker complained anyways.

Well, maybe in 3-4 months. They do seem to be working on getting something usable together.
I am waiting ~1,5 years now.

Sadly, wasting days and days on compiling compilers to no avail is something I can't afford any more :(
I never compiled compilers before at all, but this one is rather easy, as configuring, adjusting and start compiling takes ~10 minutes and uses Code::Blocks which works on Windows. Otherwise I wouldn't have wasted my time.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: Clang based CC, new CC interface
« Reply #22 on: January 17, 2014, 05:15:45 pm »
I downloaded Clang for Windows form here, installed it, added the proper paths to the project file, and it just worked (which did actually surprise me).
Oh, sorry, I should have specified.  By 'worked' I was referring to linking with this plugin, and providing access to its AST and CC.

When initializing a unit with libclang, it takes flags as if compiling through the console.  As part of the flags, my plugin passes it the search paths of MinGW's headers.  Because that seems to have worked in the plugin, maybe it will work for compiling as well... I will do some tests.

Offline Ivan171

  • Single posting newcomer
  • *
  • Posts: 1
Re: Clang based CC, new CC interface
« Reply #23 on: January 18, 2014, 09:26:52 am »
Hi, i'm new to the forum. First of all english is not my native language, so, bear with me.

Well, my experience with clang is not that bad. Everything i've tried to compile with it up to now, have worked pretty well (Although i use it mostly for testing purposes at the moment). Including C++, which i see a lot of people saying it doesn't work on Windows. It does work. At the moment, Clang from svn, is able to bootstrap on Windows (using Mingw 4.7+).

But it have some issues, like, dllimport/dllexport does not work for classes. It doesn't support Win64 EH (There's no exceptions at all on Windows 64). This issues is being worked on by the way.

Clang 3.4 does not work with Mingw 4.7+ due to ABI incompatibilities.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: Clang based CC, new CC interface
« Reply #24 on: January 29, 2014, 05:46:20 am »
A few glamour shots of this plugin.

Operator resolution (also right click, jump to declaration works).


Syntax highlighting in documentation popups.


Dynamic checking of code validity.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1575
Re: Clang based CC, new CC interface
« Reply #25 on: January 29, 2014, 04:33:40 pm »
Looks terrific (btw, you can also use the README.md or README.rst to embed screen shots  on the github page using a dir in your repo to place the images. Nice feature of github IMO)

I am sure I could figure out myself, but...

* Which docstring formats are you able to highlight code for? (What tool are you using to do the highlighting?)

* Is the dynamic check highlighting a scintilla feature (can they be hidden by clicking on them or something?) Are you making hooks in the CC manager to make this easy for all plugins to do? (Or is it easy to do without hooks). I want to do something similar for python.

Offline Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: Clang based CC, new CC interface
« Reply #26 on: January 29, 2014, 05:51:44 pm »
Splendid work Alpha !
Kernel Extremist - PedroM power

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 9938
Re: Clang based CC, new CC interface
« Reply #27 on: January 29, 2014, 09:52:51 pm »
The last image is interesting. Can you try to explain how it works and what kind of API do you use?
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1575
Re: Clang based CC, new CC interface
« Reply #28 on: January 29, 2014, 10:12:42 pm »
The last image is interesting. Can you try to explain how it works and what kind of API do you use?

Looks like just an editor hook, then uses wxScintilla annotations:

See, esp. DiagnoseEd, in https://github.com/alpha0010/ClangLib/commit/6a0c09cf1cd39448d6fa6d022afd9f3a0bed6ebb#diff-2c47c86d730d3c95d68ec3fa39ad7e7bR719

Would be nice if some of this moved out of the plugin and into the SDK, but I haven't thought about how practical that is.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 9938
Re: Clang based CC, new CC interface
« Reply #29 on: January 30, 2014, 12:16:16 am »
100% should be part of the SDK...
Does clang provide both CC info + errors/warnings info with a single compile/parse?
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]