libva-2.2.0-fix-lld-linking.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 6b0efda45140647c5340c205078741d5c5285687 Mon Sep 17 00:00:00 2001
  2. From: Dimitry Andric <dimitry@andric.com>
  3. Date: Mon, 25 Sep 2023 20:46:05 +0200
  4. Subject: [PATCH] va: fix --version-script detection for lld >= 17
  5. When building libva with lld (the llvm-project linker), version 17 or
  6. later, an error similar to the following is emitted when linking
  7. libva.so:
  8. ld: error: va/libva.so.2.2000.0.p/va_compat.c.o: symbol
  9. vaCreateSurfaces@VA_API_0.32.0 has undefined version VA_API_0.32.0
  10. The root cause is that lld 17 checks linker version scripts more
  11. strictly by default, and emits an error when undefined symbols or
  12. undefined versions are referenced.
  13. Earlier in the build, it turns out that due to these lld errors, va's
  14. meson.build fails to detect `--version-script` support:
  15. Checking if "-Wl,--version-script" : links: NO
  16. This is because the small test program used by meson to check whether a
  17. shared library can be linked with the `libva.syms` version script is
  18. completely empty, and therefore the two symbols in the version script,
  19. `vaCreateSurfaces_0_32_0` and `vaCreateSurfaces`, are undefined.
  20. Fix the problem by providing placeholder definitions for these symbols
  21. in the `code` argument to meson's `cc.links()` function. This ensures
  22. that meson correctly detects `--version-script` support with lld version
  23. 17 or later, and makes it possible to link the libva shared library.
  24. Signed-off-by: Dimitry Andric <dimitry@andric.com>
  25. ---
  26. va/meson.build | 2 +-
  27. 1 file changed, 1 insertion(+), 1 deletion(-)
  28. diff --git a/va/meson.build b/va/meson.build
  29. index 372ae89ff..fa402b0ca 100644
  30. --- a/va/meson.build
  31. +++ b/va/meson.build
  32. @@ -60,7 +60,7 @@ libva_sym_arg = '-Wl,-version-script,' + '@0@/@1@'.format(meson.current_source_d
  33. libva_link_args = []
  34. libva_link_depends = []
  35. -if cc.links('', name: '-Wl,--version-script', args: ['-shared', libva_sym_arg])
  36. +if cc.links('void vaCreateSurfaces_0_32_0(void) {} void vaCreateSurfaces() {}', name: '-Wl,--version-script', args: ['-shared', libva_sym_arg])
  37. libva_link_args = libva_sym_arg
  38. libva_link_depends = libva_sym
  39. endif