{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/2045","repository_url":"https://api.github.com/repos/rust-lang/rfcs","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/2045/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/2045/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/2045/events","html_url":"https://github.com/rust-lang/rfcs/pull/2045","id":238606351,"number":2045,"title":"RFC: target_feature","user":{"login":"gnzlbg","id":904614,"avatar_url":"https://avatars0.githubusercontent.com/u/904614?v=4","gravatar_id":"","url":"https://api.github.com/users/gnzlbg","html_url":"https://github.com/gnzlbg","followers_url":"https://api.github.com/users/gnzlbg/followers","following_url":"https://api.github.com/users/gnzlbg/following{/other_user}","gists_url":"https://api.github.com/users/gnzlbg/gists{/gist_id}","starred_url":"https://api.github.com/users/gnzlbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnzlbg/subscriptions","organizations_url":"https://api.github.com/users/gnzlbg/orgs","repos_url":"https://api.github.com/users/gnzlbg/repos","events_url":"https://api.github.com/users/gnzlbg/events{/privacy}","received_events_url":"https://api.github.com/users/gnzlbg/received_events","type":"User","site_admin":false},"labels":[{"id":211667901,"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-libs","name":"T-libs","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"assignees":[{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},{"login":"BurntSushi","id":456674,"avatar_url":"https://avatars3.githubusercontent.com/u/456674?v=4","gravatar_id":"","url":"https://api.github.com/users/BurntSushi","html_url":"https://github.com/BurntSushi","followers_url":"https://api.github.com/users/BurntSushi/followers","following_url":"https://api.github.com/users/BurntSushi/following{/other_user}","gists_url":"https://api.github.com/users/BurntSushi/gists{/gist_id}","starred_url":"https://api.github.com/users/BurntSushi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BurntSushi/subscriptions","organizations_url":"https://api.github.com/users/BurntSushi/orgs","repos_url":"https://api.github.com/users/BurntSushi/repos","events_url":"https://api.github.com/users/BurntSushi/events{/privacy}","received_events_url":"https://api.github.com/users/BurntSushi/received_events","type":"User","site_admin":false}],"milestone":null,"comments":70,"created_at":"2017-06-26T16:59:26Z","updated_at":"2017-07-19T23:11:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/2045","html_url":"https://github.com/rust-lang/rfcs/pull/2045","diff_url":"https://github.com/rust-lang/rfcs/pull/2045.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/2045.patch"},"body":"This is an RFC for `cfg!(target_feature)` and `#[target_feature]`.\r\n\r\n[Rendered](https://github.com/gnzlbg/rfcs/blob/target_feature/text/0000-target-feature.md)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/316546618","html_url":"https://github.com/rust-lang/rfcs/pull/2045#issuecomment-316546618","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/2045","id":316546618,"user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"created_at":"2017-07-19T23:11:14Z","updated_at":"2017-07-19T23:11:14Z","body":"@gnzlbg \r\n\r\n> Could you maybe expand on which aspects weren't clear?\r\n\r\nOh I just wanted to clarify for myself, it's probably clear enough.\r\n\r\n> Coul you maybe explain why you think we should ban inline(always) from being applied to target_feature functions? \r\n\r\nAh sorry so to be clear I'm just trying to make the implementation easier. It seems like it would be hard to conditionally allow `inline(always)` whereas it would be quite easy to just ban `inline(always)` on functions that mention `target_feature`. I'm not aware of a technical reason to support this (as AFAIK `#[inline]` should be more than enough). If there's a strong technical reason to support this use case then we should of course leave it in.\r\n\r\nAnecdotally, I've *never* seen `#[inline(always)]` required for performance where `#[inline]` wouldn't suffice. I've only ever seen `#[inline(always)]` needed for ABI reasons (e.g. a function call frame wouldn't work in that situation).\r\n\r\n> However, note that -C --target-feature=+avx is already on stable rust and uses the +/- syntax\r\n\r\nIndeed! I feel like these use cases are probably different though b/c is there a use case for removing a feature in the source code?\r\n\r\n> I can provide exact wording for the error messages in the RFC, is this what you mean?\r\n\r\nNah Im not thinking that level of detail is worth it. I just found that in a place or two the RFC is written as if there's two possible outcomes, both of which can be considered valid implementations. I'd prefer to see the RFC say \"rustc will do X\" rather than propose two possibilities, although when the alternatives section should certainly continue to mention other possibilities!\r\n\r\n> This is what I meant with \"the implementation either does this or that\". There are two options, but we don't know the right one yet, and this RFC isn't the right place to clear it up anyways, yet the RFC should allow both to be explored. Does this make sense?\r\n\r\nYeah makes sense to me, thanks for explaining! I personally see these questions very intertwined though in the sense that `#[target_feature]` can't ever be stabilized without rationalizing the effect it has on ABIs. It's true that we don't have an RFC for these vector types yet, but I think it's safe to say that the precise design won't really affect the question on-hand at all.\r\n\r\nYou mention though that clang/gcc auto-fix these definitions? Do you have some examples I could poke around with this? I'm notoriously bad at getting this stuff working in C...\r\n\r\n> I am open to remove it but I'd rather leave it in.\r\n\r\nOk, that's also fine by me. But yeah mind adding a link?\r\n\r\n> I've come to think that the best thing is to have run-time feature detection in the std (either a small library, or as an intrinsic).\r\n\r\nOh sorry yeah I meant to comment more on this. Can you elaborate more on the points of divergence? It seems like you're worried about the compiler's definition of what `target_feature = \"+avx2\"` implies versus the runtime function to check \"can I call that `avx2`-enabled function\". That definitely seems to me like a possible bug but one that'd never come up in practice? Are these features that hard to detect?\r\n\r\nIt also looks like the compiler-rt business and implementation in gcc/clang is all related to purely x86/x86_64, these aren't implemented for other architectures, right? It wasn't immediately clear to me that it was even possible to implement such an intrinsic for other architectures. In that sense this definitely seems like an external lib to me as it can pull in more runtime deps if needed and such.\r\n\r\nIn general it seemed to me that the risk of having and out-of-std detection crate is very small (in that divergence is possible but seems like it won't happen in practice). Additionally we only really know how to implement this on x86/x86_64, so this isn't something portable I think that's ready to go in libstd. Finally, it's just more stuff to bikeshed, possible slowing the process down.\r\n"}}
{"actor":{"display_login":"alexcrichton"}}