summary refs log tree commit diff
path: root/pkgs/applications/editors
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2023-10-06 17:00:47 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2023-10-13 17:21:42 +0200
commit4de69110fa769f9fd072e0153d89aa2c83281b4d (patch)
tree26804fd11a7c6daf694ce9da3932ef9048de8248 /pkgs/applications/editors
parent7fe947661869d2a7aef4f7c8701d6bef3db299d0 (diff)
downloadnixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar.gz
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar.bz2
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar.lz
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar.xz
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.tar.zst
nixpkgs-4de69110fa769f9fd072e0153d89aa2c83281b4d.zip
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
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r--pkgs/applications/editors/quartus-prime/default.nix24
1 files changed, 18 insertions, 6 deletions
diff --git a/pkgs/applications/editors/quartus-prime/default.nix b/pkgs/applications/editors/quartus-prime/default.nix
index 84a587e9621..cdeabc837ab 100644
--- a/pkgs/applications/editors/quartus-prime/default.nix
+++ b/pkgs/applications/editors/quartus-prime/default.nix
@@ -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.