immunant / c2rust

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

Failed to install on Ubuntu 23.04 #1042

Closed AlixANNERAUD closed 8 months ago

AlixANNERAUD commented 8 months ago

Hello, I tried to c2rust with different version of LLVM (13, 14 and 15), but it fails, even with the master branch or the corresponding (feature/llvm-X) branch. I get the following errors related to c2rust-ast-exporter :

error: failed to run custom build command for `c2rust-ast-exporter v0.16.0 (/home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter)`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-97a474bdf8914381/build-script-build` (exit status: 101)
  --- stdout
  running: cd "/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src" "-DLLVM_DIR=/usr/lib/llvm-14/lib/cmake/llvm" "-DClang_DIR=/usr/lib/llvm-14/lib/cmake/clang" "-DCMAKE_INSTALL_PREFIX=/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/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 12.3.0
  -- The CXX compiler identification is GNU 12.3.0
  -- 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/x86_64-linux-gnu/libffi.so  
  -- Performing Test Terminfo_LINKABLE
  -- Performing Test Terminfo_LINKABLE - Success
  -- Found Terminfo: /usr/lib/x86_64-linux-gnu/libtinfo.so  
  -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.13") 
  -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.14") 
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build
  running: cd "/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build" && MAKEFLAGS="-j --jobserver-fds=11,14 --jobserver-auth=11,14" "cmake" "--build" "." "--target" "clangAstExporter" "--config" "Release" "--"
  [  8%] Creating directories for 'tinycbor_build'
  [ 16%] Performing download step (download, verify and extract) for 'tinycbor_build'
  -- Downloading...
     dst='/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build/tinycbor/src/v0.5.3.tar.gz'
     timeout='none'
     inactivity timeout='none'
  -- Using src='https://github.com/intel/tinycbor/archive/v0.5.3.tar.gz'
  -- verifying file...
         file='/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build/tinycbor/src/v0.5.3.tar.gz'
  -- Downloading... done
  -- extracting...
       src='/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build/tinycbor/src/v0.5.3.tar.gz'
       dst='/tmp/cargo-installhCisjl/release/build/c2rust-ast-exporter-38e984bc8e0a6b34/out/build/tinycbor/src/tinycbor_build'
  -- extracting... [tar xfz]
  -- extracting... [analysis]
  -- extracting... [rename]
  -- extracting... [clean up]
  -- extracting... done
  [ 25%] No 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/AstExporter.cpp.o
  [ 91%] Building CXX object CMakeFiles/clangAstExporter.dir/ExportResult.cpp.o
  [ 91%] Building CXX object CMakeFiles/clangAstExporter.dir/FloatingLexer.cpp.o

  --- stderr
  CMake Warning (dev) at /usr/share/cmake-3.25/Modules/ExternalProject.cmake:3075 (message):
    The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
    not set.  The policy's OLD behavior will be used.  When using a URL
    download, the timestamps of extracted files should preferably be that of
    the time of extraction, otherwise code that depends on the extracted
    contents might not be rebuilt if the URL changes.  The OLD behavior
    preserves the timestamps from the archive instead, but this is usually not
    what you want.  Update your project to the NEW behavior or specify the
    DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
    robustness issue.
  Call Stack (most recent call first):
    /usr/share/cmake-3.25/Modules/ExternalProject.cmake:4185 (_ep_add_download_command)
    CMakeLists.txt:13 (ExternalProject_Add)
  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

  make[4]: avertissement : jobserver n'est pas disponible : utilisation de -j1. Ajouter « + » à la règle parent du make.
  make[4]: avertissement : jobserver n'est pas disponible : utilisation de -j1. Ajouter « + » à la règle parent du make.
  make[4]: avertissement : jobserver n'est pas disponible : utilisation de -j1. Ajouter « + » à la règle parent du make.
  make[4]: avertissement : jobserver n'est pas disponible : utilisation de -j1. Ajouter « + » à la règle parent du make.
  In file included from /usr/lib/llvm-15/include/clang/Basic/Version.h:18,
                   from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:26:
  /usr/lib/llvm-15/include/clang/Basic/Version.inc:2: warning: "CLANG_VERSION_STRING" redefined
      2 | #define CLANG_VERSION_STRING "15.0.7"
        | 
  <command-line>: note: this is the location of the previous definition
  In file included from /usr/lib/llvm-15/include/clang/AST/NestedNameSpecifier.h:21,
                   from /usr/lib/llvm-15/include/clang/AST/Type.h:21,
                   from /usr/lib/llvm-15/include/clang/AST/CanonicalType.h:17,
                   from /usr/lib/llvm-15/include/clang/AST/ASTContext.h:19,
                   from /usr/lib/llvm-15/include/clang/Frontend/ASTUnit.h:17,
                   from /usr/lib/llvm-15/include/clang/Frontend/FrontendAction.h:23,
                   from /usr/lib/llvm-15/include/clang/Frontend/FrontendActions.h:12,
                   from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:15:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:258:29: error: redeclared with 1 template parameter
    258 | template<typename T> struct FoldingSetTrait
        |                             ^~~~~~~~~~~~~~~
  In file included from /usr/lib/llvm-15/include/clang/Basic/Diagnostic.h:19,
                   from /usr/lib/llvm-15/include/clang/AST/NestedNameSpecifier.h:18:
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: previous declaration ‘template<class T, class Enable> struct llvm::FoldingSetTrait’ used 2 template parameters
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In member function ‘void llvm::FoldingSetNodeID::Add(const T&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:338:50: error: wrong number of template arguments (1, should be 2)
    338 |   inline void Add(const T &x) { FoldingSetTrait<T>::Profile(x, *this); }
        |                                                  ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:338:69: error: expression list treated as compound expression in initializer [-fpermissive]
    338 |   inline void Add(const T &x) { FoldingSetTrait<T>::Profile(x, *this); }
        |                                                                     ^
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In static member function ‘static bool llvm::DefaultFoldingSetTrait<T>::Equals(T&, const llvm::FoldingSetNodeID&, unsigned int, llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:378:20: error: wrong number of template arguments (1, should be 2)
    378 |   FoldingSetTrait<T>::Profile(X, TempID);
        |                    ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:378:40: error: expression list treated as compound expression in initializer [-fpermissive]
    378 |   FoldingSetTrait<T>::Profile(X, TempID);
        |                                        ^
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In static member function ‘static unsigned int llvm::DefaultFoldingSetTrait<T>::ComputeHash(T&, llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:384:20: error: wrong number of template arguments (1, should be 2)
    384 |   FoldingSetTrait<T>::Profile(X, TempID);
        |                    ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:384:40: error: expression list treated as compound expression in initializer [-fpermissive]
    384 |   FoldingSetTrait<T>::Profile(X, TempID);
        |                                        ^
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In static member function ‘static void llvm::FoldingSet<T>::GetNodeProfile(const llvm::FoldingSetBase*, Node*, llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:503:22: error: wrong number of template arguments (1, should be 2)
    503 |     FoldingSetTrait<T>::Profile(*TN, ID);
        |                      ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:503:40: error: expression list treated as compound expression in initializer [-fpermissive]
    503 |     FoldingSetTrait<T>::Profile(*TN, ID);
        |                                        ^
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In static member function ‘static bool llvm::FoldingSet<T>::NodeEquals(const llvm::FoldingSetBase*, Node*, const llvm::FoldingSetNodeID&, unsigned int, llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:512:29: error: wrong number of template arguments (1, should be 2)
    512 |     return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID);
        |                             ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In static member function ‘static unsigned int llvm::FoldingSet<T>::ComputeNodeHash(const llvm::FoldingSetBase*, Node*, llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:520:29: error: wrong number of template arguments (1, should be 2)
    520 |     return FoldingSetTrait<T>::ComputeHash(*TN, TempID);
        |                             ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: In member function ‘void llvm::FoldingSetNodeWrapper<T>::Profile(llvm::FoldingSetNodeID&)’:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:764:57: error: wrong number of template arguments (1, should be 2)
    764 |   void Profile(FoldingSetNodeID &ID) { FoldingSetTrait<T>::Profile(data, ID); }
        |                                                         ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:764:76: error: expression list treated as compound expression in initializer [-fpermissive]
    764 |   void Profile(FoldingSetNodeID &ID) { FoldingSetTrait<T>::Profile(data, ID); }
        |                                                                            ^
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h: At global scope:
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:792:47: error: wrong number of template arguments (1, should be 2)
    792 | template<typename T> struct FoldingSetTrait<T*> {
        |                                               ^
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:798:40: error: wrong number of template arguments (1, should be 2)
    798 | struct FoldingSetTrait<std::pair<T1, T2>> {
        |                                        ^~
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: provided for ‘template<class T, class Enable> struct llvm::FoldingSetTrait’
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/Type.h: In static member function ‘static void clang::PackExpansionType::Profile(llvm::FoldingSetNodeID&, clang::QualType, llvm::Optional<unsigned int>)’:
  /usr/lib/llvm-15/include/clang/AST/Type.h:5808:33: error: ‘class llvm::Optional<unsigned int>’ has no member named ‘has_value’; did you mean ‘hasValue’?
   5808 |     ID.AddBoolean(NumExpansions.has_value());
        |                                 ^~~~~~~~~
        |                                 hasValue
  In file included from /usr/lib/llvm-15/include/clang/AST/DeclBase.h:18,
                   from /usr/lib/llvm-15/include/clang/AST/Decl.h:19,
                   from /usr/lib/llvm-15/include/clang/AST/ASTContext.h:22:
  /usr/lib/llvm-15/include/clang/AST/DeclarationName.h: At global scope:
  /usr/lib/llvm-15/include/clang/AST/DeclarationName.h:216:35: error: ‘addEnumValues’ is not a member of ‘llvm’
    216 |     CXXDeductionGuideName = llvm::addEnumValues(
        |                                   ^~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/DeclarationName.h:219:36: error: ‘addEnumValues’ is not a member of ‘llvm’
    219 |     CXXLiteralOperatorName = llvm::addEnumValues(
        |                                    ^~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/DeclarationName.h:223:15: error: ‘addEnumValues’ is not a member of ‘llvm’
    223 |         llvm::addEnumValues(UncommonNameKindOffset,
        |               ^~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/DeclarationName.h:226:15: error: ‘addEnumValues’ is not a member of ‘llvm’
    226 |         llvm::addEnumValues(UncommonNameKindOffset,
        |               ^~~~~~~~~~~~~
  In file included from /usr/lib/llvm-15/include/clang/Basic/ProfileList.h:16,
                   from /usr/lib/llvm-15/include/clang/AST/ASTContext.h:40:
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:119:40: error: ‘EmitDwarfUnwindType’ in namespace ‘llvm’ does not name a type
    119 | ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
        |                                        ^~~~~~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:433:3: note: in definition of macro ‘ENUM_CODEGENOPT’
    433 |   Type get##Name() const { return static_cast<Type>(Name); } \
        |   ^~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:119:40: error: ‘llvm::EmitDwarfUnwindType’ has not been declared
    119 | ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
        |                                        ^~~~~~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:434:18: note: in definition of macro ‘ENUM_CODEGENOPT’
    434 |   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
        |                  ^~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:479:41: error: ‘ZeroCallUsedRegs’ in namespace ‘llvm’ does not name a type
    479 | ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
        |                                         ^~~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:433:3: note: in definition of macro ‘ENUM_CODEGENOPT’
    433 |   Type get##Name() const { return static_cast<Type>(Name); } \
        |   ^~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:479:41: error: ‘llvm::ZeroCallUsedRegs’ has not been declared
    479 | ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
        |                                         ^~~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:434:18: note: in definition of macro ‘ENUM_CODEGENOPT’
    434 |   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
        |                  ^~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:434:23: error: expected ‘,’ or ‘...’ before ‘Value’
    434 |   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
        |                       ^~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:479:1: note: in expansion of macro ‘ENUM_CODEGENOPT’
    479 | ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
        | ^~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def: In member function ‘void clang::CodeGenOptions::setZeroCallUsedRegs(int)’:
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.h:434:61: error: ‘Value’ was not declared in this scope; did you mean ‘APValue’?
    434 |   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
        |                                                             ^~~~~
  /usr/lib/llvm-15/include/clang/Basic/CodeGenOptions.def:479:1: note: in expansion of macro ‘ENUM_CODEGENOPT’
    479 | ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
        | ^~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/ASTContext.h: In member function ‘bool clang::ASTContext::hasSameNullabilityTypeQualifier(clang::QualType, clang::QualType, bool) const’:
  /usr/lib/llvm-15/include/clang/AST/ASTContext.h:2566:25: error: ‘class llvm::Optional<clang::NullabilityKind>’ has no member named ‘has_value’; did you mean ‘hasValue’?
   2566 |     if (SubTnullability.has_value() == SuperTnullability.has_value()) {
        |                         ^~~~~~~~~
        |                         hasValue
  /usr/lib/llvm-15/include/clang/AST/ASTContext.h:2566:58: error: ‘class llvm::Optional<clang::NullabilityKind>’ has no member named ‘has_value’; did you mean ‘hasValue’?
   2566 |     if (SubTnullability.has_value() == SuperTnullability.has_value()) {
        |                                                          ^~~~~~~~~
        |                                                          hasValue
  In file included from /usr/lib/llvm-15/include/clang/Basic/FileEntry.h:17,
                   from /usr/lib/llvm-15/include/clang/Basic/SourceManager.h:38,
                   from /usr/lib/llvm-15/include/clang/Frontend/ASTUnit.h:23:
  /usr/lib/llvm-15/include/clang/Basic/DirectoryEntry.h: In member function ‘clang::OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr::operator const clang::DirectoryEntry*() const’:
  /usr/lib/llvm-15/include/clang/Basic/DirectoryEntry.h:302:12: error: ‘has_value’ was not declared in this scope; did you mean ‘hash_value’?
    302 |     return has_value() ? &value().getDirEntry() : nullptr;
        |            ^~~~~~~~~
        |            hash_value
  /usr/lib/llvm-15/include/clang/Basic/DirectoryEntry.h:302:27: error: ‘value’ was not declared in this scope; did you mean ‘APValue’?
    302 |     return has_value() ? &value().getDirEntry() : nullptr;
        |                           ^~~~~
        |                           APValue
  /usr/lib/llvm-15/include/clang/Basic/FileEntry.h: In member function ‘clang::OptionalFileEntryRefDegradesToFileEntryPtr::operator const clang::FileEntry*() const’:
  /usr/lib/llvm-15/include/clang/Basic/FileEntry.h:316:12: error: ‘has_value’ was not declared in this scope; did you mean ‘hash_value’?
    316 |     return has_value() ? &value().getFileEntry() : nullptr;
        |            ^~~~~~~~~
        |            hash_value
  /usr/lib/llvm-15/include/clang/Basic/FileEntry.h:316:27: error: ‘value’ was not declared in this scope; did you mean ‘APValue’?
    316 |     return has_value() ? &value().getFileEntry() : nullptr;
        |                           ^~~~~
        |                           APValue
  In file included from /usr/lib/llvm-15/include/clang/Frontend/PrecompiledPreamble.h:17,
                   from /usr/lib/llvm-15/include/clang/Frontend/ASTUnit.h:30:
  /usr/lib/llvm-15/include/clang/Lex/Preprocessor.h: In member function ‘bool clang::Preprocessor::PreambleConditionalStackStore::reachedEOFWhileSkipping() const’:
  /usr/lib/llvm-15/include/clang/Lex/Preprocessor.h:583:60: error: ‘const class llvm::Optional<clang::Preprocessor::PreambleSkipInfo>’ has no member named ‘has_value’; did you mean ‘hasValue’?
    583 |     bool reachedEOFWhileSkipping() const { return SkipInfo.has_value(); }
        |                                                            ^~~~~~~~~
        |                                                            hasValue
  In file included from /usr/lib/llvm-15/include/clang/AST/DeclFriend.h:20,
                   from /usr/lib/llvm-15/include/clang/AST/DeclVisitor.h:19,
                   from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:18:
  /usr/lib/llvm-15/include/clang/AST/DeclTemplate.h: In constructor ‘clang::TemplateTypeParmDecl::TemplateTypeParmDecl(clang::DeclContext*, clang::SourceLocation, clang::SourceLocation, clang::IdentifierInfo*, bool, bool, llvm::Optional<unsigned int>)’:
  /usr/lib/llvm-15/include/clang/AST/DeclTemplate.h:1245:33: error: ‘class llvm::Optional<unsigned int>’ has no member named ‘value_or’; did you mean ‘value_type’?
   1245 |         NumExpanded(NumExpanded.value_or(0)) {}
        |                                 ^~~~~~~~
        |                                 value_type
  In file included from /usr/lib/llvm-15/include/clang/AST/DeclOpenMP.h:21,
                   from /usr/lib/llvm-15/include/clang/AST/DeclVisitor.h:21:
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h: In constructor ‘clang::OMPHasDeviceAddrClause::OMPHasDeviceAddrClause(const clang::OMPVarListLocTy&, const clang::OMPMappableExprListSizeTy&)’:
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h:7462:46: error: ‘OMPC_has_device_addr’ is not a member of ‘llvm::omp’; did you mean ‘OMPC_use_device_addr’?
   7462 |       : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
        |                                              ^~~~~~~~~~~~~~~~~~~~
        |                                              OMPC_use_device_addr
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h: In constructor ‘clang::OMPHasDeviceAddrClause::OMPHasDeviceAddrClause(const clang::OMPMappableExprListSizeTy&)’:
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h:7473:46: error: ‘OMPC_has_device_addr’ is not a member of ‘llvm::omp’; did you mean ‘OMPC_use_device_addr’?
   7473 |       : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
        |                                              ^~~~~~~~~~~~~~~~~~~~
        |                                              OMPC_use_device_addr
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h: In static member function ‘static bool clang::OMPHasDeviceAddrClause::classof(const clang::OMPClause*)’:
  /usr/lib/llvm-15/include/clang/AST/OpenMPClause.h:7532:45: error: ‘OMPC_has_device_addr’ is not a member of ‘llvm::omp’; did you mean ‘OMPC_use_device_addr’?
   7532 |     return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
        |                                             ^~~~~~~~~~~~~~~~~~~~
        |                                             OMPC_use_device_addr
  In file included from /usr/lib/llvm-15/include/clang/AST/RecursiveASTVisitor.h:37,
                   from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:20:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedDirective::OMPParallelMaskedDirective(clang::SourceLocation, clang::SourceLocation)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:2325:43: error: ‘OMPD_parallel_masked’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master’?
   2325 |                                llvm::omp::OMPD_parallel_masked, StartLoc,
        |                                           ^~~~~~~~~~~~~~~~~~~~
        |                                           OMPD_parallel_master
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedDirective::OMPParallelMaskedDirective()’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:2330:43: error: ‘OMPD_parallel_masked’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master’?
   2330 |                                llvm::omp::OMPD_parallel_masked,
        |                                           ^~~~~~~~~~~~~~~~~~~~
        |                                           OMPD_parallel_master
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPMaskedTaskLoopDirective::OMPMaskedTaskLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:3889:37: error: ‘OMPD_masked_taskloop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_master_taskloop’?
   3889 |                          llvm::omp::OMPD_masked_taskloop, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_master_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPMaskedTaskLoopDirective::OMPMaskedTaskLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:3898:37: error: ‘OMPD_masked_taskloop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_master_taskloop’?
   3898 |                          llvm::omp::OMPD_masked_taskloop, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_master_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPMaskedTaskLoopSimdDirective::OMPMaskedTaskLoopSimdDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4027:37: error: ‘OMPD_masked_taskloop_simd’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_master_taskloop_simd’?
   4027 |                          llvm::omp::OMPD_masked_taskloop_simd, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_master_taskloop_simd
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPMaskedTaskLoopSimdDirective::OMPMaskedTaskLoopSimdDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4036:37: error: ‘OMPD_masked_taskloop_simd’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_master_taskloop_simd’?
   4036 |                          llvm::omp::OMPD_masked_taskloop_simd, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_master_taskloop_simd
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedTaskLoopDirective::OMPParallelMaskedTaskLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4175:37: error: ‘OMPD_parallel_masked_taskloop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master_taskloop’?
   4175 |                          llvm::omp::OMPD_parallel_masked_taskloop, StartLoc,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_master_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedTaskLoopDirective::OMPParallelMaskedTaskLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4184:37: error: ‘OMPD_parallel_masked_taskloop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master_taskloop’?
   4184 |                          llvm::omp::OMPD_parallel_masked_taskloop,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_master_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedTaskLoopSimdDirective::OMPParallelMaskedTaskLoopSimdDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4317:37: error: ‘OMPD_parallel_masked_taskloop_simd’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master_taskloop_simd’?
   4317 |                          llvm::omp::OMPD_parallel_masked_taskloop_simd,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_master_taskloop_simd
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelMaskedTaskLoopSimdDirective::OMPParallelMaskedTaskLoopSimdDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:4326:37: error: ‘OMPD_parallel_masked_taskloop_simd’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_master_taskloop_simd’?
   4326 |                          llvm::omp::OMPD_parallel_masked_taskloop_simd,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_master_taskloop_simd
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTeamsGenericLoopDirective::OMPTeamsGenericLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:5983:37: error: ‘OMPD_teams_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_taskloop’?
   5983 |                          llvm::omp::OMPD_teams_loop, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~
        |                                     OMPD_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTeamsGenericLoopDirective::OMPTeamsGenericLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:5992:37: error: ‘OMPD_teams_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_taskloop’?
   5992 |                          llvm::omp::OMPD_teams_loop, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~
        |                                     OMPD_taskloop
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTargetTeamsGenericLoopDirective::OMPTargetTeamsGenericLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6049:37: error: ‘OMPD_target_teams_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_target_teams’?
   6049 |                          llvm::omp::OMPD_target_teams_loop, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_target_teams
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTargetTeamsGenericLoopDirective::OMPTargetTeamsGenericLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6058:37: error: ‘OMPD_target_teams_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_target_teams’?
   6058 |                          llvm::omp::OMPD_target_teams_loop, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_target_teams
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelGenericLoopDirective::OMPParallelGenericLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6114:37: error: ‘OMPD_parallel_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_for’?
   6114 |                          llvm::omp::OMPD_parallel_loop, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_for
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPParallelGenericLoopDirective::OMPParallelGenericLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6123:37: error: ‘OMPD_parallel_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_parallel_for’?
   6123 |                          llvm::omp::OMPD_parallel_loop, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~~~~
        |                                     OMPD_parallel_for
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTargetParallelGenericLoopDirective::OMPTargetParallelGenericLoopDirective(clang::SourceLocation, clang::SourceLocation, unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6180:37: error: ‘OMPD_target_parallel_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_target_parallel_for’?
   6180 |                          llvm::omp::OMPD_target_parallel_loop, StartLoc, EndLoc,
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_target_parallel_for
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h: In constructor ‘clang::OMPTargetParallelGenericLoopDirective::OMPTargetParallelGenericLoopDirective(unsigned int)’:
  /usr/lib/llvm-15/include/clang/AST/StmtOpenMP.h:6189:37: error: ‘OMPD_target_parallel_loop’ is not a member of ‘llvm::omp’; did you mean ‘OMPD_target_parallel_for’?
   6189 |                          llvm::omp::OMPD_target_parallel_loop, SourceLocation(),
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
        |                                     OMPD_target_parallel_for
  /usr/lib/llvm-15/include/clang/AST/RecursiveASTVisitor.h: At global scope:
  /usr/lib/llvm-15/include/clang/AST/RecursiveASTVisitor.h:3778:6: error: no declaration matches ‘bool clang::RecursiveASTVisitor<Derived>::VisitOMPHasDeviceAddrClause(clang::OMPHasDeviceAddrClause*)’
   3778 | bool RecursiveASTVisitor<Derived>::VisitOMPHasDeviceAddrClause(
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/lib/llvm-15/include/clang/AST/RecursiveASTVisitor.h:3778:6: note: no functions named ‘bool clang::RecursiveASTVisitor<Derived>::VisitOMPHasDeviceAddrClause(clang::OMPHasDeviceAddrClause*)’
  /usr/lib/llvm-15/include/clang/AST/RecursiveASTVisitor.h:165:35: note: ‘class clang::RecursiveASTVisitor<Derived>’ defined here
    165 | template <typename Derived> class RecursiveASTVisitor {
        |                                   ^~~~~~~~~~~~~~~~~~~
  In file included from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:25:
  /usr/lib/llvm-15/include/clang/Basic/TargetInfo.h: In member function ‘virtual bool clang::TargetInfo::shouldDLLImportComdatSymbols() const’:
  /usr/lib/llvm-15/include/clang/Basic/TargetInfo.h:1209:69: error: ‘const class llvm::Triple’ has no member named ‘isPS’; did you mean ‘isPS4’?
   1209 |            getTriple().isWindowsItaniumEnvironment() || getTriple().isPS();
        |                                                                     ^~~~
        |                                                                     isPS4
  /usr/lib/llvm-15/include/clang/Basic/TargetInfo.h: In member function ‘virtual bool clang::TargetInfo::hasPS4DLLImportExport() const’:
  /usr/lib/llvm-15/include/clang/Basic/TargetInfo.h:1214:24: error: ‘const class llvm::Triple’ has no member named ‘isPS’; did you mean ‘isPS4’?
   1214 |     return getTriple().isPS() ||
        |                        ^~~~
        |                        isPS4
  In file included from /usr/lib/llvm-15/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:17,
                   from /usr/lib/llvm-15/include/clang/Frontend/CompilerInvocation.h:22,
                   from /usr/lib/llvm-15/include/clang/Frontend/CompilerInstance.h:15,
                   from /home/alix_anneraud/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/b2b8b13/c2rust-ast-exporter/src/AstExporter.cpp:27:
  /usr/lib/llvm-15/include/clang/Analysis/PathDiagnostic.h: In member function ‘bool clang::ento::PathDiagnosticEventPiece::isPrunable() const’:
  /usr/lib/llvm-15/include/clang/Analysis/PathDiagnostic.h:553:47: error: ‘const class llvm::Optional<bool>’ has no member named ‘value_or’; did you mean ‘value_type’?
    553 |   bool isPrunable() const { return IsPrunable.value_or(false); }
        |                                               ^~~~~~~~
        |                                               value_type
  gmake[3]: *** [CMakeFiles/clangAstExporter.dir/build.make:76 : CMakeFiles/clangAstExporter.dir/AstExporter.cpp.o] Erreur 1
  gmake[2]: *** [CMakeFiles/Makefile2:247 : CMakeFiles/clangAstExporter.dir/all] Erreur 2
  gmake[1]: *** [CMakeFiles/Makefile2:254 : CMakeFiles/clangAstExporter.dir/rule] Erreur 2
  gmake: *** [Makefile:202 : clangAstExporter] Erreur 2
  thread 'main' panicked at /home/alix_anneraud/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.45/src/lib.rs:894: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
warning: build failed, waiting for other jobs to finish...
error: failed to compile `c2rust v0.16.0 (https://github.com/immunant/c2rust.git?branch=feature/llvm-15.0.0#b2b8b131)`, intermediate artifacts can be found at `/tmp/cargo-installhCisjl`.

Is there a version mismatch with llvm ? I didn't test with llvm-11 and llvm-12 though (not in the main ubuntu repository anymore).

kkysen commented 8 months ago

@thedataking, might this have something to do with #1041?

thedataking commented 8 months ago

Not entirely sure what the problem is but it appears that the build is picking up files from both LLVM 14 and 15, e.g.:

/usr/lib/llvm-14/include/llvm/ADT/FoldingSet.h:258:29: error: redeclared with 1 template parameter
    258 | template<typename T> struct FoldingSetTrait
        |                             ^~~~~~~~~~~~~~~
  In file included from /usr/lib/llvm-15/include/clang/Basic/Diagnostic.h:19,
                   from /usr/lib/llvm-15/include/clang/AST/NestedNameSpecifier.h:18:
  /usr/lib/llvm-15/include/clang/Basic/SourceLocation.h:27:47: note: previous declaration ‘template<class T, class Enable> struct llvm::FoldingSetTrait’ used 2 template parameters
     27 | template <typename T, typename Enable> struct FoldingSetTrait;
        |                                               ^~~~~~~~~~~~~~~

Can you try to explicitly set the LLVM version like this: LLVM_CONFIG_PATH=llvm-config-15 cargo install c2rust?

I just confirmed that if you install rustup and the c2rust prerequisites in a pristine ubuntu:23.04 docker image (cd /path/to/c2rust && docker run -it --rm --privileged -v $PWD:/opt/c2rust ubuntu:23.04 /bin/bash), c2rust builds correctly against LLVM 15.0.7.