Build GCC 10.3 from sisyphus

For now libsanitizer is disabled to avoid bootstrap problems.
This commit is contained in:
Alexey Sheplyakov 2021-07-29 21:21:13 +04:00
parent 143653be0b
commit 33dd161ab8

View File

@ -4,23 +4,22 @@
%define target_qemu_arch aarch64
%define target %target_arch-linux-gnu
%define gcc_branch 8
%define gcc_version 8.4.1
%define gcc_branch 10
%define gcc_version 10.3.1
%define gcc_source_version_timestamp 20200305
%define orig_gcc_release alt0.p9.1
Name: cross-gcc%gcc_branch-%target
Name: gcc-%target
Version: %gcc_version
Release: alt2
Release: alt1
ExclusiveArch: x86_64
%define binutils_version 2.31.1
%define binutils_evr 1:%binutils_version-alt4
%define glibc_version 2.27
%define glibc_release alt13
%define glibc_evr %glibc_version-%glibc_release
%define kernel_version 5.4
%define binutils_version 2.35.2
%define binutils_evr 1:%binutils_version-alt2
%define glibc_version 2.32
%define glibc_release alt4
%define glibc_evr 6:%glibc_version-%glibc_release
%define kernel_version 5.10
%define sysroot %prefix/lib/%target/sys-root
%define target_ld_linux /lib64/ld-linux-aarch64.so.1
@ -34,13 +33,14 @@ BuildPreReq: libmpc-devel libmpfr-devel libgmp-devel zlib-devel
BuildPreReq: coreutils flex bison makeinfo findutils
# Linux' headers_install uses rsync
BuildPreReq: rsync
BuildRequires: gcc-source = %gcc_version-%orig_gcc_release
BuildRequires: gcc-source = %gcc_version
BuildRequires: binutils-source = %binutils_evr
BuildRequires: glibc-source = %glibc_evr
BuildRequires: kernel-source-%kernel_version
BuildRequires: qemu-user-static-%target_qemu_arch
BuildRequires: python3
Requires: cross-binutils-%target = %binutils_version
Requires: binutils-%target = %binutils_version
Requires: cross-glibc-%target = %glibc_version
%define _libexecdir /usr/libexec
@ -48,28 +48,32 @@ Requires: cross-glibc-%target = %glibc_version
%description
%target_arch-targeted GCC cross-compiler
%package -n cross-binutils-%target
%package -n binutils-%target
Version: %binutils_version
Summary: %target_arch-targeted binutils (linker, assembler, etc)
Group: Development/C
%description -n cross-binutils-%target
%description -n binutils-%target
%target_arch-targeted binutils (linker, assembler, objdump, etc)
%package -n cross-glibc-%target
Version: %glibc_version
Summary: %target_arch-targeted cross-glibc
Group: Development/C
BuildArch: noarch
%description -n cross-glibc-%target
glibc for %target_arch. Should be used for cross-compilation only
%prep
%setup -cT
tar -xf /usr/src/gcc-source/gcc-%gcc_version-%gcc_source_version_timestamp.tar
tar -xf /usr/src/binutils-source/binutils-%binutils_version.tar
tar -xf /usr/src/kernel/sources/kernel-source-%kernel_version.tar
tar -xf /usr/src/glibc-source/glibc-%glibc_evr.tar
mkdir -p -m755 linux binutils gcc glibc
find /usr/src/gcc-source -type f -name 'gcc-*.tar' | xargs -I {} -n1 tar -x --strip-components=1 -f {} -C gcc
find /usr/src/binutils-source -type f -name 'binutils-*.tar' | xargs -I {} -n1 tar -x --strip-components=1 -f {} -C binutils
find /usr/src/kernel/sources -type f -name 'kernel-source-*.tar' | xargs -I {} -n1 tar -x --strip-components=1 -f {} -C linux
find /usr/src/glibc-source -type f -name 'glibc-*.tar' | xargs -I {} -n1 tar -x --strip-components=1 -f {} -C glibc
rm -rf stage
%build
@ -83,7 +87,7 @@ stagedir=`pwd`/stage
# kernel headers
%_make_bin -j%__nprocs \
-C kernel-source-%kernel_version \
-C linux \
O=`pwd`/obj_kheaders \
ARCH=%target_kernel \
INSTALL_HDR_PATH=${stagedir}%sysroot/usr \
@ -91,7 +95,7 @@ stagedir=`pwd`/stage
# XXX: avoid %%configure for it puts $target libraries into /usr/lib64
cd obj_binutils
../binutils-%binutils_version/configure \
../binutils/configure \
--target=%target \
--host=%{_configure_platform} \
--build=%{_configure_platform} \
@ -119,7 +123,7 @@ cd obj_binutils
# N.B.: this builds GCC in a single stage (but not all target at once)
cd ../obj_gcc
# XXX: avoid %%configure puts $target libraries in /usr/lib64
../gcc-%gcc_version-%gcc_source_version_timestamp/configure \
../gcc/configure \
--target=%target \
--host=%{_configure_platform} \
--build=%{_configure_platform} \
@ -134,6 +138,7 @@ cd ../obj_gcc
--enable-languages=c,c++ \
--enable-version-specific-runtime-libs \
--disable-nls \
--disable-libsanitizer \
--with-system-zlib
%make_build all-gcc
@ -143,7 +148,7 @@ cd ../obj_gcc
cd ../obj_glibc
# XXX: avoid %%configure since it puts target libraries/binaries into /usr/lib64
# Note: glibc's is a library, so $host must be the same as $target
../glibc-%glibc_evr/configure \
../glibc/configure \
--host=%target \
--target=%target \
--build=%{_configure_platform} \
@ -190,7 +195,7 @@ cd ../obj_gcc
export PATH=`pwd`/stage%prefix/bin:$PATH
%_make_bin -j%__nprocs \
-C kernel-source-%kernel_version \
-C linux \
O=`pwd`/obj_kheaders \
ARCH=%target_kernel \
INSTALL_HDR_PATH=%buildroot%sysroot/usr \
@ -229,7 +234,7 @@ install -m 644 specs %buildroot%prefix/lib/gcc/%target/%gcc_branch/specs
# As a result GCC still runs /usr/bin/as (instead of target assembler) when
# compiling .S files. Therefore install `as` symlinks in GCC libsubdir
# (%%prefix/lib/gcc/%%target/%%gcc_branch).
# Just in a case make symlins to other tools.
# Just in a case make symlinks to other tools.
for tool in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib readelf strip; do
ln -s ../../../../bin/%target-$tool %buildroot%prefix/lib/gcc/%target/%gcc_branch/$tool
# just in a case add a symlink into libexec too
@ -354,7 +359,7 @@ qemu-%target_qemu_arch-static ./bye_asm || exit 13
# Compatibility symlink to ld.so
%sysroot/lib/*
%files -n cross-binutils-%target
%files -n binutils-%target
%_bindir/%target-addr2line
%_bindir/%target-ar
%_bindir/%target-as