diff options
author | Dongkyun Son <dongkyun.s@samsung.com> | 2023-05-24 20:43:42 +0900 |
---|---|---|
committer | Dongkyun Son <dongkyun.s@samsung.com> | 2023-07-04 17:43:42 +0900 |
commit | 6d0402fe82654cd5372f4a29e63c8e3b4c959a3a (patch) | |
tree | d9345c263eb0e06772ccd172c515c584d93d8b85 | |
parent | 286801ec6b612ea1419e65f9ca3e6c387e24b33e (diff) | |
download | qemu-accel-6d0402fe82654cd5372f4a29e63c8e3b4c959a3a.tar.gz qemu-accel-6d0402fe82654cd5372f4a29e63c8e3b4c959a3a.tar.bz2 qemu-accel-6d0402fe82654cd5372f4a29e63c8e3b4c959a3a.zip |
packaging: add riscv64
Change-Id: If8fe5a62a424ee9b80dd28181b9e41cfb8fc19f0
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
-rw-r--r-- | packaging/baselibs_body | 4 | ||||
-rwxr-xr-x | packaging/pre_checkin.sh | 2 | ||||
-rw-r--r-- | packaging/qemu-accel-aarch64.spec | 22 | ||||
-rw-r--r-- | packaging/qemu-accel-armv7hl.spec | 22 | ||||
-rw-r--r-- | packaging/qemu-accel-armv7l.spec | 22 | ||||
-rw-r--r-- | packaging/qemu-accel-riscv64.spec | 654 | ||||
-rw-r--r-- | packaging/qemu-accel.spec.in | 22 |
7 files changed, 723 insertions, 25 deletions
diff --git a/packaging/baselibs_body b/packaging/baselibs_body index 8a9e92c..be12c14 100644 --- a/packaging/baselibs_body +++ b/packaging/baselibs_body @@ -3,6 +3,7 @@ qemu-accel targettype aarch64 block! targettype armv7l block! targettype armv7hl block! + targettype riscv64 block! targettype 32bit block! autoreqprov off +/ @@ -15,6 +16,7 @@ python-accel targettype aarch64 block! targettype armv7l block! targettype armv7hl block! + targettype riscv64 block! targettype 32bit block! autoreqprov off +/ @@ -23,6 +25,8 @@ python-accel clang-accel targettype aarch64 block! targettype armv7l block! + targettype armv7hl block! + targettype riscv64 block! targettype 32bit block! autoreqprov off +/ diff --git a/packaging/pre_checkin.sh b/packaging/pre_checkin.sh index ef0d865..d275901 100755 --- a/packaging/pre_checkin.sh +++ b/packaging/pre_checkin.sh @@ -1,7 +1,7 @@ #!/bin/bash # the script takes qemu-accel.spec and creates the qemu-accel-* packages -for arch in armv7l armv7hl aarch64; do +for arch in armv7l armv7hl aarch64 riscv64; do echo -n "Building package for $arch --> gcc-$arch ..." diff --git a/packaging/qemu-accel-aarch64.spec b/packaging/qemu-accel-aarch64.spec index e8bbfb7..22d7d4a 100644 --- a/packaging/qemu-accel-aarch64.spec +++ b/packaging/qemu-accel-aarch64.spec @@ -24,7 +24,7 @@ %define target_cpu %{cross} %define target_abi %{?armv7l:eabi}%{?armv7hl:eabihf} %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} -%define libdir %{_prefix}/lib%{?aarch64:64} +%define libdir %{_prefix}/lib%{?aarch64:64}%{?riscv64:64} #disable strip debug info due to patchelf + armv7hl bug %{?armv7hl: @@ -98,12 +98,22 @@ BuildConflicts: guile BuildRequires: guile BuildConflicts: guile-32bit %endif +%if 0%{?riscv64} +# 64bit guile is used for riscv64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif %else # x86_64 %if 0%{?aarch64} # 64bit guile is required for aarch64 build BuildRequires: guile-64bit BuildConflicts: guile %endif +%if 0%{?riscv64} +# 64bit guile is required for riscv64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif %if 0%{?armv7l} # 32bit guile is used for armv7l and armv7hl builds BuildRequires: guile @@ -230,7 +240,7 @@ for executable in %{emul_path}$LD \ %{_bindir}/eu-{addr2line,ar,elfclassify,elfcmp,elfcompress,elflint,findtextrel,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}-{addr2line,ar,as,c++filt%{!?riscv64:,dwp},elfedit,gprof,ld,ld.bfd%{!?riscv64:,ld.gold},nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ ${gcc_install_dir}{cc1,cc1plus,collect2,lto1,lto-wrapper,liblto_plugin.so*,f951} \ %{_bindir}/file \ @@ -423,7 +433,7 @@ sed -e 's|%{emul_path}/lib|%{emul_path}/usr/lib|' -i %{_sourcedir}/multilib-acce } # 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 +for binary in addr2line ar as c++filt%{!?riscv64: dwp} elfedit gprof ld ld.bfd%{!?riscv64: ld.gold} nm objcopy objdump ranlib readelf size strings strip do mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$binary ${buildroot_emul_path}%{_bindir}/$binary sed -e "\|%{emul_path}%{_bindir}/%{target_arch}-$binary|d" -i %{_sourcedir}/all-accel.list @@ -431,7 +441,7 @@ do done mkdir -p ${buildroot_emul_path}/%{_prefix}/%{target_arch}/bin -for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do +for binary in ar as ld{,.bfd%{!?riscv64:,.gold}} nm obj{copy,dump} ranlib strip; do ln -sf %{emul_path}%{_bindir}/$binary ${buildroot_emul_path}%{_prefix}/%{target_arch}/bin/$binary echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list echo "%{emul_path}%{_prefix}/%{target_arch}/bin/$binary" >> %{_sourcedir}/all-accel.list @@ -555,8 +565,8 @@ cat %{_sourcedir}/baselibs_prologue %{_sourcedir}/baselibs_body > %{_sourcedir}/ # By default this is ${gcc_install_dir}/liblto_plugin.so target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)" # update baselibs.conf, overwrite LTO plugin - -sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf + # TODO: !!! replace this dirty hack with real libdir after stabilization +sed -e "s,#PLUGIN_POSTIN#,%{?riscv64:mkdir -p /usr/lib/gcc/%{target_arch} \&\& ln -sf /usr/lib64/gcc/%{target_arch}/13.1.0 /usr/lib/gcc/%{target_arch}/13.1.0 \&\& } if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf %if 0%{?asan} || 0%{?hwasan_build} sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf %else diff --git a/packaging/qemu-accel-armv7hl.spec b/packaging/qemu-accel-armv7hl.spec index 4f3eb35..3d61ffe 100644 --- a/packaging/qemu-accel-armv7hl.spec +++ b/packaging/qemu-accel-armv7hl.spec @@ -24,7 +24,7 @@ %define target_cpu %{cross} %define target_abi %{?armv7l:eabi}%{?armv7hl:eabihf} %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} -%define libdir %{_prefix}/lib%{?aarch64:64} +%define libdir %{_prefix}/lib%{?aarch64:64}%{?riscv64:64} #disable strip debug info due to patchelf + armv7hl bug %{?armv7hl: @@ -98,12 +98,22 @@ BuildConflicts: guile BuildRequires: guile BuildConflicts: guile-32bit %endif +%if 0%{?riscv64} +# 64bit guile is used for riscv64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif %else # x86_64 %if 0%{?aarch64} # 64bit guile is required for aarch64 build BuildRequires: guile-64bit BuildConflicts: guile %endif +%if 0%{?riscv64} +# 64bit guile is required for riscv64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif %if 0%{?armv7l} # 32bit guile is used for armv7l and armv7hl builds BuildRequires: guile @@ -230,7 +240,7 @@ for executable in %{emul_path}$LD \ %{_bindir}/eu-{addr2line,ar,elfclassify,elfcmp,elfcompress,elflint,findtextrel,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}-{addr2line,ar,as,c++filt%{!?riscv64:,dwp},elfedit,gprof,ld,ld.bfd%{!?riscv64:,ld.gold},nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ ${gcc_install_dir}{cc1,cc1plus,collect2,lto1,lto-wrapper,liblto_plugin.so*,f951} \ %{_bindir}/file \ @@ -423,7 +433,7 @@ sed -e 's|%{emul_path}/lib|%{emul_path}/usr/lib|' -i %{_sourcedir}/multilib-acce } # 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 +for binary in addr2line ar as c++filt%{!?riscv64: dwp} elfedit gprof ld ld.bfd%{!?riscv64: ld.gold} nm objcopy objdump ranlib readelf size strings strip do mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$binary ${buildroot_emul_path}%{_bindir}/$binary sed -e "\|%{emul_path}%{_bindir}/%{target_arch}-$binary|d" -i %{_sourcedir}/all-accel.list @@ -431,7 +441,7 @@ do done mkdir -p ${buildroot_emul_path}/%{_prefix}/%{target_arch}/bin -for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do +for binary in ar as ld{,.bfd%{!?riscv64:,.gold}} nm obj{copy,dump} ranlib strip; do ln -sf %{emul_path}%{_bindir}/$binary ${buildroot_emul_path}%{_prefix}/%{target_arch}/bin/$binary echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list echo "%{emul_path}%{_prefix}/%{target_arch}/bin/$binary" >> %{_sourcedir}/all-accel.list @@ -555,8 +565,8 @@ cat %{_sourcedir}/baselibs_prologue %{_sourcedir}/baselibs_body > %{_sourcedir}/ # By default this is ${gcc_install_dir}/liblto_plugin.so target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)" # update baselibs.conf, overwrite LTO plugin - -sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf + # TODO: !!! replace this dirty hack with real libdir after stabilization +sed -e "s,#PLUGIN_POSTIN#,%{?riscv64:mkdir -p /usr/lib/gcc/%{target_arch} \&\& ln -sf /usr/lib64/gcc/%{target_arch}/13.1.0 /usr/lib/gcc/%{target_arch}/13.1.0 \&\& } if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf %if 0%{?asan} || 0%{?hwasan_build} sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf %else diff --git a/packaging/qemu-accel-armv7l.spec b/packaging/qemu-accel-armv7l.spec index 7f0e945..6b187f4 100644 --- a/packaging/qemu-accel-armv7l.spec +++ b/packaging/qemu-accel-armv7l.spec @@ -24,7 +24,7 @@ %define target_cpu %{cross} %define target_abi %{?armv7l:eabi}%{?armv7hl:eabihf} %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} -%define libdir %{_prefix}/lib%{?aarch64:64} +%define libdir %{_prefix}/lib%{?aarch64:64}%{?riscv64:64} #disable strip debug info due to patchelf + armv7hl bug %{?armv7hl: @@ -98,12 +98,22 @@ BuildConflicts: guile BuildRequires: guile BuildConflicts: guile-32bit %endif +%if 0%{?riscv64} +# 64bit guile is used for riscv64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif %else # x86_64 %if 0%{?aarch64} # 64bit guile is required for aarch64 build BuildRequires: guile-64bit BuildConflicts: guile %endif +%if 0%{?riscv64} +# 64bit guile is required for riscv64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif %if 0%{?armv7l} # 32bit guile is used for armv7l and armv7hl builds BuildRequires: guile @@ -230,7 +240,7 @@ for executable in %{emul_path}$LD \ %{_bindir}/eu-{addr2line,ar,elfclassify,elfcmp,elfcompress,elflint,findtextrel,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}-{addr2line,ar,as,c++filt%{!?riscv64:,dwp},elfedit,gprof,ld,ld.bfd%{!?riscv64:,ld.gold},nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ ${gcc_install_dir}{cc1,cc1plus,collect2,lto1,lto-wrapper,liblto_plugin.so*,f951} \ %{_bindir}/file \ @@ -423,7 +433,7 @@ sed -e 's|%{emul_path}/lib|%{emul_path}/usr/lib|' -i %{_sourcedir}/multilib-acce } # 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 +for binary in addr2line ar as c++filt%{!?riscv64: dwp} elfedit gprof ld ld.bfd%{!?riscv64: ld.gold} nm objcopy objdump ranlib readelf size strings strip do mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$binary ${buildroot_emul_path}%{_bindir}/$binary sed -e "\|%{emul_path}%{_bindir}/%{target_arch}-$binary|d" -i %{_sourcedir}/all-accel.list @@ -431,7 +441,7 @@ do done mkdir -p ${buildroot_emul_path}/%{_prefix}/%{target_arch}/bin -for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do +for binary in ar as ld{,.bfd%{!?riscv64:,.gold}} nm obj{copy,dump} ranlib strip; do ln -sf %{emul_path}%{_bindir}/$binary ${buildroot_emul_path}%{_prefix}/%{target_arch}/bin/$binary echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list echo "%{emul_path}%{_prefix}/%{target_arch}/bin/$binary" >> %{_sourcedir}/all-accel.list @@ -555,8 +565,8 @@ cat %{_sourcedir}/baselibs_prologue %{_sourcedir}/baselibs_body > %{_sourcedir}/ # By default this is ${gcc_install_dir}/liblto_plugin.so target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)" # update baselibs.conf, overwrite LTO plugin - -sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf + # TODO: !!! replace this dirty hack with real libdir after stabilization +sed -e "s,#PLUGIN_POSTIN#,%{?riscv64:mkdir -p /usr/lib/gcc/%{target_arch} \&\& ln -sf /usr/lib64/gcc/%{target_arch}/13.1.0 /usr/lib/gcc/%{target_arch}/13.1.0 \&\& } if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf %if 0%{?asan} || 0%{?hwasan_build} sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf %else diff --git a/packaging/qemu-accel-riscv64.spec b/packaging/qemu-accel-riscv64.spec new file mode 100644 index 0000000..70b299b --- /dev/null +++ b/packaging/qemu-accel-riscv64.spec @@ -0,0 +1,654 @@ +%define cross riscv64 +%define riscv64 1 + +# +# spec file for package qemu-accel-ARCH, where ARCH = armv7l, armv7hl 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}%{?armv7hl:eabihf} +%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} +%define libdir %{_prefix}/lib%{?aarch64:64}%{?riscv64:64} + +#disable strip debug info due to patchelf + armv7hl bug +%{?armv7hl: +%define _rpm_strip_disable 1 +} + +# default path in qemu +%define emul_path /emul + +Name: qemu-accel +Version: 0.4 +Release: 0 +AutoReqProv: off +BuildRequires: gcc-%{cross} +BuildRequires: binutils-%{cross} +BuildRequires: gcc-fortran +#BuildRequires: expect +BuildRequires: fdupes +BuildRequires: gettext-runtime +BuildRequires: gettext-tools +BuildRequires: m4 +# required for xxd +BuildRequires: vim +BuildRequires: patchelf +BuildRequires: elfutils +BuildRequires: libxslt-tools +BuildRequires: cmake +BuildRequires: gawk +BuildRequires: libstdc++ +BuildRequires: python libpython +BuildRequires: python-xml +BuildRequires: python-magic +BuildRequires: python-rpm +BuildRequires: python-ply +BuildRequires: file +BuildRequires: libasan +%ifarch x86_64 +BuildRequires: liblsan +%endif +BuildRequires: icecream +BuildRequires: libunwind +BuildRequires: libuuid +BuildRequires: clang +BuildRequires: pbzip2 +BuildRequires: python3 +BuildRequires: python3-base +BuildRequires: glibc-accel-ldso + +# required for LLVM gold plugin +BuildRequires: llvm-devel +Summary: Native binaries for speeding up cross compile +License: GPL-2.0 +Group: Development/Cross Compilation +ExclusiveArch: x86_64 %{ix86} +%ifarch x86_64 +BuildRequires: libgcc-32bit +BuildRequires: glibc-32bit +%define multilib 1 +%if 0%{?armv7l} +# 32bit guile is required for armv7l and armv7hl builds +BuildRequires: guile-32bit +BuildConflicts: guile +%endif +%if 0%{?armv7hl} +# 32bit guile is required for armv7l and armv7hl builds +BuildRequires: guile-32bit +BuildConflicts: guile +%endif +%if 0%{?aarch64} +# 64bit guile is used for aarch64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif +%if 0%{?riscv64} +# 64bit guile is used for riscv64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif +%else # x86_64 +%if 0%{?aarch64} +# 64bit guile is required for aarch64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif +%if 0%{?riscv64} +# 64bit guile is required for riscv64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif +%if 0%{?armv7l} +# 32bit guile is used for armv7l and armv7hl builds +BuildRequires: guile +BuildConflicts: guile-64bit +%endif +%if 0%{?armv7hl} +# 32bit guile is used for armv7l and armv7hl builds +BuildRequires: guile +BuildConflicts: guile-64bit +%endif +%endif +BuildRequires: guile-modules +%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. + +%package -n python-accel +AutoReqProv: off +Requires: qemu-accel +Version: %{version} +Release: %{release} +Summary: Binaries for python acceleration +License: GPL-2.0 +Group: Development/Cross Compilation + +%description -n python-accel +This package is used in qemu-accel to accelerate python. + +%post -n python-accel +ldconfig + +# Check if there is possibility of gcc-unforce-options call and fix permissions +rpm -qa --qf '%{NAME}\n' | grep force-options && \ + chmod a+w /usr/bin && \ + chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \ + && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w + +%package -n clang-accel +AutoReqProv: off +Requires: qemu-accel +Version: %{version} +Release: %{release} +Summary: Binaries for clang acceleration +License: GPL-2.0 +Group: Development/Cross Compilation +Requires: qemu-accel + +%description -n clang-accel +This package is used in qemu-accel to accelerate clang compiler. + +%post -n clang-accel +# Check if there is possibility of gcc-unforce-options call and fix permissions +pkg=$(rpm -qa --qf '%{NAME}\n' | grep force-options) +if [[ x"$pkg" != x"" ]]; then + chmod a+w /usr/bin + chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \ + && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w +fi + +%prep + +%build +%if 0%{?asan} || 0%{?ubsan} || 0%{?hwasan} +%gcc_unforce_options +%endif + +%install +set +x +# gcc version major.minor.patch +gcc_version=`gcc --version | sed -ne '1s/[^0-9]*\(\([0-9]\.\?\)*\).*/\1/p'` +# Find cross-gcc install directory, like: +# - /usr/lib/gcc/armv7l-tizen-linux-gnueabi/6.2.1/ for armv7l, +# - /usr/lib64/gcc/aarch64-tizen-linux-gnu/6.2.1/ for aarch64 +gcc_install_dir="$(%{target_arch}-gcc -print-file-name=)" + +# just like it is determided in python.spec +host_python="python$(python --version 2>&1 | sed -ne '1s/.* //p' | head -c 3)" +host_python3="python$(python3 --version | sed -ne '1s/.* //p' | sed -e 's/^\(3\.[0-9]\+\).*/\1/')" + +# Emul path inside buildroot for installation +buildroot_emul_path=%{buildroot}%{emul_path} + +# Collect all shared objects from glibc and libgcc +# excluding RTLD since it's processed in another way later +for lib in $(rpm -ql glibc) \ + $(rpm -ql libgcc) +do + [[ "$lib" =~ .*\.so(\.[[:digit:]]+)?$ && ! "$lib" =~ /ld- ]] && binaries="$binaries $lib" +done + +%ifarch %ix86 + LD="%{_libdir}/ld-linux.so.2" +%endif +%ifarch x86_64 + LD="%{_libdir}/ld-linux-x86-64.so.2" +%endif + +# Disable bash acceleration for armv7hl due to corruption +%{?!armv7hl: + BASH_EXECUTABLE=%{_bindir}/bash +} + +for executable in %{emul_path}$LD \ + $BASH_EXECUTABLE \ + %{_bindir}/{rpm,rpm2cpio,rpmdb,rpmkeys,rpmqpack,rpmbuild,rpmsign,rpmspec,rpm2archive} \ + %{_libdir}/rpm-plugins/ima.so \ + %{_libdir}/rpm-plugins/prioreset.so \ + %{_libdir}/rpm-plugins/syslog.so \ + %{_libdir}/{libdb-4.8.so,libdb_cxx-4.8.so} \ + %{_bindir}/{tar,gzip,bzip2,xz,xzdec,pbzip2} \ + %{_bindir}/{grep,sed} \ + %{_libdir}/libnssdbm3.so %{_libdir}/libsoftokn3.so %{_libdir}/libfreebl3.so \ + %{_libdir}/lib*san.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,elfclassify,elfcmp,elfcompress,elflint,findtextrel,nm,objdump,ranlib,readelf,size,stack,strings,strip,unstrip} \ + %{_bindir}/xsltproc \ + %{_bindir}/{ccmake,cmake,cpack,ctest} \ + %{_bindir}/%{target_arch}-{addr2line,ar,as,c++filt%{!?riscv64:,dwp},elfedit,gprof,ld,ld.bfd%{!?riscv64:,ld.gold},nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ + %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ + ${gcc_install_dir}{cc1,cc1plus,collect2,lto1,lto-wrapper,liblto_plugin.so*,f951} \ + %{_bindir}/file \ + %{_bindir}/icecc \ + %{_bindir}/icerun \ + %{_bindir}/{find,xargs,readlink,ls,cpio} \ + %{_rpmconfigdir}/debugedit \ + %{_rpmconfigdir}/*deps \ + %{_libdir}/{libunwind*.so*,libuuid*.so*} \ + %{_bindir}/guile \ + %{_bindir}/localedef +do + binaries="$binaries $executable" +done + +function prepare_package_list { + local bins="" + local name=$1 + local executables=${@:2} + echo "Setting up $name for $executables" + ## Prepare the clang binaries separately + for executable in $executables; do + bins="$bins $executable `ldd $executable 2>/dev/null | sed -n 's,.*=> \(/[^ ]*\) .*,\1,p'`" + done + + for b in $(echo "$bins" | tr ' ' '\n' | sort -u); do + local orig_file=$(readlink -f $b) + bins="$bins $orig_file" + if [[ "$b" != *"/../"* ]]; then + # Ignore relative paths + echo $b >> $name.list + fi; + echo $orig_file >> $name.list + done + + ## Store the resulting list for packaging, setting up the right prefix, removing duplication of %emul_path if one exists + cat $name.list | \ + sed -e 's|^|%{emul_path}|;s| |\n%{emul_path}|g' | \ + grep -v "%{emul_path}%{emul_path}" | \ + sort -u > %{_sourcedir}/$name-accel.list + binaries=$(tr ' ' '\n' <<< "$binaries $bins" | sort -u) +} + +prepare_package_list all \ + $binaries + +prepare_package_list clang \ + %{_bindir}/{clang-*,clang++,opt,lli,llc,llvm-*} \ + %{_libdir}/libLTO.so* \ + %{_libdir}/LLVMgold.so* + +prepare_package_list python \ + %{_bindir}/${host_python} \ + %{_libdir}/${host_python}/lib-dynload/*.so \ + %{_libdir}/${host_python}/site-packages/*/*.so + +prepare_package_list python3 \ + %{_bindir}/${host_python3} \ + %{_libdir}/${host_python3}/lib-dynload/*.so \ + %{_libdir}/${host_python3}/site-packages/*/*.so + +## dump list of binaries and list of packages +echo "### Binaries accelerated ###" +echo $binaries | sed -e 's/[^ ]*\///g;s/[^ ]*.so[^ ]* \?//g' +echo "### Packages used ###" +rpm -qf $binaries | grep -v "not owned" | sed -e "s/-[0-9].*//g" | sort -u +echo "" + +function patch_binary { + local binary=$1 + local rtld=$2 + # We don't need to accelerate shell scripts + local filetype=`file --brief $binary` + [[ x"$filetype" == x"POSIX shell script"* ]] && return + + local outfile=${buildroot_emul_path}$binary + [[ ! -e $binary ]] && echo "WARNING: File '${binary}' not found, ignoring" && return + [[ -f $outfile ]] && echo "WARNING: File '${outfile}' exists, ignoring" && return + mkdir -p ${outfile%/*} + cp -aL $binary $outfile + [ "$binary" == "$rtld" ] && return + [ "$binary" == "%{emul_path}$rtld" ] && return + + # not all binaries have an .interp section + if patchelf --print-interpreter $outfile 1>/dev/null 2>/dev/null; then + patchelf --set-interpreter %{emul_path}$rtld $outfile + fi + + # Only patch RUNPATH if one exists and is absolute + local rpath=$(readelf -d "$outfile" | sed -e '/RUNPATH/{s~.*\[\(.*\)\]~\1~;n};d') + if [[ x"$rpath" != x"" && ${rpath::1} == "/" ]]; then + patchelf --set-rpath "%{emul_path}%{_libdir}" $outfile + fi +} + +# Spawn single job which reads input to extract filename by index +function run_single_job() { + local arg="$1" + while :; do + # Reads (FILENUM_DIGITS + 1) bytes. Note: to drop redirection usage we + # need dd with support for status=none + filenum=$(dd bs=$(( FILENUM_DIGITS + 1 )) count=1 2>/dev/null) + if [[ -z "$filenum" ]]; then + break + fi + # Get filename for 0x$filenum index and process it + patch_binary "${bin_array[$((0x$filenum))]}" "$LD" + done +} + +# Converting to the bash array to allow access by index +bin_array=($binaries) +# Use processors count + arbitrary addend. +n_jobs=$(( $(/usr/bin/getconf _NPROCESSORS_ONLN) + 3 )) +# Supports up to 16^FILENUM_DIGITS - 1 files: +# 16^5 - 1 = 1.048.575 files +FILENUM_DIGITS=5 + +# Send the input for the jobs: enumerate all files +for ((file = 0; file < ${#bin_array[@]}; file++)); do + printf "%0${FILENUM_DIGITS}x\\n" $file +done | ( + # Implementing simple Round-robin scheduling routine + exec 3<&0 + echo "Spawn $n_jobs jobs" + for ((i = 0; i < n_jobs; i++)); do + # The shell redirects stdin to /dev/null for background jobs. Work + # around this by duplicating fd 0 + run_single_job $i <&3 & + done + wait +) + +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$'`) + +# Patch all 32bit binaries to use the right ld.so though symlink +mkdir -p ${buildroot_emul_path}%{_prefix}/lib +mkdir -p ${buildroot_emul_path}/lib +for f in $(rpm -ql glibc-32bit) \ + $(rpm -ql libgcc-32bit) +do + fdir=$(dirname $f) + [ ! -d ${buildroot_emul_path}/$fdir ] && mkdir -p ${buildroot_emul_path}/$fdir + cp -a $f ${buildroot_emul_path}/$f + echo "%{emul_path}$f" >> %{_sourcedir}/multilib-accel.list +done + +# Now we have to change the ld.so name to prevent name clashing in armv7l repos +i686_libdir="%{emul_path}/lib" + +# 1. Rename the actual ld.so binary +cross_ld_so=$(find %{buildroot}${i686_libdir} -name 'ld-*.so.2' -printf '%f') +new_cross_ld_so=$(echo ${cross_ld_so} | sed -e 's,\.so,-i686.so,') +mv %{buildroot}${i686_libdir}/${cross_ld_so} %{buildroot}${i686_libdir}/${new_cross_ld_so} +sed -e "s|${cross_ld_so}|${new_cross_ld_so}|" -i %{_sourcedir}/multilib-accel.list + +# 2. Force the symlink to point the right file. +ln -sf %{emul_path}/lib/${new_cross_ld_so} %{buildroot}${i686_libdir}/${cross_ld_symlink} +echo "${i686_libdir}/${cross_ld_symlink}" >> %{_sourcedir}/multilib-accel.list + +# create symlinks for libgcc-32bit +# libgcc-32bit library is placed under ${gcc_install_dir}32/ not just /lib for 32bit +# Process lib*.so files only, we expect that licenses are already in the +# multilib-accel.list. +for f in $(rpm -ql libgcc-32bit | grep "\/lib[^\/]*\.so.*") +do + filename=$(basename $f) + ln -sf %{emul_path}/$f %{buildroot}${i686_libdir}/${filename} + echo "${i686_libdir}/${filename}" >> %{_sourcedir}/multilib-accel.list +done +} + +# create symlinks for bash +ln -s usr/bin "${buildroot_emul_path}/bin" +ln -sf bash "${buildroot_emul_path}%{_bindir}/sh" +echo '%{emul_path}%{_bindir}/sh' >> %{_sourcedir}/all-accel.list + +mv ${buildroot_emul_path}/%{_lib}/* ${buildroot_emul_path}%{_libdir}/ +rm -rf ${buildroot_emul_path}/%{_lib} +ln -sf usr/%{_lib} ${buildroot_emul_path}/%{_lib} +%{?multilib: +mv ${buildroot_emul_path}/lib/* ${buildroot_emul_path}%{_prefix}/lib/ +rm -rf ${buildroot_emul_path}/lib +ln -sf usr/lib ${buildroot_emul_path}/lib +sed -e 's|%{emul_path}/lib|%{emul_path}/usr/lib|' -i %{_sourcedir}/multilib-accel.list +} + +# rename binutils binaries +for binary in addr2line ar as c++filt%{!?riscv64: dwp} elfedit gprof ld ld.bfd%{!?riscv64: ld.gold} nm objcopy objdump ranlib readelf size strings strip +do + mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$binary ${buildroot_emul_path}%{_bindir}/$binary + sed -e "\|%{emul_path}%{_bindir}/%{target_arch}-$binary|d" -i %{_sourcedir}/all-accel.list + echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list +done + +mkdir -p ${buildroot_emul_path}/%{_prefix}/%{target_arch}/bin +for binary in ar as ld{,.bfd%{!?riscv64:,.gold}} nm obj{copy,dump} ranlib strip; do + ln -sf %{emul_path}%{_bindir}/$binary ${buildroot_emul_path}%{_prefix}/%{target_arch}/bin/$binary + echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list + echo "%{emul_path}%{_prefix}/%{target_arch}/bin/$binary" >> %{_sourcedir}/all-accel.list +done + +# create symlinks for python +mv ${buildroot_emul_path}%{_bindir}/${host_python} ${buildroot_emul_path}%{_bindir}/${host_python}-orig +cat > ${buildroot_emul_path}%{_bindir}/${host_python} << EOF +#!/bin/bash +if [ -z "\$PYTHONPATH" ]; then + export PYTHONPATH="%{libdir}/${host_python}" +else + export PYTHONPATH+=":%{libdir}/${host_python}" +fi +export PYTHONHOME="%{emul_path}%{_prefix}" +%{emul_path}%{_bindir}/${host_python}-orig "\$@" +EOF +chmod +x ${buildroot_emul_path}%{_bindir}/${host_python} + +ln -s ${host_python} ${buildroot_emul_path}%{_bindir}/python +ln -s ${host_python} ${buildroot_emul_path}%{_libdir}/python + +# create symlinks for python3 +mv ${buildroot_emul_path}%{_bindir}/${host_python3} ${buildroot_emul_path}%{_bindir}/${host_python3}-orig +cat > ${buildroot_emul_path}%{_bindir}/${host_python3} << EOF +#!/bin/bash +if [ -z "\$PYTHONPATH" ]; then + export PYTHONPATH="%{libdir}/${host_python3}" +else + export PYTHONPATH+=":%{libdir}/${host_python3}" +fi +export PYTHONHOME="%{emul_path}%{_prefix}" +export LD_LIBRARY_PATH="%{emul_path}%{_libdir}:$LD_LIBRARY_PATH" +%{emul_path}%{_bindir}/${host_python3}-orig "\$@" +EOF +chmod +x ${buildroot_emul_path}%{_bindir}/${host_python3} + +ln -s ${host_python3} ${buildroot_emul_path}%{_bindir}/python3 +ln -s ${host_python3} ${buildroot_emul_path}%{_libdir}/python3 + +#create symlinks for Scons & ply +mkdir -p ${buildroot_emul_path}%{libdir}/${host_python}/site-packages +ln -sf %{libdir}/${host_python}/site-packages/SCons ${buildroot_emul_path}%{libdir}/${host_python}/site-packages/SCons +echo "%{libdir}/${host_python}/site-packages/SCons" >> python.list +ln -sf %{libdir}/${host_python}/site-packages/ply ${buildroot_emul_path}%{libdir}/${host_python}/site-packages/ply +echo "%{libdir}/${host_python}/site-packages/ply" >> python.list + +mkdir -p ${buildroot_emul_path}%{_libdir}/${host_python}/site-packages/rpm/ +mkdir -p ${buildroot_emul_path}%{_libdir}/${host_python}/encodings/ +cp %{_libdir}/${host_python}/site-packages/rpm/*.py ${buildroot_emul_path}%{_libdir}/${host_python}/site-packages/rpm/ +cp %{_libdir}/${host_python}/*.py ${buildroot_emul_path}%{_libdir}/${host_python}/ +cp %{_libdir}/${host_python}/encodings/*.py ${buildroot_emul_path}%{_libdir}/${host_python}/encodings/ +cp -r %{_libdir}/${host_python3} ${buildroot_emul_path}%{_libdir}/ +find ${buildroot_emul_path}%{_libdir}/${host_python3} -name *.pyc -exec rm {} \; +# Skip directories to not glob all inside them during #files processing +find %{buildroot} ! -type d -name 'python*' | sed -e "s|${buildroot_emul_path}||" | tee -a python.list + +# rename gcc binaries +for bin in c++ g++ gcc gfortran cpp gcc-ar gcc-nm gcc-ranlib gcov +do + mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$bin ${buildroot_emul_path}%{_bindir}/$bin + ln -s $bin ${buildroot_emul_path}%{_bindir}/%{target_arch}-$bin + echo "%{emul_path}%{_bindir}/$bin" >> %{_sourcedir}/all-accel.list +done +ln -s gcc ${buildroot_emul_path}/%{_bindir}/cc +echo '%{emul_path}%{_bindir}/cc' >> %{_sourcedir}/all-accel.list + +# 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_emul_path}%{_bindir}/bash +} +%endif + +# Default Tizen gcc build dir, must be synchronized with linaro-gcc spec +# definition. Expected to be 'home/abuild/rpmbuild/BUILD/gcc-${version}/obj/' +gcc_build_dir=%{_builddir}/gcc-${gcc_version}/obj + +# create symlinks for gcc build (CC_FOR_TARGET) +mkdir -p ${buildroot_emul_path}${gcc_build_dir}/gcc +for binary in as cpp gcc-ar gcc-nm gcc-ranlib gcov nm +do + ln -sf %{emul_path}%{_bindir}/${binary} ${buildroot_emul_path}${gcc_build_dir}/gcc/${binary} + echo "%{emul_path}${gcc_build_dir}/gcc/${binary}" >> %{_sourcedir}/all-accel.list +done +for binary in cc1 cc1plus collect2 lto1 lto-wrapper f951 +do + ln -sf %{emul_path}${gcc_install_dir}${binary} ${buildroot_emul_path}${gcc_build_dir}/gcc/${binary} + echo "%{emul_path}${gcc_build_dir}/gcc/${binary}" >> %{_sourcedir}/all-accel.list +done +ln -sf %{emul_path}%{_bindir}/gcc ${buildroot_emul_path}${gcc_build_dir}/gcc/xgcc +ln -sf %{emul_path}%{_bindir}/g++ ${buildroot_emul_path}${gcc_build_dir}/gcc/xg++ +echo "%{emul_path}${gcc_build_dir}/gcc/xgcc" >> %{_sourcedir}/all-accel.list +echo "%{emul_path}${gcc_build_dir}/gcc/xg++" >> %{_sourcedir}/all-accel.list + +# support /lib/cpp +ln -sf %{emul_path}%{_bindir}/cpp ${buildroot_emul_path}/usr/lib/cpp +echo '%{emul_path}/usr/lib/cpp' >> %{_sourcedir}/all-accel.list + +## guile acceleration +# we need to accelerate guile build +export GUILE_AUTO_COMPILE=0 +guile_version=$(guile --version | sed -ne '/^guile/s/.*)[[:space:]]\+//p') +guile_build_dir=%{_builddir}/guile-${guile_version}/libguile +mkdir -p ${buildroot_emul_path}${guile_build_dir} +ln -sf %{emul_path}%{_bindir}/guile ${buildroot_emul_path}${guile_build_dir}/guile +echo "%{emul_path}${guile_build_dir}/guile" >> %{_sourcedir}/all-accel.list + +# generate baselibs.conf for current architecture to prevent rpm overwriting in download repo +echo %{cross} +cat > %{_sourcedir}/baselibs_prologue << EOF +arch i686 targets %{cross}:%{cross} +arch i686 targets %{cross}:x86-%{cross} +arch x86_64 targets %{cross}:%{cross} +arch x86_64 targets %{cross}:x86_64-%{cross} +EOF +cat %{_sourcedir}/baselibs_prologue %{_sourcedir}/baselibs_body > %{_sourcedir}/baselibs.conf + +# By default this is ${gcc_install_dir}/liblto_plugin.so +target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)" +# update baselibs.conf, overwrite LTO plugin + # TODO: !!! replace this dirty hack with real libdir after stabilization +sed -e "s,#PLUGIN_POSTIN#,%{?riscv64:mkdir -p /usr/lib/gcc/%{target_arch} \&\& ln -sf /usr/lib64/gcc/%{target_arch}/13.1.0 /usr/lib/gcc/%{target_arch}/13.1.0 \&\& } if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf +%if 0%{?asan} || 0%{?hwasan_build} +sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf +%else +sed -e "s,#PLUGIN_POSTIN_SAN#,," -i %{_sourcedir}/baselibs.conf +%endif +sed -e "s,#PLUGIN_POSTUN#,ln -sf liblto_plugin.so.0 ${target_liblto_plugin}," -i %{_sourcedir}/baselibs.conf + +# Add support of gcc-unforce-options for baselibs-generated packages +sed -e "s,#PYTHON_POSTIN#,rpm -qa --qf '%%%%{NAME}' | grep force-options \&\& chmod a+w /usr/bin \&\& chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf +sed -e "s,#CLANG_POSTIN#,rpm -qa --qf '%%%%{NAME}' | grep force-options \&\& chmod a+w /usr/bin \&\& chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf + + +# Use /usr/lib for cross clang libdir on armv7l architecture +%{?armv7l: +awk '/post "/ && !x {print " post \"echo export\\ CLANG_NO_LIBDIR_SUFFIX=1 >> /etc/profile\""; print $0; x=1;next} 1' %{_sourcedir}/baselibs.conf > baselibs_updated && mv baselibs_updated %{_sourcedir}/baselibs.conf +} + +%{?multilib: +awk '/post "/ && !x {print " post \"echo '%{emul_path}/lib' >> /etc/ld.so.conf\"\n"; print $0; x=1;next} 1' %{_sourcedir}/baselibs.conf > baselibs_updated && mv baselibs_updated %{_sourcedir}/baselibs.conf +} + +# Remove the ld-$VERSION.so to prevent name clashing with native ld.so +find ${buildroot_emul_path}%{_libdir} -name 'ld-*.so' -delete +sed -e '\|%{emul_path}%{_libdir}/ld-[[:digit:]].*\.so|d' -i %{_sourcedir}/all-accel.list + +# allow build of baselibs.conf +sed -e "/targettype %{cross} block!/d" -i %{_sourcedir}/baselibs.conf + +## Prepare file lists for packages +# Change libdir to handle symlinks right +find . %{_sourcedir} -name '*.list' -exec sed -e 's|%{emul_path}/%{_lib}|%{emul_path}%{_libdir}|' -i {} \; +# Join native and multilib lists +cat %{_sourcedir}/all-accel.list %{?multilib:%{_sourcedir}/multilib-accel.list} | sort -u > %{_sourcedir}/qemu-accel.list + +## python-accel +# Generate list of all python files +find %{buildroot} -name '*.py' | sed -e "s|${buildroot_emul_path}||" >> python.list +# Generate list of all python3 files +find ${buildroot_emul_path}%{_libdir}/${host_python3} -type f | sed -e "s|${buildroot_emul_path}||" >> python.list +# Add python3 dependant libraries +for library in ffi gdbm ncursesw panelw python3 tinfow; do + find ${buildroot_emul_path}%{_libdir} -name "lib${library}.*" | sed -e "s|${buildroot_emul_path}||" >> python.list +done +sed -e 's|^|%{emul_path}|;s|%{emul_path}/%{_lib}|%{emul_path}%{_libdir}|' python.list | sort -u > python-full.list +# Remove common files from python-accel +comm -13 %{_sourcedir}/qemu-accel.list python-full.list | sort -u > %{_sourcedir}/python-accel.list + +## clang-accel +# Prepare clang files list +sed -e 's|^|%{emul_path}|;s|%{emul_path}/%{_lib}|%{emul_path}%{_libdir}|' clang.list | sort -u > clang-full.list +# Remove common files from clang-accel +comm -13 %{_sourcedir}/qemu-accel.list clang-full.list > %{_sourcedir}/clang-accel.list + +#Fix build error with rpm 4.14.1:#Not a directory +# Add symlinks to qemu-accel packaging +echo '%{emul_path}/bin' >> %{_sourcedir}/qemu-accel.list +echo '%{emul_path}/%{_lib}' >> %{_sourcedir}/qemu-accel.list +%{?multilib:echo '%{emul_path}/lib' >> %{_sourcedir}/qemu-accel.list} + +mv ${buildroot_emul_path}%{emul_path}$LD ${buildroot_emul_path}$LD +rm -rf ${buildroot_emul_path}%{emul_path} + +%fdupes %{buildroot} +%filter_provides_in %{emul_path} + +%post +ldconfig + +%postun +ldconfig + +%postun -n python-accel +ldconfig + +%files -f %{_sourcedir}/qemu-accel.list +%defattr(-,root,root) +%exclude %{emul_path}%{py_libdir}/* + +%files -n python-accel -f %{_sourcedir}/python-accel.list +%defattr(-,root,root) + +%files -n clang-accel -f %{_sourcedir}/clang-accel.list +%defattr(-,root,root) + +%changelog diff --git a/packaging/qemu-accel.spec.in b/packaging/qemu-accel.spec.in index f20f5af..a6eec54 100644 --- a/packaging/qemu-accel.spec.in +++ b/packaging/qemu-accel.spec.in @@ -21,7 +21,7 @@ %define target_cpu %{cross} %define target_abi %{?armv7l:eabi}%{?armv7hl:eabihf} %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi} -%define libdir %{_prefix}/lib%{?aarch64:64} +%define libdir %{_prefix}/lib%{?aarch64:64}%{?riscv64:64} #disable strip debug info due to patchelf + armv7hl bug %{?armv7hl: @@ -95,12 +95,22 @@ BuildConflicts: guile BuildRequires: guile BuildConflicts: guile-32bit %endif +%if 0%{?riscv64} +# 64bit guile is used for riscv64 +BuildRequires: guile +BuildConflicts: guile-32bit +%endif %else # x86_64 %if 0%{?aarch64} # 64bit guile is required for aarch64 build BuildRequires: guile-64bit BuildConflicts: guile %endif +%if 0%{?riscv64} +# 64bit guile is required for riscv64 build +BuildRequires: guile-64bit +BuildConflicts: guile +%endif %if 0%{?armv7l} # 32bit guile is used for armv7l and armv7hl builds BuildRequires: guile @@ -227,7 +237,7 @@ for executable in %{emul_path}$LD \ %{_bindir}/eu-{addr2line,ar,elfclassify,elfcmp,elfcompress,elflint,findtextrel,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}-{addr2line,ar,as,c++filt%{!?riscv64:,dwp},elfedit,gprof,ld,ld.bfd%{!?riscv64:,ld.gold},nm,objcopy,objdump,ranlib,readelf,size,strings,strip} \ %{_bindir}/%{target_arch}-{c++,g++,cpp,gcc,gcc-ar,gcc-nm,gcc-ranlib,gcov,gfortran} \ ${gcc_install_dir}{cc1,cc1plus,collect2,lto1,lto-wrapper,liblto_plugin.so*,f951} \ %{_bindir}/file \ @@ -420,7 +430,7 @@ sed -e 's|%{emul_path}/lib|%{emul_path}/usr/lib|' -i %{_sourcedir}/multilib-acce } # 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 +for binary in addr2line ar as c++filt%{!?riscv64: dwp} elfedit gprof ld ld.bfd%{!?riscv64: ld.gold} nm objcopy objdump ranlib readelf size strings strip do mv ${buildroot_emul_path}%{_bindir}/%{target_arch}-$binary ${buildroot_emul_path}%{_bindir}/$binary sed -e "\|%{emul_path}%{_bindir}/%{target_arch}-$binary|d" -i %{_sourcedir}/all-accel.list @@ -428,7 +438,7 @@ do done mkdir -p ${buildroot_emul_path}/%{_prefix}/%{target_arch}/bin -for binary in ar as ld{,.bfd,.gold} nm obj{copy,dump} ranlib strip; do +for binary in ar as ld{,.bfd%{!?riscv64:,.gold}} nm obj{copy,dump} ranlib strip; do ln -sf %{emul_path}%{_bindir}/$binary ${buildroot_emul_path}%{_prefix}/%{target_arch}/bin/$binary echo "%{emul_path}%{_bindir}/$binary" >> %{_sourcedir}/all-accel.list echo "%{emul_path}%{_prefix}/%{target_arch}/bin/$binary" >> %{_sourcedir}/all-accel.list @@ -552,8 +562,8 @@ cat %{_sourcedir}/baselibs_prologue %{_sourcedir}/baselibs_body > %{_sourcedir}/ # By default this is ${gcc_install_dir}/liblto_plugin.so target_liblto_plugin="$(%{target_arch}-gcc -print-file-name=liblto_plugin.so)" # update baselibs.conf, overwrite LTO plugin - -sed -e "s,#PLUGIN_POSTIN#,if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf + # TODO: !!! replace this dirty hack with real libdir after stabilization +sed -e "s,#PLUGIN_POSTIN#,%{?riscv64:mkdir -p /usr/lib/gcc/%{target_arch} \&\& ln -sf /usr/lib64/gcc/%{target_arch}/13.1.0 /usr/lib/gcc/%{target_arch}/13.1.0 \&\& } if [ -d $(dirname ${target_liblto_plugin}) ]; then\"\n post \" ln -sf %{emul_path}${target_liblto_plugin} ${target_liblto_plugin}\"\n post \"fi#PLUGIN_POSTIN_SAN#," -i %{_sourcedir}/baselibs.conf %if 0%{?asan} || 0%{?hwasan_build} sed -e "s,#PLUGIN_POSTIN_SAN#,\"\n post \"chmod a+w /emul/usr/bin/ \&\& chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-*/obj/gcc/ \&\& find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w," -i %{_sourcedir}/baselibs.conf %else |