-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
dictBuilder sources not in single file library #2211
Comments
Fewer compiler invocations can reduce overhead and lead to more compiler optimizations since all functions are in the same translation unit. But the real reason for this change is I want to switch to the single file zstd distribution so things are simpler and presumably faster to build. But this is blocked on facebook/zstd#2211.
My understanding is that this functionality, having the |
I could add that to the full library. I'll take a look. |
@Cyan4973 |
@cwoffenden feel free to move them to a common file. If they don't need to be inlined then |
This has now been merged as should work. |
Thanks @cwoffenden ! @indygreg , you might want to test latest development version in |
Thank you for this great feature! Emscripten: 1.39.18 $ ./build_library_test.sh
Amalgamating files... this can take a while
Processing: zstd-in.c
...
Combine script: PASSED
Single file library creation script: PASSED
Compiling roundtrip.c: PASSED
Compression: PASSED (size: 3127, uncompressed: 32768)
Decompression: PASSED
Byte comparison: PASSED
Running roundtrip.c: PASSED
zstd.c:30822:21: error: redefinition of 'g_ctx' with a different type: 'COVER_ctx_t *' vs 'POOL_ctx' (aka 'struct POOL_ctx_s')
static COVER_ctx_t *g_ctx = NULL;
^
zstd.c:7413:17: note: previous definition is here
static POOL_ctx g_ctx;
^
zstd.c:30869:26: error: passing 'POOL_ctx' (aka 'struct POOL_ctx_s') to parameter of incompatible type 'COVER_ctx_t *'
int result = COVER_cmp(g_ctx, lp, rp);
^~~~~
zstd.c:30845:35: note: passing argument to parameter 'ctx' here
static int COVER_cmp(COVER_ctx_t *ctx, const void *lp, const void *rp) {
^
zstd.c:30879:27: error: passing 'POOL_ctx' (aka 'struct POOL_ctx_s') to parameter of incompatible type 'COVER_ctx_t *'
int result = COVER_cmp8(g_ctx, lp, rp);
^~~~~
zstd.c:30853:36: note: passing argument to parameter 'ctx' here
static int COVER_cmp8(COVER_ctx_t *ctx, const void *lp, const void *rp) {
^
zstd.c:31210:11: error: assigning to 'POOL_ctx' (aka 'struct POOL_ctx_s') from incompatible type 'COVER_ctx_t *'
g_ctx = ctx;
^ ~~~
4 errors generated.
emcc: error: '/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/include -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/local/include -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/include/SSE -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/cache/wasm-lto/include -DEMSCRIPTEN -fignore-exceptions -fno-inline-functions -Wall -Wextra -Werror -Os -flto -I. zstd.c -Xclang -isystem/Users/yoshihitoh/workspace/tools/sdk/emsdk/upstream/emscripten/system/include/SDL -c -o /var/folders/x7/xy9p7bj978sgz5b15_l26_4c0000gq/T/emscripten_temp_g31g5lty/zstd_0.o -flto=full' failed (1)
Compiling emscripten.c: FAILED The symbol https://github.com/yoshihitoh/zstd/commit/c6548eac8ea6c9c6faf464d7dda9b6ec81123e5d
If it is allowed to rename those static variables, I want to make a PR. :) |
Hmm, odd that it hadn't failed for me (it does, and on the original branch I where I made the changes). Checking, it only fails when the Emscripten compiler is installed (and the Emscripten test runs). I should really extend the API tests for the regular |
How about using I confirmed this command works well on my branch https://github.com/yoshihitoh/zstd/commit/0c2c9efcbda04a45cfec7d867508a69153251e8f. (Running on contrib/single_file_libs) docker container run --rm \
--volume $PWD:/code \
--workdir /code \
trzeci/emscripten \
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM zstd.c examples/roundtrip.c |
I think that's a good idea, yes. |
contrib/single_file_libs/zstd-in.c
doesn't#include
source files indictBuilder/
, meaning the variousZDICT_
symbols aren't included in the single file library.Note that if you add the
dictBuilder/
source files, you get various symbol collisions building the resulting file. Colliding symbols includeprime4bytes
,DEFAULT_SPLITPOINT
,g_displayLevel
,g_time
, and others.Should
dictBuilder/
source files be included in the single file full library by default?The text was updated successfully, but these errors were encountered: