Skip to content
Snippets Groups Projects
Commit b099b960 authored by Ludovico de Nittis's avatar Ludovico de Nittis :palm_tree:
Browse files

runtime: correctly handle ICD for different ABI even without subdirs


Previously we used the empty directory as an indicator that the capture
of the library failed, but this worked only if we always started with an
empty directory. And this is not the case when we are not using a
subdir.

For this reason, even if the capture of a library failed, we didn't set
its "kinds" to "NONEXISTENT", and this could have leaded to errors like
having duplicated Vulkan implicit layer JSON for the same name and
different "library_path", one pointing to the correct ABI and the other
to the wrong one.

Fixes: #45

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent 8af71a32
Branches
Tags
1 merge request!202runtime: correctly handle ICD for different ABI even without subdirs
Pipeline #6160 passed
...@@ -1471,6 +1471,9 @@ bind_icd (PvRuntime *self, ...@@ -1471,6 +1471,9 @@ bind_icd (PvRuntime *self,
const char *mode; const char *mode;
g_autoptr(FlatpakBwrap) temp_bwrap = NULL; g_autoptr(FlatpakBwrap) temp_bwrap = NULL;
gsize multiarch_index; gsize multiarch_index;
g_autoptr(GDir) dir = NULL;
gsize dir_elements_before = 0;
gsize dir_elements_after = 0;
g_return_val_if_fail (runtime_architecture_check_valid (arch), FALSE); g_return_val_if_fail (runtime_architecture_check_valid (arch), FALSE);
g_return_val_if_fail (subdir != NULL, FALSE); g_return_val_if_fail (subdir != NULL, FALSE);
...@@ -1535,6 +1538,14 @@ bind_icd (PvRuntime *self, ...@@ -1535,6 +1538,14 @@ bind_icd (PvRuntime *self,
mode = "soname"; mode = "soname";
} }
dir = g_dir_open (in_current_namespace, 0, error);
if (dir == NULL)
return FALSE;
/* Number of elements before trying to capture the library */
while (g_dir_read_name (dir))
dir_elements_before++;
pattern = g_strdup_printf ("no-dependencies:even-if-older:%s:%s:%s", pattern = g_strdup_printf ("no-dependencies:even-if-older:%s:%s:%s",
options, mode, details->resolved_library); options, mode, details->resolved_library);
dependency_pattern = g_strdup_printf ("only-dependencies:%s:%s:%s", dependency_pattern = g_strdup_printf ("only-dependencies:%s:%s:%s",
...@@ -1555,17 +1566,21 @@ bind_icd (PvRuntime *self, ...@@ -1555,17 +1566,21 @@ bind_icd (PvRuntime *self,
g_clear_pointer (&temp_bwrap, flatpak_bwrap_free); g_clear_pointer (&temp_bwrap, flatpak_bwrap_free);
if (seq_str != NULL) g_dir_rewind (dir);
while (g_dir_read_name (dir))
dir_elements_after++;
if (dir_elements_before == dir_elements_after)
{ {
/* Try to remove the directory we created. If it succeeds, then we /* If we have the same number of elements it means that we didn't
* can optimize slightly by not capturing the dependencies: there's * create a symlink to the ICD itself (it must have been nonexistent
* no point, because we know we didn't create a symlink to the ICD * or for a different ABI). When this happens we set the kinds to
* itself. (It must have been nonexistent or for a different ABI.) */ * "NONEXISTENT" and return early without trying to capture the
if (g_rmdir (in_current_namespace) == 0) * dependencies. */
{ details->kinds[multiarch_index] = ICD_KIND_NONEXISTENT;
details->kinds[multiarch_index] = ICD_KIND_NONEXISTENT; /* If the directory is empty we can also remove it */
return TRUE; g_rmdir (in_current_namespace);
} return TRUE;
} }
/* Only add the numbered subdirectories to the search path. Their /* Only add the numbered subdirectories to the search path. Their
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment