packaging: Add riscv64 platform 82/297082/1
authorSlava Barinov <v.barinov@samsung.com>
Thu, 1 Jun 2023 09:21:49 +0000 (12:21 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 10 Aug 2023 04:22:20 +0000 (13:22 +0900)
Change-Id: I127a29c6910e8863bb2e3e0b1ec8c4b7f82c22f8
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
packaging/binutils-aarch64.spec
packaging/binutils-armv7hl.spec
packaging/binutils-armv7l.spec
packaging/binutils-riscv64.spec [new file with mode: 0644]
packaging/binutils.spec
packaging/pre_checkin.sh

index 454975c..f118612 100644 (file)
@@ -18,6 +18,9 @@
 %ifarch aarch64
 %define ARCH aarch64
 %endif
+%ifarch riscv64
+%define ARCH riscv64
+%endif
 
 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
 
@@ -91,6 +94,7 @@ License:        GPL-2.0+
 It contains the binutils shared libraries that applications can link
 to at runtime.
 
+%ifnarch riscv64
 %package gold
 Summary:        The gold linker
 License:        GPL-3.0+
@@ -100,7 +104,7 @@ Group:          Development/Building
 gold is an ELF linker. It is intended to have complete support for ELF
 and to run as fast as possible on modern systems.  For normal use it is
 a drop-in replacement for the older GNU linker.
-
+%endif
 
 %package devel
 Summary:        GNU binutils (BFD development files)
@@ -157,6 +161,9 @@ cd build-dir
        --infodir=%{_infodir} --mandir=%{_mandir} \
        --with-bugurl=http://bugs.tizen.org/ \
        --with-sysroot=/ \
+%ifarch riscv64
+       --with-lib-path="=%{_libdir}" \
+%endif
        --disable-nls \
        --with-separate-debug-dir=%{_prefix}/lib/debug \
        --with-pic \
@@ -167,10 +174,12 @@ cd build-dir
        --enable-64-bit-bfd \
 } \
 %{!?cross: \
-       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
+       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
 } \
        --enable-plugins \
+%ifnarch riscv64
        --enable-gold \
+%endif
        --enable-shared \
        --enable-new-dtags \
        --enable-relro=no \
@@ -210,8 +219,15 @@ done
 cd build-dir
 make DESTDIR=$RPM_BUILD_ROOT install
 
+export LINKERS="ld ld.bfd"
+%ifnarch riscv64
+# There's neither native gold nor cross-gold for riscv64 yet
+%{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
+%else
+%endif
+
 # Copy instead of hardlinks
-for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
+for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
 do
   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
 %{!?cross:
@@ -267,11 +283,13 @@ rm -rf %{buildroot}%{_datadir}
 %{_includedir}/*.h
 %{_libdir}/*.a
 
+%ifnarch riscv64
 %files gold
 %manifest binutils.manifest
 %defattr(-,root,root)
 %{_bindir}/ld.gold
 %{_prefix}/%{target_arch}/bin/ld.gold
+%endif
 }
 
 %{?binutils_run_tests:
index d362d67..ea8438d 100644 (file)
@@ -18,6 +18,9 @@
 %ifarch aarch64
 %define ARCH aarch64
 %endif
+%ifarch riscv64
+%define ARCH riscv64
+%endif
 
 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
 
@@ -91,6 +94,7 @@ License:        GPL-2.0+
 It contains the binutils shared libraries that applications can link
 to at runtime.
 
+%ifnarch riscv64
 %package gold
 Summary:        The gold linker
 License:        GPL-3.0+
@@ -100,7 +104,7 @@ Group:          Development/Building
 gold is an ELF linker. It is intended to have complete support for ELF
 and to run as fast as possible on modern systems.  For normal use it is
 a drop-in replacement for the older GNU linker.
-
+%endif
 
 %package devel
 Summary:        GNU binutils (BFD development files)
@@ -157,6 +161,9 @@ cd build-dir
        --infodir=%{_infodir} --mandir=%{_mandir} \
        --with-bugurl=http://bugs.tizen.org/ \
        --with-sysroot=/ \
+%ifarch riscv64
+       --with-lib-path="=%{_libdir}" \
+%endif
        --disable-nls \
        --with-separate-debug-dir=%{_prefix}/lib/debug \
        --with-pic \
@@ -167,10 +174,12 @@ cd build-dir
        --enable-64-bit-bfd \
 } \
 %{!?cross: \
-       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
+       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
 } \
        --enable-plugins \
+%ifnarch riscv64
        --enable-gold \
+%endif
        --enable-shared \
        --enable-new-dtags \
        --enable-relro=no \
@@ -210,8 +219,15 @@ done
 cd build-dir
 make DESTDIR=$RPM_BUILD_ROOT install
 
+export LINKERS="ld ld.bfd"
+%ifnarch riscv64
+# There's neither native gold nor cross-gold for riscv64 yet
+%{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
+%else
+%endif
+
 # Copy instead of hardlinks
-for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
+for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
 do
   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
 %{!?cross:
@@ -267,11 +283,13 @@ rm -rf %{buildroot}%{_datadir}
 %{_includedir}/*.h
 %{_libdir}/*.a
 
+%ifnarch riscv64
 %files gold
 %manifest binutils.manifest
 %defattr(-,root,root)
 %{_bindir}/ld.gold
 %{_prefix}/%{target_arch}/bin/ld.gold
+%endif
 }
 
 %{?binutils_run_tests:
index 9b57602..62ac389 100644 (file)
@@ -18,6 +18,9 @@
 %ifarch aarch64
 %define ARCH aarch64
 %endif
+%ifarch riscv64
+%define ARCH riscv64
+%endif
 
 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
 
@@ -91,6 +94,7 @@ License:        GPL-2.0+
 It contains the binutils shared libraries that applications can link
 to at runtime.
 
+%ifnarch riscv64
 %package gold
 Summary:        The gold linker
 License:        GPL-3.0+
@@ -100,7 +104,7 @@ Group:          Development/Building
 gold is an ELF linker. It is intended to have complete support for ELF
 and to run as fast as possible on modern systems.  For normal use it is
 a drop-in replacement for the older GNU linker.
-
+%endif
 
 %package devel
 Summary:        GNU binutils (BFD development files)
@@ -157,6 +161,9 @@ cd build-dir
        --infodir=%{_infodir} --mandir=%{_mandir} \
        --with-bugurl=http://bugs.tizen.org/ \
        --with-sysroot=/ \
+%ifarch riscv64
+       --with-lib-path="=%{_libdir}" \
+%endif
        --disable-nls \
        --with-separate-debug-dir=%{_prefix}/lib/debug \
        --with-pic \
@@ -167,10 +174,12 @@ cd build-dir
        --enable-64-bit-bfd \
 } \
 %{!?cross: \
-       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
+       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
 } \
        --enable-plugins \
+%ifnarch riscv64
        --enable-gold \
+%endif
        --enable-shared \
        --enable-new-dtags \
        --enable-relro=no \
@@ -210,8 +219,15 @@ done
 cd build-dir
 make DESTDIR=$RPM_BUILD_ROOT install
 
+export LINKERS="ld ld.bfd"
+%ifnarch riscv64
+# There's neither native gold nor cross-gold for riscv64 yet
+%{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
+%else
+%endif
+
 # Copy instead of hardlinks
-for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
+for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
 do
   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
 %{!?cross:
@@ -267,11 +283,13 @@ rm -rf %{buildroot}%{_datadir}
 %{_includedir}/*.h
 %{_libdir}/*.a
 
+%ifnarch riscv64
 %files gold
 %manifest binutils.manifest
 %defattr(-,root,root)
 %{_bindir}/ld.gold
 %{_prefix}/%{target_arch}/bin/ld.gold
+%endif
 }
 
 %{?binutils_run_tests:
diff --git a/packaging/binutils-riscv64.spec b/packaging/binutils-riscv64.spec
new file mode 100644 (file)
index 0000000..b0d9a6c
--- /dev/null
@@ -0,0 +1,308 @@
+%define cross riscv64
+%define riscv64 1
+
+%ifarch armv7l
+%define ARCH armv7l
+%define ABI eabi
+%endif
+%ifarch armv7hl
+%define ARCH armv7hl
+%define ABI eabihf
+%endif
+%ifarch %ix86
+%define ARCH i586
+%endif
+%ifarch x86_64
+%define ARCH x86_64
+%endif
+%ifarch aarch64
+%define ARCH aarch64
+%endif
+%ifarch riscv64
+%define ARCH riscv64
+%endif
+
+%define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
+
+%define target_cpu %{?cross}%{!?cross:%{ARCH}}
+%define target_abi %{?cross:%{?armv7l:eabi}%{?armv7hl:eabihf}}%{!?cross:%{?ABI}}
+
+%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
+
+%if 0%{?run_tests}
+%{!?cross:
+%define binutils_run_tests 1
+}
+%endif
+
+%if 0%{?dump_configure}
+%define binutils_dump_configure 1
+%endif
+
+# Enable this when testing on device to:
+# 1. Enable macro to turn on testsuite building ('binutils_run_tests 1')
+# 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
+# binutils again on device after invoking rpmbuild --short-circuit -bc ...
+# 3. Skip configure and make commands and go directly to 'make check'
+%if 0%{?run_tests_on_device}
+%define binutils_run_tests 1
+%define binutils_keep_build_dir 1
+%define binutils_skip_configure 1
+%define binutils_skip_make 1
+%endif
+
+# Exit right after 'make ..' step to keep all object files produced by binutils build
+%if 0%{?exit_on_make_finish}
+%define binutils_exit_on_make_finish 1
+%endif
+
+Name:           binutils%{?cross:-%{cross}}
+BuildRequires:  binutils-libs
+BuildRequires:  makeinfo
+BuildRequires:  bison
+BuildRequires:  flex
+BuildRequires:  ncurses-devel
+BuildRequires:  zlib-devel
+BuildRequires:  gcc-c++
+%if 0%{?binutils_run_tests}
+BuildRequires:  dejagnu
+BuildRequires:  glibc-devel-static
+%endif
+%if 0%{?binutils_dump_configure}
+BuildRequires: configure-dumper
+%endif
+Version:        2.40
+Release:        0
+Url:            http://www.gnu.org/software/binutils/
+Summary:        GNU Binutils
+License:        GFDL-1.3 and GPL-3.0+
+Group:          Development/Building
+%{?cross:ExcludeArch: %{cross}}
+Source:         binutils-%{version}.tar.bz2
+Source1001:     binutils.manifest
+
+%description
+C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
+size, strings, and strip. These utilities are needed whenever you want
+to compile a program or kernel.
+
+%package libs
+Summary:        Shared library files for binutils
+License:        GPL-2.0+
+
+%description libs
+It contains the binutils shared libraries that applications can link
+to at runtime.
+
+%ifnarch riscv64
+%package gold
+Summary:        The gold linker
+License:        GPL-3.0+
+Group:          Development/Building
+
+%description gold
+gold is an ELF linker. It is intended to have complete support for ELF
+and to run as fast as possible on modern systems.  For normal use it is
+a drop-in replacement for the older GNU linker.
+%endif
+
+%package devel
+Summary:        GNU binutils (BFD development files)
+License:        GPL-3.0+
+Group:          Development/Building
+Requires: zlib-devel
+
+%description devel
+This package includes header files and static libraries necessary to
+build programs which use the GNU BFD library, which is part of
+binutils.
+
+%{?binutils_run_tests:
+%package testresults
+Summary:       Testsuite results
+License:       Public Domain
+Group:         Development/Building
+%description testresults
+Results from running the binutils tests.
+}
+
+%{?binutils_dump_configure:
+%package configure-dump
+Summary:       GNU Binutils configure dump
+License:       GPL-3.0+
+Group:         Development/Languages
+%description configure-dump
+This package contains dump of configure variables of Binutils
+}
+
+%prep
+%setup -q -n binutils-%{version}
+cp %{SOURCE1001} .
+
+
+%build
+RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
+export CFLAGS="${RPM_OPT_FLAGS}"
+export CXXFLAGS="${RPM_OPT_FLAGS}"
+
+%{!?binutils_keep_build_dir:
+rm -rf build-dir
+}
+# Remove gdb and sim since they have separate gdb package
+rm -rf gdb gdbserver gdbsupport sim
+
+mkdir -p build-dir
+cd build-dir
+
+%{!?binutils_skip_configure:
+%{?binutils_dump_configure:patch_configure.pl ..}   # Add debug prints into configure
+../configure \
+       --prefix=%{_prefix} --libdir=%{_libdir} \
+       --infodir=%{_infodir} --mandir=%{_mandir} \
+       --with-bugurl=http://bugs.tizen.org/ \
+       --with-sysroot=/ \
+%ifarch riscv64
+       --with-lib-path="=%{_libdir}" \
+%endif
+       --disable-nls \
+       --with-separate-debug-dir=%{_prefix}/lib/debug \
+       --with-pic \
+       --build=%{host_arch} --target=%{target_arch} \
+       --host=%{host_arch} \
+%{?cross: \
+       --enable-targets=%{target_arch} \
+       --enable-64-bit-bfd \
+} \
+%{!?cross: \
+       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
+} \
+       --enable-plugins \
+%ifnarch riscv64
+       --enable-gold \
+%endif
+       --enable-shared \
+       --enable-new-dtags \
+       --enable-relro=no \
+       --disable-gprofng \
+%ifarch %ix86
+       --disable-separate-code
+%endif
+
+}
+
+%{!?binutils_skip_make:
+make %{?_smp_mflags}
+%{?binutils_dump_configure:
+ dump_configure.pl .. . \
+                  --project binutils \
+                  --project-version %{version} \
+                  --out_db binutils-%{version}-%{release}-%_project-%_repository.db
+ }
+}
+
+%{?binutils_exit_on_make_finish:
+exit 1
+}
+
+%{?binutils_run_tests:
+echo "Run testsuite"
+# asan needs a whole shadow address space
+ulimit -v unlimited || true
+make -k check %{?_smp_mflags} || true
+mkdir ../testresults
+for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
+../contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ../testresults/test_summary.txt
+done
+}
+
+%install
+cd build-dir
+make DESTDIR=$RPM_BUILD_ROOT install
+
+export LINKERS="ld ld.bfd"
+%ifnarch riscv64
+# There's neither native gold nor cross-gold for riscv64 yet
+%{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
+%else
+%endif
+
+# Copy instead of hardlinks
+for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
+do
+  rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
+%{!?cross:
+  cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
+}
+%{?cross:
+  cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
+}
+done
+
+install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
+install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include
+
+%{?binutils_run_tests:
+  find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
+  mkdir -p ../testresults && tar -xf testresults.tar -C ../testresults
+  find ../testresults/ -type f -exec chmod 644 {} \;
+}
+
+# Remove unwanted files to shut up rpm
+%{remove_docs}
+rm -rf %{buildroot}%{_bindir}/gcore
+rm -rf %{buildroot}%{_libdir}/lib{bfd,ctf,ctf-nobfd,opcodes,inproctrace,sframe}.la
+%{?cross:
+rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
+rm -rf %{buildroot}%{_prefix}/%{host_arch}
+rm -rf %{buildroot}%{_includedir}
+rm -rf %{buildroot}%{_prefix}/lib*
+rm -rf %{buildroot}%{_datadir}
+}
+
+%{?binutils_dump_configure:
+  install -D -m 0644 binutils-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
+}
+
+%files
+%manifest binutils.manifest
+%defattr(-,root,root)
+%{_bindir}/*
+%{_prefix}/%{target_arch}/bin/*
+%{!?cross:
+%exclude %{_bindir}/ld.gold
+%exclude %{_prefix}/%{target_arch}/bin/ld.gold
+%{_prefix}/%{host_arch}/lib/ldscripts
+
+%files libs
+%{_libdir}/*.so*
+%{_libdir}/bfd-plugins/*.so
+
+%files devel
+%manifest binutils.manifest
+%defattr(-,root,root)
+%{_includedir}/*.h
+%{_libdir}/*.a
+
+%ifnarch riscv64
+%files gold
+%manifest binutils.manifest
+%defattr(-,root,root)
+%{_bindir}/ld.gold
+%{_prefix}/%{target_arch}/bin/ld.gold
+%endif
+}
+
+%{?binutils_run_tests:
+%files testresults
+%defattr(-,root,root)
+%doc testresults/test_summary.txt
+%doc testresults/*
+}
+
+%{?binutils_dump_configure:
+%files configure-dump
+%manifest binutils.manifest
+%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
+}
+
+%changelog
index 6bdb283..04b61ae 100644 (file)
@@ -15,6 +15,9 @@
 %ifarch aarch64
 %define ARCH aarch64
 %endif
+%ifarch riscv64
+%define ARCH riscv64
+%endif
 
 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
 
@@ -88,6 +91,7 @@ License:        GPL-2.0+
 It contains the binutils shared libraries that applications can link
 to at runtime.
 
+%ifnarch riscv64
 %package gold
 Summary:        The gold linker
 License:        GPL-3.0+
@@ -97,7 +101,7 @@ Group:          Development/Building
 gold is an ELF linker. It is intended to have complete support for ELF
 and to run as fast as possible on modern systems.  For normal use it is
 a drop-in replacement for the older GNU linker.
-
+%endif
 
 %package devel
 Summary:        GNU binutils (BFD development files)
@@ -154,6 +158,9 @@ cd build-dir
        --infodir=%{_infodir} --mandir=%{_mandir} \
        --with-bugurl=http://bugs.tizen.org/ \
        --with-sysroot=/ \
+%ifarch riscv64
+       --with-lib-path="=%{_libdir}" \
+%endif
        --disable-nls \
        --with-separate-debug-dir=%{_prefix}/lib/debug \
        --with-pic \
@@ -164,10 +171,12 @@ cd build-dir
        --enable-64-bit-bfd \
 } \
 %{!?cross: \
-       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
+       --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
 } \
        --enable-plugins \
+%ifnarch riscv64
        --enable-gold \
+%endif
        --enable-shared \
        --enable-new-dtags \
        --enable-relro=no \
@@ -207,8 +216,15 @@ done
 cd build-dir
 make DESTDIR=$RPM_BUILD_ROOT install
 
+export LINKERS="ld ld.bfd"
+%ifnarch riscv64
+# There's neither native gold nor cross-gold for riscv64 yet
+%{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
+%else
+%endif
+
 # Copy instead of hardlinks
-for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
+for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
 do
   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
 %{!?cross:
@@ -264,11 +280,13 @@ rm -rf %{buildroot}%{_datadir}
 %{_includedir}/*.h
 %{_libdir}/*.a
 
+%ifnarch riscv64
 %files gold
 %manifest binutils.manifest
 %defattr(-,root,root)
 %{_bindir}/ld.gold
 %{_prefix}/%{target_arch}/bin/ld.gold
+%endif
 }
 
 %{?binutils_run_tests:
index 1134ae7..c70a185 100755 (executable)
@@ -2,7 +2,7 @@
 
 # the script takes binutils* and creates the cross-* packages
 # sh4 is stuck in the testsuite
-for arch in armv7l armv7hl aarch64; do
+for arch in armv7l armv7hl aarch64 riscv64; do
 
    echo -n "Building package for $arch --> binutils-$arch ..."