From 5fa683861e50fbaa0e5e2bb06c725737a5c31585 Mon Sep 17 00:00:00 2001 From: dingguangya Date: Mon, 7 Aug 2023 23:05:26 +0800 Subject: [PATCH] [gcc-cross] Fix cross-compilation tool chain --- config.xml | 12 ++++---- download.sh | 46 ++++++++++++---------------- gcc-cross.spec | 12 ++++++-- gcc_arm32le/gcc_arm_linux_release.sh | 3 +- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/config.xml b/config.xml index 12a9d14..be530d1 100644 --- a/config.xml +++ b/config.xml @@ -1,19 +1,19 @@ -COMPILER_INFO="gcc 10.3.1" +COMPILER_INFO="gcc 12.3.1" GCC="gcc" -GCC_DIR="gcc-10.3.0" +GCC_DIR="gcc-12.3.0" BINUTILS="binutils" -BINUTILS_DIR="binutils-2.37" +BINUTILS_DIR="binutils-2.40" MPFR="mpfr" -MPFR_DIR="mpfr-4.1.0" +MPFR_DIR="mpfr-4.2.0" GMP="gmp" -GMP_DIR="gmp-6.2.1" +GMP_DIR="gmp-6.3.0" MPC="libmpc" MPC_DIR="mpc-1.3.1" ISL="isl" ISL_DIR="isl-0.24" GLIBC="glibc" -GLIBC_DIR="glibc-2.36" +GLIBC_DIR="glibc-2.38" KERNEL_HEADERS="kernel_headers" KERNEL_HEADERS_64="kernel_headers_64" LINUX_KERNEL="kernel" diff --git a/download.sh b/download.sh index 5164469..aae24c3 100755 --- a/download.sh +++ b/download.sh @@ -3,6 +3,9 @@ set -e readonly LIB_PATH="$PWD/../open_source" source $PWD/config.xml +build_rpmdir=`rpm --eval "%{_builddir}"` +src_rpmdir=`rpm --eval "%{_sourcedir}"` +SRC_BRANCH="master" #judge the open_source @@ -18,49 +21,38 @@ cd $LIB_PATH && delete_dir $GCC $BINUTILS $GMP $MPC $MPFR $ISL pushd $LIB_PATH function do_patch() { pushd $1 - if [ $1 = "gmp" ];then - PKG=$(echo *.tar.*) - tar xf *.tar.* - cat *.spec | grep "Patch" | grep "\.patch" | awk -F ':' '{print $2}' > $1-patchlist - pushd ${PKG%%.tar.*} - for i in `cat ../$1-patchlist` - do - patch -p1 < ../$i - done - popd + cp -f * $src_rpmdir + specfile=`ls *.spec` + rpmbuild -bp $src_rpmdir/$specfile + PKG=$(echo *.tar.*) + pkg_dir=${PKG%%.tar.*} + if [ $1 = "isl" ];then + cp -a $build_rpmdir/$1/$pkg_dir ./ else - PKG=$(echo *.tar.*) - tar xf *.tar.* - cat *.spec | grep "Patch" | grep "\.patch" | awk '{print $2}' > $1-patchlist - pushd ${PKG%%.tar.*} - for i in `cat ../$1-patchlist` - do - patch -p1 < ../$i - done - popd + cp -a $build_rpmdir/$pkg_dir ./ fi popd } -echo "Download $GCC" && git clone -b master https://gitee.com/src-openeuler/gcc.git +echo "Download $GCC" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/gcc.git do_patch $GCC -echo "Download $GLIBC" && git clone -b master https://gitee.com/src-openeuler/glibc.git +echo "Download $GLIBC" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/glibc.git do_patch $GLIBC -echo "Download $BINUTILS" && git clone -b master https://gitee.com/src-openeuler/binutils.git +echo "Download $BINUTILS" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/binutils.git do_patch $BINUTILS -echo "Download $GMP" && git clone -b master https://gitee.com/src-openeuler/gmp.git +echo "Download $GMP" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/gmp.git do_patch $GMP -echo "Download $MPFR" && git clone -b master https://gitee.com/src-openeuler/mpfr.git +echo "Download $MPFR" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/mpfr.git do_patch $MPFR -echo "Download $MPC" && git clone -b master https://gitee.com/src-openeuler/libmpc.git +echo "Download $MPC" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/libmpc.git do_patch $MPC -echo "Download $ISL" && git clone -b master https://gitee.com/src-openeuler/isl.git +echo "Download $ISL" && git clone -b $SRC_BRANCH https://gitee.com/src-openeuler/isl.git do_patch $ISL -echo "Download $LINUX_KERNEL" && git clone -b 5.10.0-60.16.0 https://gitee.com/openeuler/kernel.git --depth 1 +echo "Download $LINUX_KERNEL" && git clone -b 6.4.0-1.0.1 https://gitee.com/openeuler/kernel.git --depth 1 cp -a $LINUX_KERNEL $LINUX_KERNEL_64 diff --git a/gcc-cross.spec b/gcc-cross.spec index 593c6ec..e3d7c1e 100644 --- a/gcc-cross.spec +++ b/gcc-cross.spec @@ -1,14 +1,16 @@ Summary: C/C++ Cross Compiler Toolchain Name: gcc-cross Version: 1.0 -Release: 4 +Release: 5 # libgcc, libgfortran, libmudflap, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD URL: http://gcc.gnu.org BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: binutils +BuildRequires: binutils, gettext, gmp-devel, isl-devel, libmpc-devel, mpfr-devel, python3-sphinx, sharutils +BuildRequires: audit-libs-devel, gd-devel, libcap-devel, libpng-devel, libselinux-devel, libstdc++-static, systemtap-sdt-devel, valgrind +BuildRequires: jansson-devel BuildRequires: gcc, gcc-c++, make, git, flex, bison, rpm-build, automake, autoconf BuildRequires: libtool, ncurses-devel, bc, zlib-devel, openssl-devel, texinfo, rsync, chrpath #ExclusiveArch: i386 x86-64 @@ -42,6 +44,12 @@ cp %{_builddir}/output/gcc_arm32le/gcc_arm32le.tar.gz %{buildroot}/tmp %attr(755, root, root) /tmp/gcc_arm32le.tar.gz %changelog +* Mon Aug 07 2023 dingguangya - 1.0-5 +-Type:Fix +-ID:NA +-SUG:NA +-DESC: Fix cross-compilation tool chain + * Mon Mar 06 2023 dingguangya - 1.0-4 -Type:Fix -ID:NA diff --git a/gcc_arm32le/gcc_arm_linux_release.sh b/gcc_arm32le/gcc_arm_linux_release.sh index c474127..2e67652 100755 --- a/gcc_arm32le/gcc_arm_linux_release.sh +++ b/gcc_arm32le/gcc_arm_linux_release.sh @@ -78,7 +78,8 @@ cp csu/crt1.o csu/crti.o csu/crtn.o $SYSROOT/usr/lib/ $PREFIX/bin/$TARGET-gcc $CFLAGS_FOR_TARGET -o "$SYSROOT/usr/lib/libc.so" -nostdlib -nostartfiles -shared -x c /dev/null && popd echo "Building GCC second..." && pushd $ROOT_TAR_DIR/obj/build-gcc-second -cp $ROOT_TAR_DIR/obj/glibc-headers/bits/stdio_lim.h $SYSROOT/usr/include/bits +# Fix this issue https://gitee.com/src-openeuler/gcc-cross/issues/I7KWH4. The reason is that gcc_arm32le/sysroot/usr/include/bits/stdio_lim.h is generated after glibc is upgraded. +#cp $ROOT_TAR_DIR/obj/glibc-headers/bits/stdio_lim.h $SYSROOT/usr/include/bits LDFLAGS="${SECURE_LDFLAGS}" CFLAGS="${SECURE_CFLAGS}" CXXFLAGS="${SECURE_CXXFLAGS}" CFLAGS_FOR_TARGET="${SECURE_CFLAGS_FOR_TARGET}" CXXFLAGS_FOR_TARGET="${SECURE_CXXFLAGS_FOR_TARGET}" $ROOT_TAR_SRC/$GCC/$GCC_DIR/configure --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIX --disable-multilib --disable-libmudflap --enable-shared --with-arch=$ARCH --enable-__cxa_atexit --with-gnu-as --with-gnu-ld --disable-nls --disable-libssp --disable-libgomp --enable-lto --disable-libquadmath --enable-poison-system-directories --enable-symvers=gnu --enable-languages=c --with-pkgversion="${COMPILER_INFO}" --with-sysroot=$SYSROOT --with-build-sysroot=$SYSROOT --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --with-isl=$PREFIX --with-build-time-tools=$PREFIX/$TARGET/bin --libdir=$PREFIX/lib --disable-bootstrap --disable-libatomic --disable-libcilkrts --disable-libstdcxx-dual-abi --with-system-zlib make -j 32 CPPFLAGS_FOR_TARGET=--sysroot=$SYSROOT build_tooldir=$PREFIX/$TARGET && make install-gcc install-target-libgcc prefix=$PREFIX exec_prefix=$PREFIX libdir=$PREFIX/lib && popd -- Gitee