Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: BlueHazzard on May 05, 2019, 01:50:01 pm

Title: GCC9 released with additional compiler output
Post by: BlueHazzard on May 05, 2019, 01:50:01 pm
Hi,
GCC 9 was released this week and while reading trough the release notes (https://gcc.gnu.org/gcc-9/changes.html) i found this: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-format JSON output of the compiler messages...
This would be very nice to have in codeblocks.

Is it acceptable to read the version of gcc after the first call or on startup and then use the json switch and use the json output for error reporting?
This is a general question and discussion of the following questions:
1) Parsing output differently for various version of gcc
2) UI Things... Can we implement a more targeted error reporting (column)
3) UI for giving hints how to fix this error
4) 2/3 are also relevant for more advanced cc plugins, can we use the same API for compiler errors and cc to the editor?
5) ecc...
Title: Re: GCC9 released with additional compiler output
Post by: oBFusCATed on May 05, 2019, 02:52:52 pm
1. We already do this I think. Generally we should get away from regexes, they are so slow and currently if some code produces tons of warnings the performance is really slow.
2. It is already possible, but someone needs to modify regexes
3. Generally this is done with two separate mechanisms:
  a. squiggle underlines like in VStudio
  b. annotations like in XCode (in fact Xcode uses both) See this random image: https://user-images.githubusercontent.com/20306622/36999160-478348e6-208d-11e8-99ea-5e776a7a0ab8.png

For 1 you'd use the Indicator API, for 2 you'd use annotation's api, but this won't achieve the same thing, so I guess scintilla would have to be modified. I think the way Xcode does it is better.

4. I'm not sure mixing the two is a good idea. But I guess we could implement some API to present/merge both results, if needed. Generally CC and compilation use different c/c++ parsers/frontend and these would never match, so we have to probably think about handling it. :(

p.s. Keep in mind performance it is really important. Currently parsing the log is really slow and in a project which generates tons of warnings the log is the bottleneck in compilation.
Title: Re: GCC9 released with additional compiler output
Post by: BlueHazzard on May 05, 2019, 04:21:18 pm
Yes, i would move away from regexp and use some dedicated json parser, like https://github.com/nlohmann/json or https://github.com/kazuho/picojson/ the later would be easy to integrate, because it is header only... But this is open for discussion...

Code
4. I'm not sure mixing the two is a good idea. But I guess we could implement some API to present/merge both results, if needed. 
I was talking about the visual side to the editor... Both show compiler errors/warnings at the editor level... the question is how to visualize them and then how to add this api to scintilla or cbEditor (or whatever)....

Quote
Currently parsing the log is really slow and in a project which generates tons of warnings the log is the bottleneck in compilation.
Parsing would be a lot faster with json... Do you know exactly where the bottleneck is? Pipe->parsing->output to wx control? I was always thinking the last is the bottleneck, but i did not make any tests or measurements, pure guessing from observation...
Title: Re: GCC9 released with additional compiler output
Post by: oBFusCATed on May 05, 2019, 05:01:29 pm
Be aware that most json parsers are plain slow. For my language server plugin, I was experimenting with the sajson lib. Probably moving directly to rapidjson is the best idea, because I'm not 100% happy with the sajons' API.

See here for details: https://github.com/miloyip/nativejson-benchmark

p.s. You don't need a lib to implement writing json. I've implemented minimal class which is perfectly fine and it is really fast in 100-200 lines. If you're interested I could share it.
Title: Re: GCC9 released with additional compiler output
Post by: oBFusCATed on May 05, 2019, 05:06:28 pm
Also check what is the output produced by clang. It has a similar mode. Probably you can make something that is working for both compilers.