DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
204 stars 34 forks source link

inform6 fails to build under termux/llvm clang #226

Closed spacehobo closed 1 year ago

spacehobo commented 1 year ago

Termux is admittedly a rather outre platform, being a shell environment in an app on Android. As such a lot of POSIX assumptions can go wrong, but usually things turn out all right.

One thing that's been a bit of a splinter in my fingers the past several months is the inability to build inform6unix because of the timespec_get() semantics under termux. This worked in the past, so either this facility was only recently added, or there's some autoconf magic that's choosing the wrong semantics based on the fact that Android has a Linux kernel or something.

Here's what I get the second time I do a run, which shows the specific failure without much flannel around it (everything up to this point seems to build happily).

make[1]: Entering directory '/data/data/com.termux/files/home/src/one_night_in_sf/inform6unix'
which: no git-archive-all in (/data/data/com.termux/files/usr/bin)
cc -DDefault_Language=\"english\" -DInclude_Directory=\"",/data/data/com.termux/files/usr/share/inform/std/lib,/data/data/com.termux/files/usr/share/inform/std/include"\" -DTemporary_Directory=\"/tmp\" -DLINUX  -o src/inform.o -c src/inform.c
cc -DDefault_Language=\"english\" -DInclude_Directory=\"",/data/data/com.termux/files/usr/share/inform/std/lib,/data/data/com.termux/files/usr/share/inform/std/include"\" -DTemporary_Directory=\"/tmp\" -DLINUX  -o src/text.o -c src/text.c
src/inform.c:1098:5: error: call to undeclared function 'timespec_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    TIMEVALUE_NOW(&time_start);
    ^
src/header.h:537:28: note: expanded from macro 'TIMEVALUE_NOW'
  #define TIMEVALUE_NOW(t) timespec_get((t), TIME_UTC)
                           ^
src/text.c:1445:13: error: call to undeclared function 'timespec_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            TIMEVALUE_NOW(&t1);
            ^
src/header.h:537:28: note: expanded from macro 'TIMEVALUE_NOW'
  #define TIMEVALUE_NOW(t) timespec_get((t), TIME_UTC)
                           ^
1 error generated.
1 error generated.
make[1]: *** [Makefile:178: src/inform.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:178: src/text.o] Error 1
erkyrath commented 1 year ago

If you drop -DUSE_C11_TIME_API from the compile flags and instead use -DUSE_POSIX_TIME_API, it should compile using clock_gettime() instead of timespec_get(). Failing that, -DUSE_OLD_TIME_API will be seriously antique and use time().

I didn't set up inform6unix or its Makefile; you'll have to ask David Griffith (https://gitlab.com/DavidGriffith/inform6unix) about that.

erkyrath commented 1 year ago

(If -DUSE_C11_TIME_API isn't being set in a Makefile, there's probably a -DLINUX and then line 230 of header.h picks it up.)

spacehobo commented 1 year ago

Cool. I filed a merge proposal over on gitlab that at least works for me.

DavidGriffith commented 1 year ago

I've merged @spacehobo's changes.

erkyrath commented 1 year ago

Thanks.