mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-29 19:30:11 +00:00
vacask: set OpenVAF target CPU (#554242)
This commit is contained in:
@@ -16,6 +16,35 @@
|
||||
boost188,
|
||||
suitesparse,
|
||||
tomlplusplus,
|
||||
|
||||
# VACASK's device models are compiled by OpenVAF, a Verilog-A compiler.
|
||||
#
|
||||
# By default, OpenVAF's `--target_cpu native` tells it to use every CPU
|
||||
# instruction available on the machine doing the build (e.g. AVX-512, if the
|
||||
# builder happens to have it). If the resulting binary is then run on a
|
||||
# different, older CPU that doesn't support those instructions, it crashes
|
||||
# with "illegal instruction" (SIGILL).
|
||||
#
|
||||
# To avoid this, we detect which instruction set the CPU we're building for
|
||||
# actually supports and tell OpenVAF to target that instead, which keeps the
|
||||
# compiled models runnable on other x86_64 machines as well.
|
||||
#
|
||||
# See:
|
||||
# - https://codeberg.org/arpadbuermen/VACASK/src/commit/bf59752fbfdfed18dc7fe2e3e11a9c02f8de28a0/README.md#installation-from-pre-built-packages
|
||||
# - https://github.com/NixOS/nixpkgs/blob/dc36b3c506df17272cdca29e85d0d0190b068981/lib/systems/architectures.nix
|
||||
openvafTargetCpu ?
|
||||
with stdenv.hostPlatform;
|
||||
if isx86_64 then
|
||||
if avx512Support then
|
||||
"x86-64-v4"
|
||||
else if avx2Support then
|
||||
"x86-64-v3"
|
||||
else if sse4_2Support then
|
||||
"x86-64-v2"
|
||||
else
|
||||
"x86-64"
|
||||
else
|
||||
"generic",
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -69,6 +98,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
cmakeFlags = [
|
||||
(lib.cmakeFeature "FLEX_INCLUDE_DIR" "${flex}/include")
|
||||
(lib.cmakeFeature "TOMLPP_DIR" "${tomlplusplus}")
|
||||
(lib.cmakeFeature "OPENVAF_OPTIONS" "--target_cpu ${openvafTargetCpu}")
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
Reference in New Issue
Block a user