quartus-prime-lite: modelsim: fix compiling encrypted device models

LD_PRELOADing libudev breaks compiling encrypted device models in
ModelSim, so only use LD_PRELOAD for non-ModelSim wrappers.

Before:

  $ "$(NIXPKGS_ALLOW_UNFREE=1 nix-build -A quartus-prime-lite)/bin/vlog" "$(NIXPKGS_ALLOW_UNFREE=1 nix-build -A quartus-prime-lite.unwrapped)/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v"
  [...]
  ** Error: /nix/store/szcr2q24izqvhz7ybalar43y5xdg172a-quartus-prime-lite-unwrapped-20.1.1.720/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
  ** Error: /nix/store/szcr2q24izqvhz7ybalar43y5xdg172a-quartus-prime-lite-unwrapped-20.1.1.720/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
  ** Error: (vlog-13069) /nix/store/szcr2q24izqvhz7ybalar43y5xdg172a-quartus-prime-lite-unwrapped-20.1.1.720/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v(38): syntax error in protected region.
  [...]
  Errors: 4, Warnings: 0

After:

  $ "$(NIXPKGS_ALLOW_UNFREE=1 nix-build -A quartus-prime-lite)/bin/vlog" "$(NIXPKGS_ALLOW_UNFREE=1 nix-build -A quartus-prime-lite.unwrapped)/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v"
  [...]
  Errors: 0, Warnings: 0
This commit is contained in:
Bjørn Forsman 2023-10-06 17:00:47 +02:00
parent 7fe9476618
commit 4de69110fa

View File

@ -77,6 +77,11 @@ in buildFHSEnv rec {
progs_wrapped+=("$wrapped")
mkdir -p "$(dirname "$wrapped")"
echo "#!${stdenv.shell}" >> "$wrapped"
case "$relname" in
modelsim_ase/*)
echo "export NIXPKGS_IS_MODELSIM_WRAPPER=1" >> "$wrapped"
;;
esac
echo "$wrapper $prog \"\$@\"" >> "$wrapped"
done
@ -86,13 +91,20 @@ in buildFHSEnv rec {
ln --symbolic --relative --target-directory ./bin ''${progs_wrapped[@]}
'';
# LD_PRELOAD fixes issues in the licensing system that cause memory corruption and crashes when
# starting most operations in many containerized environments, including WSL2, Docker, and LXC
# (a similiar fix involving LD_PRELOADing tcmalloc did not solve the issue in my situation)
# we use the name so that quartus can load the 64 bit verson and modelsim can load the 32 bit version
# https://community.intel.com/t5/Intel-FPGA-Software-Installation/Running-Quartus-Prime-Standard-on-WSL-crashes-in-libudev-so/m-p/1189032
profile = ''
export LD_PRELOAD=''${LD_PRELOAD:+$LD_PRELOAD:}libudev.so.0
# LD_PRELOAD fixes issues in the licensing system that cause memory corruption and crashes when
# starting most operations in many containerized environments, including WSL2, Docker, and LXC
# (a similiar fix involving LD_PRELOADing tcmalloc did not solve the issue in my situation)
# we use the name so that quartus can load the 64 bit verson and modelsim can load the 32 bit version
# https://community.intel.com/t5/Intel-FPGA-Software-Installation/Running-Quartus-Prime-Standard-on-WSL-crashes-in-libudev-so/m-p/1189032
#
# But, as can be seen in the above resource, LD_PRELOADing libudev breaks
# compiling encrypted device libraries in ModelSim (with error
# `(vlog-2163) Macro `<protected> is undefined.`), so only use LD_PRELOAD
# for non-ModelSim wrappers.
if [ "$NIXPKGS_IS_MODELSIM_WRAPPER" != 1 ]; then
export LD_PRELOAD=''${LD_PRELOAD:+$LD_PRELOAD:}libudev.so.0
fi
'';
# Run the wrappers directly, instead of going via bash.