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

Compilation errors in ONNX ML Inference guest code: "could not find unix in os" from filetime dependency #617

Open
grandchildrice opened this issue Mar 20, 2025 · 5 comments

Comments

@grandchildrice
Copy link

grandchildrice commented Mar 20, 2025

Context:

We are collaborating with the Novanet team to implement zkML using Jolt. As a first step, we are writing Jolt guest code to load a simple Gradient Boosting model from an ONNX file and execute inference. However, during compilation of our guest code, we are encountering errors related to the filetime crate.


Steps to Reproduce:

  1. Clone our guest implementation here run onnx in guest ICME-Lab/zkml-jolt#4
  2. Build and run the guest code using:
    cargo run -r -p onnx --bin prove_onnx

Expected Behavior:

The code should compile without issues and perform inference using the ONNX model.


Actual Behavior:

Compilation fails with errors originating from the filetime crate. Key error messages include:

  • Error regarding missing Unix module:
    error[E0433]: failed to resolve: could not find `unix` in `os`
      --> filetime-0.2.25/src/unix/mod.rs:4:14
       |
    4 | use std::os::unix::prelude::*;
       |              ^^^^ could not find `unix` in `os`
    
  • Additional errors related to libc and missing methods (e.g., as_raw_fd, mtime, atime):
    error[E0432]: unresolved import `libc`
    error[E0599]: no method named `as_raw_fd` found for reference `&File` in the current scope
    ...
    

Workarounds Attempted:

  1. Default Features Disabled:
    We set filetime = { version = "0.2", default-features = false } in our guest project’s Cargo.toml to disable Unix-specific code. However, the error still occurs.

  2. Patching filetime via [patch.crates-io]:
    We attempted to override filetime using a patch in our guest project’s Cargo.toml and then in the workspace root. The patch was rejected with the message:

    warning: patch for `filetime` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
    error: failed to resolve patches for `https://github.com/rust-lang/crates.io-index`
    Caused by:
      patch for `filetime` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources
    

    This indicates that patching the filetime crate in this way isn’t working because it points to the same source as crates.io.

  3. Target Configuration:
    We considered whether our build target might be causing the issue (i.e., a non-Unix or custom target environment where std::os::unix is unavailable). However, it is unclear whether adjusting target specifications alone can resolve the issue.


Additional Information:

  • The filetime crate’s own Cargo.toml uses conditional dependencies to include libc on Unix platforms. It appears that on our target, the #[cfg(unix)] condition is being incorrectly evaluated, leading to compilation of Unix-specific code on a non-Unix target.
  • Our project’s workspace includes Jolt’s jolt-core, which does not seem to modify the dependency on filetime directly.
  • We have confirmed that the guest code and workspace Cargo.toml do not override filetime elsewhere.

Request:

Could you please advise on how to resolve these compilation issues?

  • Is there a known workaround for building Jolt guest code on our target environment?
  • Should we use a fork of filetime with modifications for non-Unix targets?
  • Are there any adjustments required in Jolt’s dependency management for proper cross-platform compatibility?

Thank you for your assistance.

@moodlezoup
Copy link
Collaborator

@grandchildrice filetime is not in our Cargo.lock, so I think it might be some incompatibility between ONNX and your target?

@moodlezoup
Copy link
Collaborator

@grandchildrice were you able to resolve this issue?

@wyattbenno777
Copy link

I tried this on a Mac M4 and it works fine. @grandchildrice what are the machine specs?

@grandchildrice
Copy link
Author

Sorry, I have modified the relevant command to execute a different code. The error can be reproduced from this PR.

ICME-Lab#4

@grandchildrice
Copy link
Author

The filetime is imported from trac_onnx used by guest, and for some reason the os library used by this library is attempting to import unix.

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

3 participants