Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 is currently offline Elemer LelikFriend
Messages: 807
Registered: January 2015
Senior Member

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,

make -j4 

will engage four processors in parallel.

Secondly, although gcc produces stable and robust results, clang (, 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

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
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:

compiler -v
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 ( )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

make clean 

if needed in your project to get rid of old, incompatible object files ,
start a new build with

make -jx 

(where x is the number of processors you want to run the compilation in parallel)
and happily observe your accelerated Titan.

Best regards

Previous Topic:Eclipse Titan 5.5.0 binaries available
Next Topic:modifies keyword not working
Goto Forum:

Current Time: Wed Sep 19 06:02:20 GMT 2018

Powered by FUDForum. Page generated in 0.01543 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top