在 travis 上为 clang 使用不同的 libc++ 版本
using different libc++ versions on travis for clang
Travis 使用 Ubuntu Trusty,默认的 libc++ 版本是 svn199600
.
但是我想用不同的(更新的)版本进行测试,就像我已经用不同的 clang 版本做的那样。
我目前的 .travis.yml
看起来如下:
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
例如用 libc++-dev-3.9
替换 libc++-dev
没有帮助(仍然使用旧的库版本),即使添加以下行:
- sourceline: 'deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
我还尝试将以下内容添加到我的 before_install.sh
但没有成功(仍然是旧库):
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
如何在不从源代码构建的情况下正确完成?
看起来如果不从源代码构建是不可能做到的。 range-v3 library uses a script 正是这样做的。
我调整了我的 travis.yml
来使用它:
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
Travis 使用 Ubuntu Trusty,默认的 libc++ 版本是 svn199600
.
但是我想用不同的(更新的)版本进行测试,就像我已经用不同的 clang 版本做的那样。
我目前的 .travis.yml
看起来如下:
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
例如用 libc++-dev-3.9
替换 libc++-dev
没有帮助(仍然使用旧的库版本),即使添加以下行:
- sourceline: 'deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
我还尝试将以下内容添加到我的 before_install.sh
但没有成功(仍然是旧库):
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
如何在不从源代码构建的情况下正确完成?
看起来如果不从源代码构建是不可能做到的。 range-v3 library uses a script 正是这样做的。
我调整了我的 travis.yml
来使用它:
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