LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File cross-arm-none-eabi-gcc6.spec of Package cross-arm-none-eabi-gcc7 (Project home:scalpel4k)

%global processor_arch arm
%global target         %{processor_arch}-none-eabi
%global cross_target   cross-%{target}
%global gcc_version    8.2.1
%define gcc_short_ver  8.2
%define gcc_major      8

%define date 20181130
%define snapshot %{gcc_major}-%{date}

# we need newlib to compile complete gcc, but we need gcc to compile newlib,
# so compile minimal gcc first
%global bootstrap      0
%define temp 0

Name:           %{cross_target}-gcc%{gcc_major}
Version:        %{gcc_version}_%{date}
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
Source0:        ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/%{snapshot}/gcc-%{snapshot}.tar.xz
Patch1:         enable-with-multilib-list-for-arm.patch
Patch2:         gcc-dir-version.patch

BuildRequires:  gcc-c++
BuildRequires:  zlib-devel
BuildRequires:  gmp-devel
BuildRequires:  mpfr-devel
BuildRequires:  mpc-devel
BuildRequires:  isl-devel
BuildRequires:  flex
BuildRequires:  autogen
BuildRequires:	filesystem
BuildRequires:  cross-arm-none-gcc8-bootstrap

Requires:       %{cross_target}-binutils >= 2.21
Provides:       %{cross_target}-gcc = %{gcc_version}
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++
%if ! %{temp}
BuildRequires:  %{cross_target}-newlib
Requires:		%{target}-newlib
%else
BuildRequires:  cross-arm-none-newlib-devel
%endif
Requires:       %{name}-c++ = %{version}-%{release}

%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++
%if ! %{temp}
BuildRequires:  %{cross_target}-newlib
Requires:		%{target}-newlib
%else
BuildRequires:  cross-arm-none-newlib-devel
%endif
Requires:       %{name}-c++ = %{version}-%{release}
Requires:       %{name}-libstdc++-devel = %{version}-%{release}

%description libstdc++
This package contains libstdc++ for %{target} devices.

%package libstdc++-nano
Summary:        C++ Standard Library for %{target}
Group:          Development/Languages/C and C++
%if ! %{temp}
BuildRequires:  %{cross_target}-newlib-nano
Requires:		%{target}-newlib-nano
%else
BuildRequires:  cross-arm-none-newlib-devel
%endif
Requires:       %{name}-c++ = %{version}-%{release}
Requires:       %{name}-libstdc++-devel = %{version}-%{release}

%description libstdc++-nano
This package contains the stripped down nano version (no-exceptions) of libstdc++
for %{target} devices.

%endif

%prep
%setup -q -n gcc-%{snapshot}
#%patch1 -p2 -b .arm
%patch2 -p1

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() {
%if %{bootstrap}
CC="%{__cc} -fno-stack-protector" \
%else
CC="%{__cc} ${RPM_OPT_FLAGS}  -fno-stack-protector" \
%endif
    ../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-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 \
%if %{bootstrap}
    --enable-languages=c \
    --without-headers \
%else
    --enable-languages=c,c++,lto \
    --enable-gold \
    --enable-target-optspace \
    --enable-lto \
    --with-newlib \
%endif
    --with-system-zlib
}

#    --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
#    --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r,armv7-ar \
# in boostrap branch
#    --disable-fixincludes \
#    --disable-bootstrap \



%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'
export CFLAGS=${RPM_OPT_FLAGS}
export CXXFLAGS=${RPM_OPT_FLAGS}

_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 all-target-libgcc 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=$RPM_BUILD_ROOT install-strip-target-libstdc++-v3
rm $(find $RPM_BUILD_ROOT%{libexecdir} $RPM_BUILD_ROOT%{sysroot}/lib -type f -and -name '*.la' -print)
find $RPM_BUILD_ROOT%{sysroot}/lib -type f -regex ".*lib.*.a" -exec rename .a _nano.a '{}' \;
find $RPM_BUILD_ROOT%{sysroot}/lib -type f -regex ".*_nano.*" > ../filelist.nano ||:
sed -i s,$RPM_BUILD_ROOT,,g ../filelist.nano ||:
echo === FILESLIST NANO ===
cat ../filelist.nano
popd
%endif

pushd gcc-%{target}
%if %{bootstrap}
make install DESTDIR=$RPM_BUILD_ROOT
%else
make DESTDIR=$RPM_BUILD_ROOT install-strip-target-libstdc++-v3
rm $(find $RPM_BUILD_ROOT%{libexecdir} $RPM_BUILD_ROOT%{sysroot}/lib -type f -and -name '*.la' -print)
find $RPM_BUILD_ROOT%{sysroot}/lib -type f -not -regex ".*_nano.*" > ../filelist.lib ||:
sed -i s,$RPM_BUILD_ROOT,,g ../filelist.lib ||:
echo === FILESLIST LIB ===
cat ../filelist.lib
make DESTDIR=$RPM_BUILD_ROOT install-gcc
make DESTDIR=$RPM_BUILD_ROOT install-strip-target
%endif
popd

# we don't want these as we are a cross version
rm -r $RPM_BUILD_ROOT%{_infodir} ||:
rm -r $RPM_BUILD_ROOT%{_mandir}/man* ||:
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a ||:
rm -r $RPM_BUILD_ROOT%{libexecdir}/plugins/include ||:

# and these aren't usefull for embedded targets
rm -r $RPM_BUILD_ROOT%{libexecdir}/install-tools ||:

%if ! %{bootstrap}

find $RPM_BUILD_ROOT%{sysroot}/lib -type f -and -name '*[++]*' -print > c++.filelist
find $RPM_BUILD_ROOT%{sysroot}/lib -type f -and -name '*[^++]*' -print > gcc.filelist
sed -i s,$RPM_BUILD_ROOT,,g c++.filelist
sed -i s,$RPM_BUILD_ROOT,,g gcc.filelist

pushd $RPM_BUILD_ROOT/%{sysroot}

# add compiler binaries to sysroot and delete $RPM_BUILD_ROOT rpath
%define binroot $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{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

popd

pushd %{buildroot}/%{libexecdir}
rm liblto_plugin.la ||:
mkdir -p %{buildroot}%{sysroot}/lib/bfd-plugins/
ln -sf liblto_plugin.so %{buildroot}%{sysroot}/lib/bfd-plugins/
popd

%endif

mkdir -p %{buildroot}/%{_sysconfdir}/ld.so.conf.d/
touch %{buildroot}/%{_sysconfdir}/ld.so.conf.d/%{target}.conf
echo %{sysroot}/lib > %{buildroot}/%{_sysconfdir}/ld.so.conf.d/%{target}.conf

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%{_bindir}/*
%{_libdir}/gcc
%{_sysconfdir}/ld.so.conf.d/%{target}.conf

%if ! %{bootstrap}

%{sysroot}
%exclude %{_bindir}/%{target}-*++
%exclude %{libexecdir}/cc1plus
%exclude %{sysroot}/include/c++
%exclude %{sysroot}/bin/*++
%exclude %{sysroot}/lib/*
%{sysroot}/lib/bfd-plugins/*

%files c++
%{_bindir}/%{target}-*++
%{libexecdir}/cc1plus
%{sysroot}/bin/*++
%{_datadir}/%{target}
%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++-devel
%defattr(-,root,root,-)
%{sysroot}/include/c++

%files libstdc++ -f filelist.lib
%defattr(-,root,root,-)

%files libstdc++-nano -f filelist.nano
%defattr(-,root,root,-)

%endif

%changelog