Zstd: Hide static symbols from dynamic library by default

Created on 21 Apr 2018  路  7Comments  路  Source: facebook/zstd

Hi, It seems that the following symbols are missing in 1.3.4:

Can be easily verified by comparing nm -D output
nm -D /usr/lib/x86_64-linux-gnu/libzstd.so.1.3.3

Is that something you are aware of ?
Thanks!

long-term

Most helpful comment

Yeah, we can provide a macro ZSTDLIB_STATIC_VISIBILITY that can be overridden if need be.

All 7 comments

These symbols are hidden behind ZSTD_STATIC_LINKING_ONLY, and don't have stability guarantees. They were renamed to be more consistent with the rest of the new advanced API. See https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L1206.

I'm sorry but I can't even seem to find them by grepping the whole sources, so they don't seem just "hidden" by being declared as static.

Nonetheless, if they were exported in the past, and now are not anymore, it's an ABI break without appropriate SONAME change. Was that intended?

@mapreri, sorry I could've been more clear. These symbols were renamed from ZSTD_initCCtxParams() to ZSTD_CCtxParams_init() and such. They are part of the unstable API which doesn't maintain compatibility between versions (though we try not to silently break the code). To access the unstable API you have to define ZSTD_STATIC_LINKING_ONLY before including zstd.h, named because it isn't safe to use these symbols while dynamically linking in zstd.

Oh, I see what you mean now.

Can't you do something to avoid having those symbols exported in the symbols table? (e.g. using the gcc support for visibility, or by properly teaching the linker what to do (guess the most complex option here would be to use a version script)).

That would actually prevent dynamic linked programs from accessing those functions, which is probably what you want. As it stands now, somebody who thinks to be a very clever programmer can just #define that const e use the functions even when dynamically linking.

Yeah, we can provide a macro ZSTDLIB_STATIC_VISIBILITY that can be overridden if need be.

The following 6 symbols are missing in 1.3.8 compared to 1.3.5, are they removed due to the advanced API stabilization effort ? Thanks!

  1. ZSTD_setDStreamParameter
  2. ZSTD_decompress_generic_simpleArgs
  3. ZSTD_decompress_generic
  4. ZSTD_compress_generic
  5. ZSTD_compress_generic_simpleArgs
  6. ZSTD_CCtx_resetParameters

Yes,
all these symbols are part of the (unstable) experimental API,
and were updated to newer versions within the "almost stabilized" advanced API.

ZSTD_setDStreamParameter  --> ZSTD_DCtx_setParameter
ZSTD_decompress_generic_simpleArgs  --> ZSTD_decompressStream_simpleArgs
ZSTD_decompress_generic  --> ZSTD_decompressStream
ZSTD_compress_generic  --> ZSTD_compressStream2
ZSTD_compress_generic_simpleArgs  --> ZSTD_compressStream2_simpleArgs
ZSTD_CCtx_resetParameters  --> ZSTD_CCtx_reset

Symbols from the experimental API, although unstable, are still exposed in the dynamic library for the time being.
This design choice could be revisited, either for v1.4.0 or v1.5.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgdoliveira picture rgdoliveira  路  3Comments

AbdulrahmanAltabba picture AbdulrahmanAltabba  路  3Comments

robert3005 picture robert3005  路  4Comments

escalade picture escalade  路  3Comments

ga92yup picture ga92yup  路  3Comments