wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
313 stars 26 forks source link

`make' fails on Adélie Linux #24

Closed msiism closed 2 years ago

msiism commented 5 years ago

This is what I get when trying to make Es on Adélie Linux, which uses musl libc:

gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o closure.o closure.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o conv.o conv.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o dict.o dict.c
dict.c: In function ‘put’:
dict.c:126:19: warning: cast between incompatible function types from ‘Dict * (*)(Dict *, char *, void *)’ {aka ‘struct Dict * (*)(struct Dict *, char *, void *)’} to ‘void (*)(void *, char *, void *)’ [-Wcast-function-type]
   dictforall(old, (void (*)(void *, char *, void *)) put, new);
                   ^
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o eval.o eval.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o except.o except.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o fd.o fd.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o gc.o gc.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o glob.o glob.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o glom.o glom.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o input.o input.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o heredoc.o heredoc.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o list.o list.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o main.o main.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o match.o match.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o open.o open.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o opt.o opt.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o prim-ctl.o prim-ctl.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o prim-etc.o prim-etc.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o prim-io.o prim-io.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o prim-sys.o prim-sys.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o prim.o prim.c
gcc  -I. -I. -W -Wall -Wno-missing-field-initializers -Wno-unused-parameter -Wno-clobbered -g -O2   -c -o print.o print.c
print.c: In function ‘fmtprint’:
print.c:281:15: error: assignment to expression with array type
  format->args = saveargs;
               ^
make: *** [<builtin>: print.o] Error 1

Adélie developers told me that the error is indeed related to musl vs. glibc. The problem is with __va_copy, which presumably is an internal glibc macro. Replacing it with the standard va_copy fixes the issue. (Thanks to aranea.)

After fixing that, make still fails, but for other reasons.

wryun commented 5 years ago

Ah, tricky - I need to either understand how autotools works or drop pre C99 support. Or maybe just have our own va_copy...

Although supposedly __va_copy is provided by gcc:

https://www.gnu.org/software/libc/manual/html_node/Argument-Macros.html

So maybe something wrong with ifndef? Confusing.

mwgamera commented 5 years ago

There is nothing wrong with ifndef. GCC's va_copy is defined in terms of appropriate builtins in stdarg.h. What glibc manual actually means, is that this header is no longer a part of GNU C library, but instead relies on the one provided by the compiler. However, musl does provide its own stdarg.h and here va_copy is always defined regardless of chosen standard mode, and nonstandard va_copy doesn't exists. The header provided by GCC is not used.

That ifndef, by the way, is rather recent (7ee55b5c). In other places where va_list is copied (including the very same fmtprint function!), memcpy is used when assignment fails (as determined by configure script that sets NO_VA_LIST_ASSIGN). This is likely wrong too even if it works.