summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Barinov <v.barinov@samsung.com>2017-01-17 12:46:49 +0300
committerSlava Barinov <v.barinov@samsung.com>2017-01-17 18:10:14 +0300
commit106c00aca2e45a76e0d3ef2bf57c84c00b779aa4 (patch)
tree4ba3d03fb25bef74ff338326128dcff7321851b2
parentcdd524f2148e74af13e849d96ffed134bee1e645 (diff)
downloadqemu-accel-sandbox/vbarinov/multilib.tar.gz
qemu-accel-sandbox/vbarinov/multilib.tar.bz2
qemu-accel-sandbox/vbarinov/multilib.zip
Add x86 multilib support and rvct-x86 accelerationsandbox/vbarinov/multilib
Change-Id: I4b194b84dc75a30cd11eb0435bb334082eda2079
-rw-r--r--packaging/qemu-accel-aarch64.spec51
-rw-r--r--packaging/qemu-accel-armv7l.spec51
-rw-r--r--packaging/qemu-accel.spec.in51
3 files changed, 150 insertions, 3 deletions
diff --git a/packaging/qemu-accel-aarch64.spec b/packaging/qemu-accel-aarch64.spec
index c9b387f..90c0481 100644
--- a/packaging/qemu-accel-aarch64.spec
+++ b/packaging/qemu-accel-aarch64.spec
@@ -26,6 +26,11 @@
%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
%define libdir %{_prefix}/lib%{?aarch64:64}
+%ifarch x86_64
+# TODO: enable switch on the project config level
+%define multilib_x86 1
+%endif
+
# default path in qemu
%define our_path /emul
@@ -61,7 +66,9 @@ Summary: Native binaries for speeding up cross compile
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
-
+%if 0%{?multilib_x86}
+BuildRequires: glibc-32bit gcc-32bit
+%endif
%description
This package is used in %{cross} architecture builds using qemu to speed up builds
@@ -297,6 +304,48 @@ sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_ar
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
+# Enable i586 binaries if there are ones
+%if 0%{?multilib_x86}
+%define multilibarch i586
+%define multilibdir usr/lib32
+mkdir -p %{buildroot}%{our_path}/%{multilibdir}
+cp -rf /%{multilibdir}/* %{buildroot}%{our_path}/%{multilibdir}/
+(find %{buildroot}%{our_path}/%{multilibdir}/ -type f -print0 | xargs -0 file | grep ASCII | sed -e 's/:.*$//' | xargs sed -e 's|^/lib32/|/emul/lib32/|g' -i) || true
+MULTILD="ld-linux.so.2"
+ln -sf %{our_path}/%{multilibdir} %{buildroot}%{our_path}/lib32
+ln -sf %{our_path}/%{multilibdir}/${MULTILD} %{buildroot}%{our_path}/%{_lib}/${MULTILD}
+
+# Add the armcc
+binaries32bit=""
+
+for binary in $binaries32bit
+do
+ # We don't need to accelerate shell scripts
+ filetype=`file --brief $binary`
+ [[ x"$filetype" == x"POSIX shell script"* ]] && continue
+
+ 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%/*}
+ cp -aL $binary $outfile
+ objdump -s -j .rodata -j .data $outfile | sed 's/^ *\([a-z0-9]*\)/\1:/' | \
+ grep ': ' | grep -v 'file format' | grep -v 'Contents of section' | \
+ xxd -g4 -r - $outfile.data
+ if grep -q "%{multilibarch}"$outfile.data; then
+ echo "ERROR file $binary leaks host information into the guest"
+ exit 1
+ fi
+ rm -f $outfile.data
+ [ "$binary" == "$MULTILD" ] && continue
+ patchelf --set-rpath "%{our_path}/%{multilibdir}" $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}/%{multilibdir}/$MULTILD $outfile
+ fi
+done
+%endif
+
%post
ldconfig
diff --git a/packaging/qemu-accel-armv7l.spec b/packaging/qemu-accel-armv7l.spec
index ab51aee..3155e8f 100644
--- a/packaging/qemu-accel-armv7l.spec
+++ b/packaging/qemu-accel-armv7l.spec
@@ -26,6 +26,11 @@
%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
%define libdir %{_prefix}/lib%{?aarch64:64}
+%ifarch x86_64
+# TODO: enable switch on the project config level
+%define multilib_x86 1
+%endif
+
# default path in qemu
%define our_path /emul
@@ -61,7 +66,9 @@ Summary: Native binaries for speeding up cross compile
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
-
+%if 0%{?multilib_x86}
+BuildRequires: glibc-32bit gcc-32bit
+%endif
%description
This package is used in %{cross} architecture builds using qemu to speed up builds
@@ -297,6 +304,48 @@ sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_ar
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
+# Enable i586 binaries if there are ones
+%if 0%{?multilib_x86}
+%define multilibarch i586
+%define multilibdir usr/lib32
+mkdir -p %{buildroot}%{our_path}/%{multilibdir}
+cp -rf /%{multilibdir}/* %{buildroot}%{our_path}/%{multilibdir}/
+(find %{buildroot}%{our_path}/%{multilibdir}/ -type f -print0 | xargs -0 file | grep ASCII | sed -e 's/:.*$//' | xargs sed -e 's|^/lib32/|/emul/lib32/|g' -i) || true
+MULTILD="ld-linux.so.2"
+ln -sf %{our_path}/%{multilibdir} %{buildroot}%{our_path}/lib32
+ln -sf %{our_path}/%{multilibdir}/${MULTILD} %{buildroot}%{our_path}/%{_lib}/${MULTILD}
+
+# Add the armcc
+binaries32bit=""
+
+for binary in $binaries32bit
+do
+ # We don't need to accelerate shell scripts
+ filetype=`file --brief $binary`
+ [[ x"$filetype" == x"POSIX shell script"* ]] && continue
+
+ 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%/*}
+ cp -aL $binary $outfile
+ objdump -s -j .rodata -j .data $outfile | sed 's/^ *\([a-z0-9]*\)/\1:/' | \
+ grep ': ' | grep -v 'file format' | grep -v 'Contents of section' | \
+ xxd -g4 -r - $outfile.data
+ if grep -q "%{multilibarch}"$outfile.data; then
+ echo "ERROR file $binary leaks host information into the guest"
+ exit 1
+ fi
+ rm -f $outfile.data
+ [ "$binary" == "$MULTILD" ] && continue
+ patchelf --set-rpath "%{our_path}/%{multilibdir}" $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}/%{multilibdir}/$MULTILD $outfile
+ fi
+done
+%endif
+
%post
ldconfig
diff --git a/packaging/qemu-accel.spec.in b/packaging/qemu-accel.spec.in
index 8468718..0688ca3 100644
--- a/packaging/qemu-accel.spec.in
+++ b/packaging/qemu-accel.spec.in
@@ -23,6 +23,11 @@
%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
%define libdir %{_prefix}/lib%{?aarch64:64}
+%ifarch x86_64
+# TODO: enable switch on the project config level
+%define multilib_x86 1
+%endif
+
# default path in qemu
%define our_path /emul
@@ -58,7 +63,9 @@ Summary: Native binaries for speeding up cross compile
License: GPL-2.0
Group: Development/Cross Compilation
ExclusiveArch: x86_64 %{ix86}
-
+%if 0%{?multilib_x86}
+BuildRequires: glibc-32bit gcc-32bit
+%endif
%description
This package is used in %{cross} architecture builds using qemu to speed up builds
@@ -294,6 +301,48 @@ sed -i -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 %{libdir}/gcc/%{target_ar
# allow build of baselibs.conf
sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf
+# Enable i586 binaries if there are ones
+%if 0%{?multilib_x86}
+%define multilibarch i586
+%define multilibdir usr/lib32
+mkdir -p %{buildroot}%{our_path}/%{multilibdir}
+cp -rf /%{multilibdir}/* %{buildroot}%{our_path}/%{multilibdir}/
+(find %{buildroot}%{our_path}/%{multilibdir}/ -type f -print0 | xargs -0 file | grep ASCII | sed -e 's/:.*$//' | xargs sed -e 's|^/lib32/|/emul/lib32/|g' -i) || true
+MULTILD="ld-linux.so.2"
+ln -sf %{our_path}/%{multilibdir} %{buildroot}%{our_path}/lib32
+ln -sf %{our_path}/%{multilibdir}/${MULTILD} %{buildroot}%{our_path}/%{_lib}/${MULTILD}
+
+# Add the armcc
+binaries32bit=""
+
+for binary in $binaries32bit
+do
+ # We don't need to accelerate shell scripts
+ filetype=`file --brief $binary`
+ [[ x"$filetype" == x"POSIX shell script"* ]] && continue
+
+ 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%/*}
+ cp -aL $binary $outfile
+ objdump -s -j .rodata -j .data $outfile | sed 's/^ *\([a-z0-9]*\)/\1:/' | \
+ grep ': ' | grep -v 'file format' | grep -v 'Contents of section' | \
+ xxd -g4 -r - $outfile.data
+ if grep -q "%{multilibarch}"$outfile.data; then
+ echo "ERROR file $binary leaks host information into the guest"
+ exit 1
+ fi
+ rm -f $outfile.data
+ [ "$binary" == "$MULTILD" ] && continue
+ patchelf --set-rpath "%{our_path}/%{multilibdir}" $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}/%{multilibdir}/$MULTILD $outfile
+ fi
+done
+%endif
+
%post
ldconfig