忍者:构建停止:在 Fedora 35 上构建 llvm10 时子命令失败

ninja: build stopped: subcommand failed when building llvm10 on Fedora 35

我一直在尝试从源代码构建 llvm10。我从 llvm 的 github 下载源代码,过去几天一直在尝试完成构建,但每次在忍者进程结束时,都会弹出错误 -ninja: build stopped: subcommand failed

我正在使用以下命令来构建:

cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/llvm -DLLVM_ENABLE_PROJECTS=clang -DLLVM_LIBDIR_SUFFIX=64 -DLLVM_TARGETS_TO_BUILD="AMDGPU" -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_PARALLEL_LINK_JOBS=1

由于我的多次尝试都失败了,我还尝试 运行 将并行作业设置为推荐的线程数 1。也做了 ninja -j1 但 none 这有帮助。

我记得在 Fedora 34 上成功完成了这个,所以,我重新安装了 Fedora 34,但是,它也给我同样的错误。

这是弹出错误的部分:

[1/17] Building CXX object utils/bench.../benchmark.dir/benchmark_register.cc.o
FAILED: utils/benchmark/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o 
/bin/c++ -DHAVE_POSIX_REGEX -DHAVE_STD_REGEX -DHAVE_STEADY_CLOCK -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/build/utils/benchmark/src -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src -I/usr/include/libxml2 -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/build/include -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/include -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/include -I/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/../include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections  -std=c++11  -Wall  -Wextra  -Wshadow  -pedantic  -pedantic-errors  -Wfloat-equal  -fstrict-aliasing  -fno-exceptions  -Wstrict-aliasing -O3 -DNDEBUG -std=c++14 -MD -MT utils/benchmark/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o -MF utils/benchmark/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o.d -o utils/benchmark/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o -c /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.cc
In file included from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.cc:15:
/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.h: In function ‘void AddRange(std::vector<T>*, T, T, int)’:
/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.h:17:30: error: ‘numeric_limits’ is not a member of ‘std’
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                              ^~~~~~~~~~~~~~
/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.h:17:46: error: expected primary-expression before ‘>’ token
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                                              ^
/home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.h:17:49: error: ‘::max’ has not been declared; did you mean ‘std::max’?
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                                                 ^~~
      |                                                 std::max
In file included from /usr/include/c++/11/algorithm:62,
                 from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/include/benchmark/benchmark.h:175,
                 from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/internal_macros.h:4,
                 from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/check.h:8,
                 from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.h:6,
                 from /home/test/Desktop/llvm-project-llvmorg-10.0.0/llvm/utils/benchmark/src/benchmark_register.cc:15:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
ninja: build stopped: subcommand failed.

感谢任何帮助。

当时错过了 header 包含。您可能想自己添加它 (https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1) 或使用更新版本的 LLVM ;)