Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Relaxing the C/C++ compiler version check for Titan 7.1.1(compiler, version, gcc, clang)
Relaxing the C/C++ compiler version check for Titan 7.1.1 [message #1829398] Thu, 02 July 2020 17:03 Go to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Dear all,

delivery of Titan binaries is targeted to Linux distributions; this means that we
build a binary for the environment ( dependencies, C compiler versions, openSSL versions)
that defines a certain Linux distribution in the very beginning of its lifecycle.

The version of C compiler used has proved critical for certain gcc releases, as older gcc versions did not
generate compatible object/library files, so say one could not mix libraries compiled with gcc 2.95 and libraries
compiled with gcc 4.8.1 (This is a random example I did not verify but sounds about right).
To prevent mixing of incompatible binaries generated by different versions of C compilers, Titan imposed a strict version checking,
demanding the C compiler make and version to be used to build executables with Titan to be the same as
the compiler make and version that has been used to build Titan binaries and libraries.
In some situations this lead to the following complication: as Linux distributions have been upgraded, so has been the gcc compiler version
within the distro, which rendered Titan unwilling to continue and to throw an error as below:

 make
/proj/TTCN/Releases/TTCNv3_daily_LMWP3.4/bin/compiler -L  \
	RAWTest2.ttcn  - RAWTest2.ttcn
Notify: Parsing TTCN-3 module `RAWTest2.ttcn'...
Notify: Checking modules...
Notify: Generating code...
Notify: File `RAWTest2.hh' was generated.
Notify: File `RAWTest2.cc' was generated.
Notify: 2 files were updated.
touch compile
g++  -c -DLINUX -I/proj/TTCN/Releases/TTCNv3_daily_LMWP3.4/include -Wall   -o RAWTest2.o RAWTest2.cc
In file included from /proj/TTCN/Releases/TTCNv3_daily_LMWP3.4/include/TTCN3.hh:42,
                 from RAWTest2.hh:19,
                 from RAWTest2.cc:11:
/proj/TTCN/Releases/TTCNv3_daily_LMWP3.4/include/cversion.h:7:2: error: #error The version of GCC does not match the expected version (GCC 4.3.4).
    7 | #error The version of GCC does not match the expected version (GCC 4.3.4).
      |  ^~~~~
make: *** [RAWTest2.o] Error 1


In such a case, Titan had to be rebuilt for its new environment, with the new C compiler version.

However, this practice may have become obsolete in case of newer gcc and clang versions, as apparently these come with a certain guarantee
regarding their capacity to generate compatible binaries.

For details please see
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

Version checking has been extremely strict, requiring that all three version numbers (major level, minor level, patch level ) be the same.
Some time ago the rule has been somewhat relaxed (patch level equality not being required anymore) , but this proved to be insufficient.

Besides, from gcc version 5 numbering changed and uses three numbers as below:

<major_version>.<patch_level>.0

The third number does not refer to patch level as before but to the version being a released or development one:
0 released
1 dev branch

So for instance:
7.4.0 released, 4th patch of the GCC7
7.4.1 The dev branch during the development of the 4th patch of the GCC7, after release become 7.4.0

Clang also dropped minor versions from Clang5.

so in summary the version numberings are:
GCC: <major>.<patch>.0
Clang: <major>.0.<patch>

To adapt to these changes, and especially to the promise of compatible binaries, we have decided to relax the version checking
for the newest versions of compilers starting from Titan 7.1.1 (as tagged in github) as below:

-Titan libraries compiled with gcc 5.1.0 or above can be used with object files/libraries compiled with any version of gcc 5.1.0 or above
(e.g. Titan built with gcc 5.1.0 will work with an installed gcc 10.1)

-Titan libraries compiled with clang 5 or above can be used with object files/libraries compiled with any version of clang 5 or above
(e.g. Titan built with clang 5 will work with an installed clang 10)

This assumption has not been tested for all gcc or all clang version combinations, however it has been satisfactorily
tested with the lowest version (higher than 5) and the latest versions of compilers.

Mixing gcc and clang objects/libraries (although apparently technically possible) is not recommended; we see no advantage but
potential downsides to it.

The assumption has been tested with both static and dynamic linking, and both with the gcc linker and the gold linker.

A practical example follows:

I have built a Titan 7.1.1 with the latest code from github with gcc 5.1.0.
This can be verified with the compiler binary:
compiler -v
TTCN-3 and ASN.1 Compiler for the TTCN-3 Test Executor
Product number: CRL 113 200/7 R1B
Version: 7.1.pl1
Build date: Jul  2 2020 17:36:40
Compiled with: GCC 5.1.0
Using OpenSSL 0.9.8j-fips 07 Jan 2009

Copyright (c) 2000-2020 Ericsson Telecom AB


and also with the libraries in ~Install/lib, e.g.
readelf -p .comment libttcn3.a

File: libttcn3.a(TitanLoggerApi.o)

String dump of section '.comment':
  [     1]  GCC: (GNU) 5.1.0


File: libttcn3.a(TitanLoggerControl.o)

String dump of section '.comment':
  [     1]  GCC: (GNU) 5.1.0
:
: lines removed here
:

File: libttcn3.a(Single_main.o)

String dump of section '.comment':
  [     1]  GCC: (GNU) 5.1.0


When changing gcc to gcc 9.3.0
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/afs/yyy.xxx.company.com/app/vbuild/SLED11-x86_64/gcc/9.3.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /local/repo/afsworker/working/gcc-9.3.0/configure --prefix=/app/vbuild/SLED11-x86_64/gcc/9.3.0 --enable-languages=c,c++,fortran --enable-libmpx --with-as=/app/vbuild/SLED11-x86_64/binutils/2.30/bin/as --with-ld=/app/vbuild/SLED11-x86_64/binutils/2.30/bin/ld --with-gnu-as --with-gnu-ld --with-isl=
Thread model: posix
gcc version 9.3.0 (GCC) 


Titan will complain, but will compile notwithstanding:
make
/home/ethlel/titan.core/Install/bin/compiler -L  \
	RAWTest2.ttcn  - RAWTest2.ttcn
Notify: Parsing TTCN-3 module `RAWTest2.ttcn'...
Notify: Checking modules...
Notify: Generating code...
Notify: File `RAWTest2.hh' was generated.
Notify: File `RAWTest2.cc' was generated.
Notify: 2 files were updated.
touch compile
g++  -c -DLINUX -I/home/ethlel/titan.core/Install/include -Wall   -o RAWTest2.o RAWTest2.cc
In file included from /home/ethlel/titan.core/Install/include/TTCN3.hh:42,
                 from RAWTest2.hh:19,
                 from RAWTest2.cc:11:
/home/ethlel/titan.core/Install/include/cversion.h:7:2: warning: #warning The version of GCC does not match the expected version (GCC 5.1.0). In case of ABI changes between the expected and current compiler version, this may lead to difficult-to-predict issues during execution. [-Wcpp]
    7 | #warning The version of GCC does not match the expected version (GCC 5.1.0). In case of ABI changes between the expected and current compiler version, this may lead to difficult-to-predict issues during execution.
      |  ^~~~~~~
if g++   -o RAWTest2 RAWTest2.o  \
	-L/home/ethlel/titan.core/Install/lib -lttcn3 \
	-L/home/ethlel/titan.core/Install/lib -lcrypto \
	-L/home/ethlel/titan.core/Install/lib -lxml2 -lpthread -lrt; \
	then : ; else /home/ethlel/titan.core/Install/bin/titanver RAWTest2.o ; exit 1; fi



When interrogated, the resulting binary is shown as having been built with gcc 5.1.0:

./RAWTest2 -v
TTCN-3 Test Executor (single mode)
Product number: CRL 113 200/7 R1B
Version: 7.1.pl1
Build date (Base Library): Jul  2 2020 17:39:51
Base Library was compiled with: GCC 5.1.0

Copyright (c) 2000-2020 Ericsson Telecom AB

Module information:
Module name       Language  Compilation time   MD5 checksum                     Version
---------------------------------------------------------------------------------------
PreGenRecordOf     TTCN-3 Jul  2 2020 17:38:58 02ac6b4a4325302f71d8860c0c9d46cc 
RAWTest2           TTCN-3 Jul  2 2020 17:44:09 aef61d8426f32cc00f6fa576e28ede82 
TitanLoggerApi     TTCN-3 Jul  2 2020 17:38:13 805e90bb86abcd6c76d5a1abdd26f701 
---------------------------------------------------------------------------------------

however the object file produced is clearly built with gcc 9.3.0
 readelf -p .comment ./RAWTest2.o

String dump of section '.comment':
  [     1]  GCC: (GNU) 9.3.0

so we managed to mix binaries produced by two different C compiler versions.

Nonetheless, this is to be considered a new and experimental feature, not yet tested to the extreme,
so please if you encounter any problems that could be rooted in such mixing, contact us so we can investigate.
A telltale sign is the warning emitted by Titan, see above.


Best regards

Elemer

[Updated on: Thu, 02 July 2020 20:55]

Report message to a moderator

Re: Relaxing the C/C++ compiler version check for Titan 7.1.1 [message #1829407 is a reply to message #1829398] Thu, 02 July 2020 21:37 Go to previous message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

Thanks for the update. I think it's long overdue. The last known incompatibility was in the gcc-4.8 days, and now people are using gcc-9 + gcc-10.

FYI: I have been running successfully for several years with commented-out #error statement in cversion.h. This was on debian unstable, where gcc is changing every few months.
Previous Topic:Java code generator/executor of Titan
Next Topic:Implementing components in C++
Goto Forum:
  


Current Time: Thu Apr 25 09:33:18 GMT 2024

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

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

Back to the top