How to indicate the microprocessor's missing instructions/extentions when building ports

Hi,

I want to install a desktop environment from ports. But the machine's CPU has a cut-down set of extensions according to wikichip
How would one ensure that clang (and gcc for those math & graphics ports) doesn't try to use the missing avx/avx2 (and anything else)?

I'm guessing something in make.conf, perhaps the 'CFLAGS/CXXFLAGS'?

bsd.cpu.mk doesn't list such crippled CPUs it seems.

Thanks for any insights.

Edit: to clarify this stackoverflow post plus the third answer is kinda what I was wondering about.
 
This sort of thing is typically handled by platform specific preprocessor macros. There should be nothing left for you to configure at compile time if the code is written properly. I'm guessing for Freebsd this will most often mean that the optimizations will be left out because they are #Ifdefed in only for more popular platforms.

In any case, you should get the lowest common denominator and this should compile without errors on most reasonable platforms.

Yes, there's a lot of hemming and hawing in that sentence. I may be able to help if you have a specific problem you're trying to solve.
 
Isn't this being handled at runtime by the processor feature flags (they are being shown in boot dmesg), so that things like multimedia extensions instructions are being used if supported by the processor hardware, otherwise the functionality is done software libraries?
 
Also consider the possibility that Intel might have specified some features as optional for a particular generation, so compiler makers adjust for that in the runtime libraries, without need for the compiler user to take care of.
 
They look correct on my system
Code:
clang -dM -E -march=native - < /dev/null | grep -i avx                                                         
#define __AVX2__ 1
#define __AVX__ 1
 
They look correct on my system
Code:
clang -dM -E -march=native - < /dev/null | grep -i avx                                                        
#define __AVX2__ 1
#define __AVX__ 1

Hi,
Just to be certain, this command is run on the chip I linked @ wikichip above?

Thanks.
 
Also consider the possibility that Intel might have specified some features as optional for a particular generation, so compiler makers adjust for that in the runtime libraries, without need for the compiler user to take care of.
I see that lang/gcc10 depends on math/gmp which in turn has the option to optimize for the system's CPU.
the output of runing make in math/gmp may shed more light on what is detected.
 
Back
Top