9

I precise that I restrict this question to "native" development for my x86 (64bits) linux box. No embedded or non-x86 architecture.

Since I'm a C++ user and there is a C++ renaissance, I'm currently using C++ for personnal projects.

Right now I'm using the robust, traditionnal linux/gcc/make toolchain.

But through blog posts and SO questions, I recently became aware of new promising tools :

  • ''clang'' as an alternative for ''gcc'', a lot faster, giving better error messages
  • ''gold'' as a replacement of ''ld'', a lot faster

Those tools are less known and it's easy to not even know about them.

Are there other interesting less known tools that I should be aware of ? For example alternative to gdb or the like ? (I'm also using cmake)

I'm looking for ease of development first, then development speed improvement. Any other improvement is welcome.

Free tools if possible.

Offirmo
  • 18,962
  • 12
  • 76
  • 97
  • 1
    There's Intel's ICC compiler which comes with a debugger and other tools. It's free for non-commercial use on Linux, otherwise it costs. – Paul R Jan 05 '12 at 09:47
  • @PaulR Thanks Paul. Of course I'm more interested in free tools, and one that bring a notable improvement over the old ones. (Intel claims to add speed of execution but that's all I think) – Offirmo Jan 05 '12 at 09:51
  • As I said in my comment, ICC *is* free for non-commercial use on Linux. As well as good quality code generation it typically is the first compiler to have support for new CPU features (for obvious reasons), e.g. latest SSE, AVX, etc. – Paul R Jan 05 '12 at 10:32

3 Answers3

5

You could be interested by ccache (a compiler cache able to avoid useless recompilation, and transparently usable thru the same g++ command, just by adding a symlink inside your $PATH)

For C (but not C++) programming, you might be interested by tinycc - which compiles very quickly (but produce slowly running binary code).

When coding, the Boehm's garbage collector might be used. See this question related to using it in C++.

And also use valgrind to debug your memory leaks.

Sometimes, dynamically loading a shared object with dlopen is intersting. The dlsym-ed symbols should be extern "C" in C++. I sometimes love generating C or C++ code on the fly, compiling it, and dlopen-ing the module.

For building, consider investigating other builders, like e.g. omake.

When compiling, don't forget the -Wall (and perhaps -Wextra) flag to the compiler. The new link time optimization (with CXX=g++ -flto in your Makefile) could be interesting (but compile time suffers, for perhaps a 10% increase in speed of the executable).

If your source code files share all the same C++ header, pre-compiling that header is worthwhile.

Newer (e.g. better than C++) languages exist, like Ocaml and Haskell but also Go and D.

Use a version control system like GIT even for pet projects.

Qt is a good C++ framework, notably for its graphical toolkit.

Wt enables you to code in C++ quite quickly web interfaces.

Both GCC & GDB are still evolving. Don't forget to use the latest versions (eg 4.6 for GCC, 7.3 for GDB) which provide major improvements over earlier ones.

Consider extending or customizing your GCC compiler for your particular needs thru plugins or better yet using MELT extensions.

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • OK lot of answers here (I wouldn't go as far as changing language, let's keep this question on track). tinycc is C only, too bad. I'm interested in the garbage collector, taking a look. – Offirmo Jan 05 '12 at 10:44
  • @Basile Starynkevitch -- +1 for mentioning -Wall, necessary for all builds. – Pete Wilson Jan 05 '12 at 10:46
  • I never heard of MELT, looks very interesting, thanks ! – Offirmo Jan 05 '12 at 10:54
  • I'm the main author of MELT, so I really would be delighted to answer any questions!!! – Basile Starynkevitch Jan 05 '12 at 10:57
  • @BasileStarynkevitch that's nice. Could I have a link to an actual use case of MELT usage improving C++ development ? I can't (easily) find any. – Offirmo Jan 05 '12 at 11:35
  • I have no simple example of that yet. Extending GCC (either in C with plugins, or in MELT) require understanding most of GCC internal representations (and often require handling a lot of it), and that take some time. But Mozilla used their own GCC plugins (TreeHydra) for big C++ code (the Firefox browser). – Basile Starynkevitch Jan 05 '12 at 11:38
  • @Offirmo: There will be a GCC MELT tutorial at HiPEAC conference, Paris (France) 24th january 2012 – Basile Starynkevitch Jan 05 '12 at 21:14
4

I know of two alternatives :

Both can replace make, because they are faster for big projects, since they do not do so extensive checks.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
  • +1 Very interesting, thanks. "Make vs Tup" looks promising. Do you use it yourself ? Now what we need it a tup generator for cmake. I see that there are some efforts in this direction. – Offirmo Jan 05 '12 at 10:38
  • @Offirmo My colleague is working to switch from make to tup, and he mentioned some 30% improvement. – BЈовић Jan 05 '12 at 10:47
1

For replacing the make part of the toolchain I recommend waf which is fast and has a small footprint. The support is quite good as well.

I've tried gold which was not that faster than ld, but seems to be promising. It does not seem to be really maintened though, last time I've checked.

clang seems quite promising, but I have not tried it in a production project. I plan to, as its well thought design leads to really fast development. I plan to use it to switch to C++11 ^^

my2c

neuro
  • 14,948
  • 3
  • 36
  • 59
  • 1
    Gold is maintained, but is now quite mature in practice. Google has an active interest in Gold. – Basile Starynkevitch Jan 05 '12 at 10:38
  • 1
    Currently, GCC 4.6 seems to have a slightly better C++11 support than clang 3.0 – Basile Starynkevitch Jan 05 '12 at 10:44
  • I'm currently using LLVM GCC (basically clang) on OSX at the moment and I find it really fast for compilation and general development. In XCode, clang is constantly building the symbol tables in the background which makes code completion responsive and contextually aware and as mentioned previously, reduces compilation/build time. – Ian Thompson Jan 05 '12 at 11:04
  • @Basile: Thanks for the info. Have you tried it on a big project linking thousands of objects files ? – neuro Jan 05 '12 at 12:22
  • @Basile: OK. I've not checked gcc 4.6 vs last clang. Will do that before testing clang with C++11 :) – neuro Jan 05 '12 at 12:24
  • Google uses gold to build an executable of huge size (more than half a gigabyte). – Basile Starynkevitch Jan 05 '12 at 15:37