texlive.js icon indicating copy to clipboard operation
texlive.js copied to clipboard

Compiling pdftex-worker.js fails - Part 2

Open daviesian opened this issue 11 years ago • 10 comments

Following on from issue #13, there is a second, similar, error.

Environment

As in issue #13.

Issue

After applying my suggested fix for #13, the compilation still only gets as far as llvm-linking in the make pdftex-worker.js task (Line 112 of Makefile) and then fails with the following error:

/home/username/llvm32build/bin/llvm-link: link error in 
'/home/username/.emscripten_cache/libc.bc': Linking globals named 'opterr': symbol 
multiply defined!

Cause

Unlike issue #13, this error is in linking the emscripten libc library. Investigating with llvm-nm reveals that kpathsea/libkpathsea_la-getopt.o exports this symbol.

Workaround

It is hard to propose a 'fix' for this problem. We probably can't exclude the file as we did in #13, because it is genuinely part of the kpathsea library. Instead my personal workaround is to comment out line 1441 from ~/emscripten/emcc and then force a rebuild of the cache of libc.bc by running:

rm ~/.emscripten_cache/libc.bc

After applying this fix, along with my proposed solution to issue #13, texlive.js compiles successfully.

I'm not sure whether this should really be considered an issue with texlive.js or with emscripten - it's really just an incompatibility between the two.

Warning

Using more recent versions of emscripten than 1.8.2 makes things even worse. See their commit on 17th Nov 2013.

daviesian avatar Jan 23 '14 10:01 daviesian

Thanks for the issues you opened. Maybe we could fix this by applying a patch to kpathsea/libkpathsea_la-getopt.c before compiling it, so it doesn't export this symbol anymore?

manuels avatar Jan 23 '14 13:01 manuels

That sounds like a sensible idea. I'd like to learn a bit more about emscripten's expectations of the code it compiles first, I'll look into it.

Thanks for an awesome project, by the way, I'm really looking forward to using it. I hope I can help out with a few issues along the way.

Just out of interest, which version of emscripten are you using? I couldn't find one old enough to actually work on this project as-is!

daviesian avatar Jan 23 '14 13:01 daviesian

Great! I am using emscripten commit 1a007b1631509b9d72499a8f4402294017ee04dc (incoming branch).

manuels avatar Jan 23 '14 18:01 manuels

Ah, that is interesting. You don't see any of the issues I'm describing?

daviesian avatar Jan 23 '14 19:01 daviesian

Works for me, what's the error message you see?

manuels avatar Jan 27 '14 17:01 manuels

See issue #13 and #14 for the complete description of the errors I get.

daviesian avatar Jan 29 '14 13:01 daviesian

Ok, I just updated emscripten to the latest version (v1.10.0 commit ef1e460...). Works fine with this version.

PS: my LLVM version is 3.2svn and clang v3.2 (32 bit)

manuels avatar Jan 29 '14 21:01 manuels

I'm getting the same errors as @daviesian. I am using LLVM 3.3svn and emscripten 1.24.0 x86_64. @manuels can you confirm you don't get these errors..? It seems strange that we'd be getting them but you wouldn't. I see seven files with the main symbol, and pdftex.bc contains a main as well, regarding the following commands:

emcc -v -s FS_LOG=0 -s TOTAL_MEMORY=67108864 -O2 pdftex-1.40.11/build-pdftex/texk/web2c/lib/*.o pdftex-1.40.11/build-pdftex/texk/kpathsea/*.o pdftex.bc -s INVOKE_RUN=0 --pre-js pre.js --post-js post.js -o pdftex-worker.js
llvm-nm pdftex-1.40.11/build-pdftex/texk/web2c/lib/*.o pdftex-1.40.11/build-pdftex/texk/kpathsea/*.o | grep main | wc -l

I note that emscripten somehow tries to remove duplicate symbols but this is not working. And the --remove-duplicates flag has been deprecated.

ghost avatar Sep 21 '14 22:09 ghost

@daviesian's hacks worked for me.

ghost avatar Sep 21 '14 22:09 ghost

The "right way" (TM) to fix the getopts problem is using CFLAGS=-DELIDE_CODE. Look at getopts.h: This will disable kpathsea's getopts and use the libc's one

fzimmermann89 avatar Oct 07 '15 16:10 fzimmermann89