Coder Social home page Coder Social logo

rust bindings fail to build about cachelib HOT 12 OPEN

brayniac avatar brayniac commented on April 25, 2024
rust bindings fail to build

from cachelib.

Comments (12)

leozzx avatar leozzx commented on April 25, 2024

Hi @brayniac, I'm not familiar with rust, but it is complaining cachelib/rust/src/cachelib.h not found. The file does exist, so can you try to build in the root directory (CacheLib/) instead of rust directory?

from cachelib.

brayniac avatar brayniac commented on April 25, 2024

@leozzx - unfortunately that won't work because the repo root is not a crate or workspace root.

CacheLib$ cargo build --release
error: could not find `Cargo.toml` in `/home/brian/CacheLib` or any parent directory

from cachelib.

farnz avatar farnz commented on April 25, 2024

Can you try and teach the cc::Build returned by the build.rs that /home/brian/CacheLib is a root for includes? I think this would involve constructing a Path using the result of std::env::current_dir and passing it to the include method on the Build object.

from cachelib.

therealgymmy avatar therealgymmy commented on April 25, 2024

cc @agordon for advice.

from cachelib.

brayniac avatar brayniac commented on April 25, 2024

@therealgymmy @agordon @farnz - any updates on this?

from cachelib.

journaux avatar journaux commented on April 25, 2024
"Can you try and teach the [cc::Build](https://docs.rs/cc/1.0.72/cc/struct.Build.html) returned by the build.rs that /home/brian/CacheLib is a root for includes? I think this would involve constructing a Path using the result of [std::env::current_dir](https://doc.rust-lang.org/std/env/fn.current_dir.html) and passing it to the include method on the Build object."

@farnz resolves the first issue,
then in debian/ubuntu missing dependency headers forms new errors

  cargo:warning=/CacheLib/cachelib/rust/../../cachelib/rust/src/cachelib.h:24:10: fatal error: cachelib/facebook/admin/CacheAdmin.h: No such file or directory
  cargo:warning=   24 | #include "cachelib/facebook/admin/CacheAdmin.h"
  cargo:warning=      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=compilation terminated.

when removing the admin (a private facebook header file), the build fails on lack of rust bindings for folly string type.

i removed the references to std::chrono::timestamp & folly::String types, replacing them with primitives i64 & std::string respectively in order to achieve a successful compilation

by example

Screen Shot 2022-06-04 at 1 16 39 AM

all in all => need to have the folly rust bindings in order to compile cachelib - otherwise, the community can not implement Cxx Extern Type for ffi.

more than happy to help if a contributor wants to hop on a video call so that we can consume cachelib in rust/c.

thank u for a great library. the only high quality, multi threaded caching library for ssd we've found. twitter pelikan single threaded & does not support 10TB ssd drives.

from cachelib.

therealgymmy avatar therealgymmy commented on April 25, 2024

@vitruvvius: thanks for figuring out a fix! Could you send out a PR?

from cachelib.

journaux avatar journaux commented on April 25, 2024

i'd rather see folly & std::chrono::timestamp resolved w/ FFI bindings than the strategy provided

from cachelib.

journaux avatar journaux commented on April 25, 2024

what are we doing about this, if at all?
happy to contribute if the facebook team ok w/ transitioning off folly/chrono dependency on the ffi,
albeit i doubt that they want to fork + maintain an oss mirrior.

from cachelib.

journaux avatar journaux commented on April 25, 2024

one thing that might be interesting is to move away from hand-writing the FFI & integrating autocxx from google https://github.com/google/autocxx

from cachelib.

nickamorim avatar nickamorim commented on April 25, 2024

Even with the change proposed by @journaux, the Rust bindings still fail to build.

  cargo:warning=In file included from /Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/src/cachelib.h:22:0,

  cargo:warning=                 from /Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/sources/cachelib/src/lib.rs.cc:1:

  cargo:warning=/Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/allocator/CacheAllocator.h:19:10: fatal error: folly/CPortability.h: No such file or directory

  cargo:warning= #include <folly/CPortability.h>

  cargo:warning=          ^~~~~~~~~~~~~~~~~~~~~~

  cargo:warning=compilation terminated.

  exit status: 1

  --- stderr

  CXX include path:
    /Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/include
    /Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/crate


  error occurred: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/include" "-I" "/Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/crate" "-I" "/Users/nickamorim/src/github.com/Shopify/CacheLib" "-Wall" "-Wextra" "-std=c++11" "-o" "/Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/2198180abe54d98b-lib.rs.o" "-c" "/Users/nickamorim/src/github.com/Shopify/CacheLib/cachelib/rust/target/debug/build/cachelib-7bbe50bf6a183fab/out/cxxbridge/sources/cachelib/src/lib.rs.cc" with args "c++" did not execute successfully (status code exit status: 1).

from cachelib.

journaux avatar journaux commented on April 25, 2024

@nickamorim that seems a folly version / include path bug, nonetheless a lot of adjustments needed circa 8 months ago to compile properly (watch out for stack smashing in rust :: c++ ffi). anecdotally, somebody informed me facebook never released their internal cache eviction policy for cachelib, implying the public implementation does not match the private deployment.

from cachelib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.