tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: AVX2: how to detect?



On Thu, Aug 17, 2023 at 02:15:34PM -0400, Greg Troxel wrote:
> Thomas Klausner <wiz%NetBSD.org@localhost> writes:
> 
> > Some package behave differently if they find AVX2 support in the CPU.
> 
> This is a bug if it results in a different binary package.   As others
> said, this has  to be runtime.   A binary package has to run on any
> system of the build systems architecture (e.g. NetBSD/x86_64,
> NetBSD/i386), regardless of build system cpu extensions.

Note that while runtime detection is easy on amd64, it is challenging
on aarch64, as the register isn't accessible from user mode. I patched
this out to get mame to build on aarch64. It seems for arm, either
query the kernel (sysctl, syscall, /proc, whatever), or install a
SIGILL handler and just try it (I believe openssl does this?). I only
had a quick look, but I don't see us exporting processor features to
userland on arm?

fwiw, mame code is - which is actually 3rd party lzma lib:
https://github.com/mamedev/mame/blob/master/3rdparty/lzma/C/CpuArch.c

And yes, openssl uses a SIGILL handler:
https://github.com/NetBSD/src/blob/trunk/crypto/external/bsd/openssl/dist/crypto/armcap.c

> Arguably this is an upstream bug, as it doesn't play well with packaging.
> 
> Agreed that force-disable is a good first step.

-- 
Paul Ripke
"Great minds discuss ideas, average minds discuss events, small minds
 discuss people."
-- Disputed: Often attributed to Eleanor Roosevelt. 1948.


Home | Main Index | Thread Index | Old Index