From 2f1bd786c2d5a6f13d225111ce5f3aaa813f487f Mon Sep 17 00:00:00 2001 From: dingguangya Date: Mon, 6 Mar 2023 10:47:05 +0800 Subject: [PATCH] [gcc-cross] Update cross-compilation tool chain to openEuler-23.03 --- config.xml | 6 ++--- download.sh | 28 ++++++++++++++--------- gcc-cross.spec | 10 ++++++-- gcc_arm32le/build.sh | 4 ++-- gcc_arm32le/gcc_arm_linux_release.sh | 29 ++++++++++++++++++++++++ gcc_arm64le/build.sh | 4 ++-- gcc_arm64le/gcc_aarch64_linux_release.sh | 29 ++++++++++++++++++++++++ 7 files changed, 90 insertions(+), 20 deletions(-) diff --git a/config.xml b/config.xml index 28e7676..12a9d14 100644 --- a/config.xml +++ b/config.xml @@ -9,11 +9,11 @@ MPFR_DIR="mpfr-4.1.0" GMP="gmp" GMP_DIR="gmp-6.2.1" MPC="libmpc" -MPC_DIR="mpc-1.2.0" +MPC_DIR="mpc-1.3.1" ISL="isl" -ISL_DIR="isl-0.16.1" +ISL_DIR="isl-0.24" GLIBC="glibc" -GLIBC_DIR="glibc-2.34" +GLIBC_DIR="glibc-2.36" KERNEL_HEADERS="kernel_headers" KERNEL_HEADERS_64="kernel_headers_64" LINUX_KERNEL="kernel" diff --git a/download.sh b/download.sh index b492ff4..dc0bf3f 100755 --- a/download.sh +++ b/download.sh @@ -18,10 +18,16 @@ cd $LIB_PATH && delete_dir $GCC $BINUTILS $GMP $MPC $MPFR $ISL pushd $LIB_PATH function do_patch() { pushd $1 - if [ $1 = "isl" ];then - tar xf $1-0.14.tar.xz - tar xf $1-0.16.1.tar.xz - patch -p1 < *.patch + 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 else PKG=$(echo *.tar.*) tar xf *.tar.* @@ -35,25 +41,25 @@ function do_patch() { fi popd } -echo "Download $GCC" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/gcc.git +echo "Download $GCC" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/gcc.git do_patch $GCC -echo "Download $GLIBC" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/glibc.git +echo "Download $GLIBC" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/glibc.git do_patch $GLIBC -echo "Download $BINUTILS" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/binutils.git +echo "Download $BINUTILS" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/binutils.git do_patch $BINUTILS -echo "Download $GMP" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/gmp.git +echo "Download $GMP" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/gmp.git do_patch $GMP -echo "Download $MPFR" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/mpfr.git +echo "Download $MPFR" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/mpfr.git do_patch $MPFR -echo "Download $MPC" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/libmpc.git +echo "Download $MPC" && git clone -b openEuler-23.03 https://gitee.com/src-openeuler/libmpc.git do_patch $MPC -echo "Download $ISL" && git clone -b openEuler-22.03-LTS https://gitee.com/src-openeuler/isl.git +echo "Download $ISL" && git clone -b openEuler-23.03 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 diff --git a/gcc-cross.spec b/gcc-cross.spec index 9dd6bd4..7a9ecc7 100644 --- a/gcc-cross.spec +++ b/gcc-cross.spec @@ -1,7 +1,7 @@ Summary: C/C++ Cross Compiler Toolchain Name: gcc-cross Version: 1.0 -Release: 3 +Release: 4 # 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 @@ -10,7 +10,7 @@ URL: http://gcc.gnu.org BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: binutils BuildRequires: gcc, gcc-c++, make, git, flex, bison, rpm-build, automake, autoconf -BuildRequires: libtool, ncurses-devel, bc, openssl-devel, texinfo, rsync, chrpath +BuildRequires: libtool, ncurses-devel, bc, zlib-devel, openssl-devel, texinfo, rsync, chrpath #ExclusiveArch: i386 x86-64 %description @@ -42,6 +42,12 @@ cp %{_builddir}/output/gcc_arm32le/gcc_arm32le.tar.gz %{buildroot}/tmp %attr(755, root, root) /tmp/gcc_arm32le.tar.gz %changelog +* Mon Mar 06 2023 dingguangya - 1.0-4 +-Type:Fix +-ID:NA +-SUG:NA +-DESC: Update cross-compilation tool chain to openEuler-23.03 + * Mon Nov 28 2022 dingguangya - 1.0-3 -Type:Fix -ID:NA diff --git a/gcc_arm32le/build.sh b/gcc_arm32le/build.sh index f3fccdb..8f79f25 100755 --- a/gcc_arm32le/build.sh +++ b/gcc_arm32le/build.sh @@ -13,11 +13,11 @@ fi [ -e "$LOG_PATH/gcc_arm32le_build.log" ] && rm $LOG_PATH/gcc_arm32le_build.log mkdir -p $LOG_PATH -source pre_construction.sh &>> $LOG_PATH/gcc_arm32le_patch.log +source pre_construction.sh 2>&1 | tee $LOG_PATH/gcc_arm32le_patch.log echo "------------------------------------------" echo "Now building the "gcc_arm32le" toolchain ..." echo "The entire build process takes about 45 minutes (build time is related to machine preformance), you can view the detailed build log in the ${LOG_PATH} file" source gcc_update_sourcecode.sh -source gcc_arm_linux_release.sh &>> $LOG_PATH/gcc_arm32le_build.log +source gcc_arm_linux_release.sh 2>&1 | tee $LOG_PATH/gcc_arm32le_build.log echo "Build gcc_arm32le toolchain completed!" diff --git a/gcc_arm32le/gcc_arm_linux_release.sh b/gcc_arm32le/gcc_arm_linux_release.sh index bec4da3..c474127 100755 --- a/gcc_arm32le/gcc_arm_linux_release.sh +++ b/gcc_arm32le/gcc_arm_linux_release.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e +set -x # Target root directory,should be adapted according to your environment readonly ROOT_TAR_DIR="$PWD/arm32le_build_dir" @@ -94,6 +95,34 @@ for file in $(find "$PREFIX" -name "lib*so*.0") ; do chrpath --delete $file done +for file in $(find "$PREFIX/sysroot/usr/lib/gconv" -name "*so") ; do + chrpath --delete $file +done + +for file in $(find "$PREFIX" -name "*") ; do + if [ -f "$file" ] + then + result=$(file $file) + res=$(echo $result | grep "ELF" | cat) + if [[ "$res" != "" ]] + then + get_arch=`arch` + if [[ $get_arch =~ "x86_64" ]] + then + res1=$(echo $result | grep "ARM" | cat) + if [[ "$res1" != "" ]] + then + $PREFIX/bin/$TARGET-strip $file + else + strip $file + fi + else + strip $file + fi + fi + fi +done + pushd $PREFIX/.. && chmod 750 $INSTALL -R tar --format=gnu -czf $OUTPUT/$INSTALL.tar.gz $INSTALL && popd diff --git a/gcc_arm64le/build.sh b/gcc_arm64le/build.sh index 433ec01..88c575d 100755 --- a/gcc_arm64le/build.sh +++ b/gcc_arm64le/build.sh @@ -11,11 +11,11 @@ source $PWD/../config.xml [ -e "$LOG_PATH/gcc_arm64le_build.log" ] && rm $LOG_PATH/gcc_arm64le_build.log mkdir -p $LOG_PATH -source pre_construction.sh &>> $LOG_PATH/gcc_arm64le_patch.log +source pre_construction.sh 2>&1 | tee $LOG_PATH/gcc_arm64le_patch.log echo "------------------------------------------" echo "Now building the "gcc_arm64le" toolchain ..." echo "The entire build process takes about 45 minutes (build time is related to machine preformance), you can view the detailed build log in the ${LOG_PATH} file" source gcc_update_sourcecode.sh -source gcc_aarch64_linux_release.sh &>> $LOG_PATH/gcc_arm64le_build.log +source gcc_aarch64_linux_release.sh 2>&1 | tee $LOG_PATH/gcc_arm64le_build.log echo "Build gcc_arm64le toolchain completed!" diff --git a/gcc_arm64le/gcc_aarch64_linux_release.sh b/gcc_arm64le/gcc_aarch64_linux_release.sh index 3a0f9e3..59561c9 100755 --- a/gcc_arm64le/gcc_aarch64_linux_release.sh +++ b/gcc_arm64le/gcc_aarch64_linux_release.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e +set -x # Target root directory,should be adapted according to your environment readonly ROOT_TAR_DIR="$PWD/arm64le_build_dir" @@ -96,6 +97,34 @@ for file in $(find "$PREFIX" -name "lib*so*.0") ; do chrpath --delete $file done +for file in $(find "$PREFIX/sysroot/usr/lib64/gconv" -name "*so") ; do + chrpath --delete $file +done + +for file in $(find "$PREFIX" -name "*") ; do + if [ -f "$file" ] + then + result=$(file $file) + res=$(echo $result | grep "ELF" | cat) + if [[ "$res" != "" ]] + then + get_arch=`arch` + if [[ $get_arch =~ "x86_64" ]] + then + res1=$(echo $result | grep "ARM" | cat) + if [[ "$res1" != "" ]] + then + $PREFIX/bin/$TARGET-strip $file + else + strip $file + fi + else + strip $file + fi + fi + fi +done + pushd $PREFIX/.. && chmod 750 $INSTALL -R tar --format=gnu -czf $OUTPUT/$INSTALL.tar.gz $INSTALL && popd -- Gitee