Enable LTO builds using this toolchain 35/38135/1
authorNikolai Bozhenov <n.bozhenov@samsung.com>
Wed, 25 Feb 2015 07:21:47 +0000 (10:21 +0300)
committerNikolai Bozhenov <n.bozhenov@samsung.com>
Mon, 13 Apr 2015 13:23:37 +0000 (16:23 +0300)
1) Install LTO plugin for BFD utils

Add LTO plugins to the default BFD plugins directory so that binutils
(ar in particular) can work with LTO objects without any additional
options.

2) Add LTO binaries to icecream packages to enable LTO compilation in
qemu-accel mode.

Change-Id: Ic50d79a6453a51ca39e7dc6b251190e70304dae2

packaging/cross-aarch64-gcc49.spec
packaging/cross-armv7hl-gcc49.spec
packaging/cross-armv7l-gcc49.spec
packaging/cross.spec.sh
packaging/gcc.spec.in
packaging/gcc49.spec

index a79c3b4..767c00b 100644 (file)
@@ -67,6 +67,9 @@ BuildRequires: libunwind-devel
 BuildRequires: cross-%cross_arch-glibc-devel
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
 
 URL:          http://gcc.gnu.org/
@@ -147,6 +150,15 @@ gcc-obj-c++.
 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
 
+%define bfd_plugin_dir      %{_bindir}/../lib/bfd-plugins
+%define bfd_plugin_lto_name liblto_plugin_%{_arch}.so
+%define bfd_plugin_lto      %{bfd_plugin_dir}/%{bfd_plugin_lto_name}
+%if 0%{?cross_arch:1}
+%define gcc_plugin_lto      %{targetlibsubdir}/liblto_plugin.so
+%else
+%define gcc_plugin_lto      %{libsubdir}/liblto_plugin.so
+%endif
+
 
 %prep
 %setup -q -n gcc-%{version}
@@ -485,7 +497,7 @@ install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/g++
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/gcc
 
-for back in cc1 cc1plus; do
+for back in cc1 cc1plus collect2 lto1 lto-wrapper; do
        install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back          $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
 done
 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
@@ -521,12 +533,25 @@ rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
 rm -r env
 
