nightly featuers: target-specific library features are painful #120930
Labels
C-discussion
Category: Discussion or questions that doesn't represent real issues.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In rust-lang/stdarch#1486, stdarch split up its one uber-feature into a lot of small ones. This led to some rather painful updates. portable-simd now needs code like this to compile:
I think the main issue is that library features "exist" only if at least one item with that feature exists, so one has to very carefully put
cfg_atrr
around thefeature
to avoid "unknown feature" errors. std doesn't have many target-specific features so this is not usually a problem, but for stdarch it is. Additionally,feature
attributes must be inlib.rs
, so this can't be put inside the modules that actually import these functions -- those modules usually arecfg
d, but instead of reusing thosecfg
we have to repeat them.Not sure what one could do about this. rustc could ignore unknown features, but that doesn't seem great. Maybe stdarch should have a way to "declare" feature to exist even if no item in the current configuration actually carries that feature? Then portable-simd could just do
#![feature(stdarch_arm_dsp, stdarch_arm_neon_intrinsics, stdarch_powerpc)]
which would be a lot better.As a crude hack stdarch could have some "dummy item" for each feature that always exists on all targets, therefore bringing the library feature into existence and letting others enable it in a cfg-independent way.
The text was updated successfully, but these errors were encountered: