Skip to content

Commit

Permalink
va: fix --version-script detection for lld >= 17
Browse files Browse the repository at this point in the history
When building libva with lld (the llvm-project linker), version 17 or
later, an error similar to the following is emitted when linking
libva.so:

    ld: error: va/libva.so.2.2000.0.p/va_compat.c.o: symbol
    vaCreateSurfaces@VA_API_0.32.0 has undefined version VA_API_0.32.0

The root cause is that lld 17 checks linker version scripts more
strictly by default, and emits an error when undefined symbols or
undefined versions are referenced.

Earlier in the build, it turns out that due to these lld errors, va's
meson.build fails to detect `--version-script` support:

    Checking if "-Wl,--version-script" : links: NO

This is because the small test program used by meson to check whether a
shared library can be linked with the `libva.syms` version script is
completely empty, and therefore the two symbols in the version script,
`vaCreateSurfaces_0_32_0` and `vaCreateSurfaces`, are undefined.

Fix the problem by providing placeholder definitions for these symbols
in the `code` argument to meson's `cc.links()` function. This ensures
that meson correctly detects `--version-script` support with lld version
17 or later, and makes it possible to link the libva shared library.

Signed-off-by: Dimitry Andric <[email protected]>
  • Loading branch information
DimitryAndric authored and XinfengZhang committed Jun 3, 2024
1 parent 558d03b commit a619226
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion va/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ libva_sym_arg = '-Wl,-version-script,' + '@0@/@1@'.format(meson.current_source_d

libva_link_args = []
libva_link_depends = []
if cc.links('', name: '-Wl,--version-script', args: ['-shared', libva_sym_arg])
if cc.links('void vaCreateSurfaces_0_32_0(void) {} void vaCreateSurfaces() {}', name: '-Wl,--version-script', args: ['-shared', libva_sym_arg])
libva_link_args = libva_sym_arg
libva_link_depends = libva_sym
endif
Expand Down

0 comments on commit a619226

Please sign in to comment.