Skip to content
Merged
117 changes: 19 additions & 98 deletions _includes/c11-cpp11-and-beyond-and-toolchains.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## C11/C++11 (and Beyond) and Toolchain Versioning

If your project requires tools compatible with C11, C++11, or a more recent language standard, then it is likely that you will have to upgrade your compiler and/or build tools. This section covers specifically how to upgrade GCC, clang, and cmake; for other dependencies please see [Installing Dependencies](/user/installing-dependencies/).
If your project requires tools compatible with C11, C++11, or a more recent language standard, you will likely need to upgrade your compiler and/or build tools. This section covers specifically how to upgrade GCC, clang, and cmake; for other dependencies, please see [Installing Dependencies](/user/installing-dependencies/).

### GCC on Linux

* [Precise](/user/reference/precise/) ships with GCC 4.6.3
* [Trusty](/user/reference/trusty/) ships with GCC 4.8.2
* [Xenial](/user/reference/xenial/) ships with GCC 5.4.0
* [Bionic](/user/reference/bionic/) ships with GCC 7.4.0
* [Focal](/user/reference/focal/) ships with GCC 9.4.0
* [Jammy](/user/reference/jammy/) ships with GCC 11.4.0
* [Noble](/user/reference/noble/) ships with GCC 13.3.0

Note that [GCC support for ISO C11 reached a similar level of completeness as ISO C99 in 4.9](https://gcc.gnu.org/wiki/C11Status) and that C++11 is feature-complete in 5.1 (the C++ language support was feature-complete in 4.8.1 but the standard library didn't support all C++11 features until [later](https://gcc.gnu.org/gcc-5/changes.html#libstdcxx), in particular [support for `<regex>` does not exist until 4.9](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631)).

Expand All @@ -16,7 +17,6 @@ To upgrade GCC to a more recent version, you will have to install the appropriat
```yaml
matrix:
include:
# works on Precise and Trusty
- os: linux
addons:
apt:
Expand All @@ -27,7 +27,6 @@ matrix:
env:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"

# works on Precise and Trusty
- os: linux
addons:
apt:
Expand All @@ -38,7 +37,6 @@ matrix:
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"

# works on Precise and Trusty
- os: linux
addons:
apt:
Expand All @@ -49,7 +47,6 @@ matrix:
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"

# works on Precise and Trusty
- os: linux
addons:
apt:
Expand Down Expand Up @@ -84,98 +81,36 @@ addons:

### Clang on Linux

* [Precise](/user/reference/precise/) ships with Clang 3.4
* [Trusty](/user/reference/trusty/) ships with Clang 3.5.0
* [Xenial](/user/reference/xenial/) ships with Clang 7
* [Bionic](/user/reference/bionic/) ships with Clang 7
* [Bionic](/user/reference/bionic/) ships with Clang 18.1.8
* [Focal](/user/reference/focal/) ships with Clang 18.1.8
* [Jammy](/user/reference/jammy/) ships with Clang 18.1.8
* [Noble](/user/reference/noble/) ships with Clang 18.1.3

Note that [C++11 support is complete starting from Clang 3.3](http://clang.llvm.org/cxx_status.html).

To upgrade Clang to a more recent version, you will have to install the appropriate version from a `llvm-toolchain-*` source (the `ubuntu-toolchain-r-test` source must also be pulled in for dependency resolution); see below for examples:
To upgrade Clang to a more recent version, it is necessary to install the appropriate version from a `llvm-toolchain-*` source (the `ubuntu-toolchain-r-test` source must also be pulled in for dependency resolution); see below for a Focal example:

```yaml
matrix:
include:
# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
packages:
- clang-3.6
env:
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- clang-3.7
env:
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- clang-3.8
env:
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-3.9
- llvm-toolchain-focal-18
packages:
- clang-3.9
- clang-18
env:
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-4.0
packages:
- clang-4.0
env:
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"

before_install:
- eval "${MATRIX_EVAL}"
- MATRIX_EVAL="CC=clang-18 && CXX=clang++-18"
```
{: data-file=".travis.yml"}


### Clang on FreeBSD

> Clang is the default compiler on FreeBSD
> Clang is the default compiler on FreeBSD.

FreeBSD ships with Clang 8.0.1
FreeBSD ships with Clang 8.0.1.

To upgrade Clang to a more recent version, install the appropriate version from packages; see below for examples:

Expand All @@ -190,27 +125,13 @@ addons:
```
{: data-file=".travis.yml"}

> Clang is the default compiler on FreeBSD
> Clang is the default compiler on FreeBSD.

#### CMake

* [Precise](/user/reference/precise/) ships with CMake 2.8.7
* [Trusty](/user/reference/trusty/) ships with CMake 3.9.2
* [Xenial](/user/reference/xenial/) ships with CMake 3.12.4
* [Bionic](/user/reference/bionic/) ships with CMake 3.12.4
* [Bionic](/user/reference/bionic/) ships with CMake 3.26.3
* [Focal](/user/reference/focal/) ships with Clang 4.2.0
* [Jammy](/user/reference/jammy/) ships with Clang 4.2.0
* [Noble](/user/reference/noble/) ships with Clang 4.1.2
* [FreeBSD](/user/reference/freebsd/) ships with CMake 3.15.5

You can upgrade cmake to 3.2.3 on Precise from the `george-edison55-precise-backports` source (note that the `cmake-data` package contains dependencies which Aptitude does not automatically resolve), c.f.

```yaml
addons:
apt:
sources:
- george-edison55-precise-backports
packages:
- cmake-data
- cmake
```
{: data-file=".travis.yml"}


2 changes: 1 addition & 1 deletion user/build-stages/share-docker-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This example has 2 build stages:
Here's what the `.travis.yml` config could look like:

```yaml
dist: trusty
dist: noble

jobs:
include:
Expand Down
46 changes: 11 additions & 35 deletions user/installing-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ redirect_from:

## Install Packages on Standard Infrastructure

To install Ubuntu packages that are not included in the standard [precise](/user/reference/precise/), [trusty](/user/reference/trusty/), [xenial](/user/reference/xenial/), or [bionic](/user/reference/bionic/) distribution, use apt-get in the `before_install` step of your `.travis.yml`:
To install Ubuntu packages that are not included in the standard [bionic](/user/reference/bionic/), [focal](/user/reference/focal/), [jammy](/user/reference/jammy/) or [noble](/user/reference/noble/) distribution, use apt-get in the `before_install` step of your `.travis.yml`:

```yaml
before_install:
- sudo apt-get -y install libxml2-dev
```
{: data-file=".travis.yml"}

By default, `apt-get update` does not get run automatically. If you want to update `apt-get update` automatically on every build, there are two ways to do this. The first is by running `apt-get update` explicitly in the `before_install` step:
By default, `apt-get update` does not run automatically. If you want `apt-get update` to run automatically on every build, there are two ways to do so. The first is by running `apt-get update` explicitly in the `before_install` step, like shown below:

```yaml
before_install:
Expand All @@ -37,7 +37,7 @@ addons:
```
{: data-file=".travis.yml"}

> Do not run `apt-get upgrade` in your build as it downloads up to 500MB of packages and significantly extends your build time. Additionally, some packages may fail to update, which will lead to a failed build.
> Do not run `apt-get upgrade` in your build, as it downloads up to 500MB of packages and significantly extends your build time. Additionally, some packages may fail to update, resulting in a failed build.
>
> Use the `-y` parameter with apt-get to assume yes to all queries by the apt tools.

Expand All @@ -59,17 +59,6 @@ For repositories not hosted on Launchpad, you need to add a GnuPG key as well.

If you're installing packages this way, make sure you download the correct version for your environment.

This example adds the APT repository for Varnish 3.0 for Ubuntu 12.04 to the locally available list of APT sources and then installs the `varnish` package.

```yaml
before_script:
- curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
- echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-3.0" | sudo tee -a /etc/apt/sources.list
- sudo apt-get -qq update
- sudo apt-get -y install varnish
```
{: data-file=".travis.yml"}

### Install Packages without an APT Repository

For some projects, there may be a Debian/Ubuntu package available, but no corresponding APT repository. These are still easy to install, but require the extra step of downloading.
Expand Down Expand Up @@ -97,7 +86,7 @@ To add APT sources, you can use one of the following three types of entries:

1. aliases defined in [source safelist](https://github.com/travis-ci/apt-source-safelist)
2. `sourceline` key-value pairs which will be added to `/etc/apt/sources.list`
3. when APT sources require GPG keys, you can specify this with `key_url` pairs in addition to `sourceline`.
3. When APT sources require GPG keys, you can specify this with `key_url` pairs in addition to `sourceline`.

The following snippet shows these three types of APT sources.

Expand Down Expand Up @@ -139,26 +128,13 @@ addons:
```
{: data-file=".travis.yml"}

> Note: If `apt-get install` fails, the build is marked an error.
> Note: If `apt-get install` fails, the build is marked as an errored one.

> You can also have a look at the [Apt](https://config.travis-ci.com/ref/job/addons/apt) section in our [Travis CI Build Config Reference](https://config.travis-ci.com/).

### Install Snap Packages with the Snaps Addon

You can install [snap](http://snapcraft.io/) packages using our Xenial or
Bionic images:

```yaml
dist: xenial
```
{: data-file=".travis.yml"}

or

```yaml
dist: bionic
```
{: data-file=".travis.yml"}
You can also install [snap](http://snapcraft.io/) packages.

The Ubuntu Snap store offers many packages directly maintained by upstream
developers, often with newer versions than the ones available in the Apt archive.
Expand All @@ -170,7 +146,7 @@ of the two possible forms:
additional flags. For example,

```yaml
dist: xenial
dist: noble
addons:
snaps:
- hugo
Expand All @@ -190,7 +166,7 @@ of the two possible forms:
For example,

```yaml
dist: xenial
dist: noble
addons:
snaps:
- name: aws-cli
Expand All @@ -210,15 +186,15 @@ of the two possible forms:

## Install Packages on FreeBSD

To install packages that are not included in the default FreeBSD environment use `pkg` in the `before_install` step of your `.travis.yml`:
To install packages that are not included in the default FreeBSD environment, use `pkg` in the `before_install` step of your `.travis.yml`:

```yaml
before_install:
- su -m root -c 'pkg install -y curl'
```
{: data-file=".travis.yml"}

For convenience, you can use the `pkg` addon in your `.travis.yml`. For example, to install go and curl:
For convenience, you can use the `pkg` addon in your `.travis.yml`. For example, to install Go and curl:

```yaml
addons:
Expand Down Expand Up @@ -267,7 +243,7 @@ before_script:

> Note that when you're updating the `$PATH` environment variable, that part can't be moved into a shell script, as it will only update the variable for the sub-process that's running the script.

To install something from source, you can follow similar steps. Here's an example to download, compile and install the protobufs library.
To install something from source, you can follow similar steps. Here's an example to download, compile, and install the protobufs library.

```yaml
install:
Expand Down
2 changes: 0 additions & 2 deletions user/languages/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ before_install:
```
{: data-file=".travis.yml"}

{% include c11-cpp11-and-beyond-and-toolchains.md %}

## Build Config Reference

You can find more information on the build config format for [C](https://config.travis-ci.com/ref/language/c) in our [Travis CI Build Config Reference](https://config.travis-ci.com/).
1 change: 0 additions & 1 deletion user/languages/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,3 @@ before_install:
```
{: data-file=".travis.yml"}

{% include c11-cpp11-and-beyond-and-toolchains.md %}
Loading