c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

Build errors due to outdated crates

Open theoparis opened this issue 10 months ago • 3 comments

I used this default.nix from another issue on this repository and received build errors due to the unmaintained proc-macro-error crate (the flake.nix file wants me to rebuild rustc). I think the clap crate is the problem.

# nix-build -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'

{
  lib,
  pkgs,
  rustPlatform,
}:

rustPlatform.buildRustPackage {
  pname = "c2rust";
  version = "unstable";
  src = ./.;
  cargoHash = "sha256-yZC78yI0D9wLK5bY6mtuiqjkSOCeLBL0tsFQSoekBmM=";

  LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
  LIBCXX_INCLUDE_DIR = "${pkgs.llvmPackages.libcxx.dev}/include";
  LLVM_CONFIG_PATH = "${pkgs.llvmPackages.llvm.dev}/bin/llvm-config";
  LLVM_INCLUDE_DIR = "${pkgs.llvmPackages.llvm.dev}/include"; # /nix/store/w8p79yfq5059141frg9p4z17nr6s999w-llvm-11.1.0-dev/include
  LLVM_LIB_DIR = "${pkgs.llvmPackages.llvm.lib}/lib";
  LIBC_INCLUDE_DIR = "${pkgs.llvmPackages.libclang.lib}/lib/clang/${pkgs.llvmPackages.libclang.version}/include";
  # Required to prevent cmake from downloading tinycbor
  DOCS_RS = true;

  nativeBuildInputs = [
    pkgs.python3 # c2rust-refactor -> python3 process_ast.py
    pkgs.pkg-config # c2rust-bitfields-derive -> pkg-config --libs --cflags openssl
    pkgs.llvmPackages.llvm # c2rust-ast-exporter -> llvm-config
    pkgs.llvmPackages.llvm.dev # c2rust-ast-exporter -> #include "llvm/Support/CommandLine.h"
    pkgs.cmake # c2rust-ast-exporter
    pkgs.tinycbor # c2rust-ast-exporter
  ];
  buildInputs = [
    pkgs.openssl
    pkgs.zlib
    pkgs.llvmPackages.libclang.lib
    pkgs.llvmPackages.libclang.dev # c2rust-ast-exporter -> #include "clang/Frontend/FrontendActions.h"
    pkgs.llvmPackages.libcxx
    pkgs.llvmPackages.libcxx.dev # c2rust-ast-exporter -> #include <algorithm>
    pkgs.tinycbor # c2rust-ast-exporter
  ];

  meta = with lib; {
    description = "Migrate C code to Rust";
    homepage = "https://github.com/immunant/c2rust";
    license = licenses.bsd3;
  };
}

Error:

> error[E0277]: the trait bound `proc_macro2::Span: From<proc_macro::Span>` is not satisfied
       >    --> /build/c2rust-unstable-vendor.tar.gz/proc-macro-error/src/lib.rs:549:37
       >     |
       > 549 |                 first: self.clone().into(),
       >     |                                     ^^^^ the trait `From<proc_macro::Span>` is not implemented for `proc_macro2::Span`, which is required by `proc_macro::Span: Into<_>`
       >     |
       >     = note: required for `proc_macro::Span` to implement `Into<proc_macro2::Span>`
       >
       > error[E0277]: the trait bound `proc_macro2::Span: From<proc_macro::Span>` is not satisfied
       >    --> /build/c2rust-unstable-vendor.tar.gz/proc-macro-error/src/lib.rs:550:36
       >     |
       > 550 |                 last: self.clone().into(),
       >     |                                    ^^^^ the trait `From<proc_macro::Span>` is not implemented for `proc_macro2::Span`, which is required by `proc_macro::Span: Into<_>`
       >     |
       >     = note: required for `proc_macro::Span` to implement `Into<proc_macro2::Span>`
       >
       > For more information about this error, try `rustc --explain E0277`.
       > error: could not compile `proc-macro-error` (lib) due to 2 previous errors
       > warning: build failed, waiting for other jobs to finish...

theoparis avatar Jan 17 '25 01:01 theoparis

I attemped to update all of the crate versions locally and ran into https://github.com/eyre-rs/eyre/issues/214

theoparis avatar Jan 17 '25 02:01 theoparis

Hi @theoparis, I doubt we'll be able to land a PR that upgrades all crate versions. Some crates depend on a newer rustc toolchain which is difficult and risky to migrate to. (Not saying we shouldn't do it, just that it is a huge task.) May I suggest you try a more targeted update that resolves exactly the issue you're hitting - assuming that's an option?

thedataking avatar Jan 18 '25 01:01 thedataking

Some crates depend on a newer rustc toolchain which is difficult and risky to migrate to.

Is it at least possible by now to move from nightly to stable?

omarandlorraine avatar Feb 10 '25 10:02 omarandlorraine