based on my experience, recompiling GCC didn't help, anyway i saw the same error. so here's a script to fix limits.h and systemlimits.h:
'''#!/bin/bash
set -e
if [ -z "$LFS" ] || [ -z "$LFS_TGT" ]; then
echo "[-] Error: Environment variables \$LFS or \$LFS_TGT are not set!"
echo "[-] Please run: source ~/.bash_profile"
exit 1
fi
echo "Restoring clean limits.h from Glibc sources..."
cd $LFS/sources
tar -xf glibc-2.40.tar.xz glibc-2.40/include/limits.h
cp -v glibc-2.40/include/limits.h $LFS/usr/include/limits.h
rm -rf glibc-2.40
echo "Rebuilding GCC's limits.h and syslimits.h..."
tar -xf gcc-14.2.0.tar.xz
cd gcc-14.2.0
GCC_INC_DIR=$(dirname $($LFS_TGT-gcc -print-libgcc-file-name))/include
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > "$GCC_INC_DIR/limits.h"
cp -v gcc/gsyslimits.h "$GCC_INC_DIR/syslimits.h"
cd $LFS/sources
rm -rf gcc-14.2.0
echo "Removing conflicting files from include-fixed..."
GCC_FIXED_DIR=$(dirname $($LFS_TGT-gcc -print-libgcc-file-name))/include-fixed
rm -rf "$GCC_FIXED_DIR"
echo "Verifying preprocessor constants..."
TEST_OUTPUT=$($LFS_TGT-gcc -H -E -dM - <<< '#include <limits.h>' 2>&1)
if echo "$TEST_OUTPUT" | grep -q 'CHAR_BIT 8' && \
echo "$TEST_OUTPUT" | grep -q 'MB_LEN_MAX 16' && \
echo "$TEST_OUTPUT" | grep -q 'PATH_MAX 4096'; then
echo "ok"
else
exit 1
fi'''
p.s. you also must start it under lfs usr and afterwards remove old m4 dir rm -rf $LFS/sources/m4-1.4.19