[llvm-dev] enabling virtual environment for multiple clang versions

Grigori Fursin via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 23 08:47:56 PDT 2018


I now often have to switch between several versions of LLVM including 
the ones built locally when benchmarking and optimizing different AI 
libraries, and it's kind of a pain to substitute cmake or environment 
variables.

That’s why we decided to automate this process by introducing "virtual 
environments" for LLVM and related tools similar to Python virtualenv in 
the CK framework (https://github.com/ctuning/ck). We also make it work 
in the same way on Linux, MacOS and Windows. If it’s of interest, you 
can try it as follows:

  $ (sudo) pip install ck
  $ ck pull repo:ck-env

  $ ck detect soft --tags=compiler,llvm

CK will search for all installed clang instances on your machine 
(including Microsoft Visual Studio dependency on Windows) and will ask 
you which one to register for the CK virtual environment. You can then 
repeat this process and register multiple versions you use for testing. 
You can then see all registered virtual environments as follows:

  $ ck show env
or
$ ck show env --tags=compiler,llvm

Now you can start a specific virtual environment as follows:

  $ ck virtual env --tags=compiler,llvm

CK will set up PATH, LD_LIBRARY_PATH and other variables to point to a 
specific clang version, and will start bash on Linux/MacOS or shell on 
Windows. You can then use different environment variable specific to a 
given Clang instance and starting from CK_ in your own scripts:

  $ export | grep "CK_"

We also added the possibility to install pre-built versions of LLVM on 
different platforms and automatically register CK virtual environment:

  $ ck search package --tags=compiler,llvm
  $ ck install package --tags=compiler,llvm,v6.0.0
  $ ck show env --tags=compiler,llvm
  $ ck virtual env --tags=compiler,llvm,v6.0.0
   > ${CK_CC_FULL_PATH} --version

Finally, you can also rebuild LLVM from a trunk and again automatically 
register it in the CK virtual environment:

  $ ck install package --tags=compiler,llvm,vtrunk

Hope it will be of some help - if you are interested to know more, feel 
free to check this page or to get in touch: 
https://github.com/ctuning/ck/wiki/First-Steps

Regards,
Grigori Fursin



More information about the llvm-dev mailing list