failure icon indicating copy to clipboard operation
failure copied to clipboard

Support for an alloc feature?

Open cbeck88 opened this issue 4 years ago • 1 comments

I'm trying to port prost so that it can work in an alloc-only environment. Specifically we want to use it inside of an SGX enclave.

prost-derive is a proc-macro crate, that uses failure crate to do error handling. Unfortunately for us, it turns out that prost-derive uses failure::Error and failure::Bail, which require the feature failure/std. But because of long-standing issues in cargo, this means that failure crate will globally be std, and so our no_std, alloc-only targets won't build that are using failure crate.

There's a separate issue in cargo project so that deps of build.rs and proc-macro don't infect the rest of the build but it's a long way away as I understand.

Are you interested in a patch that adds an alloc feature to failure crate and makes more of failure crate, specifically the macros, work in alloc mode?

I'm trying to decide if the best way forward for our project is to patch prost-derive away from using failure crate, or to try to make these parts of failure crate more portable.

cbeck88 avatar Sep 12 '19 22:09 cbeck88

As a temporary workaround, I have republished this crate as alt-failure on cargo, so that I can make prost-derive depend on it instead of failure crate in my project, but renaming it to failure in prost-derive Cargo.toml so that no code changes in prost-derive are needed for this issue. Then the proc-macro is free to use std without causing std to infect the main target. Would love a better solution

cbeck88 avatar Sep 12 '19 22:09 cbeck88