本地构建的GCC交叉编译器报告MB_LEN_MAX错误,错误为-D_FORTIFY_SOURCE=2

本地构建的GCC交叉编译器报告MB_LEN_MAX错误,错误为-D_FORTIFY_SOURCE=2,gcc,glibc,libc,Gcc,Glibc,Libc,我目前正在构建一个针对PowerPC体系结构的交叉编译器。它能够构建Linux二进制文件,可以在目标系统上运行,但是当我启用编译器标志“-D_FORTIFY_SOURCE=2”时,我遇到了一个问题。我构建了一个简单的hello world应用程序,如下所示: #include <limits.h> #include <stdlib.h> int main(int argc, char* argv[]) { return 0; } 我相信这是因为我没有正确地引导我的

我目前正在构建一个针对PowerPC体系结构的交叉编译器。它能够构建Linux二进制文件,可以在目标系统上运行,但是当我启用编译器标志“-D_FORTIFY_SOURCE=2”时,我遇到了一个问题。我构建了一个简单的hello world应用程序,如下所示:

#include <limits.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  return 0;
}
我相信这是因为我没有正确地引导我的GCC构建,但就我所见,我正在正确地构建它。我构建编译器的脚本如下所示:

#! /bin/bash
set -e
INSTALL_PATH=$PWD/output
TARGET=powerpc-linux-gnu
LINUX_ARCH=powerpc
PARALLEL_MAKE=-j4
BINUTILS_VERSION=binutils-2.32
GCC_VERSION=gcc-8.3.0
LINUX_KERNEL_VERSION=linux-5.1.9
GLIBC_VERSION=glibc-2.29
export PATH=$INSTALL_PATH/bin:$PATH

cd $GCC_VERSION
./contrib/download_prerequisites
cd ..

mkdir -p build-binutils
cd build-binutils
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET
make $PARALLEL_MAKE
make install
cd ..

cd $LINUX_KERNEL_VERSION
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$INSTALL_PATH/$TARGET headers_install
cd ..

# Build GCC compiler
mkdir -p build-gcc
cd build-gcc
../$GCC_VERSION/configure \
  --prefix=$INSTALL_PATH \
  --target=$TARGET \
  --disable-silent-rules \
  --with-gnu-as --with-gnu-ld \
  --enable-languages="c,c++" \
  --enable-theads=posix \
  --enable-c99 \
  --enable-long-long \
  --enable-lto \
  --enable-libssp \
  --enable-secureplt \
  --disable-libmudflag \
  --enable-secureplt \
  --disable-nls \
  --with-long-double-128
make $PARALLEL_MAKE all-gcc
make install-gcc
cd ..

mkdir -p build-glibc
cd build-glibc
../$GLIBC_VERSION/configure \
  --prefix=$INSTALL_PATH/$TARGET \
  --build=$(gcc -dumpmachine) \
  --host=$TARGET \
  --target=$TARGET \
  --with-headers=$INSTALL_PATH/$TARGET/include \
  libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make $PARALLEL_MAKE csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $INSTALL_PATH/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $INSTALL_PATH/$TARGET/lib/libc.so
touch $INSTALL_PATH/$TARGET/include/gnu/stubs.h
cd ..

cd build-gcc
make $PARALLEL_MAKE all-target-libgcc
make install-target-libgcc
cd ..

cd build-glibc
make $PARALLEL_MAKE
make install
cd ..

cd build-gcc
make $PARALLEL_MAKE all
make install
cd ..

我是否错误地引导了GCC?我是否应该采取不同的措施使GCC“意识到”我的glibc头?

默认情况下,
limits.h
文件未正确配置,因此需要对其进行修补

要解决此问题,您必须进入GCC的源目录并键入以下命令:

cd $GCC_VERSION
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $(${TARGET}-gcc -print-libgcc-file-name)`/include-fixed/limits.h
这会在底部添加一个
#include_next
,最终会选择正确的标题。

快速添加到,以完成调试,在结束时不要忘记使用:

$LFS/tools/libexec/gcc/$LFS\u TGT/10.2.0/install-tools/mkheaders
cd $GCC_VERSION
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $(${TARGET}-gcc -print-libgcc-file-name)`/include-fixed/limits.h