Home » Eclipse Projects » Eclipse Titan » Accelerate your Titan compilation with clang compiler and gold linker
|Accelerate your Titan compilation with clang compiler and gold linker [message #1733511]
||Sun, 29 May 2016 09:14
|| Elemer Lelik
Registered: January 2015
As you may have observed, Titan is a two-stage compiler:
in the first step, C++ code is generated from TTCN-3;
from this onwards, the project behaves as a regular C++ project:
a C++ compiler will create object files from the C++ code,
and then the linker will link these object files into an executable.
The second stage, creating object files, is usually the most time consuming part:
for large and complex projects (millions of lines of TTCN-3 code, heavy ASN.1) compilation could take hours.
Linking might take minutes, and the first stage is usually the fastest (seconds-tens of seconds).
Although some optimization can be applied to the first stage (e.g. disabling generation of unneeded codecs),
we will focus now on the second and third step.
First of all, one should take advantage of the multi-core architecture if possible:
a build started with
will execute on a single processor,
will engage four processors in parallel.
Secondly, although gcc produces stable and robust results, clang (https://en.wikipedia.org/wiki/Clang, http://clang.llvm.org/) comes with
the promise of a compatible, but faster compilation, at the expense of a somewhat slower binary.
Indeed, in our measurements clang-3.8 compiled faster than gcc versions 4.8 to 5.3 tested, although clang seems to lose it's advantage.
However it's an alternative worth considering (your binary might run somewhat slower, but this will impact only projects with strict performance requirements).
As announced, from version 5.5.0 Titan has support for clang.
To be able to use clang, one has to build Titan with clang, C++ compiler consistency being a basic requirement for Titan.
So the first step to be taken is to install clang. We have tested and we recommend clang 3.8 so I will refer to that version.
On Ubuntu 14.04, for instance, installing clang it's as simple as:
sudo apt-get update
sudo apt-get install clang-3.8
but it can of course also be installed from source.
Next, download the source code of Titan
git clone https://github.com/eclipse/titan.core
and build and install according to the information in README.linux, with one difference: Makefile.personal should reference clang++ and clang. For example:
TTCN3_DIR := /home/someuser/titan.core/Install
OPENSSL_DIR := /usr
XMLDIR := /usr
JNI := no
GEN_PDF := no
CXX := clang++-3.8
CC := clang-3.8
If compilation and installation is successful, compiler -v should return something like:
TTCN-3 and ASN.1 Compiler for the TTCN-3 Test Executor
Product number: CRL 113 200/5 R5A
Build date: May 29 2016 09:08:29
Compiled with: clang 3.8.1
Copyright (c) 2000-2016 Ericsson Telecom AB
OK, now you can start using your new, accelerated Titan.
If you will (re-)generate a new project Makefile, makefilegen will automatically place compiler version information into it:
# Your C++ compiler:
# (if you change the platform, you may need to change the compiler)
CXX = clang++-3.8
Else, you may need to add this manually.
The gold linker (https://en.wikipedia.org/wiki/Gold_(linker) )is probably already on your Linux distribution, so in order to use it,
simply add the following linker flag to the project Makefile:
# Flags for the linker:
LDFLAGS = -fuse-ld=gold
Now, do a
if needed in your project to get rid of old, incompatible object files ,
start a new build with
(where x is the number of processors you want to run the compilation in parallel)
and happily observe your accelerated Titan.
Current Time: Wed Sep 19 06:02:20 GMT 2018
Powered by FUDForum
. Page generated in 0.01543 seconds