Skip to content

LLVM Pre 3.8 Support

bprail edited this page Apr 26, 2016 · 1 revision

The following guidelines are for using and installing Contech with LLVM support pre-3.8.

You will need to install LLVM to instrument any programs and collect new task graphs. A limited repository of task graphs is available upon request. LLVM for Contech: (tested with LLVM 3.2, 3.3,3.4 + OpenMP, and 3.4)

For best performance, Contech requires that LLVM is built with LTO support - see LLVM Gold Plugin. To use this support, clang will need to invoke gold instead of ld. You will need to run make install from common/eventLib, which will also require that $CONTECH_LLVM_HOME is set (see below) and zlib to be installed.

We further note that your build may require setting CC and CXX, to gcc and g++ respectively, before running configure. Our practice is to create a build subdirectory of the llvm location. Finally, the git repository contains the Contech pass for LLVM, which will need to be included in the LLVM source. The simplest procedure is symlink contech/llvm/lib/Transforms/Contech to $LLVM_SRC/lib/Transforms/Contech and modify $LLVM_SRC/lib/Transforms/Makefile to include Contech. You may also chose to place the LLVM source in the contech/llvm directory.

With the symlink, your lib transforms directory for LLVM may have an entry like the following:

lrwxrwxrwx 1 brailing tinker 57 Feb 21 11:40 Contech -> <full path to CONTECH_HOME>/llvm/lib/Transforms/Contech/

The symlink approach will only work if you are using a separate build directory. Then run configure from the LLVM build subdirectory. An example configure line follows:

../configure --with-binutils-include=/net/tinker/brailing/gcc/binutils-2.22/include/ --prefix=/net/tinker/local --enable-optimized --enable-cxx11

Four flags are passed to configure.

  • binutils is necessary for LTO
  • Prefix if you install in a non-standard directory
  • Optimize the compiler and analysis passes
  • CXX11 required to support C++11 features in the LLVM analysis

Two environment variables are used in Contech's instrumentation and task graph generation:

  • CONTECH_HOME - Root of Contech repository
  • CONTECH_LLVM_HOME - Install location for LLVM (same as prefix provided to LLVM's configure), specifically needed to locate the Contech LLVM pass as part of the wrapper compiler script

(Deprecated -- this approach is part of scripts/contech_wrapper.py) With using the older pass, you must also use the old compiler script: scripts/contech_wrapper.py. The script follows similar semantics to the guidelines in Collecting a Task Graph, but uses a statefile and additional environment variable.

Contech requires a small amount of information to be passed between instances of its LLVM pass. This is known as its statefile. As long as only one instance of the pass is modifying a specific statefile, there is no issue with using the default location. It is preferred that the statefile is located as part of the binary's build location and is cleared when rebuilding. (End Deprecated)