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

Compiling luatex #1139

Open
luigiScarso opened this issue Apr 6, 2024 · 2 comments
Open

Compiling luatex #1139

luigiScarso opened this issue Apr 6, 2024 · 2 comments

Comments

@luigiScarso
Copy link

Hi all,
I have managed to compile
(or I should said κόσμος-compile ) luatex and luahbtex from
https://gitlab.lisn.upsaclay.fr/texlive/luatex
under Linux Ubuntu x86_64, using its build.sh script.

  1. building is done in 2 steps, one with CC="x86_64-unknown-cosmo-cc
    and one with CC="aarch64-unknown-cosmo-cc because the arm step needs
    the "--enable-arm-neon=on option at config time.
    Then I build the ape binary following the example in cosmocc --help.
    Two steps are ok but I would like to use a single step with CC=cosmocc, any suggestion is welcome.

  2. llround is unresolved at linking time: I have replaced it with lround
    but I am not sure if it can be solved in another way.

  3. texk/web2c/luatexdir/tex/maincontrol.h has
    extern boolean privileged(void);
    that seem to conflicts with a privileged symbol used by cosmocc; I have fixed with

#ifdef __COSMOPOLITAN__
#undef privileged
#endif
extern boolean privileged(void);

There are also a few other patches to some config.ac, but I think that they can go upstream (to TexLive, I mean),
and texk/web2c/luatexdir/luasocket/src/usocket.c
has

#ifdef __COSMOPOLITAN__
#include "libc/sock/struct/pollfd.h"
#endif

that I think I cannot avoid.

The ape format runs on Linux / Windows / FreeBSD x86_64 (I have to check aarch64 with a rpi) but
I haven't done extensive testing yet.

--
luigi

@mrdomino
Copy link
Collaborator

mrdomino commented Apr 6, 2024

Awesome! Maybe you can submit a PR to superconfigure (cc @ahgamut).

For posterity, this is where privileged is defined:

#ifndef privileged
#define privileged \
_Section(".privileged") dontinline dontinstrument dontubsan dontasan
#endif

@jart perhaps privileged (and, at a cursory glance, relegated) might be candidates for renaming? It seems like simple dictionary words ought to be fair game for someone to expect to be able to use in their own namespace. Alternatively is there a reason those defs aren't gated behind _COSMO_SOURCE or something?

@dfyz
Copy link
Contributor

dfyz commented Apr 10, 2024

@luigiScarso

Hi, this is awesome! We have a similar project with slightly broader scope: we also compile other TeX binaries, such as pdfTeX and XeTeX, into a single busytex-style binary. We also managed to compile our project with Cosmo, making Cosmo fixes along the way.

I think we stumbled upon everything you described, and made some workarounds on our side. It would be great to fix those properly!

  1. We solved this by disabling NEON optimizations with --enable-arm-neon=no (this is no, not on). This only affects libpng, and our reasoning was that the upstream TeX Live never enabled SSE optimizations at all (which are present in the upstream libpng). So if they do fine without SSE-optimized routines, then we can probably ignore NEON optimizations as well. It would be nice to have a way to enable both kinds of optimizations when compiling with cosmocc, though.

  2. @jart confirmed on Discord that llround() was indeed missing. I made a quick workaround for this in my personal Cosmopolitan branch, but never upstreamed anything. I guess I should clean it up and send upstream.

  3. We made a cursed workaround with compiler flags: -Dprivileged=privileged, which only works because Cosmopolitan's definition of privileged starts with #ifndef privileged. I agree with @mrdomino here: it would be great to avoid cluttering the global namespace here.

  4. See the comment that starts here. tl;dr A couple of -D... compiler flags are sufficient to make LuaTeX compile, but it would be nice to make config.ac changes in upstream Tex Live.

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

3 participants