Skip to content

cfg_target_feature doesn't work for all supported rustc features #50077

Closed
@raphaelcohn

Description

@raphaelcohn

Viz,

target_feature does not work for rdrnd but does work for avx2 (rustc rustc 1.27.0-nightly (ac3c2288f 2018-04-18), Mac OS X El Capitan).

This is created with cargo rustc -- -C target-feature=+avx2

#[cfg(all(target_arch = "x86_64", target_feature = "avx2"))]
#[inline(always)]
pub fn generate_hyper_thread_safe_random_u64() -> u64
{
	println!("Hello World");
}

However, this is NOT created with cargo rustc -- -C target-feature=+rdrnd

#[cfg(all(target_arch = "x86_64", target_feature = "rdrnd"))]
#[inline(always)]
pub fn generate_hyper_thread_safe_random_u64() -> u64
{
	println!("Hello World");
}

ie, changing avx2 for rdrnd causes the function to not be compiled. Both avx2 and rdnrd are present inrustc --print target-features

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions