export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export LDFLAGS="-g
-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.13.sdk/usr/lib
-lxml2 -lz -lpthread -licucore"
export CFLAGS="-g -O0
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2
-I/usr/local/opt/imagemagick@6/include"
export CXXFLAGS="-g -O0"
./autogen.sh
./configure --enable-locallisppath=/usr/local/share/emacs/site-lisp \
--infodir=$EMACS_DIR/share/info/emacs \
--prefix=$EMACS_DIR \
--without-makeinfo
make -j8
You appear to be disabling optimisations, I'd try the default -O2.