19

Travis uses Ubuntu Trusty and the default libc++ version there is svn199600.

However I would like to test with different (newer) versions as I already do with different clang versions.

My current .travis.yml looks as follows:

language: generic

dist: trusty
sudo: required

matrix:
    include:
    - env: CXX=g++-7 CC=gcc-7
      addons:
        apt:
          packages:
            - g++-7
          sources: &sources
            - ubuntu-toolchain-r-test
            - llvm-toolchain-precise
            - llvm-toolchain-precise-3.9
            - llvm-toolchain-precise-3.8
            - llvm-toolchain-precise-3.7
            - llvm-toolchain-precise-3.6
            - sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main'
              key_url: 'http://apt.llvm.org/llvm-snapshot.gpg.key'
    - env: CXX=g++-6 CC=gcc-6
      addons:
        apt:
          packages:
            - g++-6
          sources: *sources
    - env: CXX=g++-5 CC=gcc-5
      addons:
        apt:
          packages:
            - g++-5
          sources: *sources
    - env: CXX=g++-4.9 CC=gcc-4.9
      addons:
        apt:
          packages:
            - g++-4.9
          sources: *sources
    - env: CXX=clang++-4.0 CC=clang-4.0
      addons:
        apt:
          packages:
            - clang-4.0
            - libc++-dev
          sources: *sources
    - env: CXX=clang++-3.9 CC=clang-3.9
      addons:
        apt:
          packages:
            - clang-3.9
            - libc++-dev
          sources: *sources
    - env: CXX=clang++-3.8 CC=clang-3.8
      addons:
        apt:
          packages:
            - clang-3.8
            - libc++-dev
          sources: *sources
    - env: CXX=clang++-3.7 CC=clang-3.7
      addons:
        apt:
          packages:
            - clang-3.7
            - libc++-dev
          sources: *sources
    - env: CXX=clang++-3.6 CC=clang-3.6
      addons:
        apt:
          packages:
            - clang-3.6
            - libc++-dev
          sources: *sources

script:
    - ./build_and_test.sh

before_install:
    - ./before_install.sh

Replacing libc++-dev with libc++-dev-3.9 for example does not help (still uses old library version), even when adding the following line:

- sourceline: 'deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'

I also attempted to add the following to my before_install.sh without success (also still old library):

sudo apt-add-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.9 main"   
sudo apt-get update   
sudo apt-get install -y libc++-dev libc++-helpers libc++1 libc++abi-dev lldb-3.9

How is it done correctly without building from source?

10
  • What do you mean by "doesn't help"? Does the build fail? Does it build with the wrong library? Does this work for you locally without uninstall libc++-dev first? Commented Sep 7, 2017 at 1:35
  • @kichik Thanks for the remark. The problem is it still builds with the old library. I updated my question accordingly. Commented Sep 7, 2017 at 12:07
  • 1
    on your env: lines, you can provide LDFLAGS="-L /path/to/libary" LDLIBS="-l :libc++-dev-3.9.so" for example to find that lib in the path given to LDFLAGS (presuming it's a .so file, in any case because I use a colon preceding the name in LDLIBS, it must be the exact filename, so it may be .a if statically linked). I personally don't use travis, but the env lines looked like makefile stuff, and the above vars are used with Makefiles, so hope that works. Commented Sep 7, 2017 at 15:04
  • @strobelight Thanks, I also tried this, but it did not change anything. Commented Sep 7, 2017 at 18:03
  • I don't think this is travis related at all. Like strobelight said: You have to provide parameters to the build script and ensure it picks up the right library. If your build script does not user the LDFLAGS LDLIBS variables you have to look at the build script and find out what they are called or you have to add them. Commented Sep 8, 2017 at 9:49

1 Answer 1

3

It looks like it is not possible to do it without building from source. The range-v3 library uses a script doing exactly this.

I adjusted my travis.yml to use it too:

language: generic

dist: trusty
sudo: required

matrix:
    include:
    - os: linux
      compiler: gcc
      env: GCC_VERSION=7
        - CC=gcc-7
        - CXX=g++-7
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-7']

    - os: linux
      compiler: gcc
      env: GCC_VERSION=6
        - CC=gcc-6
        - CXX=g++-6
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-6']

    - os: linux
      compiler: gcc
      env: GCC_VERSION=5
        - CC=gcc-5
        - CXX=g++-5
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-5']

    - os: linux
      compiler: clang
      env: CLANG_VERSION=5.0 LIBCXX=On
        - CC=clang-5.0
        - CXX=clang++-5.0
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
          packages: ['clang-5.0', 'g++-6']

    - os: linux
      compiler: clang
      env: CLANG_VERSION=4.0 LIBCXX=On
        - CC=clang-4.0
        - CXX=clang++-4.0
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
          packages: ['clang-4.0', 'g++-6']

    - os: linux
      compiler: clang
      env: CLANG_VERSION=3.9 LIBCXX=On
        - CC=clang-3.9
        - CXX=clang++-3.9
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.9']
          packages: ['clang-3.9', 'g++-6']

    - os: linux
      compiler: clang
      env: CLANG_VERSION=3.8 LIBCXX=On
        - CC=clang-3.8
        - CXX=clang++-3.8
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.8']
          packages: ['clang-3.8', 'g++-6']

before_install:
  - wget https://raw.githubusercontent.com/onqtam/doctest/master/doctest/doctest.h
  - sudo mv ./doctest.h /usr/local/include/doctest.h
  - |
    if [ -n "$GCC_VERSION" ]; then
      export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"
    fi
    if [ -n "$CLANG_VERSION" ]; then
      export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"
    fi
    if [ "$LIBCXX" == "On" ]; then
      sudo apt-get purge cmake
      sudo apt-get install cmake3
      cmake --version
      sudo CXX="$CXX" CC="$CC"
      sudo ./cmake/install_libcxx.sh
      export CXXFLAGS="-stdlib=libc++"
    fi

install:
  - mkdir -p build && cd build
  - cmake .. -DUNITTEST=ON

script:
  - which $CXX
  - $CXX --version
  - cmake --build . --target unittest --config Release -- -j4
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.