Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va: fix --version-script detection for lld >= 17 #758

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

DimitryAndric
Copy link
Contributor

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.

@mattst88
Copy link

mattst88 commented May 1, 2024

@XinfengZhang: can we commit this?

@JasonGantner
Copy link

I ran into this exact issue while building libva-2.21.0 with clang-17.0.6
The fix described here worked as expected

Copy link
Contributor

@XinfengZhang XinfengZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change LGTM, but from my understanding we may deprecate 0.32 definitions, now it is already 2.x .... and 2.x is claimed that not backward compatible with 1. x

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]>
@XinfengZhang XinfengZhang merged commit a619226 into intel:master Jun 3, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants