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

restricted_std applicability to custom JSON targets #90

Open
Mark-Simulacrum opened this issue Feb 11, 2024 · 2 comments
Open

restricted_std applicability to custom JSON targets #90

Mark-Simulacrum opened this issue Feb 11, 2024 · 2 comments
Labels
plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. stabilization blocker This needs a resolution before stabilization

Comments

@Mark-Simulacrum
Copy link
Member

In rust-lang/rust#120232, std's build script was moved to using the TARGET_OS and other fine-grained environment variables set by Cargo. This means that some JSON targets (regardless of filename, which is the previous filter?) do not enable the restricted_std mode.

Before stabilizing -Zbuild-std, we will want to figure out what guarantees we want to make here.

cc rust-lang/rust#71009, rust-lang/rust#38338

@Mark-Simulacrum Mark-Simulacrum added plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. stabilization blocker This needs a resolution before stabilization labels Feb 11, 2024
@ehuss
Copy link
Contributor

ehuss commented Feb 12, 2024

Thanks for filing the issue! I'm a little unclear about exactly what this means, can you clarify? Is this possibly suggesting that the "std supported" flag should be in the target spec and not in std's build.rs?

I think my original intent was:

  • If you create a target.json with target cfg values that match what is in std's build.rs, then you get full access to std. Presumably you are building for a custom target that is similar enough to the existing targets, and I would expect it to "just work".
  • If you create a target.json with target cfg values that do not match watch is in std's build.rs, then you don't get access to std, just core (and maybe alloc?).

There is a much larger question of "I want to build for a new target, and I need to modify std to do it.", which is tracked in #3. I'm skeptical that moving just the "std supported" flag to the target spec will be sufficient for most custom targets.

If/when build-std is stabilized, I would want to ensure that rust-lang/rust#71009 is resolved first.

#6 also contains some considerations for why target-spec JSON needs a lot of work.

@Mark-Simulacrum
Copy link
Member Author

Mark-Simulacrum commented Feb 12, 2024

I think if target specs are not stable (i.e. rust-lang/rust#71009) then this is not really a problem for build-std (any instability in std builds is under the target spec instability umbrella at that point).

The current way we decide whether std is stable or not is by matching on a small subset of the target cfg values. For example, if I am target something like wasm32-linux, that might be considered stable by the current rules in std's build script, but perhaps should not be.

I filed this mostly since we closed #60 -- there should be, IMO, some explicit decision in the RFC/FCP stabilizing build-std as to how we do the filter in std's build.rs. Right now that filter is pretty loose, we may want to tighten it (e.g., must precisely match a tier-3+ target that's in tree across all cfgs). Maybe this should be closed as a duplicate of #6.

fmease pushed a commit to fmease/rust that referenced this issue Apr 10, 2024
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.
fmease added a commit to fmease/rust that referenced this issue 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`
fmease added a commit to fmease/rust that referenced this issue 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``
fmease added a commit to fmease/rust that referenced this issue 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```
rust-timer added a commit to rust-lang-ci/rust that referenced this issue 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```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. stabilization blocker This needs a resolution before stabilization
Projects
None yet
Development

No branches or pull requests

2 participants