0

so I'm learning about llvm and I decided to build the 3.8 from the tars that I downloaded from LLVM site.

Everything works fine and I managed to build the sources in a separate build folder.

(After downloading all the sources)
$cd llvm3.8/build
$cmake -G "Unix Makefiles" ../llvm
$make -j 4
$make install

so my dir looks a bit like this:

llvm3.8/ 
llvm3.8/build 
llvm3.8/llvm

While learning how to write a LLVM pass I noticed that my build folder is missing these files:

  • Makefile.config
  • Makefile.common
  • Makefile.rule

that I use in the Makefile I have written for the pass I've implemented.

What I know is that the source has these files:

$cd llvm3.8/llvm
$ls:
CMakeLists.txt      README.txt      llvm.spec.in
CODE_OWNERS.TXT     autoconf        projects
CREDITS.TXT         bindings        resources
LICENSE.TXT         cmake           test
LLVMBuild.txt       configure       tools
Makefile            docs            unittests
Makefile.common     examples        utils
Makefile.config.in  include
Makefile.rules      lib

while my build folder doesn't.

$ cd llvm3.8/build
$ ls 
CMakeCache.txt          cmake                   libexec
CMakeFiles              cmake_install.cmake     projects
CPackConfig.cmake       compile_commands.json   share
CPackSourceConfig.cmake docs                    test
DummyConfigureOutput    examples                tools
LLVMBuild.cmake         include                 unittests
Makefile                install_manifest.txt    utils
bin                     lib

Is my build folder containing what it is supposed to contain? Maybe the pass must be written in the sources llvm3.8/llvm?

Thanks for the help.

Carlinho89
  • 157
  • 2
  • 14
  • Did my answer solve the issue? – khrm May 24 '16 at 15:59
  • Probably you use outdated tutorial which is still uses Makefiles, while they all were dropped recently. I can recommend you to take a look at this presentation: [Building, Testing and Debugging a Simple out-of-tree LLVM Pass](http://llvm.org/devmtg/2016-03/#tuto3) – AlexDenisov May 25 '16 at 05:59

1 Answers1

1

You are suppose to write your pass in llvm/lib/Transforms/YourPassName

Create a directory in build:

mkdir -p llvm3.8/build/lib/Transforms/YourPassName

I would recommend you to use cmake. As autoconf is going to be deprecated in llvm3.9. For it:

Add entry in llvm/lib/Transforms/CMakeLists.txt

add_subdirectory(YourPassName)

After putting the entry, create CMakeLists.Txt in llvm/lib/Transforms/YourPassName like the other llvm passes.

Now use

cmake ../llvm3.8

From inside the pass directory:

make

Also if you have install llvm and want to do standalone, use the approach given in this answer: https://stackoverflow.com/a/37308946/4946286

Community
  • 1
  • 1
khrm
  • 5,363
  • 1
  • 22
  • 26
  • Just to complete your answer, since it helped me understanding what were my mistakes: 1) Add your **Pass** to the llvm/lib/Transforms/MyPass --> MyPass.cpp + CMakeList.txt 2) Add entry in llvm/lib/Transforms/CMakeList.txt --> add_subdirectory(MyPass) 3) From the root of the **build** folder run `make`. This creates a folder in build/lib/Transforms named **MyPass** and the LLVMMyPass.so lib you can then **load** with `opt -load build/lib/LLVMMyPass.so`. Just to make it clear, running make on the build will not recompile everything, but just the pass you added. – Carlinho89 May 30 '16 at 08:19