Repository navigation
Build the library for a target without std - #287
Merged
Merged
Conversation
The `cgp` crate could not be used in a `no_std` environment: `cgp-base-types`, `cgp-runtime`, and `cgp-base` lacked `#![no_std]`, so a build for a target without `std` failed on them, and two defaults turned `alloc` on, so even `default-features = false` pulled it in. The three crates now carry `#![no_std]`. `cgp-error-extra`'s default is empty and its `alloc` feature gates the providers that need an allocator; `cgp-extra`'s default is empty and forwards `alloc`; and `cgp` gained an `alloc` feature that forwards to it. With default features the crate needs neither `std` nor `alloc`. `cgp-no-std-tests` builds the library for `x86_64-unknown-none` with and without `alloc`, so a `std` or `alloc` leak fails the build.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
[deepseek-v4.1-flash] The
cgpcrate now builds for a target withoutstd, and its default features need neitherstdnoralloc. Ano_stdtest crate builds the library forx86_64-unknown-nonewith and withoutalloc, so a leak fails the build.Motivation
The library could not be used in a
no_stdenvironment.cgp-base-types,cgp-runtime, andcgp-baselacked#![no_std], socargo check -p cgp --target x86_64-unknown-nonefailed oncgp-base-typeswith "can't find crate forstd". Two defaults also turnedallocon:cgp-extra'sdefault = ["full"], wherefullenabledcgp-error-extra/alloc, andcgp-error-extra's owndefault = ["alloc"], which turned the feature on regardless of who asked.Impact
The three crates carry
#![no_std].cgp-error-extra's default is empty and itsallocfeature gatesDebugErrorandDisplayError;cgp-extra's default is empty and forwardsalloc; andcgpgained anallocfeature that forwards to it. Ano_stduser who needs an allocator writesdefault-features = false, features = ["alloc"].The error backends keep their requirements:
cgp-error-anyhowandcgp-error-stdneedalloc, andcgp-error-eyreneedsstd.cgp-no-std-testsis#![no_std], uses a component, a provider,#[cgp_fn],Symbol!, and a wiring table, and gates an alloc-using provider behind itsallocfeature. Building it forx86_64-unknown-nonefails if any crate in the tree needsstd, and planting astduse in it fails with "cannot find module or cratestd".One finding is left for a follow-up: a
#[cgp_fn]with an#[implicit] name: &strargument generates aStringfield bound, so it needsalloc. The test crate uses au32implicit instead.