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

[RFC] support panic and target_has_atomic predicates #49

Merged
merged 4 commits into from
May 19, 2022

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Apr 27, 2022

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

There are a couple of new predicates in Rust 1.60: target_has_atomic
and panic. Here's a first cut at supporting them.

For now, skip implementing them in target-lexicon and always return false.

The panic predicate depends both on native platform support (default
behavior) and on a potential override through RUSTFLAGS. This can be
handled in downstream libraries that need to model such overrides.

@sunshowers
Copy link
Contributor Author

@Jake-Shadle Having looked at it, it seems too hard to maintain support for target-lexicon -- has_atomics itself is really difficult as it's a property of the whole triple rather than that of a specific architecture 😬 For example, aarch64 has 128-bit atomics on most platforms but not on Windows or UEFI.

My suggestion would probably be to remove target-lexicon support -- it's just way too difficult to maintain support.

(As a side note, I think it would be cool to also publish the minimal set of target features in builtins.rs.)

@Jake-Shadle
Copy link
Member

I think supporting target-lexicon is still nice since it allows this crate to support non-builtin targets to some degree, and this crate's motivating use case was supporting krates by filtering target specific dependencies from the graph, which is a more limited use case than that of eg rustc itself as most target filtering done in cargo manifests is limited to the basics. So I don't see a strong need to support every possible component that could appear in a cfg expression unless someone actually has a strong use case for it.

@sunshowers sunshowers force-pushed the panic-has-atomic branch 2 times, most recently from 3826447 to 9286491 Compare May 18, 2022 18:32
There are a couple of new predicates in Rust 1.60: `target_has_atomic`
and `panic`. Here's a first cut at supporting them.

The panic predicate depends both on native platform support (default
behavior) and on a potential override through RUSTFLAGS. This can be
handled in downstream libraries that need such overrides.
@sunshowers
Copy link
Contributor Author

OK, I've changed it to just return false for target-lexicon.

Copy link
Member

@Jake-Shadle Jake-Shadle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Jake-Shadle Jake-Shadle merged commit 1322205 into EmbarkStudios:main May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants