bazelbuild / platforms

Constraint values for specifying platforms and toolchains
Apache License 2.0
108 stars 71 forks source link

Constraints for CPU features? #13

Open yesudeep opened 4 years ago

yesudeep commented 4 years ago

Hi. Would it be possible to detect CPU features using something like https://github.com/google/cpu_features/ and provide them as platform constraints?

This could help in enabling certain compiler flags and instruction set architectures for targets.

What needs to be done so that something like this would work with Bazel?

aiuto commented 2 years ago

I'm not inclined to go down this path. It is never ending. Perhaps the X86 space is mostly stable, but the ARM space is growing all the time. Many people take the ARM core and add other pieces they need on the die. They should be able to innovate without having everything enumerated in platforms.

In general, micro level distinguishers should be provided by the compiler toolchains.

rickeylev commented 8 months ago

Over in Python land, there's 4 different prebuilt interpreters available that vary by micro arch: a generic one, and then 3 that target some different micro archs. These docs talk about them: https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions:~:text=Intel/AMD%20CPUs.-,x86_64_v2,-%2D*

So, perhaps you'd reconsider having those micro archs here in the platforms repo? If not, perhaps another lighter weight place?

In general, micro level distinguishers should be provided by the compiler toolchains.

That seems rather expensive in this case, though. The binaries are prebuilt, so a compiler toolchain isn't necessarily required. It would also mean the compiler repos would have to be downloaded even if they weren't used -- during toolchain resolution, the constraint has to be evaluated, which then would download that compiler repo, only to have it not match.