[gcc-cross] Fix cross-compilation tool chain

This commit is contained in:
dingguangya 2023-08-07 23:05:26 +08:00
parent 95b3e45fd6
commit 5fa683861e
4 changed files with 37 additions and 36 deletions

View File

@ -1,19 +1,19 @@
COMPILER_INFO="gcc 10.3.1" COMPILER_INFO="gcc 12.3.1"
GCC="gcc" GCC="gcc"
GCC_DIR="gcc-10.3.0" GCC_DIR="gcc-12.3.0"
BINUTILS="binutils" BINUTILS="binutils"
BINUTILS_DIR="binutils-2.37" BINUTILS_DIR="binutils-2.40"
MPFR="mpfr" MPFR="mpfr"
MPFR_DIR="mpfr-4.1.0" MPFR_DIR="mpfr-4.2.0"
GMP="gmp" GMP="gmp"
GMP_DIR="gmp-6.2.1" GMP_DIR="gmp-6.3.0"
MPC="libmpc" MPC="libmpc"
MPC_DIR="mpc-1.3.1" MPC_DIR="mpc-1.3.1"
ISL="isl" ISL="isl"
ISL_DIR="isl-0.24" ISL_DIR="isl-0.24"
GLIBC="glibc" GLIBC="glibc"
GLIBC_DIR="glibc-2.36" GLIBC_DIR="glibc-2.38"
KERNEL_HEADERS="kernel_headers" KERNEL_HEADERS="kernel_headers"
KERNEL_HEADERS_64="kernel_headers_64" KERNEL_HEADERS_64="kernel_headers_64"
LINUX_KERNEL="kernel" LINUX_KERNEL="kernel"

View File

@ -3,6 +3,9 @@ set -e
readonly LIB_PATH="$PWD/../open_source" readonly LIB_PATH="$PWD/../open_source"
source $PWD/config.xml source $PWD/config.xml
build_rpmdir=`rpm --eval "%{_builddir}"`
src_rpmdir=`rpm --eval "%{_sourcedir}"`
SRC_BRANCH="master"
#judge the open_source #judge the open_source
@ -18,49 +21,38 @@ cd $LIB_PATH && delete_dir $GCC $BINUTILS $GMP $MPC $MPFR $ISL
pushd $LIB_PATH pushd $LIB_PATH
function do_patch() { function do_patch() {
pushd $1 pushd $1
if [ $1 = "gmp" ];then cp -f * $src_rpmdir
PKG=$(echo *.tar.*) specfile=`ls *.spec`
tar xf *.tar.* rpmbuild -bp $src_rpmdir/$specfile
cat *.spec | grep "Patch" | grep "\.patch" | awk -F ':' '{print $2}' > $1-patchlist PKG=$(echo *.tar.*)
pushd ${PKG%%.tar.*} pkg_dir=${PKG%%.tar.*}
for i in `cat ../$1-patchlist` if [ $1 = "isl" ];then
do cp -a $build_rpmdir/$1/$pkg_dir ./
patch -p1 < ../$i
done
popd
else else
PKG=$(echo *.tar.*) cp -a $build_rpmdir/$pkg_dir ./
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
fi fi
popd 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 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 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 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 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 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 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 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 cp -a $LINUX_KERNEL $LINUX_KERNEL_64

View File

@ -1,14 +1,16 @@
Summary: C/C++ Cross Compiler Toolchain Summary: C/C++ Cross Compiler Toolchain
Name: gcc-cross Name: gcc-cross
Version: 1.0 Version: 1.0
Release: 4 Release: 5
# libgcc, libgfortran, libmudflap, libgomp, libstdc++ and crtstuff have # libgcc, libgfortran, libmudflap, libgomp, libstdc++ and crtstuff have
# GCC Runtime Exception. # GCC Runtime Exception.
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
URL: http://gcc.gnu.org URL: http://gcc.gnu.org
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 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: gcc, gcc-c++, make, git, flex, bison, rpm-build, automake, autoconf
BuildRequires: libtool, ncurses-devel, bc, zlib-devel, openssl-devel, texinfo, rsync, chrpath BuildRequires: libtool, ncurses-devel, bc, zlib-devel, openssl-devel, texinfo, rsync, chrpath
#ExclusiveArch: i386 x86-64 #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 %attr(755, root, root) /tmp/gcc_arm32le.tar.gz
%changelog %changelog
* Mon Aug 07 2023 dingguangya <dingguangya1@huawei.com> - 1.0-5
-Type:Fix
-ID:NA
-SUG:NA
-DESC: Fix cross-compilation tool chain
* Mon Mar 06 2023 dingguangya <dingguangya1@huawei.com> - 1.0-4 * Mon Mar 06 2023 dingguangya <dingguangya1@huawei.com> - 1.0-4
-Type:Fix -Type:Fix
-ID:NA -ID:NA

View File

@ -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 $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 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 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 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