Building LLVM/Clang on Bash on Ubuntu on Windows
はじめに
Bash on Ubuntu on Windows 上で Bazel を試してみたい。 ウォーミングアップに LLVM/Clang のビルドを実施してみる。
環境
実施
必要なツールのインストール
~/win/ubuntu/refs$ sudo apt-get install gcc g++ make cmake subversion
LLVM/Clang のビルド
- Getting Started with the LLVM System — LLVM 4.0 documentation #Checkout LLVM from Subversion
- Getting Started: Building and Running Clang
の通りにソースファイルを入手。
~/win/ubuntu/refs$ ls llvm bindings CODE_OWNERS.TXT docs lib llvm.spec.in RELEASE_TESTERS.TXT test utils cmake configure examples LICENSE.TXT projects resources tools CMakeLists.txt CREDITS.TXT include LLVMBuild.txt README.txt runtimes unittests ~/win/ubuntu/refs$ mkdir build ~/win/ubuntu/refs$ cd build ~/win/ubuntu/refs/build$ cmake -G "Unix Makefiles" ../llvm CMake Error at CMakeLists.txt:3 (cmake_minimum_required): CMake 3.4.3 or higher is required. You are running version 2.8.12.2 -- Configuring incomplete, errors occurred!``` ~/win/ubuntu/refs/build$ cd ..
CMake が古いじゃないか
~/win/ubuntu/refs$ mkdir cmake ~/win/ubuntu/refs$ cd cmake ~/win/ubuntu/refs/cmake$ wget https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz ~/win/ubuntu/refs/cmake$ tar xzf cmake-3.6.1.tar.gz ~/win/ubuntu/refs/cmake$ cd cmake-3.6.1/ ~/win/ubuntu/refs/cmake/cmake-3.6.1$ ./bootstrap --prefix=/home/ichi/bin --------------------------------------------- CMake 3.6.1, Copyright 2000-2016 Kitware, Inc. (snip) CMake has bootstrapped. Now run make. ~/win/ubuntu/refs/cmake/cmake-3.6.1$ make -j 8 --prefix=/home/ichi/bin [ 0%] Building C object Utilities/cmcompress/CMakeFiles/cmcompress.dir/cmcompress.c.o (snip) [100%] Built target ctest ~/win/ubuntu/refs/cmake/cmake-3.6.1$ make install [ 3%] Built target cmsys (snip) -- Installing: /home/ichi/share/cmake-3.6/completions/ctest ~/win/ubuntu/refs/cmake/cmake-3.6.1$ cd ../../build ~/win/ubuntu/refs/build$ cmake -G "Unix Makefiles" ../llvm ~/win/ubuntu/refs/build$ cmake -G "Unix Makefiles" ../llvm -- The C compiler identification is GNU 4.8.4 (snip) -- Build files have been written to: /home/ichi/win/ubuntu/refs/build ~/win/ubuntu/refs/build$ make -j8 Scanning dependencies of target LLVMSupport (snip) [100%] Built target c-index-test ~/win/ubuntu/refs/build$ sudo make install ~/win/ubuntu/refs/build$ clang clang-4.0: error: no input files ~/win/ubuntu/refs/build$ cd ~/tmp ~/tmp$ cat > a.cpp constexpr int fact(int n) { if (n <= 0) return 1; else return n * fact(n-1); } static_assert(fact(10) == 3628800, ""); // OK static_assert(fact(1) == 0, ""); // error int main() { return 0; } ~/tmp$ clang --std=c++14 a.cpp a.cpp:10:1: error: static_assert failed "" static_assert(fact(1) == 0, ""); // error ^ ~~~~~~~~~~~~ 1 error generated. ~/tmp$