File cross-arm-none-eabi-gcc.spec of Package cross-arm-none-eabi-gcc
#
# spec file for package cross-arm-none-eabi-gcc
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global processor_arch arm
%global target %{processor_arch}-none-eabi
%global cross_target cross-%{target}
%global gcc_version 12.2.0
%define gcc_short_ver 12.2
%define gcc_major 12
%define date 20201211
%define snapshot %{gcc_version}
# we need newlib to compile complete gcc, but we need gcc to compile newlib,
# so compile minimal gcc first
%global bootstrap 0
Name: %{cross_target}-gcc%{gcc_major}
Version: %{gcc_version}
Release: 1
Summary: GNU GCC Compiler for %{target} target
Group: Development/Languages/C and C++
# Most of the sources are licensed under GPLv3+ with these exceptions:
# LGPLv2+ libquadmath/ libjava/libltdl/ gcc/testsuite/objc.dg/gnu-encoding/generate-random
# libgcc/soft-fp/ libffi/msvcc.sh
# LGPLv3+ gcc/prefix.c
# BSD libgo/go/regexp/testdata/testregex.cz zlib/example.c libffi/
# libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java
# GPLv2+ libitm/testsuite/libitm.c/memset-1.c libjava/
# Public Domain libjava/classpath/external/sax/org/xml/sax/ext/EntityResolver2.java
# libjava/classpath/external/sax/org/xml/sax/ext/DeclHandler.java
# BSL zlib/contrib/dotzlib/DotZLib/GZipStream.cs
License: GPL-2.0+ and GPL-3.0+ and LGPL-2.0+ and BSD-2-Clause and BSD-3-Clause
URL: https://gcc.gnu.org/
Source0: gcc-%{snapshot}.tar.xz
BuildRequires: gcc-c++
BuildRequires: %{cross_target}-binutils >= 2.21
BuildRequires: zlib-devel
BuildRequires: gmp-devel
BuildRequires: mpfr-devel
BuildRequires: mpc-devel
BuildRequires: isl-devel >= 0.14
BuildRequires: flex
BuildRequires: autogen
%if ! %{bootstrap}
BuildRequires: chrpath
%endif
Requires: %{cross_target}-binutils >= 2.21
Provides: %{target}-gcc = %{gcc_version}
Provides: %{target}-gcc%{gcc_major} = %{gcc_version}
%description
This is a Cross Compiling version of GNU GCC, which can be used to
compile for the %{target} platform, instead of for the
native %{_arch} platform.
%if ! %{bootstrap}
%package c++
Summary: C++ Cross Compiler for %{target}
Group: Development/Languages/C and C++
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libstdc++ = %{version}-%{release}
Provides: %{cross_target}-gcc-c++ = %{gcc_version}
Provides: %{target}-gcc-c++ = %{gcc_version}
%description c++
This package contains the Cross Compiling version of g++, which can be used to
compile c++ code for the %{target} platform, instead of for the native
%{_arch} platform.
%package libstdc++-devel
Summary: C++ Headers for %{target}
Group: Development/Languages/C and C++
BuildRequires: %{cross_target}-newlib
Requires: %{name}-c++ = %{version}-%{release}
Requires: %{target}-newlib
%description libstdc++-devel
This package contains the C++ headers for %{target} devices.
%package libstdc++
Summary: C++ Standard Library for %{target}
Group: Development/Languages/C and C++
BuildRequires: %{cross_target}-newlib
Requires: %{name}-c++ = %{version}-%{release}
Requires: %{name}-libstdc++-devel = %{version}-%{release}
Requires: %{target}-newlib
%description libstdc++
This package contains libstdc++ for %{target} devices.
%package libstdc++-nano
Summary: C++ Standard Library for %{target}
Group: Development/Languages/C and C++
BuildRequires: %{cross_target}-newlib-nano
Requires: %{name}-c++ = %{version}-%{release}
Requires: %{name}-libstdc++-devel = %{version}-%{release}
Requires: %{target}-newlib-nano
%description libstdc++-nano
This package contains the stripped down nano version (no-exceptions) of libstdc++
for %{target} devices.
%endif
%prep
%setup -q -n gcc-%{version}
contrib/gcc_update --touch
# Split version file into version used for directories (X) and
# version to report with --version (X.Y.Z).
# See also gcc-dir-version.patch.
mv gcc/BASE-VER gcc/FULL-VER
cat gcc/FULL-VER | cut -d '.' -f 1 > gcc/BASE-VER
%build
%define libexecdir %{_libdir}/gcc/%{target}/%{gcc_major}
%define sysroot %{_prefix}/%{target}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
_configure_gcc() {
CC="%{__cc} ${RPM_OPT_FLAGS} -fPIC -fno-stack-protector" \
../configure \
--prefix=%{_prefix} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--with-sysroot=%{sysroot} \
--with-python-dir=share/%{target}/gcc/%{gcc_major} \
--with-pkgversion="openSUSE %{version}-%{release}" \
--with-bugurl='https://bugs.opensuse.org/' \
--target=%{target} \
--enable-multilib \
--enable-multiarch \
--enable-interwork \
--enable-plugins \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libstdcxx-dual-abi \
--disable-libstdcxx-verbose \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-tls \
--with-gnu-as \
--with-gnu-ld \
--with-gmp \
--with-mpfr \
--with-mpc \
--with-isl \
--with-libelf \
--enable-gnu-indirect-function \
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
%if %{bootstrap}
--enable-languages=c \
%else
--enable-languages=c,c++ \
--enable-gold \
--enable-target-optspace \
--enable-lto \
--without-headers \
--with-newlib \
%endif
--with-system-zlib
}
%if !%{bootstrap}
mkdir -p gcc-nano
pushd gcc-nano
export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
_configure_gcc
make all-target INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
popd
%endif
mkdir -p gcc-%{target}
pushd gcc-%{target}
export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
export CXXFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
_configure_gcc
%if %{bootstrap}
make all-gcc INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
%else
make all INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
#make all-target-libgcc INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
#make target-libstdc++-v3 INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
#make target-newlib INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
%endif
popd
%install
%if !%{bootstrap}
pushd gcc-nano
make DESTDIR=%{buildroot} install-strip-target-libstdc++-v3
rm $(find %{buildroot}%{libexecdir} %{buildroot}%{sysroot}/lib -type f -and -name '*.la' -print)
find %{buildroot}%{sysroot}/lib -type f -regex ".*lib.*.a" -exec rename .a _nano.a '{}' \;
find $%{buildroot}%{sysroot}/lib -type f -regex ".*_nano.*" > ../filelist.nano ||:
sed -i s,%{buildroot},,g ../filelist.nano ||:
echo === FILESLIST NANO ===
cat ../filelist.nano
popd
%endif
pushd gcc-%{target}
%if %{bootstrap}
make install-strip-gcc DESTDIR=%{buildroot}
%else
make DESTDIR=%{buildroot} install-strip-target-libstdc++-v3
rm $(find %{buildroot}%{libexecdir} %{buildroot}%{sysroot}/lib -type f -and -name '*.la' -print)
find %{buildroot}%{sysroot}/lib -type f -not -regex ".*_nano.*" > ../filelist.lib ||:
sed -i s,%{buildroot},,g ../filelist.lib ||:
echo === FILESLIST LIB ===
cat ../filelist.lib
make DESTDIR=%{buildroot} install-gcc
make DESTDIR=%{buildroot} install-strip-target
%endif
popd
# we don't want these as we are a cross version
rm -r %{buildroot}%{_infodir} ||:
rm -r %{buildroot}%{_mandir}/man* ||:
rm -f %{buildroot}%{_libdir}/libiberty.a ||:
rm -r %{buildroot}%{libexecdir}/plugins/include ||:
# and these aren't usefull for embedded targets
rm -r %{buildroot}%{libexecdir}/install-tools ||:
%if ! %{bootstrap}
find %{buildroot}%{sysroot}/lib -type f -and -name '*[++]*' -print > c++.filelist
find %{buildroot}%{sysroot}/lib -type f -and -name '*[^++]*' -print > gcc.filelist
sed -i s,%{buildroot},,g c++.filelist
sed -i s,%{buildroot},,g gcc.filelist
pushd %{buildroot}/%{sysroot}
# add compiler binaries to sysroot and delete $RPM_BUILD_ROOT rpath
%define binroot %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{sysroot}/bin ||:
for f in %{binroot}/%{target}* ; do
# chrpath -d $f
ln -sf %{_bindir}/$(basename $f) ./bin/$(echo $f | sed -r 's/.*(%{target})-([a-z]*)/\2/g')
done
# add language headers to sysroot
%define incroot %{buildroot}%{libexecdir}/include
#mkdir -p %{buildroot}%{sysroot}/include ||:
#for f in %{incroot}/*.h ; do
# ln -sf %{libexecdir}/include/$(basename $f) ./include/$(basename $f)
#done
#for f in %{incroot}-fixed/*.h ; do
# ln -sf %{libexecdir}/include-fixed/$(basename $f) ./include/$(basename $f)
#done
#ln -sf %{libexecdir}/include/c++ ./include/c++
# add target-specific library files to sysroot
#%define libroot %{buildroot}%{libexecdir}/lib
#mkdir -p %{buildroot}%{sysroot}/lib ||:
#for d in %{libroot}/thumb %{libroot}/fpu %{libroot}/arm* ; do
# mkdir -p ./lib/$(basename $d)
# for f in %{libroot}/$(basename $d)/* ; do
# ln -sf %{libroot}/$(basename $d)/$(basename $f) ./lib/$(basename $d)/$(basename $f)
# done
#done
popd
%endif
%files
#%doc README COPYING
%{_bindir}/*
%{_libdir}/gcc
%if ! %{bootstrap}
%{sysroot}
%exclude %{_bindir}/%{target}-*++
%exclude %{libexecdir}/cc1plus
%exclude %{sysroot}/include/c++
%exclude %{sysroot}/bin/*++
%exclude %{sysroot}/lib/*
%endif
%if ! %{bootstrap}
%files c++
%{_bindir}/%{target}-*++
%{libexecdir}/cc1plus
%{sysroot}/bin/*++
%{_datadir}/%{target}
%files libstdc++-devel
%{sysroot}/include/c++
%files libstdc++ -f filelist.lib
%dir %{sysroot}/lib/arm
%dir %{sysroot}/lib/arm/autofp
%dir %{sysroot}/lib/arm/autofp/v5te
%dir %{sysroot}/lib/arm/autofp/v5te/fpu
%dir %{sysroot}/lib/thumb/autofp
%dir %{sysroot}/lib/thumb/autofp/v7
%dir %{sysroot}/lib/thumb/autofp/v7/fpu
%files libstdc++-nano -f filelist.nano
%endif
%changelog