denoland/rusty_v8

zlib multiple definition error when linking rusty_v8 with deno

lrowe opened this issue · 0 comments

Now that deno_runtime has a libz-ng-sys dependency it is difficult to build deno and rusty_v8 together.

Checking out rusty_v8 and adding as a workspace dependency to deno:

v8 = { version = "0.76.0", default-features = false, path = "../rusty_v8" }

Then building deno with:

V8_FROM_SOURCE=1 cargo build -vv

Results in the following linker error:

  = note: /usr/bin/ld: /workspaces/deno/target/debug/deps/libv8-4e0d723af656b7d3.rlib(zutil.o): in function `z_error':
          ./../../../../../usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.76.0/third_party/zlib/zutil.c:126: multiple definition of `z_error'; /workspaces/deno/target/debug/deps/liblibz_ng_sys-e7d2dfc7f5d74c22.rlib(zutil.c.o):/usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.12/src/zlib-ng/zutil.c:90: first defined here
          /usr/bin/ld: /workspaces/deno/target/debug/deps/libv8-4e0d723af656b7d3.rlib(zutil.o):(.bss+0x0): multiple definition of `z_verbose'; /workspaces/deno/target/debug/deps/liblibz_ng_sys-e7d2dfc7f5d74c22.rlib(zutil.c.o):/usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.12/src/zlib-ng/zutil.c:88: first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `deno_runtime` (build script) due to previous error

The linker error can be ignored by setting RUSTFLAGS:

RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition" V8_FROM_SOURCE=1 cargo build -vv

@mmastrac notes that we might actually be able to remove the zlib dep from rusty_v8 now as we're using zlib-ng in deno