Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build errors due to outdated crates #1196

Open
theoparis opened this issue Jan 17, 2025 · 2 comments
Open

Build errors due to outdated crates #1196

theoparis opened this issue Jan 17, 2025 · 2 comments

Comments

@theoparis
Copy link

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
Copy link
Author

I attemped to update all of the crate versions locally and ran into eyre-rs/eyre#214

@thedataking
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants