I saw that the libstdc++ Profile Mode has been deprecated recently (see GCC 7 changes).
I just know that the Profile Mode provides some useful suggestions about the usage of c++ standard library. But since it is deprecated, how to get similar suggestions instead?
I'd suggest looking at Callgrind and KCacheGrind as UI. A quick search presented these results:
How to profile C++ application with Callgrind / KCacheGrind
Callgrind: Profile a specific part of my code
Related
I'm trying to write a plugin to clang or gcc to interpret custom [[cxx11::attributes]] and generate some code based on that.
Since version 4.5, gcc supports plugins that can be hooked at almost every compilation steps. However, I think gcc is not very clear about how modify its AST and navigate through it (at least I'm having a bad time trying...).
Then I remembered that clang was designed to be extended and used as a library and I gave it a shot. After digging around I found some topics saying clang does not support custom attributes. I cried.
My main goal is to generate code based on any kind of annotations that user can use at code. I'd like to use c++11 attributes because they are very clear. Pragmas are also an option but they have some limitations.
Here are the questions:
1) Is it really (currently) impossible to have custom attributes in clang?
2) What is the best way to learn gcc internals? (I read lots of pages of documentation but still they didn't say what I want)
3) Does gcc have some dump function to print its AST like clang does? It would help a lot to explore its tree.
Thank you! Any information/tip would be appreciated!
GCC plugins are specific to GCC, and even (in principle) to a particular version of GCC (there is no guarantee that a plugin coded for GCC 4.8 would work on GCC 4.9).
You might consider extending GCC with MELT, which is a lispy domain specific language to extend GCC, implemented as a GCC (meta-) plugin.
However, you need to understand the internal representations of GCC (Gimple, Trees, the pass manager, ...). Read first my slides on GCC plugins thru the MELT example (Linux Collaboration Summit, march 2014)
You can easily add GCC attributes with plugins and with MELT, and probably also C++11 attributes.
And yes, GCC has a lot of possible dumps (try using -fdump-tree-all).
You'll better use recent versions of GCC (e.g. 4.9.1) and of MELT (e.g. 1.1.2 or later; I'll probably release MELT 1.1.3 within a week or two)
What Installation package would you suggest for both IDE for C++ with CLang on Linux as of now 2013? Fresh Start.
I would want to test Modern C++ 11 feature complete syntax . Ease of installation of components is a concern. Console output is fine for now. GUI rendering is secondary.
1. IDE Graphical with the luxury of menus and panels
2. LLVM Clang tool chain
I am aware of SourceForge but I may not understand their summary and documentation to find what I want. A specific link on which I can click in a web page would be appreciated.
I tend to believe this is a rather ordinary question. Please tell me if it is not.
I want to experience the more expressive error messages with Clang. I am not concerned with MS Windows compatibilty.
Thanks for you suggestions.
we have C++ code that we want to profile with Nividia Nsight Eclipse (Linux version) before adding CUDA code to it. The idea is to profile C++ first, find hotspots, convert those to CUDA, profile again, and iterate through this process to successively speed up the code. However, when we profile C++ only it looks like the profiler requires some existing CUDA code before it generates a timeline and profile output. Has anyone else encountered this?
Nsight Eclipse Edition can only profile CUDA code. You may want to install 3rd party profiling plug-ins to profile host code.
You may try installing OProfile integration from the Eclipse Foundation site (paste http://download.eclipse.org/releases/indigo/ into Help/Install New Software... dialog) - I just tried it but was unable to properly setup oprofile command-line.
You can manually instrument your code using nvtx (NVIDIA Tools Extension) and have the timeline shown in Nsight, but for automatic profiling and detailed counters it can only profile GPU code.
Yes, Nsight Eclipse can profile C++ code. To rephrase your question, it can also profile Host (CPU) C++ code. By default, it only profiles GPU code. CPU profiling is a much more manual task; it will not profile functions automatically.
You need to use NVTX. Like so:
#include "nvToolsExt.h"
nvtxNameOsThread(0,"InputVideo");
nvtxRangePush(__FUNCTION__);
// .. do some CPU computing here
nvtxRangePop();
Build with -lnvToolsExt -L/usr/local/cuda/lib64
The path to libnvToolsExt.so will be different for everyone. NVTX comes with the CUDA Toolkit.
The CUDA blog has a post on this.
The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program.
Is "produce LLVM C++ API code" output a clang option (and if so, what is it)?
Or is it an llvm tool option (which one)?
Is it possible to do the same thing but from LLVM-IR input? Basically I'd like to see the proper llvm c++ api calls needed to produce a particular given llvm-ir sequence. I'd like to learn backwards by example rather than forwards from the documentation.
Manual pages and --help and --help-hidden for clang, llvm-as and llvm-dis don't show anything obvious.
edit: OK now I see in the output on that web page, "generated by llvm2cpp". But I can't find that tool in recent llvm releases, only old releases, has a new tool in 2.9 and 3.0 taken over for llvm2cpp?
Yes. C++ backend is the tool which does this. Try "llc -march=cpp foo.bc"
I ran into exactly the same problem and saw the CPPBuilder mentioned a couple of times. This approach unfortunately no longer works on recent LLVM versions as the CPPBackend was removed between 3.8 and 3.9.
If you want the CPP backend you (i) have to configure llvm and add cppbackend to -DLLVM_TARGETS_TO_BUILD during the initial configure and (ii) run an llvm <= 3.8.
The feature was removed because it did not use IRBuilder and almost nobody used it. My solution was to rely on the old version to get inspired, then implement it myself.
The clang C++ compiler claims to be built for, among other things, better IDE integration by providing an API for the IDE to use for tasks such as parsing the code.
So, are there are any good C++ IDE's that use clang to provide features such as semantic highlighting, refactoring, and finding and showing semantic errors in real-time?
I've been using Eclipse CDT, but its C++ parser is full of imperfections that cause the IDE to report a lot of annoying false positive errors in the code. I would like to have an IDE that reports an error if and only if the compiler would report the same error, hence my interest in an IDE that's built on a compiler's internals.
I'm primarily interested in cross-platform IDE's, although I wouldn't mind knowing about single-platform ones for Windows or Linux (so not Xcode), as long as they are FOSS (another reason why not Xcode).
Qt Creator is basing their next-gen code parsing and associated functionality on Clang:
https://www.qt.io/blog/2011/10/19/qt-creator-and-clang
Looks very, very promising!
have you tried clang complete?
if you're punk rock, then vim is enough ide ;)
i often work with xcode so... can't really share firsthand experience, but i knew of its existence.
gedit isn't really an IDE, but there is a plugin for it that provides code assistance using clang
It seems that CodeLite v3.5 starts supports Clang natively. However I haven't found is it possible to setup LLVM as backend.
A relevant new development in this area in the Language Server Protocol (LSP) project, which aims to be a language-agnostic API that allows editors / IDEs to be decoupled from backends that provide code intelligence / analysis.
There is ongoing work to create a clang-based C++ backend called Clangd.
There is also ongoing work on several editors / IDEs to support the LSP as a client.
Once the backend implementation matures, all editors supporting the LSP will, in principle, be able to leverage clang's capabilities as exposed through Clangd.
KDevelop now has clang based c and c++ support, including semantic analysis and autocomplete. It is primarily for linux but (as of October 2016) has a beta release out for windows and mac as well.
For emacs there are irony-mode and rtags that provide features such as auto-complete, on fly error checking and jump to symbol. When combined with cmake-ide they are very powerful tools and one well versed in emacs can be highly productive in this environment.
Not FOSS, but JetBrains (of IDEA and ReSharper fame) are building out their AppCode product into a full C++ IDE supporting Win/Linux/Mac and using clang.
Yes, really.
jucipp
~900 stars on GitHub in 2019Q2: https://github.com/cppit/jucipp
Now moved to GitLab: https://gitlab.com/cppit/jucipp
Clearly advertises libclang backend as a main feature.