237 lines
6.7 KiB
RPMSpec
237 lines
6.7 KiB
RPMSpec
|
|
%define target aarch64-linux-gnu
|
|
%define target_kernel arm64
|
|
%define gcc_branch 8
|
|
|
|
Name: cross-gcc%gcc_branch-%target
|
|
Version: 8.4.1
|
|
Release: alt1
|
|
|
|
%define gcc_source_version_timestamp 20200305
|
|
%define orig_gcc_release alt0.p9.1
|
|
%define binutils_version 2.31.1
|
|
%define binutils_evr 1:%binutils_version-alt4
|
|
%define glibc_evr 2.27-alt13
|
|
%define kernel_version 5.4
|
|
|
|
%define sysroot %prefix/%target/sys-root
|
|
|
|
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
|
|
Group: Development/C
|
|
|
|
BuildPreReq: gcc-c++
|
|
BuildPreReq: libmpc-devel libmpfr-devel libgmp-devel zlib-devel
|
|
BuildPreReq: coreutils flex bison makeinfo
|
|
BuildRequires: gcc-source = %version-%orig_gcc_release
|
|
BuildRequires: binutils-source = %binutils_evr
|
|
BuildRequires: glibc-source = %glibc_evr
|
|
BuildRequires: kernel-source-%kernel_version
|
|
|
|
%define _libexecdir /usr/libexec
|
|
|
|
%description
|
|
aarch64-targeted GCC cross-toolchain
|
|
|
|
%prep
|
|
%setup -cT
|
|
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/kernel/sources/kernel-source-%kernel_version.tar
|
|
tar -xf /usr/src/glibc-source/glibc-%glibc_evr.tar
|
|
rm -rf stage
|
|
|
|
%build
|
|
mkdir -p obj_binutils
|
|
mkdir -p obj_gcc
|
|
mkdir -p obj_kheaders
|
|
mkdir -p obj_glibc
|
|
mkdir -p -m755 stage%prefix/bin
|
|
export PATH=`pwd`/stage%prefix/bin:$PATH
|
|
stagedir=`pwd`/stage
|
|
|
|
# kernel headers
|
|
%_make_bin -j%__nprocs \
|
|
-C kernel-source-%kernel_version \
|
|
O=`pwd`/obj_kheaders \
|
|
ARCH=%target_kernel \
|
|
INSTALL_HDR_PATH=${stagedir}%sysroot/usr \
|
|
headers_install
|
|
|
|
# XXX: avoid %%configure for it puts $target libraries into /usr/lib64
|
|
cd obj_binutils
|
|
../binutils-%binutils_version/configure \
|
|
--target=%target \
|
|
--host=%{_configure_platform} \
|
|
--build=%{_configure_platform} \
|
|
--prefix=%prefix \
|
|
--disable-bootstrap \
|
|
--disable-multiarch \
|
|
--disable-multilib \
|
|
--disable-werror \
|
|
--disable-shared \
|
|
--disable-nls \
|
|
--with-sysroot=%sysroot \
|
|
--with-build-sysroot=${stagedir}%sysroot \
|
|
--with-system-zlib \
|
|
--enable-plugins \
|
|
--enable-gold=yes \
|
|
--enable-ld=default \
|
|
--enable-64-bit-bfd \
|
|
--enable-relro \
|
|
--enable-textrel-check=warning
|
|
|
|
%make_build
|
|
# XXX: avoid makeinstall for it puts $target libraries into /usr/lib64
|
|
%make_install install DESTDIR=${stagedir}
|
|
|
|
# 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-%version-%gcc_source_version_timestamp/configure \
|
|
--target=%target \
|
|
--host=%{_configure_platform} \
|
|
--build=%{_configure_platform} \
|
|
--prefix=%prefix \
|
|
--disable-bootstrap \
|
|
--disable-multiarch \
|
|
--disable-multilib \
|
|
--disable-werror \
|
|
--with-sysroot=%sysroot \
|
|
--with-build-sysroot=${stagedir}%sysroot \
|
|
--with-gcc-major-version-only \
|
|
--enable-languages=c,c++ \
|
|
--enable-version-specific-runtime-libs \
|
|
--disable-nls \
|
|
--with-system-zlib
|
|
|
|
%make_build all-gcc
|
|
# XXX: avoid makeinstall for it puts $target libraries into /usr/lib64
|
|
%make_install install-gcc DESTDIR=${stagedir}
|
|
|
|
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 \
|
|
--host=%target \
|
|
--target=%target \
|
|
--build=%{_configure_platform} \
|
|
--prefix=%prefix \
|
|
--with-sysroot=%sysroot \
|
|
--with-build-sysroot=${stagedir}%sysroot \
|
|
--with-headers=${stagedir}%sysroot/usr/include \
|
|
--with-lib=${stagedir}%sysroot/usr/lib \
|
|
--disable-multilib \
|
|
--disable-crypt \
|
|
libc_cv_forced_unwind=yes
|
|
|
|
# glibc: headers, C runtime
|
|
%_make_bin -j%__nprocs install-bootstrap-headers=yes install-headers DESTDIR=${stagedir}%sysroot
|
|
%_make_bin -j%__nprocs csu/subdir_lib
|
|
install -d -m755 ${stagedir}%sysroot/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 "${stagedir}%sysroot/usr/lib/libc.so"
|
|
touch ${stagedir}/%sysroot/usr/include/gnu/stubs.h
|
|
touch ${stagedir}/%sysroot/usr/include/bits/stdio_lim.h
|
|
|
|
# libgcc
|
|
cd ../obj_gcc
|
|
%make_build all-target-libgcc
|
|
# XXX: avoid makeinstall since it puts target libs into /usr/lib64
|
|
%make_install install-target-libgcc DESTDIR=${stagedir}
|
|
|
|
# finish off glibc
|
|
cd ../obj_glibc
|
|
%make_build
|
|
# XXX: avoid makeinstall since it puts target libs into /usr/lib64
|
|
# Note: target glibc **must** be installed into sysroot to prevent
|
|
# native compilers from using it by default
|
|
%make_install install DESTDIR=${stagedir}%sysroot
|
|
|
|
# finish off gcc (g++, libstdc++, libssp, whatever)
|
|
cd ../obj_gcc
|
|
%make_build
|
|
# XXX: avoid makeinstall since it puts target libs into /usr/lib64
|
|
%make_install install DESTDIR=${stagedir}
|
|
|
|
%install
|
|
|
|
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
|
|
|
|
# relocate target libgcc_s
|
|
mv %buildroot%prefix/lib/gcc/%target/lib64/libgcc_s.so* %buildroot%prefix/lib/gcc/%target/%gcc_branch/
|
|
rmdir %buildroot%prefix/lib/gcc/%target/lib64
|
|
|
|
|
|
rm -rf %buildroot%sysroot/etc
|
|
rm -rf %buildroot%sysroot/var
|
|
rm -rf %buildroot%sysroot/sbin
|
|
rm -rf %buildroot%sysroot/usr/share
|
|
rm -rf %buildroot%sysroot/usr/bin
|
|
rm -rf %buildroot%sysroot/usr/sbin
|
|
rm -rf %buildroot%sysroot/usr/libexec
|
|
rm -rf %buildroot%sysroot/usr/lib64/audit
|
|
rm -rf %buildroot%sysroot/usr/lib64/gconv
|
|
|
|
# XXX: gcc needs this to locate crt1.o
|
|
install -d -m 755 %buildroot%sysroot/usr/lib
|
|
|
|
# Leave alone $target libraries
|
|
%add_verify_elf_skiplist %sysroot/* %prefix/lib/gcc/%target/%gcc_branch/*
|
|
%add_findreq_skiplist %sysroot/* %prefix/lib/gcc/%target/%gcc_branch/*
|
|
%add_findprov_skiplist %sysroot/* %prefix/lib/gcc/%target/%gcc_branch/*
|
|
%add_debuginfo_skiplist %sysroot/* %prefix/lib/gcc/%target/%gcc_branch/*
|
|
|
|
%check
|
|
|
|
cat > hello.c <<EOF
|
|
#include <stdio.h>
|
|
int main(int argc, char** argv) {
|
|
printf("Hello, %%s!\n", argc > 1 ? argv[1] : "world");
|
|
return 0;
|
|
}
|
|
EOF
|
|
|
|
cat > hello.cpp <<EOF
|
|
#include <iostream>
|
|
int main(int argc, char** argv) {
|
|
std::cout << "Hello, " << (argc > 1 ? argv[1] : "world") << "!" << std::endl;
|
|
return 0;
|
|
}
|
|
EOF
|
|
|
|
%buildroot%prefix/bin/%target-gcc -o hello_c hello.c || exit 2
|
|
%buildroot%prefix/bin/%target-g++ -o hello_cpp hello.cpp || exit 3
|
|
|
|
%files
|
|
%_bindir/*
|
|
%prefix/lib/gcc/%target/%gcc_branch/*
|
|
%prefix/libexec/gcc/%target/*
|
|
%prefix/%target/bin/*
|
|
%prefix/%target/lib/ldscripts/*
|
|
%sysroot/usr/include/*
|
|
%sysroot/usr/lib
|
|
%sysroot/lib64/*
|
|
%sysroot/usr/lib64/*
|
|
|
|
%changelog
|
|
* Fri Jun 04 2021 Alexey Sheplyakov <asheplyakov@altlinux.org> 8.4.1-alt1
|
|
- Initial build
|
|
|