Skip to content

Test the symbols exported by libzstd.so, hide ZSTD_isDeterministicBuild() with the experimental API - #5055

Merged
Cyan4973 merged 2 commits into
devfrom
lib-symbols-visibility
Dec 3, 2026
Merged

Cyan4973 merged 2 commits into
devfrom
lib-symbols-visibility

Conversation

@Cyan4973

Copy link
Copy Markdown
Contributor

This affects builds that hide the experimental API from libzstd.so: ZSTDLIB_STATIC_API=ZSTDLIB_HIDDEN and ZDICTLIB_STATIC_API=ZDICTLIB_HIDDEN with Make, or the ZSTDLIB_STATIC_API option with CMake (#4789). Default builds are unchanged.

Problem

No test checks which symbols libzstd.so exports.
ZSTD_isDeterministicBuild() (#4331, v1.6.0) is declared in the experimental section of zstd.h, but tagged ZSTDLIB_API, so it stays exported when the experimental API is hidden.

Fix

  • ZSTD_isDeterministicBuild() is now tagged ZSTDLIB_STATIC_API.

  • tests/libzstd_builds.sh (job lz4-threadpool-libs) builds libzstd.so twice, and compares nm -D with the functions declared by zstd.h, zdict.h and zstd_errors.h:

    • by default, it must export the whole API (186 functions);
    • with the experimental API hidden, only the stable API (78 functions): the declarations outside the ZSTD_STATIC_LINKING_ONLY and ZDICT_STATIC_LINKING_ONLY sections.

    GCC's -aux-info lists the declarations.

Test

The new check passes with the fix. It fails without it (ZSTD_isDeterministicBuild exported by the hidden build), when a stable function loses its ZSTDLIB_API tag, and when an internal function gets default visibility.

ZSTD_isDeterministicBuild() (#4331) is declared in the experimental
section of zstd.h, but tagged ZSTDLIB_API: it stayed exported when
ZSTDLIB_STATIC_API=ZSTDLIB_HIDDEN hides the experimental API.
Default builds are unchanged.
libzstd_builds.sh now checks that libzstd.so exports the whole API
by default, and only the stable API when ZSTDLIB_STATIC_API and
ZDICTLIB_STATIC_API are hidden. The API is read from the headers,
outside and inside their static-linking-only sections.
@meta-cla meta-cla Bot added the CLA Signed label Nov 27, 2026
@Cyan4973 Cyan4973 self-assigned this Nov 27, 2026
@Cyan4973 Cyan4973 added tests CI and removed CI labels Nov 27, 2026
@Cyan4973
Cyan4973 merged commit d7ce24d into dev Dec 3, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants