(1) Are the illegal instructions happening because an advanced
instruction (such as AVX-512) are being used by the binary, and this
instructions doesn't exist on some systems?
It depends, and you probably need to show the code that's causing them. In the past OpenSSL used CPU feature probes to see what was available on all (nearly all?) platforms. Also see questions like SSL_library_init cause SIGILL when running under gdb.
In the latest sources OpenSSL does not perform CPU feature probes on Apple platforms because a SIGILL
trashes memory. It is some sort of Apple bug and it affects Botan, Crypto++, OpenSSL and others probing the cpu. (All the listed libraries moved away from Apple feature probes). That's a recent change, however. Also see OpenSSL PR 3108, SIGILL-free processor capabilities detection on MacOS X.
(2) How do i build versions of libssl and libcrypto that can be
bundled and used by the vast majority of relatively recent apple
systems?
If you are not doing so, use the latest OpenSSL. That should avoid the cpu feature probes on Apple platforms.
The library also uses -force_cpusubtype_ALL
, so the compile should target the least capable machine in a class of cpu's. That should be enough to avoid instructions not available on later cpu's.
If the project is using AVX-512, then it's use is certainly guarded at runtime. My guess is the guard likely checks the result of CPUID
. We would need to see the code in question that is using AVX-512 instructions and causing the SIGILL
to say more. But like I said, it is only a guess until we see the code.