Skip to content

Commit

Permalink
Extract just library files when on GL32
Browse files Browse the repository at this point in the history
This avoids needlessly duplicating some meta files between GL and GL32.

Notably, this prevents Vulkan's ICD Loader from incorrectly reporting
duplicate GPUs for applications, which occurred because, before this
change, we were installing NVIDIA's ICD file in both the GL and GL32
extensions.

Now, we follow the approach used by Arch Linux for their
lib32-nvidia-utils package, which includes only the libraries and no
extra stuff.
  • Loading branch information
guihkx committed Jan 24, 2025
1 parent 19e105a commit d55b7cb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions nvidia-apply-extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ should_extract (struct archive_entry *entry)
if (strcmp (ARCH, "i386") != 0 && has_prefix (path, "32/"))
return 0;

/* Extract just library files when on GL32. */
if (strcmp (ARCH, "i386") == 0)
goto libs_only;

if (strcmp (path, "nvidia_icd.json") == 0 || strcmp (path, "nvidia_icd.json.template") == 0)
{
archive_entry_set_pathname (entry, "./vulkan/icd.d/nvidia_icd.json");
Expand Down Expand Up @@ -179,6 +183,7 @@ should_extract (struct archive_entry *entry)
return 1;
}

libs_only:
/* Nvidia no longer has 32bit drivers so we are getting
* the 32bit compat libs from the 64bit drivers */
if (strcmp (ARCH, "i386") == 0 && nvidia_major_version > 390)
Expand Down Expand Up @@ -533,7 +538,7 @@ main (int argc, char *argv[])
checked_symlink ("../libnvidia-allocator.so." NVIDIA_VERSION, "gbm/nvidia-drm_gbm.so");
}

if (nvidia_major_version >= 319)
if (strcmp (ARCH, "i386") != 0 && nvidia_major_version >= 319)
{
checked_symlink ("nvidia-application-profiles-" NVIDIA_VERSION "-key-documentation",
"share/nvidia/nvidia-application-profiles-key-documentation");
Expand All @@ -548,13 +553,16 @@ main (int argc, char *argv[])
"libnvidia-tls.so." NVIDIA_VERSION);
}

mkdir ("OpenCL", 0755);
mkdir ("OpenCL/vendors", 0755);
create_file_with_content ("OpenCL/vendors/nvidia.icd", "libnvidia-opencl.so");
if (strcmp (ARCH, "i386") != 0)
{
mkdir ("OpenCL", 0755);
mkdir ("OpenCL/vendors", 0755);
create_file_with_content ("OpenCL/vendors/nvidia.icd", "libnvidia-opencl.so");

if (nvidia_major_version > 340)
replace_string_in_file ("vulkan/icd.d/nvidia_icd.json",
"__NV_VK_ICD__", "libGLX_nvidia.so.0");
if (nvidia_major_version > 340)
replace_string_in_file ("vulkan/icd.d/nvidia_icd.json",
"__NV_VK_ICD__", "libGLX_nvidia.so.0");
}

return 0;
}

0 comments on commit d55b7cb

Please sign in to comment.