+# liblto_plugin alternatives
+mkdir -p "$RPM_BUILD_ROOT%{bfd_plugin_dir}"
+touch "$RPM_BUILD_ROOT%{bfd_plugin_lto}"
+
+%post
+"%_sbindir/update-alternatives" --install \
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 5
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
+
 %files
 %defattr(-,root,root)
 %{_prefix}/bin/*
 %dir %{targetlibsubdir}
 %dir %{_libdir}/gcc/%{gcc_target_arch}
 %{targetlibsubdir}
+%ghost %{bfd_plugin_lto}
 
 %files -n cross-%cross_arch-gcc49-icecream-backend
 %defattr(-,root,root)
index 770546c..d82ae39 100644 (file)
@@ -67,6 +67,9 @@ BuildRequires: libunwind-devel
 BuildRequires: cross-%cross_arch-glibc-devel
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
 
 URL:          http://gcc.gnu.org/
@@ -147,6 +150,15 @@ gcc-obj-c++.
 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
 
+%define bfd_plugin_dir      %{_bindir}/../lib/bfd-plugins
+%define bfd_plugin_lto_name liblto_plugin_%{_arch}.so
+%define bfd_plugin_lto      %{bfd_plugin_dir}/%{bfd_plugin_lto_name}
+%if 0%{?cross_arch:1}
+%define gcc_plugin_lto      %{targetlibsubdir}/liblto_plugin.so
+%else
+%define gcc_plugin_lto      %{libsubdir}/liblto_plugin.so
+%endif
+
 
 %prep
 %setup -q -n gcc-%{version}
@@ -485,7 +497,7 @@ install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/g++
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/gcc
 
-for back in cc1 cc1plus; do
+for back in cc1 cc1plus collect2 lto1 lto-wrapper; do
        install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back          $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
 done
 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
@@ -521,12 +533,25 @@ rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
 rm -r env
 
+# liblto_plugin alternatives
+mkdir -p "$RPM_BUILD_ROOT%{bfd_plugin_dir}"
+touch "$RPM_BUILD_ROOT%{bfd_plugin_lto}"
+
+%post
+"%_sbindir/update-alternatives" --install \
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 5
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
+
 %files
 %defattr(-,root,root)
 %{_prefix}/bin/*
 %dir %{targetlibsubdir}
 %dir %{_libdir}/gcc/%{gcc_target_arch}
 %{targetlibsubdir}
+%ghost %{bfd_plugin_lto}
 
 %files -n cross-%cross_arch-gcc49-icecream-backend
 %defattr(-,root,root)
index 6c863a5..ee2a4f6 100644 (file)
@@ -67,6 +67,9 @@ BuildRequires: libunwind-devel
 BuildRequires: cross-%cross_arch-glibc-devel
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
 
 URL:          http://gcc.gnu.org/
@@ -147,6 +150,15 @@ gcc-obj-c++.
 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
 
+%define bfd_plugin_dir      %{_bindir}/../lib/bfd-plugins
+%define bfd_plugin_lto_name liblto_plugin_%{_arch}.so
+%define bfd_plugin_lto      %{bfd_plugin_dir}/%{bfd_plugin_lto_name}
+%if 0%{?cross_arch:1}
+%define gcc_plugin_lto      %{targetlibsubdir}/liblto_plugin.so
+%else
+%define gcc_plugin_lto      %{libsubdir}/liblto_plugin.so
+%endif
+
 
 %prep
 %setup -q -n gcc-%{version}
@@ -485,7 +497,7 @@ install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/g++
 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}   $RPM_BUILD_ROOT/env/usr/bin/gcc
 
-for back in cc1 cc1plus; do
+for back in cc1 cc1plus collect2 lto1 lto-wrapper; do
        install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back          $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
 done
 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
@@ -521,12 +533,25 @@ rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
 rm -r env
 
+# liblto_plugin alternatives
+mkdir -p "$RPM_BUILD_ROOT%{bfd_plugin_dir}"
+touch "$RPM_BUILD_ROOT%{bfd_plugin_lto}"
+
+%post
+"%_sbindir/update-alternatives" --install \
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 5
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
+
 %files
 %defattr(-,root,root)
 %{_prefix}/bin/*
 %dir %{targetlibsubdir}
 %dir %{_libdir}/gcc/%{gcc_target_arch}
 %{targetlibsubdir}
+%ghost %{bfd_plugin_lto}
 
 %files -n cross-%cross_arch-gcc49-icecream-backend
 %defattr(-,root,root)
index c6d0417..5e81819 100755 (executable)
@@ -75,6 +75,9 @@ BuildRequires: libunwind-devel
 BuildRequires: cross-%cross_arch-glibc-devel
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 # COMMON-BEGIN
 # COMMON-END
 
@@ -130,7 +133,7 @@ install -s \$RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
 install -s \$RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
        \$RPM_BUILD_ROOT/env/usr/bin/gcc
 
-for back in cc1 cc1plus; do
+for back in cc1 cc1plus collect2 lto1 lto-wrapper; do
        install -s -D \$RPM_BUILD_ROOT/%{targetlibsubdir}/\$back \
                \$RPM_BUILD_ROOT/env%{targetlibsubdir}/\$back
 done
@@ -170,12 +173,25 @@ rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
 rm -r env
 
+# liblto_plugin alternatives
+mkdir -p "\$RPM_BUILD_ROOT%{bfd_plugin_dir}"
+touch "\$RPM_BUILD_ROOT%{bfd_plugin_lto}"
+
+%post
+"%_sbindir/update-alternatives" --install \\
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 5
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
+
 %files
 %defattr(-,root,root)
 %{_prefix}/bin/*
 %dir %{targetlibsubdir}
 %dir %{_libdir}/gcc/%{gcc_target_arch}
 %{targetlibsubdir}
+%ghost %{bfd_plugin_lto}
 
 %files -n cross-%cross_arch-gcc@base_ver@-icecream-backend
 %defattr(-,root,root)
index 34e4776..8bc8450 100644 (file)
 
 %define selfconflict() %1
 
+
 Name:         gcc@base_ver@
 # For unknown reason when libgcc.so is built with gold, it causes python to
 # make syscalls with zero-length buffers. That's why we disable gold for gcc
@@ -170,6 +171,9 @@ BuildRequires: expect
 BuildRequires: gdb
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 %define separate_bi32 0
 %define separate_bi64 0
 %ifarch ppc sparcv9
@@ -940,6 +944,15 @@ Results from running the gcc and target library testsuites.
 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
 
+%define bfd_plugin_dir      %{_bindir}/../lib/bfd-plugins
+%define bfd_plugin_lto_name liblto_plugin_%{_arch}.so
+%define bfd_plugin_lto      %{bfd_plugin_dir}/%{bfd_plugin_lto_name}
+%if 0%{?cross_arch:1}
+%define gcc_plugin_lto      %{targetlibsubdir}/liblto_plugin.so
+%else
+%define gcc_plugin_lto      %{libsubdir}/liblto_plugin.so
+%endif
+
 # COMMON-END
 
 # Versionspecific directories
@@ -1759,6 +1772,17 @@ cd ..
 %find_lang libstdc++
 cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > gcc@base_ver@-locale.lang
 
+# liblto_plugin alternatives
+mkdir -p $RPM_BUILD_ROOT%{bfd_plugin_dir}
+touch $RPM_BUILD_ROOT%{bfd_plugin_lto}
+
+%post
+"%_sbindir/update-alternatives" --install \
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 10
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
 %post info
 %install_info --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz
 %install_info --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz
@@ -1826,6 +1850,7 @@ cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > gcc@base_ver@-locale.lang
 %{libsubdir}/lto1
 %{libsubdir}/lto-wrapper
 %{libsubdir}/liblto_plugin.so*
+%ghost %{bfd_plugin_lto}
 %{libsubdir}/include-fixed/README
 %{libsubdir}/include-fixed/limits.h
 %{libsubdir}/include-fixed/syslimits.h
index fb8e2cf..99a14c4 100644 (file)
 
 %define selfconflict() %1
 
+
 Name:         gcc49
 # For unknown reason when libgcc.so is built with gold, it causes python to
 # make syscalls with zero-length buffers. That's why we disable gold for gcc
@@ -170,6 +171,9 @@ BuildRequires: expect
 BuildRequires: gdb
 %endif
 
+Requires(post):    update-alternatives
+Requires(postun):  update-alternatives
+
 %define separate_bi32 0
 %define separate_bi64 0
 %ifarch ppc sparcv9
@@ -1475,6 +1479,15 @@ Results from running the gcc and target library testsuites.
 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
 
+%define bfd_plugin_dir      %{_bindir}/../lib/bfd-plugins
+%define bfd_plugin_lto_name liblto_plugin_%{_arch}.so
+%define bfd_plugin_lto      %{bfd_plugin_dir}/%{bfd_plugin_lto_name}
+%if 0%{?cross_arch:1}
+%define gcc_plugin_lto      %{targetlibsubdir}/liblto_plugin.so
+%else
+%define gcc_plugin_lto      %{libsubdir}/liblto_plugin.so
+%endif
+
 
 # Versionspecific directories
 %define versmainlibdir %{libsubdir}
@@ -2278,6 +2291,17 @@ cd ..
 %find_lang libstdc++
 cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > gcc49-locale.lang
 
+# liblto_plugin alternatives
+mkdir -p $RPM_BUILD_ROOT%{bfd_plugin_dir}
+touch $RPM_BUILD_ROOT%{bfd_plugin_lto}
+
+%post
+"%_sbindir/update-alternatives" --install \
+    "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 10
+
+%preun
+"%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
+
 %post info
 %install_info --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz
 %install_info --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz
@@ -2345,6 +2369,7 @@ cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > gcc49-locale.lang
 %{libsubdir}/lto1
 %{libsubdir}/lto-wrapper
 %{libsubdir}/liblto_plugin.so*
+%ghost %{bfd_plugin_lto}
 %{libsubdir}/include-fixed/README
 %{libsubdir}/include-fixed/limits.h
 %{libsubdir}/include-fixed/syslimits.h