Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What (working) alternate toolchains exist for x86 C++ development on linux? [closed]

Tags:

c++

linux

gcc

clang

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.

like image 532
Offirmo Avatar asked Jan 05 '12 09:01

Offirmo


People also ask

What is a toolchain in Linux?

A toolchain is a set of distinct software development tools that are linked (or chained) together by specific stages such as GCC, binutils and glibc (a portion of the GNU Toolchain). Optionally, a toolchain may contain other tools such as a debugger or a compiler for a specific programming language, such as C++.

What are the different components into the toolchain?

The major components of a toolchain include, but aren't limited to, a compiler, an assembler, and a linker. The compiler is responsible for parsing source files written in a high-level programming language, such as C. The files are first translated into an intermediate language, used internally to the compiler.

Is GCC a toolchain?

GCC is a toolchain that compiles code, links it with any library dependencies, converts that code to assembly, and then prepares executable files.

Which of the following are provided by toolchain?

The toolchain contains GNU m4, GNU Make, GNU Bison, GCC, GNU Binutils, GNU Debugger and the GNU build system. Let's understand these tools one by one in detail.


3 Answers

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.

like image 104
Basile Starynkevitch Avatar answered Oct 11 '22 12:10

Basile Starynkevitch


I know of two alternatives :

  • tup
  • ninja build

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

like image 29
BЈовић Avatar answered Oct 11 '22 13:10

BЈовић


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

like image 25
neuro Avatar answered Oct 11 '22 12:10

neuro