Building Erlang 23.0.3 and 23.0.4 on macOS 10.15.6 fails with
drivers/common/inet_drv.c:1484:30: error: static declaration of 'in6addr_any' follows non-static declaration
static const struct in6_addr in6addr_any = { { IN6ADDR_ANY_INIT } };
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet6/in6.h:211:30: note: previous declaration is here
extern const struct in6_addr in6addr_any;
^
drivers/common/inet_drv.c:1493:30: error: static declaration of 'in6addr_loopback' follows non-static declaration
static const struct in6_addr in6addr_loopback =
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet6/in6.h:212:30: note: previous declaration is here
extern const struct in6_addr in6addr_loopback;
^
CC obj/x86_64-apple-darwin19.6.0/opt/smp/zlib_nif.o
CC obj/x86_64-apple-darwin19.6.0/opt/smp/prim_socket_nif.o
2 errors generated.
make[4]: *** [obj/x86_64-apple-darwin19.6.0/opt/smp/inet_drv.o] Error 1
make[4]: *** Waiting for unfinished jobs....
nifs/common/prim_socket_nif.c:2903:30: error: static declaration of 'in6addr_any' follows non-static declaration
static const struct in6_addr in6addr_any = { { IN6ADDR_ANY_INIT } };
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet6/in6.h:211:30: note: previous declaration is here
extern const struct in6_addr in6addr_any;
^
nifs/common/prim_socket_nif.c:2912:30: error: static declaration of 'in6addr_loopback' follows non-static declaration
static const struct in6_addr in6addr_loopback =
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet6/in6.h:212:30: note: previous declaration is here
extern const struct in6_addr in6addr_loopback;
^
2 errors generated.
make[4]: *** [obj/x86_64-apple-darwin19.6.0/opt/smp/prim_socket_nif.o] Error 1
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [smp] Error 2
make: *** [emulator] Error 2
I just updated to Xcode 12, which is my suspicion as culprit. However I'm not knowledgeable in Erlang builds, so I'm not sure how to fix this.
Looks like it may be related to #157, but I already have Xcode installed and turning off the implicit function decl warning feels wrong.
Did you try this? https://github.com/asdf-vm/asdf-erlang/issues/157#issuecomment-669441058
That works, except -02 should be -O2, otherwise it breaks completely. Nonetheless it seems like this shouldn't be necessary (why are we setting the optimization level?), should I file this upstream with kerl or somewhere like that?
I guess CFLAGS only works if you set an optimization level. That explains that part. Doesn't explain why it doesn't build on macOS without this flag.
Most helpful comment
https://bugs.erlang.org/browse/ERL-1306