cross-toolchain: use separate stagedir

This commit is contained in:
Alexey Sheplyakov 2021-06-09 05:57:48 +00:00
parent 9cdf784823
commit cb8d13f7e7

View File

@ -16,7 +16,6 @@ Release: alt1
%define kernel_version 5.4 %define kernel_version 5.4
%define sysroot %prefix/%target/libc %define sysroot %prefix/%target/libc
%define buildsysroot %buildroot%prefix/%target/libc
Summary: aarch64-targeted GCC cross-toolchain Summary: aarch64-targeted GCC cross-toolchain
License: LGPL-2.1-or-later and LGPL-3.0-or-later and GPL-2.0-or-later and GPL-3.0-or-later and GPL-3.0-or-later with GCC-exception-3.1 License: LGPL-2.1-or-later and LGPL-3.0-or-later and GPL-2.0-or-later and GPL-3.0-or-later and GPL-3.0-or-later with GCC-exception-3.1
@ -41,23 +40,23 @@ tar -xf /usr/src/gcc-source/gcc-%version-%gcc_source_version_timestamp.tar
tar -xf /usr/src/binutils-source/binutils-%binutils_version.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/kernel/sources/kernel-source-%kernel_version.tar
tar -xf /usr/src/glibc-source/glibc-%glibc_evr.tar tar -xf /usr/src/glibc-source/glibc-%glibc_evr.tar
rm -rf %buildroot rm -rf stage
%build %build
mkdir -p %buildroot
mkdir -p obj_binutils mkdir -p obj_binutils
mkdir -p obj_gcc mkdir -p obj_gcc
mkdir -p obj_kheaders mkdir -p obj_kheaders
mkdir -p obj_glibc mkdir -p obj_glibc
mkdir -p -m755 %buildroot%prefix/bin mkdir -p -m755 stage%prefix/bin
export PATH=%buildroot%prefix/bin:$PATH export PATH=`pwd`/stage%prefix/bin:$PATH
stagedir=`pwd`/stage
# kernel headers # kernel headers
%_make_bin -j%__nprocs \ %_make_bin -j%__nprocs \
-C kernel-source-%kernel_version \ -C kernel-source-%kernel_version \
O=`pwd`/obj_kheaders \ O=`pwd`/obj_kheaders \
ARCH=%target_kernel \ ARCH=%target_kernel \
INSTALL_HDR_PATH=%buildsysroot/usr \ INSTALL_HDR_PATH=${stagedir}%sysroot/usr \
headers_install headers_install
# XXX: avoid %%configure for it puts $target libraries into /usr/lib64 # XXX: avoid %%configure for it puts $target libraries into /usr/lib64
@ -74,7 +73,7 @@ cd obj_binutils
--disable-shared \ --disable-shared \
--disable-nls \ --disable-nls \
--with-sysroot=%sysroot \ --with-sysroot=%sysroot \
--with-build-sysroot=%buildsysroot \ --with-build-sysroot=${stagedir}%sysroot \
--with-system-zlib \ --with-system-zlib \
--enable-plugins \ --enable-plugins \
--enable-gold=yes \ --enable-gold=yes \
@ -85,7 +84,7 @@ cd obj_binutils
%make_build %make_build
# XXX: avoid makeinstall for it puts $target libraries into /usr/lib64 # XXX: avoid makeinstall for it puts $target libraries into /usr/lib64
%make_install install DESTDIR=%buildroot %make_install install DESTDIR=${stagedir}
# N.B.: this builds GCC in a single stage (but not all target at once) # N.B.: this builds GCC in a single stage (but not all target at once)
cd ../obj_gcc cd ../obj_gcc
@ -100,7 +99,7 @@ cd ../obj_gcc
--disable-multilib \ --disable-multilib \
--disable-werror \ --disable-werror \
--with-sysroot=%sysroot \ --with-sysroot=%sysroot \
--with-build-sysroot=%buildsysroot \ --with-build-sysroot=${stagedir}%sysroot \
--with-gcc-major-version-only \ --with-gcc-major-version-only \
--enable-languages=c,c++ \ --enable-languages=c,c++ \
--disable-nls \ --disable-nls \
@ -108,7 +107,7 @@ cd ../obj_gcc
%make_build all-gcc %make_build all-gcc
# XXX: avoid makeinstall for it puts $target libraries into /usr/lib64 # XXX: avoid makeinstall for it puts $target libraries into /usr/lib64
%make_install install-gcc DESTDIR=%buildroot %make_install install-gcc DESTDIR=${stagedir}
cd ../obj_glibc cd ../obj_glibc
# XXX: avoid %%configure since it puts target libraries/binaries into /usr/lib64 # XXX: avoid %%configure since it puts target libraries/binaries into /usr/lib64
@ -119,27 +118,27 @@ cd ../obj_glibc
--build=%{_configure_platform} \ --build=%{_configure_platform} \
--prefix=%prefix \ --prefix=%prefix \
--with-sysroot=%sysroot \ --with-sysroot=%sysroot \
--with-build-sysroot=%buildsysroot \ --with-build-sysroot=${stagedir}%sysroot \
--with-headers=%buildsysroot/usr/include \ --with-headers=${stagedir}%sysroot/usr/include \
--with-lib=%buildsysroot/usr/lib \ --with-lib=${stagedir}%sysroot/usr/lib \
--disable-multilib \ --disable-multilib \
--disable-crypt \ --disable-crypt \
libc_cv_forced_unwind=yes libc_cv_forced_unwind=yes
# glibc: headers, C runtime # glibc: headers, C runtime
%_make_bin -j%__nprocs install-bootstrap-headers=yes install-headers DESTDIR=%buildsysroot %_make_bin -j%__nprocs install-bootstrap-headers=yes install-headers DESTDIR=${stagedir}%sysroot
%_make_bin -j%__nprocs csu/subdir_lib %_make_bin -j%__nprocs csu/subdir_lib
install -d -m755 %buildsysroot/usr/lib install -d -m755 ${stagedir}%sysroot/usr/lib
install csu/crt1.o csu/crti.o csu/crtn.o %buildsysroot/usr/lib install csu/crt1.o csu/crti.o csu/crtn.o ${stagedir}%sysroot/usr/lib
%target-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o "%buildsysroot/usr/lib/libc.so" %target-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o "${stagedir}%sysroot/usr/lib/libc.so"
touch %buildsysroot/usr/include/gnu/stubs.h touch ${stagedir}/%sysroot/usr/include/gnu/stubs.h
touch %buildsysroot/usr/include/bits/stdio_lim.h touch ${stagedir}/%sysroot/usr/include/bits/stdio_lim.h
# libgcc # libgcc
cd ../obj_gcc cd ../obj_gcc
%make_build all-target-libgcc %make_build all-target-libgcc
# XXX: avoid makeinstall since it puts target libs into /usr/lib64 # XXX: avoid makeinstall since it puts target libs into /usr/lib64
%make_install install-target-libgcc DESTDIR=%buildroot %make_install install-target-libgcc DESTDIR=${stagedir}
# finish off glibc # finish off glibc
cd ../obj_glibc cd ../obj_glibc
@ -147,16 +146,35 @@ cd ../obj_glibc
# XXX: avoid makeinstall since it puts target libs into /usr/lib64 # XXX: avoid makeinstall since it puts target libs into /usr/lib64
# Note: target glibc **must** be installed into sysroot to prevent # Note: target glibc **must** be installed into sysroot to prevent
# native compilers from using it by default # native compilers from using it by default
%make_install install DESTDIR=%buildsysroot %make_install install DESTDIR=${stagedir}%sysroot
# finish off gcc (g++, libstdc++, libssp, whatever) # finish off gcc (g++, libstdc++, libssp, whatever)
cd ../obj_gcc cd ../obj_gcc
%make_build %make_build
# XXX: avoid makeinstall since it puts target libs into /usr/lib64 # XXX: avoid makeinstall since it puts target libs into /usr/lib64
%make_install install DESTDIR=%buildroot %make_install install DESTDIR=${stagedir}
%install %install
true
export PATH=`pwd`/stage%prefix/bin:$PATH
%_make_bin -j%__nprocs \
-C kernel-source-%kernel_version \
O=`pwd`/obj_kheaders \
ARCH=%target_kernel \
INSTALL_HDR_PATH=%buildroot%sysroot/usr \
headers_install
cd obj_binutils
%make_install install DESTDIR=%buildroot
cd ../obj_glibc
%make_install install DESTDIR=%buildroot%sysroot
cd ../obj_gcc
%make_install install DESTDIR=%buildroot
find %buildroot
%files %files
%_bindir/* %_bindir/*