Skip to content
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

Pass CCexe=gcc to freetype make command #4

Open
vadimkantorov opened this issue Aug 24, 2020 · 102 comments
Open

Pass CCexe=gcc to freetype make command #4

vadimkantorov opened this issue Aug 24, 2020 · 102 comments

Comments

@vadimkantorov
Copy link

This seems to remove the need for copying apinames from native build and maybe makes the native build less necessary

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 24, 2020

Passing --disable-shared to libexpat configure was also important to bypass duplicate memcpy errors.

Now it's failing at xdvipdfmx with:

error: undefined symbol: getpass (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _getpass may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: popen (referenced by top-level compiled C/C++ code)
warning: _popen may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/mnt/c/Users/user/emsdk/node/12.18.1_64bit/bin/node /mnt/c/Users/user/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpbhq191nf.txt' failed (1)
make[6]: *** [xdvipdfmx] Error 1
make[5]: *** [all-recursive] Error 1
make[4]: *** [all] Error 2
make[3]: *** [subtexk] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
Makefile:329: recipe for target 'build-js-xetex-toplevel.stamp' failed

I'm trying to repro the build using recent emscripten

getpass issue seems related to http://project.ktug.org/dvipdfmx/mailman/dvipdfmx/2011-February/000250.html

@vadimkantorov
Copy link
Author

There was also a suspicious configure: WARNING: Sorry, neither ApplicationServices framework nor fontconfig library: disabling xetex, possibly during some web2c run.

@vadimkantorov
Copy link
Author

To bypass the undefined functions, -s ERROR_ON_UNDEFINED_SYMBOLS=0 should be added to EMCC_FLAGS inside build-js-xetex-toplevel.stamp

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 25, 2020

Then getting this:

make: make -C build-js/build-xetex/texk/web2c/ -o ctangle -o otangle -o tangle -o tangleboot -o tie -o web2c/fixwrites -o web2c/makecpool -o web2c/splitup -o web2c/web2c xetex
clang-12: warning: argument unused during compilation: '-ffunction-sections' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-fdata-sections' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-D _REENTRANT' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-D U_ENABLE_DYLOAD=0' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-D U_HAVE_POPEN=0' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-D U_ATTRIBUTE_DEPRECATED=' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-D PIC' [-Wunused-command-line-argument]
./out/tmp/icudt51l_dat.s:2:20: error: Expected ,, instead got: -
        .section .note.GNU-stack,"",%progbits
                          ^
./out/tmp/icudt51l_dat.s:3:18: error: Expected ,, instead got:

        .section .rodata
                        ^
./out/tmp/icudt51l_dat.s:5:20: error: Expected label,@type declaration, got: %
        .type icudt51_dat,%object
                          ^
emcc: error: '/mnt/c/Users/user/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -ffunction-sections -fdata-sections -D_REENTRANT -DU_ENABLE_DYLOAD=0 -DU_HAVE_POPEN=0 -DU_ATTRIBUTE_DEPRECATED= -g -O3 -Wno-error=implicit-function-declaration -c -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/icu/icu-51.1/source/common -I../common -DPIC -fPIC -o ./out/tmp/icudt51l_dat.o ./out/tmp/icudt51l_dat.s -c -o ./out/tmp/icudt51l_dat.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
-- return status = 256
Error creating with assembly code. Failed command: �����
Error generating assembly code for data.

This is a false alert, since it happens before replacing icu binaries

@vadimkantorov
Copy link
Author

So it seems it's trying to use inline assembly duing non-native build and fails

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 25, 2020

Also there's expected error ../bin/icupkg: line 1: syntax error near unexpected token ('`, during first attempt before replacing icu binaries

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 25, 2020

In file included from /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/Engine.cpp:120:
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2203:10: error: constant expression evaluates to 69786 which cannot be narrowed to type 'UInt16' (aka 'unsigned short') [-Wc++11-narrowing]
        {0x0000,0x1109A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2203:10: note: insert an explicit cast to silence this issue
        {0x0000,0x1109A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
                static_cast<UInt16>( )
In file included from /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/Engine.cpp:120:
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2203:10: error: constant expression evaluates to 69786 which cannot be narrowed to type 'UInt16' (aka 'unsigned short') [-Wc++11-narrowing]
        {0x0000,0x1109A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2203:10: note: insert an explicit cast to silence this issue
        {0x0000,0x1109A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
                static_cast<UInt16>( )
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2204:10: error: constant expression evaluates to 69788 which cannot be narrowed to type 'UInt16' (aka 'unsigned short') [-Wc++11-narrowing]
        {0x0000,0x1109C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2204:10: note: insert an explicit cast to silence this issue
        {0x0000,0x1109C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
                static_cast<UInt16>( )
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2205:10: error: constant expression evaluates to 69803 which cannot be narrowed to type 'UInt16' (aka 'unsigned short') [-Wc++11-narrowing]
        {0x0000,0x110AB,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/libs/teckit/TECkit-2.5.3/source/NormalizationData.c:2205:10: note: insert an explicit cast to silence this issue
        {0x0000,0x110AB,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
                ^~~~~~~
                static_cast<UInt16>( )

This seems the only error that stays. And this makes sense, these numbers don't fit into UINT16

@vadimkantorov
Copy link
Author

This issue was brought up in gentoo as well: https://bugs.gentoo.org/594660

@vadimkantorov
Copy link
Author

Basically TECkit 2.5.3 is buggy with this respect and an update is needed. I'll first stub out these constants and then will try to bump the version

@vadimkantorov
Copy link
Author

Then it seems that passed fontconfig path is not propagated to xetex compilation:

em++: error: '/mnt/c/Users/user/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=0 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/local/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/SSE -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/compiler-rt/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libunwind/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/cache/wasm/include -DEMSCRIPTEN -fignore-exceptions -DHAVE_CONFIG_H -I. -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c -I./w2c -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/texk -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir -DXETEX_BUILD_DATE="2020082517" -DU_STATIC_IMPLEMENTATION -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/icu/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/freetype2/freetype2 -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/freetype2 -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/teckit/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/harfbuzz/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/graphite2/include -DGRAPHITE2_STATIC -DXETEX_OTHER -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler/goo -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler/poppler -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/libpng/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/zlib/include -g -O2 -MT xetexdir/libxetex_a-XeTeXFontMgr.o -MD -MP -MF xetexdir/.deps/libxetex_a-XeTeXFontMgr.Tpo -c -o xetexdir/libxetex_a-XeTeXFontMgr.o /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/SDL -c -o xetexdir/libxetex_a-XeTeXFontMgr.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)

After patching this, it fails to find w2c/c-auto.h:

clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=0 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/local/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/SSE -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/compiler-rt/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/lib/libunwind/include -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/cache/wasm/include -DEMSCRIPTEN -fignore-exceptions -DHAVE_CONFIG_H -I. -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c -I./w2c -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/texk -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk -I/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir -DXETEX_BUILD_DATE="2020082517" -DU_STATIC_IMPLEMENTATION -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/icu/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/freetype2/freetype2 -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/freetype2 -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/teckit/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/harfbuzz/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/graphite2/include -DGRAPHITE2_STATIC -DXETEX_OTHER -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler/goo -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/poppler/poppler -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/libpng/include -I/mnt/c/Users/user/texet/xetex-js/build-js/build-xetex/libs/zlib/include -g -O2 -MT xetexdir/libxetex_a-XeTeXFontInst.o -MD -MP -MF xetexdir/.deps/libxetex_a-XeTeXFontInst.Tpo -c -o xetexdir/libxetex_a-XeTeXFontInst.o /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeXFontInst.cpp -Xclang -isystem/mnt/c/Users/user/emsdk/upstream/emscripten/system/include/SDL -c -o xetexdir/libxetex_a-XeTeXFontInst.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr
In file included from /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeXFontInst.cpp:42:
In file included from /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeXFontInst.h:51:
In file included from /mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeXFontMgr.h:47:
/mnt/c/Users/user/texet/xetex-js/build-sources/xetex-0.9999.3/source/texk/web2c/xetexdir/XeTeX_ext.h:39:10: fatal error: 'w2c/c-auto.h' file not found
#include <w2c/c-auto.h>  /* needed for SIZEOF_LONG and NO_DUMP_SHARE */
         ^~~~~~~~~~~~~~
1 error generated.

@lyze
Copy link
Owner

lyze commented Aug 26, 2020

Ah thanks for investigating! Sadly, this repository has bitrotted. The artifacts branch has some older compiled binaries from back when things worked. I'll try to take some time this weekend to take a look.

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 26, 2020

I'm advancing towards building xetex + dvipdfm-x from scratch from recent TexLive repo: https://tex.stackexchange.com/questions/560046/how-to-build-xetex-and-dvipdfmx-from-source-texlive-2020

I currently have a proof of concept of in-browser-only tex editor (not new, was already tried by SwiftLatex and texlive.js and https://people.math.osu.edu/fowler.291/latex/ - I also try to hack around GitHub API for the usecase of editing CVs or small-ish repos with scientific papers):

My frankenstein (Monaco + xterm.js + pdf.js + emscripten):
image

Unfortunately I don't have experience with web programming, so all this is in one https://github.com/vadimkantorov/texet/blob/master/index.html (so that it's easily hackable). Unsolved issues: how to import TypeScript module in JavaScript (xterm.js Fit Addon); simple split-pane UI to resolve issues of pdf.js and xterm.js overlaying everything; xetex + bibtex + automatically downloading and caching texmf files in a worker thread (similar to your repo or https://github.com/manuels/texlive.js/)

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 26, 2020

I managed to compile xetex and dvipdfm-x from TexLive (for now with native toolchain). However, creating a format file fails:

wget http://mirrors.ctan.org/macros/latex/base.zip
unzip -o base.zip

TEXINPUTS=base//: $XELATEX_EXE -ini -etex -output-directory=base unpack.ins
# works

TEXINPUTS=base//: $XELATEX_EXE -ini -etex -output-directory=base latex.ltx 
# fails as below
Local config file preload.cfg used

=====================================
(base/preload.cfg (base/preload.ltx
kpathsea: Running mktextfm cmex10
mktextfm: No such file or directory
kpathsea: Appending font creation commands to missfont.log.

! Font \OMX/cmex/m/n/10=cmex10 not loadable: Metric (TFM) file or installed fon
t not found.
<to be read again>
                   \relax
l.41 ...ame OMX/cmex/m/n/10\endcsname=cmex10\relax

@vadimkantorov
Copy link
Author

Do you make use of native INSTALL_TL_UNX_ARCHIVE to get around this?

@lyze
Copy link
Owner

lyze commented Aug 27, 2020

It looks like in this case that's an error specific to the native texlive environment. It's looking for the cmex10 font but it's not found. If you add an entry around here to configure texlive to download an additional font package containing cmex10, then that would work. You may need to run the interactive texlive installation UI to figure out what packages are available.

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 27, 2020

You are right, I think (I don't have a native install except for installer used as part of Makefile). I tried the following (texlive.js version which is slightly simpler), but still fails (I'll try again!). I think I need to pass it some paths to my new native install.

How does xelatex -ini command is supposed to know about the path of native install root? TEXINPUTS seems to pass the path to base. Do I need to set some other env variable?

Is profile file only destined for the installer?

TEXLIVE_BASE_URL=http://mirrors.ctan.org/macros/latex/base.zip
TEXLIVE_INSTALLER_URL=http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz

mkdir -p texlive
echo selected_scheme scheme-basic > texlive/profile.input
echo TEXDIR $PWD/texlive >> texlive/profile.input
echo TEXMFLOCAL $PWD/texlive/texmf-local >> texlive/profile.input
echo TEXMFSYSVAR $PWD/texlive/texmf-var >> texlive/profile.input
echo TEXMFSYSCONFIG $PWD/texlive/texmf-config >> texlive/profile.input
echo TEXMFVAR $PWD/home/texmf-var >> texlive/profile.input

wget $TEXLIVE_INSTALLER_URL
pushd texlive
tar xzvf ../install-tl-unx.tar.gz
./install-tl-*/install-tl -profile profile.input
rm -rf bin readme* tlpkg install* *.html texmf-dist/doc texmf-var/web2c
echo "Done! Please run 'make texlive.lst' now!"
popd

wget $TEXLIVE_BASE_URL
mkdir -p latex_format
pushd latex_format
unzip -o ../base.zip
pushd base
$XELATEX_EXE -ini -etex unpack.ins
$XELATEX_EXE -ini -etex latex.ltx

@vadimkantorov
Copy link
Author

vadimkantorov@DESKTOP-4UF8FID:/mnt/c/Users/user/blfstexlive/texlive$ ls
LICENSE.CTAN  README             install-tl-20200826  release-texlive.txt  texmf-dist   texmf-var  texmfcnf.lua
LICENSE.TL    README.usergroups  profile.input        texmf-config         texmf-local  texmf.cnf

vadimkantorov@DESKTOP-4UF8FID:/mnt/c/Users/user/blfstexlive/texlive$ find texmf-dist -name cm
texmf-dist/fonts/afm/public/amsfonts/cm
texmf-dist/fonts/map/dvips/cm
texmf-dist/fonts/pk/ljfour/public/cm
texmf-dist/fonts/source/public/cm
texmf-dist/fonts/tfm/public/cm
texmf-dist/fonts/type1/public/amsfonts/cm

So in theory fonts are present. How do I point newly built $XELATEX_EXE to the prepared texlive root?

@lyze
Copy link
Owner

lyze commented Aug 28, 2020

I believe TFMFONTS is the variable to use to find tfm fonts, and TTFONTS for truetype.

I think setting TEXMFDIST would work. [1]

[1] https://wiki.archlinux.org/index.php/TeX_Live#texmf_trees_and_Kpathsea
[2] https://tex.stackexchange.com/questions/507299/why-doesnt-texinputs-work-for-fonts
[3] https://tex.stackexchange.com/questions/224867/fontspec-not-searching-in-texinputs

@vadimkantorov
Copy link
Author

The full script I currently execute is here: https://gist.github.com/vadimkantorov/501634e4f0c93b2940b43aea071dff03
I did more research in https://tex.stackexchange.com/questions/560336/how-to-create-a-latex-format-file-without-an-existing-texlive-install and it seems that:

somehow kpathsea cannot find mktextfm which is in $TEXLIVE_SOURCE_DIR/texk/texlive/linked_scripts/texlive. If I add it to PATH, then ./prefix/bin/kpsewhich cannot find mktex.opt which is in ./texlive/texmf-dist/web2c/mktex.opt. ./prefix/share/texmf-dist/web2c/texmf.cnf does not know anything about ./texlive. How do I make sure that ./prefix/bin/kpsewhich can discover ./texlive and produce format files?

So yes, the primary problem seems to be in discovery of tools' paths. I'll try TEXMFDIST

@vadimkantorov
Copy link
Author

export TEXMFDIST=$PWD/texlive/texmf-dist does not help, ksewhich still cannot discover texlive/texmf-dist/web2c/mktex.opt

@vadimkantorov
Copy link
Author

Here is strace of kpsewhich failing:

fonts/tfm//:!!/mnt/c/Users/user/blfstexlive/texmf-dist/fonts/tfm//:/home/vadimkantorov/.texlive2020/texmf-var/fonts/tfm//
vadimkantorov@DESKTOP-4UF8FID:/mnt/c/Users/user/blfstexlive$ strace -fff ./prefix/bin/kpsewhich --format='web2c files' mktex.opt
execve("./prefix/bin/kpsewhich", ["./prefix/bin/kpsewhich", "--format=web2c files", "mktex.opt"], 0x7fffcbf94238 /* 21 vars */) = 0
brk(NULL)                               = 0x7fffd1827000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=68021, ...}) = 0
mmap(NULL, 68021, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb2cc05000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb2cc00000
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb2c400000
mprotect(0x7fbb2c5e7000, 2097152, PROT_NONE) = 0
mmap(0x7fbb2c7e7000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7fbb2c7e7000
mmap(0x7fbb2c7ed000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb2c7ed000
close(3)                                = 0
arch_prctl(ARCH_SET_FS, 0x7fbb2cc01540) = 0
mprotect(0x7fbb2c7e7000, 16384, PROT_READ) = 0
mprotect(0x7fbb2d016000, 4096, PROT_READ) = 0
mprotect(0x7fbb2ca27000, 4096, PROT_READ) = 0
munmap(0x7fbb2cc05000, 68021)           = 0
brk(NULL)                               = 0x7fffd1827000
brk(0x7fffd1848000)                     = 0x7fffd1848000
lstat(".", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lstat("./prefix", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lstat("./prefix/bin", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lstat("./prefix/bin/kpsewhich", {st_mode=S_IFREG|0777, st_size=517032, ...}) = 0
getcwd("/mnt/c/Users/user/blfstexlive", 4097) = 30
stat("/mnt/c/Users/user/blfstexlive/prefix/bin", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
access("/mnt/c/Users/user/blfstexlive/prefix/bin/texmf.cnf", R_OK) = 0
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/texmf.cnf", {st_mode=S_IFREG|0777, st_size=39451, ...}) = 0
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/share/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/share/texmf-dist/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/share/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/texmf-dist/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/bin/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
access("/mnt/c/Users/user/blfstexlive/prefix/texmf.cnf", R_OK) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/share/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/share/texmf-dist/web2c", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
access("/mnt/c/Users/user/blfstexlive/prefix/share/texmf-dist/web2c/texmf.cnf", R_OK) = 0
stat("/mnt/c/Users/user/blfstexlive/prefix/share/texmf-dist/web2c/texmf.cnf", {st_mode=S_IFREG|0777, st_size=39451, ...}) = 0
stat("/mnt/c/Users/user/blfstexlive/prefix/share/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/texmf-dist/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/prefix/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
access("/mnt/c/Users/user/blfstexlive/texmf.cnf", R_OK) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/share/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/share/texmf-dist/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/share/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf-local/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf-dist/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf/web2c", 0x7fffd87dfe30) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/mnt/c/Users/user/blfstexlive/prefix/bin/texmf.cnf", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0777, st_size=39451, ...}) = 0
read(3, "% original texmf.cnf -- runtime "..., 4096) = 4096
read(3, "aces.\nTEXMFAUXTREES = {}\n\n% List"..., 4096) = 4096
read(3, "st      = $TEXMFDOTDIR;$TEXMF/{t"..., 4096) = 4096
read(3, "//\n\n% XeTeX.\nTEXINPUTS.xelatex  "..., 4096) = 4096
read(3, "TEXPOOL}\nMPPOOL = ${TEXPOOL}\n\n% "..., 4096) = 4096
read(3, "IR;$TEXMF/metapost/support\n\n% Fo"..., 4096) = 4096
read(3, "IR;$TEXMF/scripts/{$progname,$en"..., 4096) = 4096
read(3, "nds are allowed.  Although this\n"..., 4096) = 4096
read(3, "ost = eptex\n\n% These variables s"..., 4096) = 4096
read(3, "curios/page.php/8191.html\nnest_s"..., 4096) = 2587
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/mnt/c/Users/user/blfstexlive/prefix/share/texmf-dist/web2c/texmf.cnf", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0777, st_size=39451, ...}) = 0
read(3, "% original texmf.cnf -- runtime "..., 4096) = 4096
read(3, "aces.\nTEXMFAUXTREES = {}\n\n% List"..., 4096) = 4096
read(3, "st      = $TEXMFDOTDIR;$TEXMF/{t"..., 4096) = 4096
read(3, "//\n\n% XeTeX.\nTEXINPUTS.xelatex  "..., 4096) = 4096
read(3, "TEXPOOL}\nMPPOOL = ${TEXPOOL}\n\n% "..., 4096) = 4096
read(3, "IR;$TEXMF/metapost/support\n\n% Fo"..., 4096) = 4096
read(3, "IR;$TEXMF/scripts/{$progname,$en"..., 4096) = 4096
read(3, "nds are allowed.  Although this\n"..., 4096) = 4096
read(3, "ost = eptex\n\n% These variables s"..., 4096) = 4096
read(3, "curios/page.php/8191.html\nnest_s"..., 4096) = 2587
read(3, "", 4096)                       = 0
close(3)                                = 0
stat("/mnt/c/Users/user/texmf-local", 0x7fffd87dfd90) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf-config", 0x7fffd87dfd90) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf-var", 0x7fffd87dfd90) = -1 ENOENT (No such file or directory)
stat("/mnt/c/Users/user/blfstexlive/texmf-dist", 0x7fffd87dfd90) = -1 ENOENT (No such file or directory)
mmap(NULL, 516096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb2cb80000
munmap(0x7fbb2cb80000, 516096)          = 0
brk(0x7fffd1869000)                     = 0x7fffd1869000
stat("/home/vadimkantorov/.texlive2020/texmf-config/web2c", 0x7fffd87dfed0) = -1 ENOENT (No such file or directory)
stat("/home/vadimkantorov/.texlive2020/texmf-var/web2c", 0x7fffd87dfed0) = -1 ENOENT (No such file or directory)
stat("/home/vadimkantorov/texmf/web2c", 0x7fffd87dfed0) = -1 ENOENT (No such file or directory)
exit_group(1)                           = ?
+++ exited with 1 +++

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 28, 2020

Yay! There were some stupid path bug on my side. I managed to get a latex format file

@vadimkantorov
Copy link
Author

@vadimkantorov
Copy link
Author

Will now try your next steps after the format file is done

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 29, 2020

Would you have an advice on how to share FS between several Emscripten MODULARIZE'd programs? emscripten-core/emscripten#12074

E.g. I first want to not deal with objects and have a common FS and manually launch xetex / bibtex (if needed) / dvipdfmx modules (for now without workers). For that it'd be good to have them a shared MEMFS.

@lyze
Copy link
Owner

lyze commented Aug 30, 2020

I see. I read through the issues referenced. What we really need is a pluggable filesystem or an abstraction to hack away on emscripten-core/emscripten/issues/777.

Depending on the extent of the data, maybe a workaround is to just copy what you need among the modularized filesystems. The common shared files, like the tex distribution itself, would still be accessed lazily with XHR. This may mean more memory use, but the common requests should go to the browser cache, so maybe things would be just fine.

@vadimkantorov
Copy link
Author

maybe a workaround is to just copy what you need among the modularized filesystems.

Makes sense! At least until there is some feedback in emscripten repo!

So will now try to build xetex/dvipdfmx with emscripten. Will let you know how it builds now from source (if the issues you described still persist)

@vadimkantorov
Copy link
Author

Do I understand correctly that your Makefile does not build a separate kpathsea binary? And somehow builds it into xetex itself?

@vadimkantorov
Copy link
Author

vadimkantorov commented Aug 31, 2020

So emconfigure of TexLive (from trunk) succeeded.
Making currently fails in upmendex at https://github.com/TeX-Live/texlive-source/blob/trunk/texk/upmendex/configure#L3081

Somehow upmendex tries to check the compiler and doesn't detect the .js output (even if it's not required, TexLive still tries to configure everything and does it in making time!). Can't figure out a way to patch it out :( or set some config.site / config.cache presets. Would be glad if you have any advice!

@vadimkantorov
Copy link
Author

I managed to continue the build by removing upmendex from texlive-source/texlive-build-wasm/texk/Makefile from CONF_SUBDIRS variable, but definitely a cleaner hack would be great

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 8, 2020

Not sure why it tries to search for xelatex.fmt when it is preloaded and texmf.cnf seems discovered ok

@vadimkantorov
Copy link
Author

Afte specifying format file explicitly, I started to get:

(index):90 /xelatex: option is ambiguous: 
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2021/dev_EM) (preloaded format=/xelatex.fmt)
(index):84 entering extended mode
(index):84 Ĉͻ^^@I^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^
(index):84 ^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^
(index):84 @^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@
....
@^^@^^@^^@^^@^^@^^@^^@^^@^^@^^@Iͼ
(index):84 (Press Enter to retry, or Control-D to exit;Ά')
(index):84 ͿΈ
(index):84 Ĉğ
(index):84 ε

So apparently there is some error, and no xdv is produced, but the output is scrambled :(

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 9, 2020

I was running it with Module.callMain(['--interaction=nonstopmode', '--no-pdf', '--fmt=' + xelatexFmtPath, '--output-directory=/home/web_user', '--', sourcePath])

When I remove -- then option is ambiguous: disappears. This is quite strange since natively compiled one does not have a problem with --. Probably this is some divergence of emscripten cstdlib.

@vadimkantorov
Copy link
Author

I think somehow it cannot create/open log file (judging from the stack trace), but not sure why it can't open it.

@vadimkantorov
Copy link
Author

This is very strange, because file reading clearly works. And writing files from JavaScript clearly works as well.

@vadimkantorov
Copy link
Author

After adding TEXMFVAR = /home/web_user into /texmf.cnf, I still get the same error, but now I got xelatex.fmt42.fls created next to /home/web_user/source.tex. So it's really some paths issue

@vadimkantorov
Copy link
Author

but it seems that logs should be created in the current directory (/home/web_user), so it's still strange

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 9, 2020

Maybe it's a conflict between /texmf.cnf and /texlive/texmf-dist/web2c/texmf.cnf and /texlive/texmf.cnf

@vadimkantorov
Copy link
Author

I removed /texlive/texmf.cnf, but error still persists. Very mysterious.

@vadimkantorov
Copy link
Author

I confirmed, openlogfile fails for some reason

@vadimkantorov
Copy link
Author

With very tedious printf debugging, I found out that for some reason xetex does not set the log file name (in nameoffile + 1), so it tries to open the directory for writing and that obviously fails. Now a question is where does xetex normally set the log filename

@vadimkantorov
Copy link
Author

It almost looks like constant string buffer got corrupted somehow

@vadimkantorov
Copy link
Author

Okay, I think I have found the reason, and it's really strange:

zpackfilename (L13891 in attached xetex0.c) assumes that passed in str_numbers are >= 65536. But this is not the case for str_numbers passed in from L14283 (".log" seems to be encoded as 902).

xetex0.zip

Here is excerpt from native xetex0.c:

void
openlogfile ( void )
{
  openlogfile_regmem
  unsigned char oldsetting  ;
  integer k  ;
  integer l  ;
  constcstring months  ;
  oldsetting = selector ;
  if ( jobname == 0 )
  jobname = getjobname ( 66180L ) ;
  packjobname ( 66181L ) ;
  recorderchangefilename ( stringcast ( nameoffile + 1 ) ) ;
  packjobname ( 66182L ) ;
  while ( ! aopenout ( logfile ) ) {

    selector = 17 ;
    promptfilename ( 66184L , 66182L ) ;
  }

And here's excerpt from wasm one:

void
openlogfile ( void )
{
  openlogfile_regmem
  unsigned char oldsetting  ;
  integer k  ;
  integer l  ;
  constcstring months  ;
  oldsetting = selector ;
  if ( jobname == 0 )
  jobname = getjobname ( 900 ) ;
  packjobname ( 901 ) ;
  recorderchangefilename ( stringcast ( nameoffile + 1 ) ) ;
  packjobname ( 902 ) ;

  while ( ! aopenout ( logfile ) ) {

    selector = 17 ;
    promptfilename ( 904 , 902 ) ;
  }

How these offsets are determined? Maybe I miss some compiler options?

@vadimkantorov
Copy link
Author

After copying xetex0.c from native (though still would be good to figure it out), things moved to "article.cls not found" - again some cnf/texmfdist problem. I've got article.cls in ./texlive/texmf-dist/tex/latex/base/article.cls

@vadimkantorov
Copy link
Author

After using texmf.cnf from prefix-native/share/texmf-dist/web2c/texmf.cnf, I've started to get this error in JavaScript: "Fontconfig error: Cannot load default config file"

@vadimkantorov
Copy link
Author

How does fontconfig in your case discover fonts? Do you bundle the fonts somehow?

@vadimkantorov
Copy link
Author

Do you configure it somehow to look into texmf-dist/fonts/?

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 10, 2020

FONTCONFIG_PATH and FONTCONFIG_FILE helped!

@lyze
Copy link
Owner

lyze commented Sep 12, 2020

When I did this some time ago, I recall setting TEXMFDIST "just"(tm) worked. I think in this case you might have run into issues with using the texmf.cnf in the web2c directory, but I'm not certain.

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 12, 2020

Everything mostly worked! I managed to run XeTeX in browser (for now in synchronous mode) and even to link xetex and dvipdfmx in one executable by renaming some symbols

@lyze
Copy link
Owner

lyze commented Sep 13, 2020

nice!

@vadimkantorov
Copy link
Author

image

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 13, 2020

After renaming a few symbols and creating some dummy files,

#include <string.h>

extern int busymain_xetex(int argc, char* argv[]);
extern int busymain_dvipdfmx(int argc, char* argv[]);

int main(int argc, char* argv[])
{
    if(strcmp("xetex", argv[1]) == 0 || strcmp("xelatex", argv[1]) == 0)
        return busymain_xetex(argc - 1, argv + 1);
    else if(strcmp("dvipdfmx", argv[1]) == 0)
        return busymain_dvipdfmx(argc - 1, argv + 1);
}

calling this multiple times via invokeMain works well! https://github.com/vadimkantorov/busytex/

I think of making some latexmk surrogate in C to simplify JavaScript interaction + this static "all-in-one" scheme would be useful for native builds as well

@vadimkantorov
Copy link
Author

zpackfilename (L13891 in attached xetex0.c) assumes that passed in str_numbers are >= 65536. But this is not the case for str_numbers passed in from L14283 (".log" seems to be encoded as 902).

Would you have any ideas about this?

@vadimkantorov
Copy link
Author

A problem with implementing latexmk in C code seems that xetex uses exit(0) or exit(1) to stop execution. Any ideas on how to patch out exit to allow for sequential calls:

busymain_xetex(argc - 1, argv + 1);
...
busymain_dvipdfmx(argc - 1, argv + 1);
busymain_xetex(argc - 1, argv + 1);

@lyze
Copy link
Owner

lyze commented Sep 14, 2020

I don't know what the state of support for system calls is today with emscripten, but perhaps it's worth a shot trying a wrapper with fork and exec.

@vadimkantorov
Copy link
Author

I managed to get bibtex8 working as well. Now it's a single executable combining xetex/bibtex8/dvidpfmx

@vadimkantorov
Copy link
Author

image

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 24, 2020

A question: all these three tools together (unoptimized) take 45 Mb of wasm.

How far did you manage to go by enabling O3 + maybe lto?

@lyze
Copy link
Owner

lyze commented Sep 24, 2020

In my memory, -O3 generally worked fine, though using --closure caused problems. This might require some trial and error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants