构建LLVM失败,并显示空错误消息

编程入门 行业动态 更新时间:2024-10-24 16:22:04
本文介绍了构建LLVM失败,并显示空错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试构建LLVM 3.1和Clang 3.1.我从 Clang的网站按照入门指南进行操作-在必要的地方查看存储库,获取Python等

如果我安装了Python 3.3,它将给出一个Python语义错误-from main import main,没有名为main的模块.如果我安装了Python 2.7,它将显示

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

这是最无益的.关于在Windows上构建LLVM和Clang可以做什么的任何建议,或者至少尝试确定问题出在哪里?

请注意,我正在尝试使用Visual Studio 2012进行构建,该版本由CMake正式支持,但是在创建LLVM 3.1和Clang 3.1时并未发布.

这是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()

在这里,您可以看到${LLVMBUILDRESULT}不好,但是显然应该包含构建错误的${LLVMBUILDERRORS}不包含任何内容.

解决方案

问题有两个:

首先,LLVM需要Python2.x.如果尝试强制使用3.3,它将失败.文档可能应该对此说些什么(当我看时我找不到任何引用),但是在此阶段,项目只是说"Python"或"Python 2.6+"仍然很普遍.他们的意思是"2.6-2.7,但不是3.x".

第二,像大多数配置/构建工具一样,CMake仅检测代码中的依赖项更改,而不检测系统配置中的依赖项更改.因此,如果您尝试构建,然后更改系统,然后再次尝试构建,它不会注意到更改并相应地调整其配置.它已经配置为使用Python 3.3,并且没有注意到您已将其替换为Python 2.7,因此出现了问题.您必须强制其重新配置-您可以通过清除缓存来进行配置,但是最简单,最干净的答案是仅解压缩/git/任何您自己的干净目录,然后重新开始. (或者,如果您可以像许多项目一样在树外构建,只需清除构建目录并重新开始.)

最后,根据文档,您确实不需要Python来构建llvm和clang,除非您想运行测试.因此,除非文档是错误的(当然是可能的),否则,如果您刚刚完成了一个完全没有Python的全新构建,那将是可行的.尝试时不起作用的原因与安装2.7后不起作用的原因相同:您处于部分配置的状态,它认为它具有Python,因此坚持使用它.

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.

解决方案

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.

更多推荐

构建LLVM失败,并显示空错误消息

本文发布于:2023-11-06 01:23:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   消息   LLVM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!