immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.79k stars 219 forks source link

fail build on archlinux #1068

Open Sherlock-Holo opened 3 months ago

Sherlock-Holo commented 3 months ago
   Compiling c2rust-ast-exporter v0.18.0
error: failed to run custom build command for `c2rust-ast-exporter v0.18.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installqMkDu0/release/build/c2rust-ast-exporter-519eea21922eb81e/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
  CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
  CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-unknown-linux-gnu = None
  CMAKE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE = None
  CMAKE = None
  running: cd "/tmp/cargo-installqMkDu0/release/build/c2rust-ast-exporter-0b42c66dd899ffc8/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src" "-DLLVM_DIR=/usr/lib/cmake/llvm" "-DClang_DIR=/usr/lib/cmake/clang" "-DCMAKE_INSTALL_PREFIX=/tmp/cargo-installqMkDu0/release/build/c2rust-ast-exporter-0b42c66dd899ffc8/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- The C compiler identification is GNU 13.2.1
  -- The CXX compiler identification is GNU 13.2.1
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Performing Test HAVE_FFI_CALL
  -- Performing Test HAVE_FFI_CALL - Success
  -- Found FFI: /usr/lib/libffi.so
  -- Looking for histedit.h
  -- Looking for histedit.h - found
  -- Found LibEdit: /usr/include (found version "2.11")
  -- Performing Test Terminfo_LINKABLE
  -- Performing Test Terminfo_LINKABLE - Success
  -- Found Terminfo: /usr/lib/libtinfo.so
  -- Found ZLIB: /usr/lib/libz.so (found version "1.3.1")
  -- Found zstd: /usr/lib/libzstd.so
  -- Found LibXml2: /usr/lib/libxml2.so (found version "2.12.5")
  -- Configuring done (0.7s)
  -- Generating done (0.0s)
  -- Build files have been written to: /tmp/cargo-installqMkDu0/release/build/c2rust-ast-exporter-0b42c66dd899ffc8/out/build
  running: cd "/tmp/cargo-installqMkDu0/release/build/c2rust-ast-exporter-0b42c66dd899ffc8/out/build" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "cmake" "--build" "." "--target" "clangAstExporter" "--config" "Release"
  [  8%] Creating directories for 'tinycbor_build'
  [ 16%] Performing download step (git clone) for 'tinycbor_build'
  [ 25%] Performing update step for 'tinycbor_build'
  [ 33%] Performing patch step for 'tinycbor_build'
  patching file Makefile
  patching file Makefile.configure
  [ 41%] Performing configure step for 'tinycbor_build'
  .config file not yet created
  [ 50%] Performing build step for 'tinycbor_build'
  [ 58%] Performing install step for 'tinycbor_build'
  [ 66%] Completed 'tinycbor_build'
  [ 66%] Built target tinycbor_build
  [ 75%] Building CXX object CMakeFiles/clangAstExporter.dir/FloatingLexer.cpp.o
  [ 83%] Building CXX object CMakeFiles/clangAstExporter.dir/ExportResult.cpp.o
  [ 91%] Building CXX object CMakeFiles/clangAstExporter.dir/AstExporter.cpp.o

  --- stderr
  CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

  CMake Warning (dev) at /usr/share/cmake/Modules/CheckIncludeFile.cmake:77 (message):
    Policy CMP0075 is not set: Include file check macros honor
    CMAKE_REQUIRED_LIBRARIES.  Run "cmake --help-policy CMP0075" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    CMAKE_REQUIRED_LIBRARIES is set to:

      /usr/lib/libedit.so

    For compatibility with CMake 3.11 and below this check is ignoring it.
  Call Stack (most recent call first):
    /usr/lib/cmake/llvm/FindLibEdit.cmake:28 (check_include_file)
    /usr/lib/cmake/llvm/LLVMConfig.cmake:262 (find_package)
    CMakeLists.txt:57 (find_package)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_COMPILER
      CMAKE_ASM_FLAGS

  正克隆到 'tinycbor_build'...
  HEAD 目前位于 d393c16 Parser: fix reading it->extra on big endian when bytesNeeded == 1
  make[4]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
  make[4]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
  make[4]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
  make[4]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:88:1: 错误:‘Optional’不是一个类型名
     88 | Optional<APSInt> getIntegerConstantExpr(const Expr &E, const ASTContext &Ctx) {
        | ^~~~~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp: In member function ‘bool TranslateASTVisitor::evaluateConstantInt(clang::Expr*, llvm::APSInt&)’:
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:576:22: 错误:‘getIntegerConstantExpr’在此作用域中尚未声明
    576 |         auto value = getIntegerConstantExpr(*E, *Context);
        |                      ^~~~~~~~~~~~~~~~~~~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp: In member function ‘bool TranslateASTVisitor::VisitOffsetOfExpr(clang::OffsetOfExpr*)’:
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1352:22: 错误:‘getIntegerConstantExpr’在此作用域中尚未声明
   1352 |         auto value = getIntegerConstantExpr(*E, *this->Context);
        |                      ^~~~~~~~~~~~~~~~~~~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp: 在 lambda 函数中:
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1356:21: 错误:‘value’未被捕获
   1356 |                 if (value) {
        |                     ^~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1355:58: 附注:the lambda has no capture-default
   1355 |             E, TagOffsetOfExpr, childIds, [this, E, value](CborEncoder *extras) {
        |                                                          ^
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1352:14: 附注:‘<类型前缀错误>value’ declared here
   1352 |         auto value = getIntegerConstantExpr(*E, *this->Context);
        |              ^~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1357:46: 错误:‘value’未被捕获
   1357 |                     cbor_encode_uint(extras, value->getZExtValue());
        |                                              ^~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1355:58: 附注:the lambda has no capture-default
   1355 |             E, TagOffsetOfExpr, childIds, [this, E, value](CborEncoder *extras) {
        |                                                          ^
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1352:14: 附注:‘<类型前缀错误>value’ declared here
   1352 |         auto value = getIntegerConstantExpr(*E, *this->Context);
        |              ^~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp: 在 lambda 函数中:
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1490:41: 错误:‘getIntegerConstantExpr’在此作用域中尚未声明
   1490 |                         auto constant = getIntegerConstantExpr(
        |                                         ^~~~~~~~~~~~~~~~~~~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1502:63: 错误:‘class clang::DesignatedInitExpr::Designator’ has no member named ‘getField’; did you mean ‘getFieldLoc’?
   1502 |                                          uintptr_t(designator.getField()));
        |                                                               ^~~~~~~~
        |                                                               getFieldLoc
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:1507:41: 错误:‘getIntegerConstantExpr’在此作用域中尚未声明
   1507 |                         auto constant = getIntegerConstantExpr(
        |                                         ^~~~~~~~~~~~~~~~~~~~~~
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp: In member function ‘bool TranslateASTVisitor::evaluateConstantInt(clang::Expr*, llvm::APSInt&)’:
  /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-ast-exporter-0.18.0/src/AstExporter.cpp:595:5: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
    595 |     }
        |     ^
  make[3]: *** [CMakeFiles/clangAstExporter.dir/build.make:76:CMakeFiles/clangAstExporter.dir/AstExporter.cpp.o] 错误 1
  make[2]: *** [CMakeFiles/Makefile2:274:CMakeFiles/clangAstExporter.dir/all] 错误 2
  make[1]: *** [CMakeFiles/Makefile2:281:CMakeFiles/clangAstExporter.dir/rule] 错误 2
  make: *** [Makefile:215:clangAstExporter] 错误 2
  thread 'main' panicked at /home/sherlock/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 2

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to compile `c2rust v0.18.0`, intermediate artifacts can be found at `/tmp/cargo-installqMkDu0`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

I have installed llvm clang cmake openssl python

run cargo +stable install c2rust fail with this error message

rustc version is

rustc 1.76.0 (07dca489a 2024-02-04) binary: rustc commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce commit-date: 2024-02-04 host: x86_64-unknown-linux-gnu release: 1.76.0 LLVM version: 17.0.6

Algorhythm-sxv commented 3 months ago

I received the same error with cargo install c2rust, using cargo install --git https://github.com/immunant/c2rust.git c2rust completed without errors.

At time of writing current HEAD is https://github.com/immunant/c2rust/commit/4058b111bf5df2c16733698417b395ecbcacb8fa

Vadoola commented 3 months ago

I initially tried compiling the tagged releases 0.18.0, and 0.17.0 and got the exact same error.

However when I tried to compile HEAD https://github.com/immunant/c2rust/commit/4058b111bf5df2c16733698417b395ecbcacb8fa (at the time), it succeeded. Not quite sure what the difference is at the moment. However that version crashes as soon as I try to use it with multiple errors about missing child of AstNode and "Exported Clang AST was invalid. Check warnings above for unimplemented features"