Skip to contentSkip to conversation

RISC-V Build fixes

PATCH In review Khem Raj 2 participants 12 messages Mar 17, 2018 – Mar 19, 2018 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

cover RISC-V Build fixes

These packages were failing to build for qemuriscv64 world build Some fixes are common, some are backports and some are already submitted to respective upstream

The following changes since commit c94271d87d16323f920891344642f76dfb3c994f:

buildperf: measure the size of core-image-sato rootfs (2018-03-16 03:42:03 -0700)

are available in the Git repository at:

git://git.openembedded.org/openembedded-core-contrib kraj/riscv64-fixes-3
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=kraj/riscv64-fixes-3

Khem Raj (5):
gcc: Do not use --with-linker-hash-style if LINKER_HASH_STYLE is empty
mtd-utils: Explicitly add pthread options to cflags
x264: Use updated gnu-config artifacts
python-numpy: Fix build for riscv64
dpkg: Backport riscv support

 .../0001-arch-Add-support-for-riscv64-CPU.patch    |  54 ++++++++
 .../dpkg/dpkg/glibc2.5-sync_file_range.patch       |  21 +++-
 meta/recipes-devtools/dpkg/dpkg_1.18.24.bb         |   1 +
 meta/recipes-devtools/gcc/gcc-7.3.inc              |   2 +-
 meta/recipes-devtools/mtd/mtd-utils_git.bb         |   2 +
 .../files/0001-npy_cpu-Add-riscv-support.patch     |  28 +++++
 .../python-numpy/files/riscv64/_numpyconfig.h      |  32 +++++
 .../python-numpy/files/riscv64/config.h            | 139 +++++++++++++++++++++
 .../recipes-devtools/python-numpy/python-numpy.inc |   5 +
 meta/recipes-multimedia/x264/x264_git.bb           |   2 +
 10 files changed, 280 insertions(+), 6 deletions(-)
 create mode 100644 meta/recipes-devtools/dpkg/dpkg/0001-arch-Add-support-for-riscv64-CPU.patch
 create mode 100644 meta/recipes-devtools/python-numpy/files/0001-npy_cpu-Add-riscv-support.patch
 create mode 100644 meta/recipes-devtools/python-numpy/files/riscv64/_numpyconfig.h
 create mode 100644 meta/recipes-devtools/python-numpy/files/riscv64/config.h
Signature · 1 line
2.16.2
author
#1 lore raw

PATCH 1/5 gcc: Do not use --with-linker-hash-style if LINKER_HASH_STYLE is empty

We allow to set LINKER_HASH_STYLE to be empty so this would fail since --with-linker-hash-style needs an argument and cant be empty

---
 meta/recipes-devtools/gcc/gcc-7.3.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-7.3.inc +1 -1
index d56d2c5e06..a80926216b 100644
@@ -100,7 +100,7 @@ EXTRA_OECONF_BASE = "\
     --disable-bootstrap \
     --disable-libmudflap \
     --with-system-zlib \
-    --with-linker-hash-style=${LINKER_HASH_STYLE} \
+    ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \
     --enable-linker-build-id \
     --with-ppl=no \
     --with-cloog=no \
Signature · 1 line
2.16.2
author
#2 lore raw

PATCH 2/5 mtd-utils: Explicitly add pthread options to cflags

In reply to Khem Raj

Some architectures e.g. riscv gcc does not add -D_REENTRANT when enabling pthreads. Help it here by adding these options while gcc gets fixed

---
 meta/recipes-devtools/mtd/mtd-utils_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/mtd/mtd-utils_git.bb +2 -0
index 3c34bdd84e..d09d633022 100644
@@ -24,6 +24,8 @@ S = "${WORKDIR}/git/"
 PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}"
 PACKAGECONFIG[xattr] = ",,acl,"
 
+CPPFLAGS_append_riscv64  = " -pthread -D_REENTRANT"
+
 EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} ${@bb.utils.contains('PACKAGECONFIG', 'xattr', '', '-DWITHOUT_XATTR', d)} -I${S}/include' 'BUILDDIR=${S}'"
 
 ALTERNATIVE_${PN} = "flash_eraseall"
Signature · 1 line
2.16.2
author
#3 lore raw

