Embed LLVM/Clang in our project

Hi All,
   We want to compile LLVM/Clang and use the resulting headers/libraries in our project. But we compile it during out build process. I can build LLVM/Clang by adding it to our cmakelists.txt but when our code tries to use one of the headers (clang/CodeGen/ModuleBuilder.h), its not found as it doesnt exist. If I do a 'make install' in the llvm directory, then the file is generated in the LLVM_INSTALL_PREFIX directory. Is the 'make install' step necessary even though I'm compiling llvm along with my code?

TIA,
ashok

Ashok Nalkund <ashoknn@qti.qualcomm.com> writes:

  We want to compile LLVM/Clang and use the resulting
headers/libraries in our project. But we compile it during out build
process. I can build LLVM/Clang by adding it to our cmakelists.txt but
when our code tries to use one of the headers
(clang/CodeGen/ModuleBuilder.h), its not found as it doesnt exist. If
I do a 'make install' in the llvm directory, then the file is
generated in the LLVM_INSTALL_PREFIX directory. Is the 'make install'
step necessary even though I'm compiling llvm along with my code?

If you wish to use LLVM/Clang whitout installing it, you must add both
the build output header path and the source header path (in this order)
to your list of include paths, like this:

include_directories( ${LLVM_BUILD_DIR}/include ${LLVM_SOURCE_DIR}/include )

Replace LLVM_SOURCE_DIR/LLVM_BUILD_DIR with the respective directories.
Same for Clang

Thanks for the response, it worked. I can now compile my code by adding the additional include paths.

I was using the find_package(LLVM llvm/share/llvm/cmake) and llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) to get the libraries to link against. This works well for the libLLVM* libraries, but how do I implement similar find stuff for clang libraries?

TIA,
ashok

Ashok Nalkund <ashoknn@qti.qualcomm.com> writes:

I was using the find_package(LLVM llvm/share/llvm/cmake) and
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) to get
the libraries to link against. This works well for the libLLVM*
libraries, but how do I implement similar find stuff for clang
libraries?

AFAIK, there is no such feature for Clang.

Thanks Oscar.

ashok

Ashok Nalkund <ashoknn@qti.qualcomm.com> writes:

I was using the find_package(LLVM llvm/share/llvm/cmake) and
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) to get
the libraries to link against. This works well for the libLLVM*
libraries, but how do I implement similar find stuff for clang
libraries?

AFAIK, there is no such feature for Clang.

I noticed that the following files are modified even though I'm compiling outside the source tree (using cmake):

# modified: src/utils/llvm-build/llvmbuild/__init__.pyc
# modified: src/utils/llvm-build/llvmbuild/componentinfo.pyc
# modified: src/utils/llvm-build/llvmbuild/configutil.pyc
# modified: src/utils/llvm-build/llvmbuild/main.pyc
# modified: src/utils/llvm-build/llvmbuild/util.pyc

Does anybody know why the sources are being modified?

thanks,
ashok

I would have expected the .pyc files to go in the objects directory. Maybe
Daniel knows why that's not happening.

Ciao, Duncan.

This is just standard behavior of the Python interpreter. The files
are just a cache (it is not the sources being modified) and also won't
be written if the source tree is made read only, and shouldn't cause a
problem in practice.

- Daniel

Thanks, I'll just ignore these files then.

ashok