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

Document restricted_std #123360

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

adamgemmell
Copy link
Contributor

This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't.

This commit fixes rust-lang/wg-cargo-std-aware#87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see #27242 #103765).

Note that the message says "platform" and "environment" because, since #120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable rust-lang/wg-cargo-std-aware#90), but a JSON target with the right configuration should hopefully have some partial libstd support.

I propose closing rust-lang/wg-cargo-std-aware#69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time.

The alternative to closing rust-lang/wg-cargo-std-aware#69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.

cc @ehuss

This PR aims to pin down exactly what restricted_std is meant to achieve
and what it isn't.

This commit fixes rust-lang/wg-cargo-std-aware#87
by explaining why the error appears and what the choices the user has.
The error describes how std cannot function without knowing about some
form of OS/platform support. Any features of std that work without an
OS should be moved to core/alloc (see rust-lang#27242
rust-lang#103765).

Note that the message says "platform" and "environment" because, since
rust-lang#120232, libstd can be built for
some JSON targets. This is still unsupported (all JSON targets probably
should be unstable rust-lang/wg-cargo-std-aware#90),
but a JSON target with the right configuration should hopefully have
some partial libstd support.

I propose closing rust-lang/wg-cargo-std-aware#69
as "Won't fix" since any support of std without properly configured os,
vendor or env fields is very fragile considering future upgrades of Rust
or dependencies. In addition there's no likely path to it being fixed
long term (making std buildable for all targets being the only
solution). This is distinct from tier 3 platforms with limited std
support implemented (and as such aren't restricted_std) because these
platforms can conceptually work in the future and std support should
mainly improve over time.

The alternative to closing rust-lang/wg-cargo-std-aware#69
is a new crate feature for std which escapes the restricted_std
mechanism in build.rs. It could be used with the -Zbuild-std-features
flag if we keep it permanently unstable, which I hope we can do anyway.
A minor side-effect in this scenario is that std wouldn't be marked as
unstable if documentation for it were generated with build-std.
@rustbot
Copy link
Collaborator

rustbot commented Apr 2, 2024

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 2, 2024
@Amanieu
Copy link
Member

Amanieu commented Apr 10, 2024

r? @ehuss

@rustbot rustbot assigned ehuss and unassigned Amanieu Apr 10, 2024
@ehuss
Copy link
Contributor

ehuss commented Apr 10, 2024

Thanks! I'm still not sure what the long-term solution will be here, particularly since I think this will be a common problem. There might need to be other things like explicit statements of compatibility in Cargo.toml, or having rustc know and report when a platform has std support. I don't know what that will ultimately look like.

This is a definite improvement, though!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 10, 2024

📌 Commit 8923b58 has been approved by ehuss

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 10, 2024
fmease added a commit to fmease/rust that referenced this pull request Apr 10, 2024
…d-std, r=ehuss

Document restricted_std

This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't.

This commit fixes rust-lang/wg-cargo-std-aware#87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see rust-lang#27242 rust-lang#103765).

Note that the message says "platform" and "environment" because, since rust-lang#120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable rust-lang/wg-cargo-std-aware#90), but a JSON target with the right configuration should hopefully have some partial libstd support.

I propose closing rust-lang/wg-cargo-std-aware#69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time.

The alternative to closing rust-lang/wg-cargo-std-aware#69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.

cc `@ehuss`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 10, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#122470 (`f16` and `f128` step 4: basic library support)
 - rust-lang#122954 (Be more specific when flagging imports as redundant due to the extern prelude)
 - rust-lang#123314 (Skip `unused_parens` report for `Paren(Path(..))` in macro.)
 - rust-lang#123360 (Document restricted_std)
 - rust-lang#123703 (Use `fn` ptr signature instead of `{closure@..}` in infer error)
 - rust-lang#123732 (Factor some common `io::Error` constants)

r? `@ghost`
`@rustbot` modify labels: rollup
fmease added a commit to fmease/rust that referenced this pull request Apr 10, 2024
…d-std, r=ehuss

Document restricted_std

This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't.

This commit fixes rust-lang/wg-cargo-std-aware#87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see rust-lang#27242 rust-lang#103765).

Note that the message says "platform" and "environment" because, since rust-lang#120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable rust-lang/wg-cargo-std-aware#90), but a JSON target with the right configuration should hopefully have some partial libstd support.

I propose closing rust-lang/wg-cargo-std-aware#69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time.

The alternative to closing rust-lang/wg-cargo-std-aware#69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.

cc ``@ehuss``
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 10, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#122470 (`f16` and `f128` step 4: basic library support)
 - rust-lang#122954 (Be more specific when flagging imports as redundant due to the extern prelude)
 - rust-lang#123314 (Skip `unused_parens` report for `Paren(Path(..))` in macro.)
 - rust-lang#123360 (Document restricted_std)
 - rust-lang#123661 (Stabilize `cstr_count_bytes`)
 - rust-lang#123703 (Use `fn` ptr signature instead of `{closure@..}` in infer error)
 - rust-lang#123704 (Tweak value suggestions in `borrowck` and `hir_analysis`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 11, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#122470 (`f16` and `f128` step 4: basic library support)
 - rust-lang#122954 (Be more specific when flagging imports as redundant due to the extern prelude)
 - rust-lang#123314 (Skip `unused_parens` report for `Paren(Path(..))` in macro.)
 - rust-lang#123360 (Document restricted_std)
 - rust-lang#123661 (Stabilize `cstr_count_bytes`)
 - rust-lang#123703 (Use `fn` ptr signature instead of `{closure@..}` in infer error)
 - rust-lang#123756 (clean up docs for `File::sync_*`)
 - rust-lang#123761 (Use `suggest_impl_trait` in return type suggestion on type error)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 11, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#122470 (`f16` and `f128` step 4: basic library support)
 - rust-lang#122954 (Be more specific when flagging imports as redundant due to the extern prelude)
 - rust-lang#123314 (Skip `unused_parens` report for `Paren(Path(..))` in macro.)
 - rust-lang#123360 (Document restricted_std)
 - rust-lang#123661 (Stabilize `cstr_count_bytes`)
 - rust-lang#123703 (Use `fn` ptr signature instead of `{closure@..}` in infer error)
 - rust-lang#123756 (clean up docs for `File::sync_*`)
 - rust-lang#123761 (Use `suggest_impl_trait` in return type suggestion on type error)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 084d27b into rust-lang:master Apr 11, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 11, 2024
Rollup merge of rust-lang#123360 - adamgemmell:dev/adagem01/restricted-std, r=ehuss

Document restricted_std

This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't.

This commit fixes rust-lang/wg-cargo-std-aware#87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see rust-lang#27242 rust-lang#103765).

Note that the message says "platform" and "environment" because, since rust-lang#120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable rust-lang/wg-cargo-std-aware#90), but a JSON target with the right configuration should hopefully have some partial libstd support.

I propose closing rust-lang/wg-cargo-std-aware#69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time.

The alternative to closing rust-lang/wg-cargo-std-aware#69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.

cc ```@ehuss```
@adamgemmell adamgemmell deleted the dev/adagem01/restricted-std branch April 11, 2024 08:49
@adamgemmell
Copy link
Contributor Author

@ehuss Makes sense. It looks like the target spec recently gained a mechanism to report whether it supports std. Maybe the best path forwards then is to use that.

If we do that, I think restricted_std should stay in case a JSON target says it supports std but doesn't set it's os/env fields to something std knows about. In that case #69 could be closed with the answer "use a different target" or "edit your JSON spec"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The restricted_std error message is confusing
5 participants