Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptarget_feature cfg only obeys `-C target-feature="+feature"` #31662
Comments
huonw
changed the title
cfg_target_feature is pretty terrible
target_feature cfg only obeys `-C target-feature="+feature"`
Feb 15, 2016
This comment has been minimized.
This comment has been minimized.
|
Yeah, this should be looking at the target spec in use (i.e. even if it is a custom one, not only knowing about the built-in ones), and it should also correctly turn off features when requested (e.g.
(I tried to do this, but couldn't find a way to actually get it to work. This would be far-and-away the nicest way if someone could make it work.) |
This comment has been minimized.
This comment has been minimized.
|
Argh, LLVM apparently doesn't want anybody to get/query CPU features. This means it'll require a patch to LLVM to do properly, not a big one, since the functionality we need is basically already there (is feature X enabled), but it's not exposed at present. |
This comment has been minimized.
This comment has been minimized.
|
Querying LLVM would be perfect, but since we're committed to supporting some official releases (not sure which ones exactly) this won't be a solution in the short term. Still, if someone wrote that patch and got it upstream now, this issue could be solved properly in the future (whenever we bump our minimum requirement to, let's say, 3.9). |
This comment has been minimized.
This comment has been minimized.
|
I think it might be possible to extract the features from LLVM without any changes to its code base. |
rkruppe commentedFeb 14, 2016
This program on a 32 bit Linux outputs
no SSE :(even though our default target does enable SSE and SSE2:I'll save myself the hassle of copying
rustc -vVfrom the VM I tested this on, because the relevant code hasn't been touched sincecfg_target_featurewas introduced in 4f44258 (July 2015).This is because the feature detection is really naive, neither asking LLVM for details nor even looking at rustc's own target definitions. @huonw mentioned this in #27731 (comment) but IMHO this deserves an issue of its own.