4

I'm trying to build LLVM 3.1 and Clang 3.1. I followed the Getting Started guide from Clang's website- check out the repositories in the requisite places, get Python, etc.

If I have Python 3.3 installed, it gives a Python semantic error- from main import main, no module called main. If I have Python 2.7 installed, it gives

CMake Error at CMakeLists.txt:307 (message):
  Unexpected failure executing llvm-build:
Configuring incomplete, errors occurred!

This is most unhelpful. Any suggestions as to what I can do to build LLVM and Clang on Windows, or at least attempt to determine what the problem is?

Just as a note, I am attempting to build with Visual Studio 2012, which is officially supported by CMake but was not released when LLVM 3.1 and Clang 3.1 were created.

Edit: Here are the requisite lines from CMakeLists.txt

message(STATUS "Constructing LLVMBuild project information")
execute_process(
  COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
            --native-target "${LLVM_NATIVE_ARCH}"
            --enable-targets "${LLVM_TARGETS_TO_BUILD}"
            --enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
            --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC}
            --write-cmake-fragment ${LLVMBUILDCMAKEFRAG}
            ERROR_VARIABLE LLVMBUILDOUTPUT
            ERROR_VARIABLE LLVMBUILDERRORS
            OUTPUT_STRIP_TRAILING_WHITESPACE
            ERROR_STRIP_TRAILING_WHITESPACE
  RESULT_VARIABLE LLVMBUILDRESULT)

# On Win32, CMake doesn't properly handle piping the default output/error
# streams into the GUI console. So, we explicitly catch and report them.
if( NOT "${LLVMBUILDOUTPUT}" STREQUAL "")
  message(STATUS "llvm-build output: ${LLVMBUILDOUTPUT}")
endif()
if( NOT "${LLVMBUILDRESULT}" STREQUAL "0" )
  message(FATAL_ERROR
    "Unexpected failure executing llvm-build: ${LLVMBUILDERRORS}")
endif()

Here, you can see that ${LLVMBUILDRESULT} is not good, but ${LLVMBUILDERRORS} which is obviously supposed to contain the build errors does not contain anything.

6
  • First, I'm pretty sure you do need Python 2.x, so 3.3 won't work, even if the docs don't say this explicitly. (But I could be wrong—clang evolves pretty fast…) Beyond that, what makes you think the error has anything to do with Python? Nothing in the message you showed makes any mention of Python; it's refers to "Configuring". (You have CMakeLists.txt in front of you, so you can look at line 307 and see what it's doing.)
    – abarnert
    Dec 7, 2012 at 23:47
  • Second, did you try to configure with Python 3.3, then uninstall that and install Python 2.7 and try to build without cleaning out and reconfiguring first? Because it's possible it's just confused about whether or not it can use Python. Most configuration systems are bad at "resuming" a configuration when the system has changed in the mean time.
    – abarnert
    Dec 7, 2012 at 23:48
  • Finally, as the docs you linked to make clear, Python is only needed if you will be running the tests. If you're planning to hack on Clang or LLVM (rather than just use them), or if you've got an installation set up but you're getting mysterious failures, then you want to run the tests. But otherwise, you don't need to. So, why not just not configure in Python at all?
    – abarnert
    Dec 7, 2012 at 23:51
  • @abarnert, nope, Python is required to build LLVM. It's used for running llvm-build tool on CMake configure stage and for some reason it errors out.
    – arrowd
    Dec 8, 2012 at 6:44
  • What happens in line 307 is a call to Python, hence why I'm fairly certain it's about Python. I did not try clearing the cache, I'll do that now.
    – Puppy
    Dec 8, 2012 at 18:46

3 Answers 3

4

The problem is two-fold:

First, LLVM requires Python 2.x. If you try to force it to use 3.3, it will fail. The docs probably should say something about this (and I couldn't find any reference to it when I looked), but at this stage it's still pretty common for projects to just say, e.g., "Python" or "Python 2.6+" when they mean "2.6-2.7 but not 3.x".

Second, like most configuration/build tools, CMake only detects dependency changes in the code, not in your system configuration. So if you try to build, then change your system, then try to build again, it won't notice the change and adjust its configuration accordingly. It was already configured to use Python 3.3, and it didn't notice you'd replaced it with Python 2.7, hence the problem. You have to force it to reconfigure—which you can do by clearing the cache, but the simplest and cleanest answer is to just untar/git/whatever yourself a clean directory and start over. (Or, if you can build out-of-tree, as you can with many projects, just wipe out the build directory and start over.)

Finally, according to the docs, you really don't need Python to build llvm and clang, unless you want to run the tests. So, unless the docs are wrong (which is of course possible), if you had just done a clean build with no Python at all, it would have worked. The reason it didn't work when you tried it is the same reason it didn't work after you installed 2.7: You were in a partially-configured state, it thought it had Python, and therefore it insisted on using it.

2

I used something like

"c:\Program Files (x86)\CMake\bin\cmake.exe" -G "Visual Studio 12 2013" -DPYTHON_EXECUTABLE="C:\Python27\python27.exe" -DLLVM_TARGETS_TO_BUILD="X86" ..\llvm-3.5.0.src

and it worked for me. In my case cmake was not finding python so I had to use

-DPYTHON_EXECUTABLE="C:\Python27\python27.exe"

Notice that I didn't override my system folders then somebody with the same problem should use something different for each folder of the command.

0

Apparently, this is a CMake fail primarily, it would have succeeded if I had cleared the cache after installing Python 2.7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.