Now the package supports running i686 binaries in x86_64 environment.
In order to prevent name clashing between i686 and armv7l ld-${version}.so binaries the
i686 one is renamed to ld-${version}-i686.so in /emul/.
The i686 binaries interpreter is set to /emul/lib/ld-linux.so.2 by default.
Change-Id: Idb9487e765be375bf81e4c841e5425e3332949e6
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
+%ifarch x86_64
+BuildRequires: glibc-32bit
+%define multilib 1
+%endif
%description
%{_bindir}/icerun \
${real_compiler} \
%{_bindir}/{find,xargs,readlink,ls,cpio} \
- %{_prefix}/lib/rpm/debugedit \
- %{_prefix}/lib/rpm/*deps \
+ %{_rpmconfigdir}/debugedit \
+ %{_rpmconfigdir}/*deps \
%{_bindir}/mono-sgen \
%{_libdir}/{libmonoboehm-*.so.*,libMonoPosixHelper.so,libmonosgen-*.so.*} \
%{_libdir}/{libunwind*.so*,libuuid*.so*}
done | grep -v "not owned" | sed -e "s/-[0-9].*//g" | sort -u
echo ""
-
-for binary in $binaries
-do
+function patch_binary {
+ local binary=$1
+ local rtld=$2
# We don't need to accelerate shell scripts
- filetype=`file --brief $binary`
+ local filetype=`file --brief $binary`
[[ x"$filetype" == x"POSIX shell script"* ]] && continue
- outfile=%{buildroot}/%{our_path}/$binary
+ local outfile=%{buildroot}/%{our_path}/$binary
[ ! -e $binary ] && echo "WARNING: File '${binary}' not found, ignoring" && continue
[ -f $outfile ] && echo "WARNING: File '${outfile}' exists, ignoring" && continue
mkdir -p ${outfile%/*}
exit 1
fi
rm -f $outfile.data
- [ "$binary" == "$LD" ] && continue
- patchelf --set-rpath "%{our_path}/%{libdir}" $outfile
+ [ "$binary" == "$rtld" ] && continue
+ patchelf --set-rpath "%{our_path}/%{_libdir}" $outfile
# not all binaries have an .interp section
if patchelf --print-interpreter $outfile 1>/dev/null 2>/dev/null; then
- patchelf --set-interpreter %{our_path}$LD $outfile
+ patchelf --set-interpreter %{our_path}$rtld $outfile
fi
+}
+
+for binary in $binaries
+do
+ patch_binary $binary $LD
+done
+set -x
+
+%{?multilib:
+# Detect name of current ld.so. E.g. ld-linux.so.2
+cross_ld_symlink=$(basename `rpm -ql glibc-32bit | grep -E 'ld-linux\.so\.[[:digit:]]+'`)
+
+# Patch all 32bit binaries to use the right ld.so though symlink
+mkdir -p %{buildroot}%{our_path}%{_prefix}/lib
+mkdir -p %{buildroot}%{our_path}/lib
+for f in $(rpm -ql glibc-32bit)
+do
+ patch_binary $f /lib/${cross_ld_symlink}
done
+# Now we have to change the ld.so name to prevent name clashing in armv7l repos
+i686_libdir="%{buildroot}%{our_path}/lib"
+
+# 1. Rename the actual ld.so binary
+cross_ld_so=$(find ${i686_libdir} -name 'ld-*.so' -printf '%f')
+new_cross_ld_so=$(echo ${cross_ld_so} | sed -e 's,\.so,-i686.so,')
+mv ${i686_libdir}/${cross_ld_so} ${i686_libdir}/${new_cross_ld_so}
+
+# 2. Force the symlink to point the right file.
+ln -sf %{our_path}/lib/${new_cross_ld_so} ${i686_libdir}/${cross_ld_symlink}
+}
+
# create symlinks for bash
ln -s usr/bin "%{buildroot}%{our_path}/bin"
ln -sf bash "%{buildroot}%{our_path}/usr/bin/sh"
-# move everything into single usr/lib
-mkdir -p %{buildroot}%{our_path}/usr/lib_new
-if [ ! "%{_libdir}" == "%{libdir}" ]; then
- rm -rf %{buildroot}%{our_path}%{_libdir}/gcc
-fi
-for dir in /usr/lib /usr/lib64 /lib64 /lib; do
- [ -d "%{buildroot}%{our_path}$dir" ] || continue
- mv %{buildroot}%{our_path}$dir/* %{buildroot}%{our_path}/usr/lib_new
-done
-rm -rf %{buildroot}%{our_path}/{usr/lib64,usr/lib,lib64,lib}
-mv %{buildroot}%{our_path}/usr/lib_new %{buildroot}%{our_path}/usr/lib
-ln -s lib %{buildroot}%{our_path}/usr/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib
+mv %{buildroot}%{our_path}/%{_lib}/* %{buildroot}%{our_path}%{_libdir}/
+rm -rf %{buildroot}%{our_path}/%{_lib}
+ln -sf usr/%{_lib} %{buildroot}%{our_path}/%{_lib}
+%{?multilib:
+mv %{buildroot}%{our_path}/lib/* %{buildroot}%{our_path}%{_prefix}/lib/
+rm -rf %{buildroot}%{our_path}/lib
+ln -sf usr/lib %{buildroot}%{our_path}/lib
+}
# rename binutils binaries
for binary in addr2line ar as c++filt dwp elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip
ln -s python${python_version} %{buildroot}%{our_path}%{_libdir}/python
#create symlinks for Scons
+mkdir -p %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages
ln -sf %{libdir}/python${python_version}/site-packages/SCons %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages/SCons
# rpmlint acceleration
# support /lib/cpp
ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp
-set -x
+# Find gcc install directory
+gcc_install_dir=$(%{target_arch}-gcc -print-search-dirs | sed -ne '/install: /s/install: //p')
# update baselibs.conf, overwrite LTO plugin
-sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}%{_libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
-sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}${gcc_install_dir}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${gcc_install_dir}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+
+%{?multilib:
+sed -i -e '/post "/a post "echo '%{our_path}/lib' >> /etc/ld.so.conf"\n post "[ ! -e %{_rpmconfigdir} ] && mkdir -p $(dirname %{_rpmconfigdir}) && ln -s /usr/lib/rpm %{_rpmconfigdir}"' %{_sourcedir}/baselibs.conf
+# Set rpm config directory corresponding to architecture
+mkdir -p %{buildroot}%{_sysconfdir}/profile.d/
+echo "export RPM_CONFIGDIR=%{libdir}/rpm" > %{buildroot}%{_sysconfdir}/profile.d/rpm.bash
+}
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
%files
%defattr(-,root,root)
%{our_path}
+%{?multilib:%{_sysconfdir}/profile.d/rpm.bash}
%exclude %{our_path}%{_bindir}/python*
%files -n python-accel
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
+%ifarch x86_64
+BuildRequires: glibc-32bit
+%define multilib 1
+%endif
%description
%{_bindir}/icerun \
${real_compiler} \
%{_bindir}/{find,xargs,readlink,ls,cpio} \
- %{_prefix}/lib/rpm/debugedit \
- %{_prefix}/lib/rpm/*deps \
+ %{_rpmconfigdir}/debugedit \
+ %{_rpmconfigdir}/*deps \
%{_bindir}/mono-sgen \
%{_libdir}/{libmonoboehm-*.so.*,libMonoPosixHelper.so,libmonosgen-*.so.*} \
%{_libdir}/{libunwind*.so*,libuuid*.so*}
done | grep -v "not owned" | sed -e "s/-[0-9].*//g" | sort -u
echo ""
-
-for binary in $binaries
-do
+function patch_binary {
+ local binary=$1
+ local rtld=$2
# We don't need to accelerate shell scripts
- filetype=`file --brief $binary`
+ local filetype=`file --brief $binary`
[[ x"$filetype" == x"POSIX shell script"* ]] && continue
- outfile=%{buildroot}/%{our_path}/$binary
+ local outfile=%{buildroot}/%{our_path}/$binary
[ ! -e $binary ] && echo "WARNING: File '${binary}' not found, ignoring" && continue
[ -f $outfile ] && echo "WARNING: File '${outfile}' exists, ignoring" && continue
mkdir -p ${outfile%/*}
exit 1
fi
rm -f $outfile.data
- [ "$binary" == "$LD" ] && continue
- patchelf --set-rpath "%{our_path}/%{libdir}" $outfile
+ [ "$binary" == "$rtld" ] && continue
+ patchelf --set-rpath "%{our_path}/%{_libdir}" $outfile
# not all binaries have an .interp section
if patchelf --print-interpreter $outfile 1>/dev/null 2>/dev/null; then
- patchelf --set-interpreter %{our_path}$LD $outfile
+ patchelf --set-interpreter %{our_path}$rtld $outfile
fi
+}
+
+for binary in $binaries
+do
+ patch_binary $binary $LD
+done
+set -x
+
+%{?multilib:
+# Detect name of current ld.so. E.g. ld-linux.so.2
+cross_ld_symlink=$(basename `rpm -ql glibc-32bit | grep -E 'ld-linux\.so\.[[:digit:]]+'`)
+
+# Patch all 32bit binaries to use the right ld.so though symlink
+mkdir -p %{buildroot}%{our_path}%{_prefix}/lib
+mkdir -p %{buildroot}%{our_path}/lib
+for f in $(rpm -ql glibc-32bit)
+do
+ patch_binary $f /lib/${cross_ld_symlink}
done
+# Now we have to change the ld.so name to prevent name clashing in armv7l repos
+i686_libdir="%{buildroot}%{our_path}/lib"
+
+# 1. Rename the actual ld.so binary
+cross_ld_so=$(find ${i686_libdir} -name 'ld-*.so' -printf '%f')
+new_cross_ld_so=$(echo ${cross_ld_so} | sed -e 's,\.so,-i686.so,')
+mv ${i686_libdir}/${cross_ld_so} ${i686_libdir}/${new_cross_ld_so}
+
+# 2. Force the symlink to point the right file.
+ln -sf %{our_path}/lib/${new_cross_ld_so} ${i686_libdir}/${cross_ld_symlink}
+}
+
# create symlinks for bash
ln -s usr/bin "%{buildroot}%{our_path}/bin"
ln -sf bash "%{buildroot}%{our_path}/usr/bin/sh"
-# move everything into single usr/lib
-mkdir -p %{buildroot}%{our_path}/usr/lib_new
-if [ ! "%{_libdir}" == "%{libdir}" ]; then
- rm -rf %{buildroot}%{our_path}%{_libdir}/gcc
-fi
-for dir in /usr/lib /usr/lib64 /lib64 /lib; do
- [ -d "%{buildroot}%{our_path}$dir" ] || continue
- mv %{buildroot}%{our_path}$dir/* %{buildroot}%{our_path}/usr/lib_new
-done
-rm -rf %{buildroot}%{our_path}/{usr/lib64,usr/lib,lib64,lib}
-mv %{buildroot}%{our_path}/usr/lib_new %{buildroot}%{our_path}/usr/lib
-ln -s lib %{buildroot}%{our_path}/usr/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib
+mv %{buildroot}%{our_path}/%{_lib}/* %{buildroot}%{our_path}%{_libdir}/
+rm -rf %{buildroot}%{our_path}/%{_lib}
+ln -sf usr/%{_lib} %{buildroot}%{our_path}/%{_lib}
+%{?multilib:
+mv %{buildroot}%{our_path}/lib/* %{buildroot}%{our_path}%{_prefix}/lib/
+rm -rf %{buildroot}%{our_path}/lib
+ln -sf usr/lib %{buildroot}%{our_path}/lib
+}
# rename binutils binaries
for binary in addr2line ar as c++filt dwp elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip
ln -s python${python_version} %{buildroot}%{our_path}%{_libdir}/python
#create symlinks for Scons
+mkdir -p %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages
ln -sf %{libdir}/python${python_version}/site-packages/SCons %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages/SCons
# rpmlint acceleration
# support /lib/cpp
ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp
-set -x
+# Find gcc install directory
+gcc_install_dir=$(%{target_arch}-gcc -print-search-dirs | sed -ne '/install: /s/install: //p')
# update baselibs.conf, overwrite LTO plugin
-sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}%{_libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
-sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}${gcc_install_dir}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${gcc_install_dir}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+
+%{?multilib:
+sed -i -e '/post "/a post "echo '%{our_path}/lib' >> /etc/ld.so.conf"\n post "[ ! -e %{_rpmconfigdir} ] && mkdir -p $(dirname %{_rpmconfigdir}) && ln -s /usr/lib/rpm %{_rpmconfigdir}"' %{_sourcedir}/baselibs.conf
+# Set rpm config directory corresponding to architecture
+mkdir -p %{buildroot}%{_sysconfdir}/profile.d/
+echo "export RPM_CONFIGDIR=%{libdir}/rpm" > %{buildroot}%{_sysconfdir}/profile.d/rpm.bash
+}
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
%files
%defattr(-,root,root)
%{our_path}
+%{?multilib:%{_sysconfdir}/profile.d/rpm.bash}
%exclude %{our_path}%{_bindir}/python*
%files -n python-accel
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
+%ifarch x86_64
+BuildRequires: glibc-32bit
+%define multilib 1
+%endif
%description
%{_bindir}/icerun \
${real_compiler} \
%{_bindir}/{find,xargs,readlink,ls,cpio} \
- %{_prefix}/lib/rpm/debugedit \
- %{_prefix}/lib/rpm/*deps \
+ %{_rpmconfigdir}/debugedit \
+ %{_rpmconfigdir}/*deps \
%{_bindir}/mono-sgen \
%{_libdir}/{libmonoboehm-*.so.*,libMonoPosixHelper.so,libmonosgen-*.so.*} \
%{_libdir}/{libunwind*.so*,libuuid*.so*}
done | grep -v "not owned" | sed -e "s/-[0-9].*//g" | sort -u
echo ""
-
-for binary in $binaries
-do
+function patch_binary {
+ local binary=$1
+ local rtld=$2
# We don't need to accelerate shell scripts
- filetype=`file --brief $binary`
+ local filetype=`file --brief $binary`
[[ x"$filetype" == x"POSIX shell script"* ]] && continue
- outfile=%{buildroot}/%{our_path}/$binary
+ local outfile=%{buildroot}/%{our_path}/$binary
[ ! -e $binary ] && echo "WARNING: File '${binary}' not found, ignoring" && continue
[ -f $outfile ] && echo "WARNING: File '${outfile}' exists, ignoring" && continue
mkdir -p ${outfile%/*}
exit 1
fi
rm -f $outfile.data
- [ "$binary" == "$LD" ] && continue
- patchelf --set-rpath "%{our_path}/%{libdir}" $outfile
+ [ "$binary" == "$rtld" ] && continue
+ patchelf --set-rpath "%{our_path}/%{_libdir}" $outfile
# not all binaries have an .interp section
if patchelf --print-interpreter $outfile 1>/dev/null 2>/dev/null; then
- patchelf --set-interpreter %{our_path}$LD $outfile
+ patchelf --set-interpreter %{our_path}$rtld $outfile
fi
+}
+
+for binary in $binaries
+do
+ patch_binary $binary $LD
+done
+set -x
+
+%{?multilib:
+# Detect name of current ld.so. E.g. ld-linux.so.2
+cross_ld_symlink=$(basename `rpm -ql glibc-32bit | grep -E 'ld-linux\.so\.[[:digit:]]+'`)
+
+# Patch all 32bit binaries to use the right ld.so though symlink
+mkdir -p %{buildroot}%{our_path}%{_prefix}/lib
+mkdir -p %{buildroot}%{our_path}/lib
+for f in $(rpm -ql glibc-32bit)
+do
+ patch_binary $f /lib/${cross_ld_symlink}
done
+# Now we have to change the ld.so name to prevent name clashing in armv7l repos
+i686_libdir="%{buildroot}%{our_path}/lib"
+
+# 1. Rename the actual ld.so binary
+cross_ld_so=$(find ${i686_libdir} -name 'ld-*.so' -printf '%f')
+new_cross_ld_so=$(echo ${cross_ld_so} | sed -e 's,\.so,-i686.so,')
+mv ${i686_libdir}/${cross_ld_so} ${i686_libdir}/${new_cross_ld_so}
+
+# 2. Force the symlink to point the right file.
+ln -sf %{our_path}/lib/${new_cross_ld_so} ${i686_libdir}/${cross_ld_symlink}
+}
+
# create symlinks for bash
ln -s usr/bin "%{buildroot}%{our_path}/bin"
ln -sf bash "%{buildroot}%{our_path}/usr/bin/sh"
-# move everything into single usr/lib
-mkdir -p %{buildroot}%{our_path}/usr/lib_new
-if [ ! "%{_libdir}" == "%{libdir}" ]; then
- rm -rf %{buildroot}%{our_path}%{_libdir}/gcc
-fi
-for dir in /usr/lib /usr/lib64 /lib64 /lib; do
- [ -d "%{buildroot}%{our_path}$dir" ] || continue
- mv %{buildroot}%{our_path}$dir/* %{buildroot}%{our_path}/usr/lib_new
-done
-rm -rf %{buildroot}%{our_path}/{usr/lib64,usr/lib,lib64,lib}
-mv %{buildroot}%{our_path}/usr/lib_new %{buildroot}%{our_path}/usr/lib
-ln -s lib %{buildroot}%{our_path}/usr/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib64
-ln -s usr/lib %{buildroot}%{our_path}/lib
+mv %{buildroot}%{our_path}/%{_lib}/* %{buildroot}%{our_path}%{_libdir}/
+rm -rf %{buildroot}%{our_path}/%{_lib}
+ln -sf usr/%{_lib} %{buildroot}%{our_path}/%{_lib}
+%{?multilib:
+mv %{buildroot}%{our_path}/lib/* %{buildroot}%{our_path}%{_prefix}/lib/
+rm -rf %{buildroot}%{our_path}/lib
+ln -sf usr/lib %{buildroot}%{our_path}/lib
+}
# rename binutils binaries
for binary in addr2line ar as c++filt dwp elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip
ln -s python${python_version} %{buildroot}%{our_path}%{_libdir}/python
#create symlinks for Scons
+mkdir -p %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages
ln -sf %{libdir}/python${python_version}/site-packages/SCons %{buildroot}%{our_path}%{libdir}/python${python_version}/site-packages/SCons
# rpmlint acceleration
# support /lib/cpp
ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp
-set -x
+# Find gcc install directory
+gcc_install_dir=$(%{target_arch}-gcc -print-search-dirs | sed -ne '/install: /s/install: //p')
# update baselibs.conf, overwrite LTO plugin
-sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}%{_libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
-sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTIN#,ln -sf %{our_path}${gcc_install_dir}/liblto_plugin.so %{libdir}/gcc/%{target_arch}/${gcc_version}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${gcc_install_dir}/liblto_plugin.so," %{_sourcedir}/baselibs.conf
+
+%{?multilib:
+sed -i -e '/post "/a post "echo '%{our_path}/lib' >> /etc/ld.so.conf"\n post "[ ! -e %{_rpmconfigdir} ] && mkdir -p $(dirname %{_rpmconfigdir}) && ln -s /usr/lib/rpm %{_rpmconfigdir}"' %{_sourcedir}/baselibs.conf
+# Set rpm config directory corresponding to architecture
+mkdir -p %{buildroot}%{_sysconfdir}/profile.d/
+echo "export RPM_CONFIGDIR=%{libdir}/rpm" > %{buildroot}%{_sysconfdir}/profile.d/rpm.bash
+}
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
%files
%defattr(-,root,root)
%{our_path}
+%{?multilib:%{_sysconfdir}/profile.d/rpm.bash}
%exclude %{our_path}%{_bindir}/python*
%files -n python-accel