C++: Travis CI で clang 3.5 を使う
gcc には、関数ポインタが constexpr 性を失うという致命的なバグがあり、
現時点の最新バージョン 4.9 でもまだ対応されていない。(5.0 で対応予定のようだ)
メッセージ出力例
src/xxx.hpp:24:29: error: expression 'xxx::yyy::zzz' does not designate a constexpr function
|
gcc が使えないのであれば、clang を使うより詮方無い。
ところがMac では問題なかったものの、Travis.CI (Ubuntu 12.04) で動作させると別の問題が発生した。
In file included from /usr/local/include/boost/config/select_stdlib_config.hpp:18:
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/cstddef:51:11: error:
no member named 'max_align_t' in the global namespace
using ::max_align_t;
~~^
1 error generated.
|
gcc 4.9 以降の libstdc++ を clang で使うと max_align_t が見つからないというエラーが出る、という事象のようだ。
libstdc++ がダメなら libc++ か、と思って試してみた(コンパイルオプションに -stdlib=libc++ を追加)が、
これまた別の問題が発生して使い物にならない。
/usr/local/include/boost/config/select_stdlib_config.hpp:18:12: fatal error:
'cstddef' file not found
# include <cstddef>
^
1 error generated.
|
かといって libstdc++ のバージョンを下げても別のエラーが出るだけである。
In file included from /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:30:
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:229:31: error: no
type named 'allocator_traits' in namespace 'std'
typedef typename std::allocator_traits<A>::template rebind_alloc...
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
|
というわけで、clang のバージョンを上げることにしたいのだが、これもまた一筋縄ではいかない。
.travis.yml にこんな風に書いたがダメ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | env:
global:
- LIBSTDC_VERSION=4.9
- CLANG_VERSION=3.5
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update
install:
- sudo apt-get -qq install build-essential
- sudo apt-get -qq install libstdc++-${LIBSTDC_VERSION}-dev
- sudo apt-get -qq install clang-${CLANG_VERSION}
|
$ if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq install clang-${CLANG_VERSION}; fi
E: Package 'clang-3.5' has no installation candidate
|
もう、どうにもダメかと諦めかけてきた時、偶然流れてきた Travis CI の画面に clang 3.5 の文字が。
マネをしたら、インストールは成功。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | env:
global:
- LIBSTDC_VERSION=4.9
- CLANG_VERSION=3.5
before_install:
- sudo apt-get update -qq
install:
- sudo apt-get -qq install build-essential
- sudo apt-get -qq --allow-unauthenticated install libstdc++-${LIBSTDC_VERSION}-dev
- sudo apt-get -qq --allow-unauthenticated install clang-${CLANG_VERSION}
script:
- clang++ --version
|
しかしまだ、バージョン表示が 3.4 のまま。
$ clang++ --version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
|
clang++-3.5 のようにバージョン付きのコマンドを使ってようやく解決。
$ clang++-3.5 --version
Ubuntu clang version 3.5.0-svn217304-1~exp1 (branches/release_35) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
|
ここまで長かった。。。
この周辺、ぐぐっても情報が見つかりにくいのが何ともつらい。
References