Something seems to be wrong with the SDK you have. On my system:
% ls -l /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/socket.h
-r--r--r-- 1 root wheel 32534 13 Aug 14:03 /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/socket.h
Your machine/endian.h
also seems to be including i386/endian.h
when building for arm:
configure:17916: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -arch arm64 -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -arch arm64 conftest.c >&5
In file included from conftest.c:155:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/stdlib.h:58:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/_stdlib.h:66:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/wait.h:186:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/machine/endian.h:35:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/i386/endian.h:85:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/sys/_endian.h:131:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/libkern/_OSByteOrder.h:62:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/libkern/arm/_OSByteOrder.h:50:1: error: redefinition of '_OSSwapInt16'
50 | _OSSwapInt16(
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/libkern/i386/_OSByteOrder.h:50:1: note: previous definition is here
50 | _OSSwapInt16(
| ^