kleisauke / wasm-vips

libvips for the browser and Node.js, compiled to WebAssembly with Emscripten.
https://kleisauke.github.io/wasm-vips/
MIT License
463 stars 25 forks source link

Build fails when compiling for node-es6 #41

Closed atjn closed 1 year ago

atjn commented 1 year ago

My build fails when compiling newer versions of wasm-vips. It fails when generating the node-es6 bindings with the following errors:

wasm-ld: error: /src/build/target/lib/libz.a(crc32.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `crc_table`; recompile with -fPIC
wasm-ld: error: /src/build/target/lib/libz.a(crc32.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `functable`; recompile with -fPIC
wasm-ld: error: /src/build/target/lib/libz.a(functable.o): relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `insert_string_c`; recompile with -fPIC
wasm-ld: error: /src/build/target/lib/libz.a(functable.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `cpu_check_features.features_checked`; recompile with -fPIC
wasm-ld: error: /src/build/target/lib/libz.a(functable.o): relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `quick_insert_string_c`; recompile with -fPIC

There are many more lines that are all similar to the ones above.

I am building this in the Docker container by running npm run build, so I would be surprised if this issue is specific to my computer.

I am happy to test a fix for you. I am trying to figure one out myself, but so far have not found anything.

atjn commented 1 year ago

After messing around for a few hours I was suddenly able to compile the latest version without errors. I am guessing that I had an old version of something cached, and for some reason it wasn't invalidated.

kleisauke commented 1 year ago

Looks like PIC and non-PIC libraries are mixed. If this occurs again, removing the build/target directory would probably fix this. This ensures that all dependencies are rebuilt.