PATCH 3/5 x264: Use updated gnu-config artifacts

In reply to Khem Raj

It is not using autoconf completely, therefore there is no autoreconf happening, so when we depend on latest gnu-config changes e.g. new architectures like riscv the build does not see them and fails.

Installing these files from native sysroot helps

---
 meta/recipes-multimedia/x264/x264_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-multimedia/x264/x264_git.bb +2 -0
index a669295044..c445d15e69 100644
@@ -43,6 +43,8 @@ EXTRA_OECONF = '--prefix=${prefix} \
                '
 
 do_configure() {
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess ${S}
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
     ./configure ${EXTRA_OECONF}
 }
 
Signature · 1 line
2.16.2
#4 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

Quoted 18 lines · Khem Raj

It is not using autoconf completely, therefore there is no autoreconf happening, so when we depend on latest gnu-config changes e.g. new architectures like riscv the build does not see them and fails.

Installing these files from native sysroot helps

---
 meta/recipes-multimedia/x264/x264_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-multimedia/x264/x264_git.bb +0 -0
index a669295044..c445d15e69 100644

meta/recipes-multimedia/x264/x264_git.bb EXTRA_OECONF = '--prefix=${prefix} \ · line 49

Quoted 7 lines
meta/recipes-multimedia/x264/x264_git.bb +2 -0
@@ -43,6 +43,8 @@ EXTRA_OECONF = '--prefix=${prefix} \
                '
 
 do_configure() {
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess
 ${S}
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
     ./configure ${EXTRA_OECONF}

A neater way is to call gnu-configize --force ${S}.

Ross

author
#5 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

Thanks for the tip!

Quoted 33 lines · Ross
Quoted 18 lines · Khem Raj

It is not using autoconf completely, therefore there is no autoreconf happening, so when we depend on latest gnu-config changes e.g. new architectures like riscv the build does not see them and fails.

Installing these files from native sysroot helps

---
 meta/recipes-multimedia/x264/x264_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-multimedia/x264/x264_git.bb +0 -0
index a669295044..c445d15e69 100644

meta/recipes-multimedia/x264/x264_git.bb EXTRA_OECONF = '--prefix=${prefix} \ · line 49

Quoted 7 lines
meta/recipes-multimedia/x264/x264_git.bb +2 -0
@@ -43,6 +43,8 @@ EXTRA_OECONF = '--prefix=${prefix} \
                '
 
 do_configure() {
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess
 ${S}
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
     ./configure ${EXTRA_OECONF}

A neater way is to call gnu-configize --force ${S}.

Ross

author
#6 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

In reply to Burton, Ross
Quoted 22 lines · Ross
Quoted 21 lines · Khem Raj

It is not using autoconf completely, therefore there is no autoreconf happening, so when we depend on latest gnu-config changes e.g. new architectures like riscv the build does not see them and fails.

Installing these files from native sysroot helps

---
 meta/recipes-multimedia/x264/x264_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-multimedia/x264/x264_git.bb +0 -0
index a669295044..c445d15e69 100644
@@ -43,6 +43,8 @@ EXTRA_OECONF = '--prefix=${prefix} \
                '
 
Quoted 9 lines

meta/recipes-multimedia/x264/x264_git.bb EXTRA_OECONF = '--prefix=${prefix} \ · line 48

Quoted 5 lines
meta/recipes-multimedia/x264/x264_git.bb +2 -0
 do_configure() {
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess
 ${S}
+    install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S}
     ./configure ${EXTRA_OECONF}

A neater way is to call gnu-configize --force ${S}.

this only works if the system uses autotools in full respect. x264 has a hand woven configure but rely on other parts of autotools. So we have to stay with proposed solution.

Quoted 1 line

Ross

#7 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

Quoted 5 lines · Khem Raj

this only works if the system uses autotools in full respect. x264 has a hand woven configure but rely on other parts of autotools. So we have to stay with proposed solution.

gnu-configize should be sufficiently dumb that it should work in non-autotools trees, did it give you an error message?

Ross

author
#8 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

Quoted 11 lines · Ross
Quoted 5 lines · Khem Raj

this only works if the system uses autotools in full respect. x264 has a hand woven configure but rely on other parts of autotools. So we have to stay with proposed solution.

gnu-configize should be sufficiently dumb that it should work in non-autotools trees, did it give you an error message?

its looking for configure.in or configure.ac

Quoted 1 line

Ross

#9 lore raw

Re: [PATCH 3/5] x264: Use updated gnu-config artifacts

Huh, I was hoping that passing a path would just force it.

Maybe we should stop the script being so "clever".

Ross

Quoted 18 lines · Khem Raj
Quoted 11 lines · Ross
Quoted 5 lines · Khem Raj

this only works if the system uses autotools in full respect. x264 has a hand woven configure but rely on other parts of autotools. So we have to stay with proposed solution.

gnu-configize should be sufficiently dumb that it should work in non-autotools trees, did it give you an error message?

its looking for configure.in or configure.ac

Quoted 1 line

Ross

author
#10 lore raw

PATCH 4/5 python-numpy: Fix build for riscv64

In reply to Khem Raj
---
 .../files/0001-npy_cpu-Add-riscv-support.patch     |  28 +++++
 .../python-numpy/files/riscv64/_numpyconfig.h      |  32 +++++
 .../python-numpy/files/riscv64/config.h            | 139 +++++++++++++++++++++
 .../recipes-devtools/python-numpy/python-numpy.inc |   5 +
 4 files changed, 204 insertions(+)
 create mode 100644 meta/recipes-devtools/python-numpy/files/0001-npy_cpu-Add-riscv-support.patch
 create mode 100644 meta/recipes-devtools/python-numpy/files/riscv64/_numpyconfig.h
 create mode 100644 meta/recipes-devtools/python-numpy/files/riscv64/config.h
meta/recipes-devtools/python-numpy/files/0001-npy_cpu-Add-riscv-support.patch new file +28 -0
new file mode 100644
index 0000000000..4f5c4f5f0d
@@ -0,0 +1,28 @@
+From 30fb1bf9244bb0789c02ec7c98a923acc7200206 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 16 Mar 2018 19:55:21 -0700
+Subject: [PATCH] npy_cpu: Add riscv support
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+Upstream-Status: Submitted [https://github.com/numpy/numpy/pull/10761]
+
+ numpy/core/include/numpy/npy_cpu.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h
+index 84653ea18..9e88db873 100644
+--- a/numpy/core/include/numpy/npy_cpu.h
++++ b/numpy/core/include/numpy/npy_cpu.h
+@@ -78,6 +78,8 @@
+     #define NPY_CPU_AARCH64
+ #elif defined(__mc68000__)
+     #define NPY_CPU_M68K
++#elif defined(__riscv)
++    #define NPY_CPU_RISCV
+ #elif defined(__arc__) && defined(__LITTLE_ENDIAN__)
+     #define NPY_CPU_ARCEL
+ #elif defined(__arc__) && defined(__BIG_ENDIAN__)
+-- 
+2.16.2
+
meta/recipes-devtools/python-numpy/files/riscv64/_numpyconfig.h new file +32 -0
new file mode 100644
index 0000000000..109deb0435
@@ -0,0 +1,32 @@
+#define NPY_HAVE_ENDIAN_H 1
+#define NPY_SIZEOF_SHORT SIZEOF_SHORT
+#define NPY_SIZEOF_INT SIZEOF_INT
+#define NPY_SIZEOF_LONG SIZEOF_LONG
+#define NPY_SIZEOF_FLOAT 4
+#define NPY_SIZEOF_COMPLEX_FLOAT 8
+#define NPY_SIZEOF_DOUBLE 8
+#define NPY_SIZEOF_COMPLEX_DOUBLE 16
+#define NPY_SIZEOF_LONGDOUBLE 16
+#define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
+#define NPY_SIZEOF_PY_INTPTR_T 8
+#define NPY_SIZEOF_PY_LONG_LONG 8
+#define NPY_SIZEOF_LONGLONG 8
+#define NPY_SIZEOF_OFF_T 8
+#define NPY_NO_SMP 0
+#define NPY_HAVE_DECL_ISNAN
+#define NPY_HAVE_DECL_ISINF
+#define NPY_HAVE_DECL_ISFINITE
+#define NPY_HAVE_DECL_SIGNBIT
+#define NPY_USE_C99_COMPLEX 1
+#define NPY_HAVE_COMPLEX_DOUBLE 1
+#define NPY_HAVE_COMPLEX_FLOAT 1
+#define NPY_HAVE_COMPLEX_LONG_DOUBLE 1
+#define NPY_ENABLE_SEPARATE_COMPILATION 1
+#define NPY_USE_C99_FORMATS 1
+#define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
+#define NPY_ABI_VERSION 0x01000009
+#define NPY_API_VERSION 0x0000000A
+
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS 1
+#endif
meta/recipes-devtools/python-numpy/files/riscv64/config.h new file +139 -0

139 lines not on this page · raw message

meta/recipes-devtools/python-numpy/python-numpy.inc +5 -0
index 10af4c50e3..5c5f0c837a 100644
@@ -8,6 +8,7 @@ SRCNAME = "numpy"
 SRC_URI = "https://github.com/${SRCNAME}/${SRCNAME}/releases/download/v${PV}/${SRCNAME}-${PV}.tar.gz \
            file://0001-Don-t-search-usr-and-so-on-for-libraries-by-default-.patch \
            file://fix_shebang_f2py.patch \
+           file://0001-npy_cpu-Add-riscv-support.patch \
            ${CONFIGFILESURI} "
 SRC_URI[md5sum] = "0e09f20f62ab9f8a02cb7bd3fd023482"
 SRC_URI[sha256sum] = "8708a775be9a9a457b80a49193c57bd9d51a8a195ed1f1c4b8e89eaf3aa646ee"
@@ -69,6 +70,10 @@ CONFIGFILESURI_mipsarchn32el = " \
     file://config.h \
     file://_numpyconfig.h \
 "
+CONFIGFILESURI_riscv64 = " \
+    file://config.h \
+    file://_numpyconfig.h \
+"
 
 S = "${WORKDIR}/numpy-${PV}"
 
Signature · 1 line
2.16.2
author
#11 lore raw

PATCH 5/5 dpkg: Backport riscv support

In reply to Khem Raj

Refresh patches with devtool

---
 .../0001-arch-Add-support-for-riscv64-CPU.patch    | 54 ++++++++++++++++++++++
 .../dpkg/dpkg/glibc2.5-sync_file_range.patch       | 21 +++++++--
 meta/recipes-devtools/dpkg/dpkg_1.18.24.bb         |  1 +
 3 files changed, 71 insertions(+), 5 deletions(-)
 create mode 100644 meta/recipes-devtools/dpkg/dpkg/0001-arch-Add-support-for-riscv64-CPU.patch
meta/recipes-devtools/dpkg/dpkg/0001-arch-Add-support-for-riscv64-CPU.patch new file +54 -0
new file mode 100644
index 0000000000..45c606e690
@@ -0,0 +1,54 @@
+From 319f32d743f5b5e725012654d124e49226d5de91 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 16 Mar 2018 20:28:24 -0700
+Subject: [PATCH] arch: Add support for riscv64 CPU
+
+  * Architecture support:
+    - Add support for riscv64 CPU. Closes: #822914
+      Thanks to Manuel A. Fernandez Montecelo <[email protected]>
+
+Upstream-Status: Backport [https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=dpkg%2Fdpkg.git;a=commitdiff_plain;h=ee0855cc66076691de4796be48f8a0d889fde001;hp=2f5816d8be40b449d2473b22f9e0c33b32f3bd78]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ data/cputable         | 1 +
+ scripts/t/Dpkg_Arch.t | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/data/cputable b/data/cputable
+index a2bd7d6..9f2a8e0 100644
+--- a/data/cputable
++++ b/data/cputable
+@@ -41,6 +41,7 @@ powerpc		powerpc		(powerpc|ppc)		32	big
+ powerpcel	powerpcle	powerpcle		32	little
+ ppc64		powerpc64	(powerpc|ppc)64		64	big
+ ppc64el		powerpc64le	powerpc64le		64	little
++riscv64		riscv64		riscv64			64	little
+ s390		s390		s390			32	big
+ s390x		s390x		s390x			64	big
+ sh3		sh3		sh3			32	little
+diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t
+index d478b49..ecd5d66 100644
+--- a/scripts/t/Dpkg_Arch.t
++++ b/scripts/t/Dpkg_Arch.t
+@@ -16,7 +16,7 @@
+ use strict;
+ use warnings;
+ 
+-use Test::More tests => 16367;
++use Test::More tests => 16832;
+ 
+ use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
+                         debarch_eq debarch_is debarch_is_wildcard
+@@ -162,7 +162,7 @@ is(gnutriplet_to_debarch(undef), undef, 'undef gnutriplet');
+ is(gnutriplet_to_debarch('unknown-unknown-unknown'), undef, 'unknown gnutriplet');
+ is(gnutriplet_to_debarch('x86_64-linux-gnu'), 'amd64', 'known gnutriplet');
+ 
+-is(scalar get_valid_arches(), 524, 'expected amount of known architectures');
++is(scalar get_valid_arches(), 539, 'expected amount of known architectures');
+ 
+ {
+     local $ENV{CC} = 'false';
+-- 
+2.16.2
+
meta/recipes-devtools/dpkg/dpkg/glibc2.5-sync_file_range.patch +16 -5
index d56b8a69a3..d48386647e 100644
@@ -1,12 +1,17 @@
+From 9d260d408f9e17abd1d1dccd685bd7e80a3655a9 Mon Sep 17 00:00:00 2001
+From: Donn Seeley <[email protected]>
+Date: Tue, 25 Feb 2014 17:44:04 +0800
+Subject: [PATCH] dpkg: fix a link problem for dpkg-native on CentOS 5.8
+
 CentOS 5.8 kernels and headers support the sync_file_range() system call,
 but glibc 2.5 doesn't provide the syscall stub.  It appears that this
 problem is known but will never be fixed:
 
   https://bugzilla.redhat.com/show_bug.cgi?id=518581
 
-  Bug 518581 - [RHEL5] glibc misses sync_file_range syscall interface 
+  Bug 518581 - [RHEL5] glibc misses sync_file_range syscall interface
 
-  Status:       CLOSED CANTFIX 
+  Status:       CLOSED CANTFIX
   Last Closed:  2009-11-22 22:19:55
 
   Kirby Zhou 2009-08-20 23:37:55 EDT
@@ -60,13 +65,16 @@ Upstream-Status: Inappropriate [everyone else builds on newer hosts :-)]
 
 Signed-off-by: Donn Seeley <[email protected]>
 Signed-off-by: Lei Liu <[email protected]>
+
 ---
- src/archives.c |    4 ++--
+ src/archives.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
+diff --git a/src/archives.c b/src/archives.c
+index 4b2fc92..a92b795 100644
 --- a/src/archives.c
 +++ b/src/archives.c
-@@ -75,7 +75,7 @@
+@@ -69,7 +69,7 @@ fd_writeback_init(int fd)
    /* Ignore the return code as it should be considered equivalent to an
     * asynchronous hint for the kernel, we are doing an fsync() later on
     * anyway. */
@@ -75,7 +83,7 @@ Signed-off-by: Lei Liu <[email protected]>
    sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WRITE);
  #elif defined(HAVE_POSIX_FADVISE)
    posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
-@@ -1179,7 +1179,7 @@
+@@ -1078,7 +1078,7 @@ tarobject(void *ctx, struct tar_entry *ti)
    return 0;
  }
  
@@ -84,3 +92,6 @@ Signed-off-by: Lei Liu <[email protected]>
  static void
  tar_writeback_barrier(struct fileinlist *files, struct pkginfo *pkg)
  {
+-- 
+2.16.2
+
meta/recipes-devtools/dpkg/dpkg_1.18.24.bb +1 -0
index c0c59f1410..6d8ec34768 100644
@@ -14,6 +14,7 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20170518T093838Z/pool/main/
            file://0006-add-musleabi-to-known-target-tripets.patch \
            file://0007-dpkg-deb-build.c-Remove-usage-of-clamp-mtime-in-tar.patch \
            file://0001-dpkg-Support-muslx32-build.patch \
+           file://0001-arch-Add-support-for-riscv64-CPU.patch \
            "
 SRC_URI_append_class-native = " file://glibc2.5-sync_file_range.patch "
 
Signature · 1 line
2.16.2