I’m trying to develop a clang-tool, following such kind of tutorial : https://clang.llvm.org/docs/LibASTMatchersTutorial.html.
I’m using GitHub with Travis-CI and I can’t build clang/llvm on Travis because of the free-plan constraints. I’m wondering if it is possible to build such a tool without having to build clang/llvm, i.e., is there a way to simply install clang (from any package manager) with its LibTooling and LibASTMatchers, to which I could link my tool with?
Have you tried the pre-build packages for Ubuntu or Darwin? I'm using
them for my out-of-tree tutorial:
I'm not using LibTooling and LibASTMatchers myself, but from what I can
see they are shipped in Homebrew packages for LLVM 9:
brew install llvm@9
I haven't checked on Ubuntu. This is how you can install the packages
there (for Ubuntu Bionic):
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/
llvm-toolchain-bionic-9.0 main" sudo apt-get update
sudo apt-get install -y llvm-9 llvm-9-dev llvm-9-tools clang-9
In the past I hit similar issue - not being able to build LLVM in
Travis-CI. Fortunately for me, the packages for Ubuntu and Darwin worked
fine. Windows is a bit trickier. Speaking of building LLVM using free CI
systems, I am yet to try https://drone.io/.
Check out this repository by Peter Goldsborough where he used docker to build clang tools.
this is exactly what you were looking for:
Use it as template project for your own standalone tool.
thanks everyone for you help!
Kim, your solution looks hopeful, unfortunately it seems to not work anymore, since it fails on travis with the following message:
$ cmake -GNinja -DCMAKE_PREFIX_PATH=$ROOT_PATH -DCMAKE_C_COMPILER=$BIN_PATH/clang -DCMAKE_CXX_COMPILER=$BIN_PATH/clang++ -DCMAKE_INSTALL_PREFIX=./ ../
295-- IWYU: out-of-tree configuration
296-- The C compiler identification is Clang 10.0.0
297-- The CXX compiler identification is Clang 10.0.0
298-- Check for working C compiler: /usr/lib/llvm-10/bin/clang
299-- Check for working C compiler: /usr/lib/llvm-10/bin/clang -- works
300-- Detecting C compiler ABI info
301-- Detecting C compiler ABI info - done
302-- Detecting C compile features
303-- Detecting C compile features - done
304-- Check for working CXX compiler: /usr/lib/llvm-10/bin/clang++
305-- Check for working CXX compiler: /usr/lib/llvm-10/bin/clang++ -- works
306-- Detecting CXX compiler ABI info
307-- Detecting CXX compiler ABI info - done
308-- Detecting CXX compile features
309-- Detecting CXX compile features - done
316CMake Error at /usr/lib/llvm-10/lib/cmake/llvm/LLVMExports.cmake:1344 (message):
317 The imported target "ExampleIRTransforms" references the file
321 but this file does not exist. Possible reasons include:
323 * The file was deleted, renamed, or moved to another location.
325 * An install or uninstall procedure did not complete successfully.
327 * The installation package was faulty and contained
331 but not all the files it references.
333Call Stack (most recent call first):
334 /usr/lib/llvm-10/cmake/LLVMConfig.cmake:256 (include)
335 CMakeLists.txt:15 (find_package)
338-- Configuring incomplete, errors occurred!
339See also "/home/travis/build/thvnx/clang-fco/build/CMakeFiles/CMakeOutput.log".
340The command "cmake -GNinja -DCMAKE_PREFIX_PATH=$ROOT_PATH -DCMAKE_C_COMPILER=$BIN_PATH/clang -DCMAKE_CXX_COMPILER=$BIN_PATH/clang++ -DCMAKE_INSTALL_PREFIX=./ ../" exited with 1.
(I’ve double-checked with a clone of your repo) Any idea?
Glad to hear it helps!
If you look at the history of .travis.yml, you’ll find a few ‘sed’ hacks to strip missing files of the llvm cmake modules.
Looks like we need to reinstate some of them again.