How can I configure travis-ci such that my project builds with more than one version of a compiler?
Say, I want to build it with gcc-4.8, gcc-4.9, clang-3.4, clang-3.5 and clang-3.6.
I know how to build on both gcc and clang, but not on more than one version of them.
To give a little bit more context, my project is a C++ library and I want to ensure compatibility with those compilers.
GNU Compiler Collection (GCC): a compiler suite that supports many languages, such as C/C++ and Objective-C/C++. GNU Make: an automation tool for compiling and building applications. GNU Binutils: a suite of binary utility tools, including linker and assembler.
GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel. With roughly 15 million lines of code in 2019, GCC is one of the biggest free programs in existence.
DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.
It was (and still is) quite painful to figure out what is possible/allowed with Travis CI and what isn't. My current solution looks like this:
language: cpp
matrix:
include:
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8']
env: COMPILER=g++-4.8
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9']
env: COMPILER=g++-4.9
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env: COMPILER=g++-5
- os: linux
compiler: clang
env: COMPILER=clang++
- os: linux
compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['clang-3.5']
env: COMPILER=clang++-3.5
- os: linux
compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['clang-3.6']
env: COMPILER=clang++-3.6
# Activate when 3.7 is released and the repository is available
# - os: linux
# compiler: clang
# addons:
# apt:
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
# packages: ['clang-3.7']
# env: COMPILER=clang++-3.7
# Activate when we are allowed to use MacOS X
# - os: osx
# compiler: clang
# env: COMPILER=clang++
script:
make CXX=$COMPILER -j3
Some remarks:
CXX
directly as Travis CI will overwrite it. You need an intermediate variable like COMPILER
clang++
without extension is currently Clang 3.4llvm-toolchain-precise
repository is currently black-listed(Note that the above will change/improve over time, now (2016-01-11) Clang 3.7 is available, as is MacOS X. The above is meant as a starting point, adapt as needed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With