diff options
author | Yury Usishchev <y.usishchev@samsung.com> | 2015-07-20 16:10:54 +0300 |
---|---|---|
committer | Yury Usishchev <y.usishchev@samsung.com> | 2015-08-05 15:58:31 +0300 |
commit | 96b1f9f254a70a6012cdecd5b5bba619226c7d93 (patch) | |
tree | 52b161290de33f7a537a21df2f326ad47e1427ad | |
parent | 822b1565f4c215e5ecbf269dfb33c28278fd01bc (diff) | |
download | qemu-accel-96b1f9f254a70a6012cdecd5b5bba619226c7d93.tar.gz qemu-accel-96b1f9f254a70a6012cdecd5b5bba619226c7d93.tar.bz2 qemu-accel-96b1f9f254a70a6012cdecd5b5bba619226c7d93.zip |
Rework packaging for Tizen.sandbox/jolfzverb/merge
Change-Id: Ibac85492878e64e6b03c4bc537fe83a26474b226
-rw-r--r-- | packaging/baselibs.conf | 175 | ||||
-rwxr-xr-x | packaging/gcc-wrapper.sh | 30 | ||||
-rwxr-xr-x | packaging/ld-wrapper.sh | 27 | ||||
-rwxr-xr-x | packaging/pre_checkin.sh | 24 | ||||
-rw-r--r-- | packaging/qemu-accel-aarch64.spec | 324 | ||||
-rw-r--r-- | packaging/qemu-accel-armv7l.spec | 324 | ||||
-rw-r--r-- | packaging/qemu-accel.spec | 206 | ||||
-rw-r--r-- | packaging/qemu-accel.spec.in | 321 |
8 files changed, 439 insertions, 992 deletions
diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 4668884..2e3fcbb 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -1,166 +1,13 @@ -arch i686 targets armv7l:cross-arm aarch64:cross-aarch64 -arch x86_64 targets aarch64:cross-aarch64 +arch i686 targets armv7l:armv7l aarch64:aarch64 +arch x86_64 targets armv7l:armv7l aarch64:aarch64 -qemu-accel-armv7l - targettype cross-arm requires "gcc" - targettype cross-arm requires "binutils" - targettype cross-arm requires "binutils-gold" - targettype cross-aarch64 block! +qemu-accel + targettype aarch64 block! + targettype armv7l block! targettype 32bit block! - targettype cross-arm - autoreqprov off - extension -cross - post "set -x" - post "if [ $(uname -m) = armv7l ]; then" - post " builtin echo armv7l arch" - post " ln -sf /emul/i586-for-arm/lib/libnsl.so.1 /lib/libnsl.so.1 || true" - post " /usr/sbin/ldconfig || true" - post "fi" - post "# load the binfmt_misc module" - post "if [ ! -d /proc/sys/fs/binfmt_misc ]; then" - post " builtin echo Calling modprobe" - post " /sbin/modprobe binfmt_misc" - post "fi" - post "" - post "did_mount_it=''" - post "" - post "if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then" - post " builtin echo mounting binfmt_misc" - post " mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc" - post " did_mount_it=1" - post "fi" - post "" - post "if [ -e /proc/sys/fs/binfmt_misc/arm ]; then" - post " builtin echo Registering accelerated handler" - post " builtin echo -1 > /proc/sys/fs/binfmt_misc/arm" - post " builtin echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/qemu/qemu-arm-binfmt:P' > /proc/sys/fs/binfmt_misc/register" - post "fi" - post "" - post "if [ $did_mount_it ]; then " - post " builtin echo "Unmounting again.";" - post " umount /proc/sys/fs/binfmt_misc" - post "fi" - post "" - post "ls /qemu | while read f ; do" - post " if [ -f /usr/bin/$f ] ; then" - post " builtin echo /usr/bin/$f already presents!" - post " else" - post " ln -s /qemu/$f /usr/bin/$f" - post " fi" - post "done" - post "" - post "builtin echo All done" - post "" - post "# Fix up sysroot paths" - post "rm -rf /usr/armv7l-tizen-linux-gnueabi/lib" - post "ln -s /lib /usr/armv7l-tizen-linux-gnueabi/usr/lib" - post "builtin echo 0 >/proc/sys/vm/mmap_min_addr" - post "" - post "if [ -f /usr/bin/gcc ] ; then" - post " export GCCVER=$(LANG=C gcc --version | head -1 | sed -e "s/^.*gcc[^0-9]*\(\([0-9]*\.\)\+[0-9]*\).*$/\1/") " - post " # Create symlinks to files needed by native ld for the case if we want to use it instead of cross ld:" - post " for f in crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o ; do" - post " ln -s /usr/lib/gcc/armv7l-tizen-linux-gnueabi/${GCCVER}/$f /usr/armv7l-tizen-linux-gnueabi/bin/$f;" - post " done" - post "fi" - post "" - post "HOST_ARCH=`echo -n %{_host_cpu} | sed -e 's/i.86/i586/'`" - post "ACCEL_DIR=/emul/$HOST_ARCH-for-arm" - post "mkdir -p %_bindir/../lib/bfd-plugins" - post "%_sbindir/update-alternatives --install \" - post " %_bindir/../lib/bfd-plugins/liblto_plugin_%{_arch}.so \" - post " liblto_plugin_%{_arch}.so \" - post " $ACCEL_DIR/usr/lib/gcc/armv7l-tizen-linux-gnueabi/${GCCVER}/liblto_plugin.so \" - post " 3" - post "" - postun "HOST_ARCH=`echo -n %{_host_cpu} | sed -e 's/i.86/i586/'`" - postun "ACCEL_DIR=/emul/$HOST_ARCH-for-arm" - postun "GCCVER=$(LANG=C gcc --version | head -1 | sed -e "s/^.*gcc[^0-9]*\(\([0-9]*\.\)\+[0-9]*\).*$/\1/") " - postun "%_sbindir/update-alternatives --remove \" - postun " liblto_plugin_%{_arch}.so \" - postun " $ACCEL_DIR/usr/lib/gcc/armv7l-tizen-linux-gnueabi/${GCCVER}/liblto_plugin.so" - +/ - config -/pkg-config$ - -qemu-accel-aarch64 - targettype cross-aarch64 requires "gcc" - targettype cross-aarch64 requires "binutils" - targettype cross-aarch64 requires "binutils-gold" - targettype cross-arm block! - targettype 32bit block! - targettype cross-aarch64 - autoreqprov off - extension -cross - post "set -x" - post "builtin echo 'Starting qemu post script'" - post "if [ $(uname -m) = aarch64 ]; then" - post " builtin echo aarch64 arch" - post " ln -sf %{our_path}/lib/libnsl.so.1 /lib/libnsl.so.1 || true" - post "fi" - post "# load the binfmt_misc module" - post "if [ ! -d /proc/sys/fs/binfmt_misc ]; then" - post " builtin echo Calling modprobe" - post " /sbin/modprobe binfmt_misc" - post "fi" - post "" - post "did_mount_it=''" - post "" - post "if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then" - post " builtin echo mounting binfmt_misc" - post " mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc" - post " did_mount_it='1'" - post "fi" - post "" - post "if [ -e /proc/sys/fs/binfmt_misc/aarch64 ]; then" - post " builtin echo Unregistering accelerated handler" - post " builtin echo -1 > /proc/sys/fs/binfmt_misc/aarch64" - post "fi" - post "if [ ! -e /proc/sys/fs/binfmt_misc/aarch64 ]; then" - post " builtin echo Registering right binfmt handler" - post "builtin echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu/qemu-aarch64-binfmt:P' > /proc/sys/fs/binfmt_misc/register" - post "fi" - post "cat /proc/sys/fs/binfmt_misc/aarch64 | sed -e 's/mask/mask /'" - post "" - post "if [ -n $did_mount_it ]; then " - post " builtin echo "Unmounting again.";" - post " umount /proc/sys/fs/binfmt_misc" - post "fi" - post "" - post "ls /qemu | while read f ; do" - post " if [ -f /usr/bin/$f ] ; then" - post " builtin echo /usr/bin/$f already presents!" - post " else" - post " ln -s /qemu/$f /usr/bin/$f" - post " fi" - post "done" - post "" - post "echo All done" - post "" - post "# Fix up sysroot paths" - post "echo 0 >/proc/sys/vm/mmap_min_addr" - post "" - post "if [ -f /usr/bin/gcc ] ; then" - post " export GCCVER=$(LANG=C gcc --version | head -1 | sed -e "s/^.*gcc[^0-9]*\(\([0-9]*\.\)\+[0-9]*\).*$/\1/") " - post " # Create symlinks to files needed by native ld for the case if we want to use it instead of cross ld:" - post " for f in crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o ; do" - post " ln -s /usr/lib64/gcc/aarch64-tizen-linux/${GCCVER}/$f /usr/lib/$f;" - post " done" - post "fi" - post "" - post "HOST_ARCH=`echo -n %{_host_cpu} | sed -e 's/i.86/i586/'`" - post "ACCEL_DIR=/emul/$HOST_ARCH-for-aarch64" - post "mkdir -p %_bindir/../lib/bfd-plugins" - post "%_sbindir/update-alternatives --install \" - post " %_bindir/../lib/bfd-plugins/liblto_plugin_%{_arch}.so \" - post " liblto_plugin_%{_arch}.so \" - post " $ACCEL_DIR/usr/lib/gcc/aarch64-tizen-linux/${GCCVER}/liblto_plugin.so \" - post " 3" - post "" - postun "HOST_ARCH=`echo -n %{_host_cpu} | sed -e 's/i.86/i586/'`" - postun "ACCEL_DIR=/emul/$HOST_ARCH-for-aarch64" - postun "GCCVER=$(LANG=C gcc --version | head -1 | sed -e "s/^.*gcc[^0-9]*\(\([0-9]*\.\)\+[0-9]*\).*$/\1/") " - postun "%_sbindir/update-alternatives --remove \" - postun " liblto_plugin_%{_arch}.so \" - postun " $ACCEL_DIR/usr/lib/gcc/aarch64-tizen-linux/${GCCVER}/liblto_plugin.so" - +/ - config -/pkg-config$ + autoreqprov off + +/ + requires "gcc" + config -/pkg-config$ + post "#PLUGIN_POSTIN#" + postun "#PLUGIN_POSTUN#" diff --git a/packaging/gcc-wrapper.sh b/packaging/gcc-wrapper.sh deleted file mode 100755 index bb26666..0000000 --- a/packaging/gcc-wrapper.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# This script is used as a wrapper for GCC. It's purpose is to provide working -# cross-gcc for use inside Open Build Service. - -# Import variables from script, which is generated during the build of -# qemu-accel-* package (from spec-file): -source wrapper-config.sh - -# Get the name of executed file (it can be gcc, cc, g++, c++, ...): -COMPILER_NAME=`basename $0` - -NATIVE_COMPILER_NAME=/usr/bin/${COMPILER_NAME} - -#TODO: This part of script is legacy. Actually, it disables all cross-utilities, -# including cross toolchain, if variable LIBRARY_PATH is set, and runs native -# compiler. Do we really need to keep this? It came from OpenSUSE. -if [ "$LIBRARY_PATH" ]; then - mv ${CROSS_ACCELERATION_DIRECTORY}{,.bkp} - exec ${QEMU_NAME} ${NATIVE_COMPILER_NAME} "$@" -fi - -NATIVE_COMPILER_NAME="/usr/bin/${COMPILER_NAME}" -CROSS_COMPILER_NAME=${CROSS_ACCELERATION_DIRECTORY}/usr/bin/${COMPILER_NAME}.real - -# Run cross compiler, but set the name of process as native compiler: -exec -a ${NATIVE_COMPILER_NAME} ${CROSS_COMPILER_NAME} \ - "$@" \ - -B${CROSS_ACCELERATION_DIRECTORY}/${CROSS_BIN_PREFIX} \ - -B${CROSS_ACCELERATION_DIRECTORY}/${GCC_LIBEXEC_DIRECTORY} diff --git a/packaging/ld-wrapper.sh b/packaging/ld-wrapper.sh deleted file mode 100755 index 1991c5b..0000000 --- a/packaging/ld-wrapper.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# This script is used as a wrapper for Dynamic Linker (ld) from binutils -# package. It's purpose is to provide working cross-ld for use inside Open -# Build Service. - -# Import variables from script, which is generated during the build of -# qemu-accel-* package (from spec-file): -source wrapper-config.sh - -# Get the name of executed file (it can be ld, ld.bfd, ld.gold): -LD_NAME=`basename $0` - -# Set the namd of cross ld: -CROSS_LD_NAME="${CROSS_ACCELERATION_DIRECTORY}/${CROSS_BIN_PREFIX}/${LD_NAME}.real" - -# Set the name of native ld: -NATIVE_LD_NAME="${NATIVE_BIN_PREFIX}/${LD_NAME}" - -for i in "$@"; do - if [ "${i:0:10}" = "--sysroot=" ]; then - ${CROSS_LD_NAME} "$@" || ${QEMU_NAME} ${NATIVE_LD_NAME} -L${GCC_LIBEXEC_DIRECTORY} `echo "$@" | sed -e "s#${CROSS_ACCELERATION_DIRECTORY}##g;s#--sysroot=[^[:space:]]\+# #g"` - exit $? - fi -done - -${CROSS_LD_NAME} --sysroot=/ "$@" || ${QEMU_NAME} ${NATIVE_LD_NAME} -L${GCC_LIBEXEC_DIRECTORY} `echo "$@" | sed -e "s#${CROSS_ACCELERATION_DIRECTORY}##g;s#--sysroot=[^[:space:]]\+# #g"` diff --git a/packaging/pre_checkin.sh b/packaging/pre_checkin.sh index 48a4a35..b86717a 100755 --- a/packaging/pre_checkin.sh +++ b/packaging/pre_checkin.sh @@ -1,18 +1,14 @@ #!/bin/bash -cp qemu-accel.spec.in qemu-accel-armv7l.spec -sed -i qemu-accel-armv7l.spec \ - -e "s/EMULATED_ARCH_LONG/armv7l/g" \ - -e "s/EMULATED_ARCH_SHORT/arm/g" \ - -e "s/EMULATED_ARCH_SYNONIM/arm/g" \ - -e "s/EMULATED_ARCH_TRIPLE_SHORT/\%\{emulated_arch_short\}-tizen-linux-gnueabi/g" \ - -e "s/EMULATED_ARCH_TRIPLE_LONG/\%\{emulated_arch_long\}-tizen-linux-gnueabi/g" +# the script takes qemu-accel.spec and creates the qemu-accel-* packages +for arch in armv7l aarch64; do -cp qemu-accel.spec.in qemu-accel-aarch64.spec -sed -i qemu-accel-aarch64.spec \ - -e "s/EMULATED_ARCH_LONG/aarch64/g" \ - -e "s/EMULATED_ARCH_SHORT/aarch64/g" \ - -e "s/EMULATED_ARCH_SYNONIM/arm64/g" \ - -e "s/EMULATED_ARCH_TRIPLE_SHORT/\%\{emulated_arch_short\}-tizen-linux/g" \ - -e "s/EMULATED_ARCH_TRIPLE_LONG/\%\{emulated_arch_long\}-tizen-linux/g" + echo -n "Building package for $arch --> gcc-$arch ..." + + echo "%define cross $arch" > qemu-accel-${arch}.spec + echo "%define $arch 1" >> qemu-accel-${arch}.spec + echo "" >> qemu-accel-${arch}.spec + cat qemu-accel.spec >> qemu-accel-${arch}.spec + echo " done." +done diff --git a/packaging/qemu-accel-aarch64.spec b/packaging/qemu-accel-aarch64.spec index eca2b54..db9fb6a 100644 --- a/packaging/qemu-accel-aarch64.spec +++ b/packaging/qemu-accel-aarch64.spec @@ -1,7 +1,11 @@ +%define cross aarch64 +%define aarch64 1 + # # spec file for package qemu-accel-ARCH, where ARCH = armv7l or aarch64 # # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 Tizen # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,42 +16,27 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.tizen.org/ # -%define emulated_arch_long aarch64 -%define emulated_arch_short aarch64 -%define emulated_arch_synonim arm64 -%define emulated_arch_triple_short %{emulated_arch_short}-tizen-linux -%define emulated_arch_triple_long %{emulated_arch_long}-tizen-linux - -# Check whether macro "gcc_version" was defined via project config -%if 0%{?gcc_version} -%else -# If the macro was undefined, set it to this default value: -%define gcc_version 49 -%endif -%{expand:%%define gcc_version_dot %(echo -n "%{gcc_version}" | sed -e "s/\([0-9]\)\([0-9]\)/\1.\2/g")} -# Choose which gcc hijack method (if any) to use. -# Only select one of the two at a time! -%define hijack_gcc 1 +# arm +%define target_cpu %{cross} +%define target_abi %{?armv7l:eabi} +%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} +%define libdir %{_prefix}/lib%{?aarch64:64} +# default path in qemu +%define our_path /emul -Name: qemu-accel-%{emulated_arch_long} +Name: qemu-accel Version: 0.4 Release: 0 AutoReqProv: off -Source0: ld-wrapper.sh -Source1: gcc-wrapper.sh -BuildRequires: cross-%{emulated_arch_short}-binutils -BuildRequires: cross-%{emulated_arch_short}-binutils-gold -%if %hijack_gcc -BuildRequires: cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend -%endif +BuildRequires: gcc-%{cross} +BuildRequires: binutils-%{cross} #BuildRequires: expect BuildRequires: fdupes -BuildRequires: gcc-c++ BuildRequires: gettext-runtime BuildRequires: gettext-tools BuildRequires: m4 @@ -55,37 +44,19 @@ BuildRequires: m4 BuildRequires: vim BuildRequires: patchelf BuildRequires: rpmlint-mini -BuildRequires: qemu-linux-user -BuildRequires: elfutils -BuildRequires: libxslt-tools -BuildRequires: cmake -Requires: coreutils -Requires(post): update-alternatives -Requires(postun): update-alternatives +BuildRequires: elfutils +BuildRequires: libxslt-tools +BuildRequires: cmake +BuildRequires: gawk +BuildRequires: libstdc++ Summary: Native binaries for speeding up cross compile License: GPL-2.0 Group: Development/Cross Compilation -ExclusiveArch: x86_64 %ix86 +ExclusiveArch: x86_64 %{ix86} -# default path in qemu -%define HOST_ARCH %(echo -n "%{_host_cpu}" | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;") -%define our_path /emul/%{HOST_ARCH}-for-%{emulated_arch_short} -%ifarch %ix86 -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_i386 -%else -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_x86_64 -%endif -%define binaries_binutils addr2line ar as elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip -%define binaries_binutils_comma %(echo %{binaries_binutils} | sed -e "s/ /,/g") - -%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} -%define gcc_plugin_lto %{our_path}%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot}/liblto_plugin.so - %description -This package is used in %{emulated_arch_long} architecture builds using qemu to speed up builds +This package is used in %{cross} architecture builds using qemu to speed up builds with native binaries. This should not be installed on systems, it is just intended for qemu environments. @@ -94,71 +65,46 @@ This should not be installed on systems, it is just intended for qemu environmen %build %install +gcc_version=`gcc --version | sed -ne '1s/.* //p'` + binaries="%{_libdir}/libnsl.so.1 %{_libdir}/libnss_compat.so.2" # loaded via dlopen by glibc %ifarch %ix86 - LD="/lib/ld-linux.so.2" -%else -%ifarch x86_64 - LD="/lib64/ld-linux-x86-64.so.2" -%else - echo "ERROR unhandled arch" - exit 1 + LD="/%{_lib}/ld-linux.so.2" %endif +%ifarch x86_64 + LD="/%{_lib}/ld-linux-x86-64.so.2" %endif -# XXX this fails with the following error: -# /opt/testing/bin/python: error while loading shared libraries: libpython2.7.so.1.0: wrong ELF class: ELFCLASS32 - for executable in $LD \ - /usr/bin/bash \ - /usr/bin/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ + %{_bindir}/bash \ + %{_bindir}/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ %{_libdir}/rpm-plugins/exec.so \ %{_libdir}/{libdb-4.8.so,libdb_cxx-4.8.so} \ - /usr/bin/{tar,gzip,bzip2,xz,xzdec} \ - /usr/bin/{grep,sed} \ -%ifarch %ix86 + %{_bindir}/{tar,gzip,bzip2,xz,xzdec} \ + %{_bindir}/{grep,sed} \ %{_libdir}/libnssdbm3.so %{_libdir}/libsoftokn3.so %{_libdir}/libfreebl3.so \ -%else - /usr/lib64/libnssdbm3.so /usr/lib64/libsoftokn3.so /lib64/libfreebl3.so \ -%endif - /usr/bin/{cat,expr,mkdir,mv,rm,rmdir} \ - /usr/bin/{msgexec,msgfmt,msgcat,msgmerge} \ - /usr/bin/make \ - /usr/bin/m4 \ - /usr/bin/patch \ - /usr/bin/%{emulated_arch_triple_short}-{%{binaries_binutils_comma}} \ - /usr/bin/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ - /usr/bin/xsltproc \ - /usr/bin/{ccmake,cmake,cpack,ctest} + %{_bindir}/{cat,expr,mkdir,mv,rm,rmdir} \ + %{_bindir}/{msgexec,msgfmt,msgcat,msgmerge} \ + %{_bindir}/make \ + %{_bindir}/m4 \ + %{_bindir}/{awk,gawk} \ + %{_bindir}/patch \ + %{_bindir}/diff \ + %{_bindir}/echo \ + %{_bindir}/head \ + %{_bindir}/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ + %{_bindir}/xsltproc \ + %{_bindir}/{ccmake,cmake,cpack,ctest} \ + %{_bindir}/%{target_arch}-{addr2line,ar,as,c++filt,dwp,elfedit,gprof,ld,ld.bfd,ld.gold,nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ + %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-${gcc_version},gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ + %{libdir}/gcc/%{target_arch}/${gcc_version}/{cc1,cc1plus,collect2,f951,lto1,lto-wrapper,liblto_plugin.so} do binaries="$binaries $executable `ldd $executable | sed -n 's,.*=> \(/[^ ]*\) .*,\1,p'`" done -%if %hijack_gcc -# extract cross-compiler -mkdir -p cross-compiler-tmp -for executable in $(tar -C cross-compiler-tmp -xvzf /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz); do - if [ ! -d "cross-compiler-tmp/$executable" ] ; then - binaries="$binaries cross-compiler-tmp/$executable" - fi -done -%endif - - -%if %hijack_gcc -# Install -mkdir -p %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -cp -a /usr/share/icecream-envs/%{icecream_cross_env}.tar.gz \ - %buildroot%{our_path}/usr/share/icecream-envs -# And extract it for direct usage -tar xvz -C %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -f /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz -# It needs a tmp working directory which is writable -install -d -m0755 %buildroot%{our_path}/usr/share/icecream-envs -%endif - for binary in $binaries do - outfile=%buildroot%{our_path}$(echo $binary | sed 's:cross-compiler-tmp::;s:/opt/cross/%{emulated_arch_triple_long}:/usr:') + outfile=%{buildroot}/%{our_path}/$binary [ -f $outfile ] && continue mkdir -p ${outfile%/*} cp -aL $binary $outfile @@ -171,7 +117,7 @@ do fi rm -f $outfile.data [ "$binary" == "$LD" ] && continue - patchelf --debug --set-rpath "%our_path/%_lib:%our_path%_libdir" $outfile + patchelf --debug --set-rpath "%{our_path}/%{libdir}" $outfile # not all binaries have an .interp section if patchelf --print-interpreter $outfile; then patchelf --debug --set-interpreter %{our_path}$LD $outfile @@ -179,143 +125,85 @@ do done # create symlinks for bash -mkdir -p "%{buildroot}%{our_path}/bin/" -mkdir -p "%{buildroot}%{our_path}/usr/bin/" -ln -sf ../usr/bin/bash "%{buildroot}%{our_path}/bin/sh" -ln -sf ../../bin/bash "%{buildroot}%{our_path}/usr/bin/sh" +ln -s usr/bin "%{buildroot}%{our_path}/bin" +ln -sf bash "%{buildroot}%{our_path}/usr/bin/sh" -# binutils needs to be exposed in /usr/bin -if [ ! -d %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin ] ; then - mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin +# 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 i in %{binaries_binutils} ; do - if [ -f %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i ] ; then - mv %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/$i - if [ -f %{buildroot}%{our_path}/%{_bindir}/$i ] ; then - rm %{buildroot}%{our_path}/%{_bindir}/$i - fi - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/$i - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i - 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 -pushd %{buildroot}%{our_path} && ln -s usr/bin && popd - -%if %hijack_gcc -# create symlinks for lib64 / lib mappings (gcc!) -mkdir -p "%{buildroot}%{our_path}/usr/lib/" -# binutils secondary directories -mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/ -ln -sf ../bin %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/bin - -%ifarch %ix86 -ln -sf ../lib/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%else -ln -sf ../lib64/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%endif - -# Enable wrapper for GCC compiler: -mv %{buildroot}%{our_path}/usr/bin/gcc{,.real} -mv %{buildroot}%{our_path}/usr/bin/g++{,.real} -cp %{SOURCE1} %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -chmod 755 %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh - -# Create symlinks for different synonims of compiler names: -for compiler in gcc cc g++ c++ ; do - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler} - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot} - ln -sf ${compiler}.real %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot}.real +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 + +# 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 +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$binary %{buildroot}%{our_path}%{_bindir}/$binary done -# g++ can also be called c++ -ln -sf g++.real "%{buildroot}%{our_path}/usr/bin/c++.real" -# gcc can also be called cc -ln -sf gcc.real "%{buildroot}%{our_path}/usr/bin/cc.real" - - -# allow abuild to do the mv -chmod 755 %{buildroot}/emul -# make cross ld work with emulated compilers -cp %{SOURCE0} %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -for LD_NAME in ld ld.gold ; do - mv %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME}{,.real} - ln -s ld-wrapper.sh %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME} +mkdir -p %{buildroot}/%{our_path}/%{_prefix}/%{target_arch}/bin +for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do + ln -sf %{our_path}%{_bindir}/$binary %{buildroot}%{our_path}%{_prefix}/%{target_arch}/bin/$binary done -# Write config that will be used by wrappers at run-time. -echo ' -QEMU_NAME=/usr/bin/qemu-%{emulated_arch_synonim} -CROSS_ACCELERATION_DIRECTORY=%{our_path} -GCC_LIBEXEC_DIRECTORY=%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot} -CROSS_BIN_PREFIX=/usr/%{emulated_arch_triple_short}/bin -NATIVE_BIN_PREFIX=/usr/%{emulated_arch_triple_long}/bin -' > %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh -ln -s %{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh %{buildroot}%{our_path}/usr/bin/wrapper-config.sh - -chmod 755 %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -%if "%{emulated_arch_short}" == "arm" -# -# as is not writing right EABI ELF header inside of arm environment for unknown -# reason. -# TODO: Still the case (2014-12-11). -# -mv %{buildroot}%{our_path}/usr/bin/as{,.real} -echo '#!/bin/bash -exec -a /usr/bin/as %{our_path}/usr/bin/as.real -meabi=5 "$@" -' > %{buildroot}%{our_path}/usr/bin/as -chmod +x %{buildroot}%{our_path}/usr/bin/as -%endif +# rename gcc binaries +for bin in c++ g++ cpp gcc gcc-ar gcc-nm gcc-ranlib gfortran +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin %{buildroot}/%{our_path}%{_bindir}/$bin + ln -s $bin %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin +done +mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-gcov %{buildroot}%{our_path}%{_bindir}/gcov +ln -s gcc %{buildroot}%{our_path}/%{_bindir}/cc -# To support gcc sysroot -mkdir -p %{buildroot}/usr/%{emulated_arch_triple_long} -ln -sf .. %{buildroot}/usr/%{emulated_arch_triple_long}/usr -ln -sf ../include %{buildroot}/usr/%{emulated_arch_triple_long}/include +# rpmbuild when generating 'requires' tag for gobject-introspection binaries +# selects (64-bit) suffix for libs based on ${HOSTTYPE} bash variable +# so we replace x86_64 to armv7l to avoid bogus dependencies +%ifarch x86_64 +%{?armv7l: +sed -i -e "s/x86_64/armv7l/g" %{buildroot}%{our_path}%{_bindir}/bash +} %endif -# Make QEMU available through /qemu -mkdir %buildroot/qemu -cp -L /usr/bin/qemu-%{emulated_arch_short}{,-binfmt} %buildroot/qemu/ -mkdir -p %buildroot/usr/bin/ - -if [[ %{emulated_arch_short} != %{emulated_arch_synonim} ]] ; then - ln -sf /qemu/qemu-%{emulated_arch_short} %buildroot/qemu/qemu-%{emulated_arch_synonim} - ln -sf /qemu/qemu-%{emulated_arch_short}-binfmt %buildroot/qemu/qemu-%{emulated_arch_synonim}-binfmt -fi - - -export NO_BRP_CHECK_RPATH="true" +# create symlinks for gcc build (CC_FOR_TARGET) +mkdir -p %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc +for binary in as cpp gcc-ar gcc-nm gcc-ranlib gcov gfortran nm +do + ln -sf %{our_path}%{_bindir}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +for binary in cc1 cc1plus collect2 f951 lto1 lto-wrapper +do + ln -sf %{our_path}/usr/lib/gcc/%{target_arch}/${gcc_version}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +ln -sf %{our_path}%{_bindir}/gcc %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xgcc +ln -sf %{our_path}%{_bindir}/g++ %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xg++ -rm -rf %{buildroot}/%{our_path}/bin -ln -s %{our_path}/usr/bin %{buildroot}/%{our_path}/bin -rm -rf %{buildroot}/%{our_path}/sbin -ln -s %{our_path}/usr/sbin %{buildroot}/%{our_path}/sbin +# support /lib/cpp +ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmquery -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmverify +# 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 -mkdir -p "%{buildroot}%{bfd_plugin_dir}" -touch "%{buildroot}%{bfd_plugin_lto}" +# allow build of baselibs.conf +sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf %post ldconfig -"%_sbindir/update-alternatives" --install \ - "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 3 %postun ldconfig -"%_sbindir/update-alternatives" --remove %{bfd_plugin_lto_name} "%{gcc_plugin_lto}" + %files %defattr(-,root,root) -%dir /usr/%{emulated_arch_triple_long} -/usr/%{emulated_arch_triple_long}/usr -/usr/%{emulated_arch_triple_long}/include -/emul -/qemu -%ghost %{bfd_plugin_lto} +%{our_path} %changelog diff --git a/packaging/qemu-accel-armv7l.spec b/packaging/qemu-accel-armv7l.spec index f2aa79f..b41cb8b 100644 --- a/packaging/qemu-accel-armv7l.spec +++ b/packaging/qemu-accel-armv7l.spec @@ -1,7 +1,11 @@ +%define cross armv7l +%define armv7l 1 + # # spec file for package qemu-accel-ARCH, where ARCH = armv7l or aarch64 # # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 Tizen # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,42 +16,27 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.tizen.org/ # -%define emulated_arch_long armv7l -%define emulated_arch_short arm -%define emulated_arch_synonim arm -%define emulated_arch_triple_short %{emulated_arch_short}-tizen-linux-gnueabi -%define emulated_arch_triple_long %{emulated_arch_long}-tizen-linux-gnueabi - -# Check whether macro "gcc_version" was defined via project config -%if 0%{?gcc_version} -%else -# If the macro was undefined, set it to this default value: -%define gcc_version 49 -%endif -%{expand:%%define gcc_version_dot %(echo -n "%{gcc_version}" | sed -e "s/\([0-9]\)\([0-9]\)/\1.\2/g")} -# Choose which gcc hijack method (if any) to use. -# Only select one of the two at a time! -%define hijack_gcc 1 +# arm +%define target_cpu %{cross} +%define target_abi %{?armv7l:eabi} +%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} +%define libdir %{_prefix}/lib%{?aarch64:64} +# default path in qemu +%define our_path /emul -Name: qemu-accel-%{emulated_arch_long} +Name: qemu-accel Version: 0.4 Release: 0 AutoReqProv: off -Source0: ld-wrapper.sh -Source1: gcc-wrapper.sh -BuildRequires: cross-%{emulated_arch_short}-binutils -BuildRequires: cross-%{emulated_arch_short}-binutils-gold -%if %hijack_gcc -BuildRequires: cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend -%endif +BuildRequires: gcc-%{cross} +BuildRequires: binutils-%{cross} #BuildRequires: expect BuildRequires: fdupes -BuildRequires: gcc-c++ BuildRequires: gettext-runtime BuildRequires: gettext-tools BuildRequires: m4 @@ -55,37 +44,19 @@ BuildRequires: m4 BuildRequires: vim BuildRequires: patchelf BuildRequires: rpmlint-mini -BuildRequires: qemu-linux-user -BuildRequires: elfutils -BuildRequires: libxslt-tools -BuildRequires: cmake -Requires: coreutils -Requires(post): update-alternatives -Requires(postun): update-alternatives +BuildRequires: elfutils +BuildRequires: libxslt-tools +BuildRequires: cmake +BuildRequires: gawk +BuildRequires: libstdc++ Summary: Native binaries for speeding up cross compile License: GPL-2.0 Group: Development/Cross Compilation -ExclusiveArch: x86_64 %ix86 +ExclusiveArch: x86_64 %{ix86} -# default path in qemu -%define HOST_ARCH %(echo -n "%{_host_cpu}" | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;") -%define our_path /emul/%{HOST_ARCH}-for-%{emulated_arch_short} -%ifarch %ix86 -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_i386 -%else -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_x86_64 -%endif -%define binaries_binutils addr2line ar as elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip -%define binaries_binutils_comma %(echo %{binaries_binutils} | sed -e "s/ /,/g") - -%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} -%define gcc_plugin_lto %{our_path}%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot}/liblto_plugin.so - %description -This package is used in %{emulated_arch_long} architecture builds using qemu to speed up builds +This package is used in %{cross} architecture builds using qemu to speed up builds with native binaries. This should not be installed on systems, it is just intended for qemu environments. @@ -94,71 +65,46 @@ This should not be installed on systems, it is just intended for qemu environmen %build %install +gcc_version=`gcc --version | sed -ne '1s/.* //p'` + binaries="%{_libdir}/libnsl.so.1 %{_libdir}/libnss_compat.so.2" # loaded via dlopen by glibc %ifarch %ix86 - LD="/lib/ld-linux.so.2" -%else -%ifarch x86_64 - LD="/lib64/ld-linux-x86-64.so.2" -%else - echo "ERROR unhandled arch" - exit 1 + LD="/%{_lib}/ld-linux.so.2" %endif +%ifarch x86_64 + LD="/%{_lib}/ld-linux-x86-64.so.2" %endif -# XXX this fails with the following error: -# /opt/testing/bin/python: error while loading shared libraries: libpython2.7.so.1.0: wrong ELF class: ELFCLASS32 - for executable in $LD \ - /usr/bin/bash \ - /usr/bin/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ + %{_bindir}/bash \ + %{_bindir}/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ %{_libdir}/rpm-plugins/exec.so \ %{_libdir}/{libdb-4.8.so,libdb_cxx-4.8.so} \ - /usr/bin/{tar,gzip,bzip2,xz,xzdec} \ - /usr/bin/{grep,sed} \ -%ifarch %ix86 + %{_bindir}/{tar,gzip,bzip2,xz,xzdec} \ + %{_bindir}/{grep,sed} \ %{_libdir}/libnssdbm3.so %{_libdir}/libsoftokn3.so %{_libdir}/libfreebl3.so \ -%else - /usr/lib64/libnssdbm3.so /usr/lib64/libsoftokn3.so /lib64/libfreebl3.so \ -%endif - /usr/bin/{cat,expr,mkdir,mv,rm,rmdir} \ - /usr/bin/{msgexec,msgfmt,msgcat,msgmerge} \ - /usr/bin/make \ - /usr/bin/m4 \ - /usr/bin/patch \ - /usr/bin/%{emulated_arch_triple_short}-{%{binaries_binutils_comma}} \ - /usr/bin/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ - /usr/bin/xsltproc \ - /usr/bin/{ccmake,cmake,cpack,ctest} + %{_bindir}/{cat,expr,mkdir,mv,rm,rmdir} \ + %{_bindir}/{msgexec,msgfmt,msgcat,msgmerge} \ + %{_bindir}/make \ + %{_bindir}/m4 \ + %{_bindir}/{awk,gawk} \ + %{_bindir}/patch \ + %{_bindir}/diff \ + %{_bindir}/echo \ + %{_bindir}/head \ + %{_bindir}/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ + %{_bindir}/xsltproc \ + %{_bindir}/{ccmake,cmake,cpack,ctest} \ + %{_bindir}/%{target_arch}-{addr2line,ar,as,c++filt,dwp,elfedit,gprof,ld,ld.bfd,ld.gold,nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ + %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-${gcc_version},gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ + %{libdir}/gcc/%{target_arch}/${gcc_version}/{cc1,cc1plus,collect2,f951,lto1,lto-wrapper,liblto_plugin.so} do binaries="$binaries $executable `ldd $executable | sed -n 's,.*=> \(/[^ ]*\) .*,\1,p'`" done -%if %hijack_gcc -# extract cross-compiler -mkdir -p cross-compiler-tmp -for executable in $(tar -C cross-compiler-tmp -xvzf /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz); do - if [ ! -d "cross-compiler-tmp/$executable" ] ; then - binaries="$binaries cross-compiler-tmp/$executable" - fi -done -%endif - - -%if %hijack_gcc -# Install -mkdir -p %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -cp -a /usr/share/icecream-envs/%{icecream_cross_env}.tar.gz \ - %buildroot%{our_path}/usr/share/icecream-envs -# And extract it for direct usage -tar xvz -C %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -f /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz -# It needs a tmp working directory which is writable -install -d -m0755 %buildroot%{our_path}/usr/share/icecream-envs -%endif - for binary in $binaries do - outfile=%buildroot%{our_path}$(echo $binary | sed 's:cross-compiler-tmp::;s:/opt/cross/%{emulated_arch_triple_long}:/usr:') + outfile=%{buildroot}/%{our_path}/$binary [ -f $outfile ] && continue mkdir -p ${outfile%/*} cp -aL $binary $outfile @@ -171,7 +117,7 @@ do fi rm -f $outfile.data [ "$binary" == "$LD" ] && continue - patchelf --debug --set-rpath "%our_path/%_lib:%our_path%_libdir" $outfile + patchelf --debug --set-rpath "%{our_path}/%{libdir}" $outfile # not all binaries have an .interp section if patchelf --print-interpreter $outfile; then patchelf --debug --set-interpreter %{our_path}$LD $outfile @@ -179,143 +125,85 @@ do done # create symlinks for bash -mkdir -p "%{buildroot}%{our_path}/bin/" -mkdir -p "%{buildroot}%{our_path}/usr/bin/" -ln -sf ../usr/bin/bash "%{buildroot}%{our_path}/bin/sh" -ln -sf ../../bin/bash "%{buildroot}%{our_path}/usr/bin/sh" +ln -s usr/bin "%{buildroot}%{our_path}/bin" +ln -sf bash "%{buildroot}%{our_path}/usr/bin/sh" -# binutils needs to be exposed in /usr/bin -if [ ! -d %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin ] ; then - mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin +# 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 i in %{binaries_binutils} ; do - if [ -f %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i ] ; then - mv %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/$i - if [ -f %{buildroot}%{our_path}/%{_bindir}/$i ] ; then - rm %{buildroot}%{our_path}/%{_bindir}/$i - fi - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/$i - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i - 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 -pushd %{buildroot}%{our_path} && ln -s usr/bin && popd - -%if %hijack_gcc -# create symlinks for lib64 / lib mappings (gcc!) -mkdir -p "%{buildroot}%{our_path}/usr/lib/" -# binutils secondary directories -mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/ -ln -sf ../bin %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/bin - -%ifarch %ix86 -ln -sf ../lib/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%else -ln -sf ../lib64/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%endif - -# Enable wrapper for GCC compiler: -mv %{buildroot}%{our_path}/usr/bin/gcc{,.real} -mv %{buildroot}%{our_path}/usr/bin/g++{,.real} -cp %{SOURCE1} %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -chmod 755 %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh - -# Create symlinks for different synonims of compiler names: -for compiler in gcc cc g++ c++ ; do - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler} - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot} - ln -sf ${compiler}.real %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot}.real +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 + +# 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 +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$binary %{buildroot}%{our_path}%{_bindir}/$binary done -# g++ can also be called c++ -ln -sf g++.real "%{buildroot}%{our_path}/usr/bin/c++.real" -# gcc can also be called cc -ln -sf gcc.real "%{buildroot}%{our_path}/usr/bin/cc.real" - - -# allow abuild to do the mv -chmod 755 %{buildroot}/emul -# make cross ld work with emulated compilers -cp %{SOURCE0} %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -for LD_NAME in ld ld.gold ; do - mv %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME}{,.real} - ln -s ld-wrapper.sh %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME} +mkdir -p %{buildroot}/%{our_path}/%{_prefix}/%{target_arch}/bin +for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do + ln -sf %{our_path}%{_bindir}/$binary %{buildroot}%{our_path}%{_prefix}/%{target_arch}/bin/$binary done -# Write config that will be used by wrappers at run-time. -echo ' -QEMU_NAME=/usr/bin/qemu-%{emulated_arch_synonim} -CROSS_ACCELERATION_DIRECTORY=%{our_path} -GCC_LIBEXEC_DIRECTORY=%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot} -CROSS_BIN_PREFIX=/usr/%{emulated_arch_triple_short}/bin -NATIVE_BIN_PREFIX=/usr/%{emulated_arch_triple_long}/bin -' > %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh -ln -s %{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh %{buildroot}%{our_path}/usr/bin/wrapper-config.sh - -chmod 755 %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -%if "%{emulated_arch_short}" == "arm" -# -# as is not writing right EABI ELF header inside of arm environment for unknown -# reason. -# TODO: Still the case (2014-12-11). -# -mv %{buildroot}%{our_path}/usr/bin/as{,.real} -echo '#!/bin/bash -exec -a /usr/bin/as %{our_path}/usr/bin/as.real -meabi=5 "$@" -' > %{buildroot}%{our_path}/usr/bin/as -chmod +x %{buildroot}%{our_path}/usr/bin/as -%endif +# rename gcc binaries +for bin in c++ g++ cpp gcc gcc-ar gcc-nm gcc-ranlib gfortran +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin %{buildroot}/%{our_path}%{_bindir}/$bin + ln -s $bin %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin +done +mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-gcov %{buildroot}%{our_path}%{_bindir}/gcov +ln -s gcc %{buildroot}%{our_path}/%{_bindir}/cc -# To support gcc sysroot -mkdir -p %{buildroot}/usr/%{emulated_arch_triple_long} -ln -sf .. %{buildroot}/usr/%{emulated_arch_triple_long}/usr -ln -sf ../include %{buildroot}/usr/%{emulated_arch_triple_long}/include +# rpmbuild when generating 'requires' tag for gobject-introspection binaries +# selects (64-bit) suffix for libs based on ${HOSTTYPE} bash variable +# so we replace x86_64 to armv7l to avoid bogus dependencies +%ifarch x86_64 +%{?armv7l: +sed -i -e "s/x86_64/armv7l/g" %{buildroot}%{our_path}%{_bindir}/bash +} %endif -# Make QEMU available through /qemu -mkdir %buildroot/qemu -cp -L /usr/bin/qemu-%{emulated_arch_short}{,-binfmt} %buildroot/qemu/ -mkdir -p %buildroot/usr/bin/ - -if [[ %{emulated_arch_short} != %{emulated_arch_synonim} ]] ; then - ln -sf /qemu/qemu-%{emulated_arch_short} %buildroot/qemu/qemu-%{emulated_arch_synonim} - ln -sf /qemu/qemu-%{emulated_arch_short}-binfmt %buildroot/qemu/qemu-%{emulated_arch_synonim}-binfmt -fi - - -export NO_BRP_CHECK_RPATH="true" +# create symlinks for gcc build (CC_FOR_TARGET) +mkdir -p %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc +for binary in as cpp gcc-ar gcc-nm gcc-ranlib gcov gfortran nm +do + ln -sf %{our_path}%{_bindir}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +for binary in cc1 cc1plus collect2 f951 lto1 lto-wrapper +do + ln -sf %{our_path}/usr/lib/gcc/%{target_arch}/${gcc_version}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +ln -sf %{our_path}%{_bindir}/gcc %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xgcc +ln -sf %{our_path}%{_bindir}/g++ %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xg++ -rm -rf %{buildroot}/%{our_path}/bin -ln -s %{our_path}/usr/bin %{buildroot}/%{our_path}/bin -rm -rf %{buildroot}/%{our_path}/sbin -ln -s %{our_path}/usr/sbin %{buildroot}/%{our_path}/sbin +# support /lib/cpp +ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmquery -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmverify +# 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 -mkdir -p "%{buildroot}%{bfd_plugin_dir}" -touch "%{buildroot}%{bfd_plugin_lto}" +# allow build of baselibs.conf +sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf %post ldconfig -"%_sbindir/update-alternatives" --install \ - "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 3 %postun ldconfig -"%_sbindir/update-alternatives" --remove %{bfd_plugin_lto_name} "%{gcc_plugin_lto}" + %files %defattr(-,root,root) -%dir /usr/%{emulated_arch_triple_long} -/usr/%{emulated_arch_triple_long}/usr -/usr/%{emulated_arch_triple_long}/include -/emul -/qemu -%ghost %{bfd_plugin_lto} +%{our_path} %changelog diff --git a/packaging/qemu-accel.spec b/packaging/qemu-accel.spec new file mode 100644 index 0000000..94915b3 --- /dev/null +++ b/packaging/qemu-accel.spec @@ -0,0 +1,206 @@ +# +# spec file for package qemu-accel-ARCH, where ARCH = armv7l or aarch64 +# +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 Tizen +# +# 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 http://bugs.tizen.org/ +# + + +# arm +%define target_cpu %{cross} +%define target_abi %{?armv7l:eabi} +%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} +%define libdir %{_prefix}/lib%{?aarch64:64} + +# default path in qemu +%define our_path /emul + +Name: qemu-accel +Version: 0.4 +Release: 0 +AutoReqProv: off +BuildRequires: gcc-%{cross} +BuildRequires: binutils-%{cross} +#BuildRequires: expect +BuildRequires: fdupes +BuildRequires: gettext-runtime +BuildRequires: gettext-tools +BuildRequires: m4 +# required for xxd +BuildRequires: vim +BuildRequires: patchelf +BuildRequires: rpmlint-mini +BuildRequires: elfutils +BuildRequires: libxslt-tools +BuildRequires: cmake +BuildRequires: gawk +BuildRequires: libstdc++ +Summary: Native binaries for speeding up cross compile +License: GPL-2.0 +Group: Development/Cross Compilation +ExclusiveArch: x86_64 %{ix86} + + +%description +This package is used in %{cross} architecture builds using qemu to speed up builds +with native binaries. +This should not be installed on systems, it is just intended for qemu environments. + +%prep + +%build + +%install +gcc_version=`gcc --version | sed -ne '1s/.* //p'` + +binaries="%{_libdir}/libnsl.so.1 %{_libdir}/libnss_compat.so.2" # loaded via dlopen by glibc +%ifarch %ix86 + LD="/%{_lib}/ld-linux.so.2" +%endif +%ifarch x86_64 + LD="/%{_lib}/ld-linux-x86-64.so.2" +%endif + +for executable in $LD \ + %{_bindir}/bash \ + %{_bindir}/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ + %{_libdir}/rpm-plugins/exec.so \ + %{_libdir}/{libdb-4.8.so,libdb_cxx-4.8.so} \ + %{_bindir}/{tar,gzip,bzip2,xz,xzdec} \ + %{_bindir}/{grep,sed} \ + %{_libdir}/libnssdbm3.so %{_libdir}/libsoftokn3.so %{_libdir}/libfreebl3.so \ + %{_bindir}/{cat,expr,mkdir,mv,rm,rmdir} \ + %{_bindir}/{msgexec,msgfmt,msgcat,msgmerge} \ + %{_bindir}/make \ + %{_bindir}/m4 \ + %{_bindir}/{awk,gawk} \ + %{_bindir}/patch \ + %{_bindir}/diff \ + %{_bindir}/echo \ + %{_bindir}/head \ + %{_bindir}/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ + %{_bindir}/xsltproc \ + %{_bindir}/{ccmake,cmake,cpack,ctest} \ + %{_bindir}/%{target_arch}-{addr2line,ar,as,c++filt,dwp,elfedit,gprof,ld,ld.bfd,ld.gold,nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ + %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-${gcc_version},gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ + %{libdir}/gcc/%{target_arch}/${gcc_version}/{cc1,cc1plus,collect2,f951,lto1,lto-wrapper,liblto_plugin.so} +do + binaries="$binaries $executable `ldd $executable | sed -n 's,.*=> \(/[^ ]*\) .*,\1,p'`" +done + +for binary in $binaries +do + outfile=%{buildroot}/%{our_path}/$binary + [ -f $outfile ] && 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 "%{HOST_ARCH}"$outfile.data; then + echo "ERROR file $binary leaks host information into the guest" + exit 1 + fi + rm -f $outfile.data + [ "$binary" == "$LD" ] && continue + patchelf --debug --set-rpath "%{our_path}/%{libdir}" $outfile +# not all binaries have an .interp section + if patchelf --print-interpreter $outfile; then + patchelf --debug --set-interpreter %{our_path}$LD $outfile + fi +done + +# 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 + +# 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 +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$binary %{buildroot}%{our_path}%{_bindir}/$binary +done + +mkdir -p %{buildroot}/%{our_path}/%{_prefix}/%{target_arch}/bin +for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do + ln -sf %{our_path}%{_bindir}/$binary %{buildroot}%{our_path}%{_prefix}/%{target_arch}/bin/$binary +done + +# rename gcc binaries +for bin in c++ g++ cpp gcc gcc-ar gcc-nm gcc-ranlib gfortran +do + mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin %{buildroot}/%{our_path}%{_bindir}/$bin + ln -s $bin %{buildroot}%{our_path}%{_bindir}/%{target_arch}-$bin +done +mv %{buildroot}%{our_path}%{_bindir}/%{target_arch}-gcov %{buildroot}%{our_path}%{_bindir}/gcov +ln -s gcc %{buildroot}%{our_path}/%{_bindir}/cc + +# rpmbuild when generating 'requires' tag for gobject-introspection binaries +# selects (64-bit) suffix for libs based on ${HOSTTYPE} bash variable +# so we replace x86_64 to armv7l to avoid bogus dependencies +%ifarch x86_64 +%{?armv7l: +sed -i -e "s/x86_64/armv7l/g" %{buildroot}%{our_path}%{_bindir}/bash +} +%endif + +# create symlinks for gcc build (CC_FOR_TARGET) +mkdir -p %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc +for binary in as cpp gcc-ar gcc-nm gcc-ranlib gcov gfortran nm +do + ln -sf %{our_path}%{_bindir}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +for binary in cc1 cc1plus collect2 f951 lto1 lto-wrapper +do + ln -sf %{our_path}/usr/lib/gcc/%{target_arch}/${gcc_version}/${binary} %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/${binary} +done +ln -sf %{our_path}%{_bindir}/gcc %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xgcc +ln -sf %{our_path}%{_bindir}/g++ %{buildroot}%{our_path}/home/abuild/rpmbuild/BUILD/gcc-${gcc_version}/obj/gcc/xg++ + +# support /lib/cpp +ln -sf %{our_path}%{_bindir}/cpp %{buildroot}%{our_path}/usr/lib/cpp + +# 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 + +# allow build of baselibs.conf +sed -i -e "/targettype %{cross} block!/d" %{_sourcedir}/baselibs.conf + +%post +ldconfig + +%postun +ldconfig + + +%files +%defattr(-,root,root) +%{our_path} + +%changelog diff --git a/packaging/qemu-accel.spec.in b/packaging/qemu-accel.spec.in deleted file mode 100644 index 860c366..0000000 --- a/packaging/qemu-accel.spec.in +++ /dev/null @@ -1,321 +0,0 @@ -# -# spec file for package qemu-accel-ARCH, where ARCH = armv7l or aarch64 -# -# Copyright (c) 2012 SUSE LINUX Products 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 http://bugs.opensuse.org/ -# - -%define emulated_arch_long EMULATED_ARCH_LONG -%define emulated_arch_short EMULATED_ARCH_SHORT -%define emulated_arch_synonim EMULATED_ARCH_SYNONIM -%define emulated_arch_triple_short EMULATED_ARCH_TRIPLE_SHORT -%define emulated_arch_triple_long EMULATED_ARCH_TRIPLE_LONG - -# Check whether macro "gcc_version" was defined via project config -%if 0%{?gcc_version} -%else -# If the macro was undefined, set it to this default value: -%define gcc_version 49 -%endif -%{expand:%%define gcc_version_dot %(echo -n "%{gcc_version}" | sed -e "s/\([0-9]\)\([0-9]\)/\1.\2/g")} - -# Choose which gcc hijack method (if any) to use. -# Only select one of the two at a time! -%define hijack_gcc 1 - - -Name: qemu-accel-%{emulated_arch_long} -Version: 0.4 -Release: 0 -AutoReqProv: off -Source0: ld-wrapper.sh -Source1: gcc-wrapper.sh -BuildRequires: cross-%{emulated_arch_short}-binutils -BuildRequires: cross-%{emulated_arch_short}-binutils-gold -%if %hijack_gcc -BuildRequires: cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend -%endif -#BuildRequires: expect -BuildRequires: fdupes -BuildRequires: gcc-c++ -BuildRequires: gettext-runtime -BuildRequires: gettext-tools -BuildRequires: m4 -# required for xxd -BuildRequires: vim -BuildRequires: patchelf -BuildRequires: rpmlint-mini -BuildRequires: qemu-linux-user -BuildRequires: elfutils -BuildRequires: libxslt-tools -BuildRequires: cmake -Requires: coreutils -Requires(post): update-alternatives -Requires(postun): update-alternatives -Summary: Native binaries for speeding up cross compile -License: GPL-2.0 -Group: Development/Cross Compilation -ExclusiveArch: x86_64 %ix86 - - -# default path in qemu -%define HOST_ARCH %(echo -n "%{_host_cpu}" | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;") -%define our_path /emul/%{HOST_ARCH}-for-%{emulated_arch_short} -%ifarch %ix86 -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_i386 -%else -%define icecream_cross_env cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_x86_64 -%endif -%define binaries_binutils addr2line ar as elfedit gprof ld ld.bfd ld.gold nm objcopy objdump ranlib readelf size strings strip -%define binaries_binutils_comma %(echo %{binaries_binutils} | sed -e "s/ /,/g") - -%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} -%define gcc_plugin_lto %{our_path}%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot}/liblto_plugin.so - -%description -This package is used in %{emulated_arch_long} architecture builds using qemu to speed up builds -with native binaries. -This should not be installed on systems, it is just intended for qemu environments. - -%prep - -%build - -%install -binaries="%{_libdir}/libnsl.so.1 %{_libdir}/libnss_compat.so.2" # loaded via dlopen by glibc -%ifarch %ix86 - LD="/lib/ld-linux.so.2" -%else -%ifarch x86_64 - LD="/lib64/ld-linux-x86-64.so.2" -%else - echo "ERROR unhandled arch" - exit 1 -%endif -%endif - -# XXX this fails with the following error: -# /opt/testing/bin/python: error while loading shared libraries: libpython2.7.so.1.0: wrong ELF class: ELFCLASS32 - -for executable in $LD \ - /usr/bin/bash \ - /usr/bin/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec} \ - %{_libdir}/rpm-plugins/exec.so \ - %{_libdir}/{libdb-4.8.so,libdb_cxx-4.8.so} \ - /usr/bin/{tar,gzip,bzip2,xz,xzdec} \ - /usr/bin/{grep,sed} \ -%ifarch %ix86 - %{_libdir}/libnssdbm3.so %{_libdir}/libsoftokn3.so %{_libdir}/libfreebl3.so \ -%else - /usr/lib64/libnssdbm3.so /usr/lib64/libsoftokn3.so /lib64/libfreebl3.so \ -%endif - /usr/bin/{cat,expr,mkdir,mv,rm,rmdir} \ - /usr/bin/{msgexec,msgfmt,msgcat,msgmerge} \ - /usr/bin/make \ - /usr/bin/m4 \ - /usr/bin/patch \ - /usr/bin/%{emulated_arch_triple_short}-{%{binaries_binutils_comma}} \ - /usr/bin/eu-{addr2line,ar,elfcmp,elflint,findtextrel,ld,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ - /usr/bin/xsltproc \ - /usr/bin/{ccmake,cmake,cpack,ctest} -do - binaries="$binaries $executable `ldd $executable | sed -n 's,.*=> \(/[^ ]*\) .*,\1,p'`" -done - -%if %hijack_gcc -# extract cross-compiler -mkdir -p cross-compiler-tmp -for executable in $(tar -C cross-compiler-tmp -xvzf /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz); do - if [ ! -d "cross-compiler-tmp/$executable" ] ; then - binaries="$binaries cross-compiler-tmp/$executable" - fi -done -%endif - - -%if %hijack_gcc -# Install -mkdir -p %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -cp -a /usr/share/icecream-envs/%{icecream_cross_env}.tar.gz \ - %buildroot%{our_path}/usr/share/icecream-envs -# And extract it for direct usage -tar xvz -C %buildroot%{our_path}/usr/share/icecream-envs/%{icecream_cross_env} -f /usr/share/icecream-envs/cross-%{emulated_arch_long}-gcc%{gcc_version}-icecream-backend_*.tar.gz -# It needs a tmp working directory which is writable -install -d -m0755 %buildroot%{our_path}/usr/share/icecream-envs -%endif - -for binary in $binaries -do - outfile=%buildroot%{our_path}$(echo $binary | sed 's:cross-compiler-tmp::;s:/opt/cross/%{emulated_arch_triple_long}:/usr:') - [ -f $outfile ] && 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 "%{HOST_ARCH}"$outfile.data; then - echo "ERROR file $binary leaks host information into the guest" - exit 1 - fi - rm -f $outfile.data - [ "$binary" == "$LD" ] && continue - patchelf --debug --set-rpath "%our_path/%_lib:%our_path%_libdir" $outfile -# not all binaries have an .interp section - if patchelf --print-interpreter $outfile; then - patchelf --debug --set-interpreter %{our_path}$LD $outfile - fi -done - -# create symlinks for bash -mkdir -p "%{buildroot}%{our_path}/bin/" -mkdir -p "%{buildroot}%{our_path}/usr/bin/" -ln -sf ../usr/bin/bash "%{buildroot}%{our_path}/bin/sh" -ln -sf ../../bin/bash "%{buildroot}%{our_path}/usr/bin/sh" - -# binutils needs to be exposed in /usr/bin -if [ ! -d %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin ] ; then - mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin -fi - -for i in %{binaries_binutils} ; do - if [ -f %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i ] ; then - mv %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/$i - if [ -f %{buildroot}%{our_path}/%{_bindir}/$i ] ; then - rm %{buildroot}%{our_path}/%{_bindir}/$i - fi - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/$i - ln -s ../%{emulated_arch_triple_short}/bin/$i %{buildroot}%{our_path}/%{_bindir}/%{emulated_arch_triple_short}-$i - fi -done -pushd %{buildroot}%{our_path} && ln -s usr/bin && popd - -%if %hijack_gcc -# create symlinks for lib64 / lib mappings (gcc!) -mkdir -p "%{buildroot}%{our_path}/usr/lib/" -# binutils secondary directories -mkdir -p %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/ -ln -sf ../bin %{buildroot}%{our_path}/usr/%{emulated_arch_triple_long}/bin - -%ifarch %ix86 -ln -sf ../lib/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%else -ln -sf ../lib64/gcc "%{buildroot}%{our_path}/usr/lib/gcc" -%endif - -# Enable wrapper for GCC compiler: -mv %{buildroot}%{our_path}/usr/bin/gcc{,.real} -mv %{buildroot}%{our_path}/usr/bin/g++{,.real} -cp %{SOURCE1} %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -chmod 755 %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/bin/gcc-wrapper.sh - -# Create symlinks for different synonims of compiler names: -for compiler in gcc cc g++ c++ ; do - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler} - ln -sf gcc-wrapper.sh %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot} - ln -sf ${compiler}.real %{buildroot}%{our_path}/usr/bin/${compiler}-%{gcc_version_dot}.real -done -# g++ can also be called c++ -ln -sf g++.real "%{buildroot}%{our_path}/usr/bin/c++.real" -# gcc can also be called cc -ln -sf gcc.real "%{buildroot}%{our_path}/usr/bin/cc.real" - - -# allow abuild to do the mv -chmod 755 %{buildroot}/emul - -# make cross ld work with emulated compilers -cp %{SOURCE0} %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh -sed -i -e "s|wrapper-config.sh|%{our_path}/usr/bin/wrapper-config.sh|" %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -for LD_NAME in ld ld.gold ; do - mv %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME}{,.real} - ln -s ld-wrapper.sh %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/${LD_NAME} -done - -# Write config that will be used by wrappers at run-time. -echo ' -QEMU_NAME=/usr/bin/qemu-%{emulated_arch_synonim} -CROSS_ACCELERATION_DIRECTORY=%{our_path} -GCC_LIBEXEC_DIRECTORY=%{_libdir}/gcc/%{emulated_arch_triple_long}/%{gcc_version_dot} -CROSS_BIN_PREFIX=/usr/%{emulated_arch_triple_short}/bin -NATIVE_BIN_PREFIX=/usr/%{emulated_arch_triple_long}/bin -' > %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh -ln -s %{our_path}/usr/%{emulated_arch_triple_short}/bin/wrapper-config.sh %{buildroot}%{our_path}/usr/bin/wrapper-config.sh - -chmod 755 %{buildroot}%{our_path}/usr/%{emulated_arch_triple_short}/bin/ld-wrapper.sh - -%if "%{emulated_arch_short}" == "arm" -# -# as is not writing right EABI ELF header inside of arm environment for unknown -# reason. -# TODO: Still the case (2014-12-11). -# -mv %{buildroot}%{our_path}/usr/bin/as{,.real} -echo '#!/bin/bash -exec -a /usr/bin/as %{our_path}/usr/bin/as.real -meabi=5 "$@" -' > %{buildroot}%{our_path}/usr/bin/as -chmod +x %{buildroot}%{our_path}/usr/bin/as -%endif - -# To support gcc sysroot -mkdir -p %{buildroot}/usr/%{emulated_arch_triple_long} -ln -sf .. %{buildroot}/usr/%{emulated_arch_triple_long}/usr -ln -sf ../include %{buildroot}/usr/%{emulated_arch_triple_long}/include -%endif - -# Make QEMU available through /qemu -mkdir %buildroot/qemu -cp -L /usr/bin/qemu-%{emulated_arch_short}{,-binfmt} %buildroot/qemu/ -mkdir -p %buildroot/usr/bin/ - -if [[ %{emulated_arch_short} != %{emulated_arch_synonim} ]] ; then - ln -sf /qemu/qemu-%{emulated_arch_short} %buildroot/qemu/qemu-%{emulated_arch_synonim} - ln -sf /qemu/qemu-%{emulated_arch_short}-binfmt %buildroot/qemu/qemu-%{emulated_arch_synonim}-binfmt -fi - - -export NO_BRP_CHECK_RPATH="true" - -rm -rf %{buildroot}/%{our_path}/bin -ln -s %{our_path}/usr/bin %{buildroot}/%{our_path}/bin -rm -rf %{buildroot}/%{our_path}/sbin -ln -s %{our_path}/usr/sbin %{buildroot}/%{our_path}/sbin - -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmquery -ln -s %{our_path}/usr/bin/rpm %{buildroot}/%{our_path}/usr/bin/rpmverify - -mkdir -p "%{buildroot}%{bfd_plugin_dir}" -touch "%{buildroot}%{bfd_plugin_lto}" - -%post -ldconfig -"%_sbindir/update-alternatives" --install \ - "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 3 - -%postun -ldconfig -"%_sbindir/update-alternatives" --remove %{bfd_plugin_lto_name} "%{gcc_plugin_lto}" - -%files -%defattr(-,root,root) -%dir /usr/%{emulated_arch_triple_long} -/usr/%{emulated_arch_triple_long}/usr -/usr/%{emulated_arch_triple_long}/include -/emul -/qemu -%ghost %{bfd_plugin_lto} - -%changelog |