Skip to contentSkip to conversation

libmad: Define O2 for all arches as default optimization

PATCH New Khem Raj 1 participant 5 messages Nov 18, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/5 libmad: Define O2 for all arches as default optimization

Extend mips inline asm fix to build on clang

../libmad-0.15.1b/layer12.c:94:10: error: invalid output constraint '=h' in asm

  return mad_f_mul(sample, linear_table[nb - 2]);
         ^
---
 ...ove-clang-unsupported-compiler-flags.patch | 92 +++++++++++++------
 .../libmad/fix_for_mips_with_gcc-4.5.0.patch  |  8 +-
 2 files changed, 69 insertions(+), 31 deletions(-)
meta-oe/recipes-multimedia/libmad/libmad/0004-Remove-clang-unsupported-compiler-flags.patch +66 -26
index 5bfce4d908..70723f2d08 100644
@@ -7,37 +7,77 @@ Subject: [PATCH 4/4] Remove clang unsupported compiler flags
  configure.ac | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
 
-diff --git a/configure.ac b/configure.ac
-index 4fcd48b..40302db 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -140,20 +140,20 @@ then
-     case "$optimize" in
- 	-O|"-O "*)
- 	    optimize="-O"
+@@ -124,70 +124,7 @@ done
+ 
+ if test "$GCC" = yes
+ then
+-    if test -z "$arch"
+-    then
+-	case "$host" in
+-	    i386-*)           ;;
+-	    i?86-*)           arch="-march=i486" ;;
+-	    arm*-empeg-*)     arch="-march=armv4 -mtune=strongarm1100" ;;
+-	    armv4*-*)         arch="-march=armv4 -mtune=strongarm" ;;
+-	    powerpc-*)        ;;
+-	    mips*-agenda-*)   arch="-mcpu=vr4100" ;;
+-	    mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;;
+-	esac
+-    fi
+-
+-    case "$optimize" in
+-	-O|"-O "*)
+-	    optimize="-O"
 -	    optimize="$optimize -fforce-addr"
-+	    : #optimize="$optimize -fforce-addr"
- 	    : #x optimize="$optimize -finline-functions"
- 	    : #- optimize="$optimize -fstrength-reduce"
+-	    : #x optimize="$optimize -finline-functions"
+-	    : #- optimize="$optimize -fstrength-reduce"
 -	    optimize="$optimize -fthread-jumps"
 -	    optimize="$optimize -fcse-follow-jumps"
 -	    optimize="$optimize -fcse-skip-blocks"
-+	    : #optimize="$optimize -fthread-jumps"
-+	    : #optimize="$optimize -fcse-follow-jumps"
-+	    : #optimize="$optimize -fcse-skip-blocks"
- 	    : #x optimize="$optimize -frerun-cse-after-loop"
- 	    : #x optimize="$optimize -frerun-loop-opt"
- 	    : #x optimize="$optimize -fgcse"
- 	    optimize="$optimize -fexpensive-optimizations"
+-	    : #x optimize="$optimize -frerun-cse-after-loop"
+-	    : #x optimize="$optimize -frerun-loop-opt"
+-	    : #x optimize="$optimize -fgcse"
+-	    optimize="$optimize -fexpensive-optimizations"
 -	    optimize="$optimize -fregmove"
-+	    : #optimize="$optimize -fregmove"
- 	    : #* optimize="$optimize -fdelayed-branch"
- 	    : #x optimize="$optimize -fschedule-insns"
+-	    : #* optimize="$optimize -fdelayed-branch"
+-	    : #x optimize="$optimize -fschedule-insns"
 -	    optimize="$optimize -fschedule-insns2"
-+	    : #optimize="$optimize -fschedule-insns2"
- 	    : #? optimize="$optimize -ffunction-sections"
- 	    : #? optimize="$optimize -fcaller-saves"
- 	    : #> optimize="$optimize -funroll-loops"
--- 
-2.1.0
-
+-	    : #? optimize="$optimize -ffunction-sections"
+-	    : #? optimize="$optimize -fcaller-saves"
+-	    : #> optimize="$optimize -funroll-loops"
+-	    : #> optimize="$optimize -funroll-all-loops"
+-	    : #x optimize="$optimize -fmove-all-movables"
+-	    : #x optimize="$optimize -freduce-all-givs"
+-	    : #? optimize="$optimize -fstrict-aliasing"
+-	    : #* optimize="$optimize -fstructure-noalias"
+-
+-	    case "$host" in
+-		arm*-*)
+-		    optimize="$optimize -fstrength-reduce"
+-		    ;;
+-		mips*-*)
+-		    optimize="$optimize -fstrength-reduce"
+-		    optimize="$optimize -finline-functions"
+-		    ;;
+-		i?86-*)
+-		    optimize="$optimize -fstrength-reduce"
+-		    ;;
+-		powerpc-apple-*)
+-		    # this triggers an internal compiler error with gcc2
+-		    : #optimize="$optimize -fstrength-reduce"
+-
+-		    # this is really only beneficial with gcc3
+-		    : #optimize="$optimize -finline-functions"
+-		    ;;
+-		*)
+-		    # this sometimes provokes bugs in gcc 2.95.2
+-		    : #optimize="$optimize -fstrength-reduce"
+-		    ;;
+-	    esac
+-	    ;;
+-    esac
++	optimize="-O2"
+ fi
+ 
+ case "$host" in
meta-oe/recipes-multimedia/libmad/libmad/fix_for_mips_with_gcc-4.5.0.patch +3 -5
index 01c7aa3c8c..5bc91f355d 100644
@@ -11,15 +11,13 @@ Upstream-Status: Pending
 2010/07/29
 Nitin A Kamble <[email protected]>
 
-Index: libmad-0.15.1b/fixed.h
-===================================================================
---- libmad-0.15.1b.orig/fixed.h
-+++ libmad-0.15.1b/fixed.h
+--- a/fixed.h
++++ b/fixed.h
 @@ -297,6 +297,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t
  
  /* --- MIPS ---------------------------------------------------------------- */
  
-+# elif defined(FPM_MIPS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
++# elif defined(FPM_MIPS) && (defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 +    typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
 +#   define MAD_F_MLX(hi, lo, x, y) \
 +    do { \
Signature · 1 line
2.24.0
author
#1 lore raw

PATCH 2/5 libkcapi: Move static inline functions where used

Clang warns about unused functions on some arches e.g. mips unused function '_bswap32' [-Werror,-Wunused-function]

---
 .../0001-kcapi-kdf-Move-code-to-fix.patch     | 67 +++++++++++++++++++
 .../recipes-crypto/libkcapi/libkcapi_git.bb   |  1 +
 2 files changed, 68 insertions(+)
 create mode 100644 meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kdf-Move-code-to-fix.patch
meta-oe/recipes-crypto/libkcapi/libkcapi/0001-kcapi-kdf-Move-code-to-fix.patch new file +67 -0
new file mode 100644
index 0000000000..3801207ed9
@@ -0,0 +1,67 @@
+From bf6c816ef61240a1dbbbf6f2a7b2a5ad5f846461 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 16 Nov 2019 23:03:51 -0800
+Subject: [PATCH] kcapi-kdf: Move code to fix
+
+Fixes clang build
+unused function '_bswap32' [-Werror,-Wunused-function]
+
+Upstream-Status: Submitted [https://github.com/smuellerDD/libkcapi/pull/83]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ lib/kcapi-kdf.c | 32 +++++++++++++++++---------------
+ 1 file changed, 17 insertions(+), 15 deletions(-)
+
+diff --git a/lib/kcapi-kdf.c b/lib/kcapi-kdf.c
+index ea39846..49c2d88 100644
+--- a/lib/kcapi-kdf.c
++++ b/lib/kcapi-kdf.c
+@@ -54,21 +54,6 @@
+ #include "kcapi.h"
+ #include "internal.h"
+ 
+-static inline uint32_t rol32(uint32_t x, int n)
+-{
+-	return ( (x << (n&(32-1))) | (x >> ((32-n)&(32-1))) );
+-}
+-
+-static inline uint32_t ror32(uint32_t x, int n)
+-{
+-	return ( (x >> (n&(32-1))) | (x << ((32-n)&(32-1))) );
+-}
+-
+-static inline uint32_t _bswap32(uint32_t x)
+-{
+-	return ((rol32(x, 8) & 0x00ff00ffL) | (ror32(x, 8) & 0xff00ff00L));
+-}
+-
+ #define GCC_VERSION (__GNUC__ * 10000		\
+ 		     + __GNUC_MINOR__ * 100	\
+ 		     + __GNUC_PATCHLEVEL__)
+@@ -86,6 +71,23 @@ static inline uint32_t _bswap32(uint32_t x)
+ #if __BYTE_ORDER__ ==  __ORDER_BIG_ENDIAN__
+ # define be_bswap32(x) ((uint32_t)(x))
+ #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
++
++static inline uint32_t rol32(uint32_t x, int n)
++{
++	return ( (x << (n&(32-1))) | (x >> ((32-n)&(32-1))) );
++}
++
++static inline uint32_t ror32(uint32_t x, int n)
++{
++	return ( (x >> (n&(32-1))) | (x << ((32-n)&(32-1))) );
++}
++
++
++static inline uint32_t _bswap32(uint32_t x)
++{
++	return ((rol32(x, 8) & 0x00ff00ffL) | (ror32(x, 8) & 0xff00ff00L));
++}
++
+ # define be_bswap32(x) _swap32(x)
+ #else
+ #error "Endianess not defined"
+-- 
+2.24.0
+
meta-oe/recipes-crypto/libkcapi/libkcapi_git.bb +1 -0
index 799070972a..aa438e5859 100644
@@ -10,6 +10,7 @@ SRCREV = "5649050d201856bf06c8738b5d2aa1710c86ac2f"
 PV = "1.1.5"
 SRC_URI = " \
     git://github.com/smuellerDD/libkcapi.git \
+    file://0001-kcapi-kdf-Move-code-to-fix.patch \
 "
 
 inherit autotools
Signature · 1 line
2.24.0
author
#2 lore raw

PATCH 3/5 rsyslog: Dont force enable atomic builtins on mips

In reply to Khem Raj

This would ensure that checks are performed properly before using them

---
 meta-oe/recipes-extended/rsyslog/rsyslog_8.1910.0.bb | 1 +
 1 file changed, 1 insertion(+)
meta-oe/recipes-extended/rsyslog/rsyslog_8.1910.0.bb +1 -0
index f50f9a34bb..951bf4d5c1 100644
@@ -39,6 +39,7 @@ inherit autotools pkgconfig systemd update-rc.d ptest
 
 EXTRA_OECONF += "--disable-generate-man-pages ap_cv_atomic_builtins=yes"
 EXTRA_OECONF += "--enable-imfile-tests"
+EXTRA_OECONF_remove_mipsarch_toolchain-clang = "ap_cv_atomic_builtins=yes"
 
 # first line is default yes in configure
 PACKAGECONFIG ??= " \
Signature · 1 line
2.24.0
author
#3 lore raw

PATCH 4/5 libtorrent: Drop 64bit atomics patch for mips/ppc

In reply to Khem Raj

These patches are no longer needed with latest gcc/clang

---
 ...-64bit-atomic-helpers-for-ppc-32-bit.patch |  30 --
 ...0001-implement-64bit-atomic-for-mips.patch | 263 ------------------
 .../libtorrent/libtorrent_git.bb              |   2 -
 3 files changed, 295 deletions(-)
 delete mode 100644 meta-oe/recipes-connectivity/libtorrent/libtorrent/0001-Define-64bit-atomic-helpers-for-ppc-32-bit.patch
 delete mode 100644 meta-oe/recipes-connectivity/libtorrent/libtorrent/0001-implement-64bit-atomic-for-mips.patch
meta-oe/recipes-connectivity/libtorrent/libtorrent/0001-Define-64bit-atomic-helpers-for-ppc-32-bit.patch deleted +0 -30
deleted file mode 100644
index 4d0979710c..0000000000
@@ -1,30 +0,0 @@
-From c9859a38a58996b8767a30e14febc03845f66f95 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Sat, 1 Jul 2017 13:10:53 -0700
-Subject: [PATCH] Define 64bit atomic helpers for ppc 32-bit
-
-Signed-off-by: Khem Raj <[email protected]>
----
- src/atomic64.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/atomic64.c b/src/atomic64.c
-index f841b39b..35c7c9d8 100644
---- a/src/atomic64.c
-+++ b/src/atomic64.c
-@@ -18,10 +18,10 @@
- #include <stdbool.h>
- 
- /*
-- * only need these on MIPS, since it lacks hardware 64-bit atomics,
-+ * only need these on MIPS & PPC32, since it lacks hardware 64-bit atomics,
-  * unlike x86 and ARM.
-  */
--#if defined(__mips__) || defined(__mipsel__)
-+#if defined(__mips__) || defined(__mipsel__) || defined(__powerpc__)
- 
- static void __spin_lock(volatile int *lock) {
-   while (__sync_lock_test_and_set(lock, 1))
--- 
-2.13.2
-
meta-oe/recipes-connectivity/libtorrent/libtorrent/0001-implement-64bit-atomic-for-mips.patch deleted +0 -263

263 lines not on this page · raw message

meta-oe/recipes-connectivity/libtorrent/libtorrent_git.bb +0 -2
index fa106ea41d..a3902b25f6 100644
@@ -8,8 +8,6 @@ DEPENDS = "zlib libsigc++-2.0 openssl cppunit"
 
 SRC_URI = "git://github.com/rakshasa/libtorrent \
            file://don-t-run-code-while-configuring-package.patch \
-           file://0001-implement-64bit-atomic-for-mips.patch \
-           file://0001-Define-64bit-atomic-helpers-for-ppc-32-bit.patch \
            "
 SRCREV = "756f70010779927dc0691e1e722ed433d5d295e1"
 
Signature · 1 line
2.24.0
author
#4 lore raw

PATCH 5/5 libtorrent: Disable instrumentation on ppc/mips

In reply to Khem Raj

From https://github.com/rakshasa/rtorrent/issues/156
all atomics (__sync_fetch_and_and_8) are not avaliable on mips/ppc, this patch helps workaround the build error

Fixes
ld: libtorrent.so: undefined reference to `__sync_add_and_fetch_8'

---
 meta-oe/recipes-connectivity/libtorrent/libtorrent_git.bb | 7 +++++++
 1 file changed, 7 insertions(+)
meta-oe/recipes-connectivity/libtorrent/libtorrent_git.bb +7 -0
index a3902b25f6..3ee69554b6 100644
@@ -15,6 +15,13 @@ PV = "0.13.8"
 
 S = "${WORKDIR}/git"
 
+PACKAGECONFIG ??= "instrumentation"
+
+PACKAGECONFIG_remove_mipsarch = "instrumentation"
+PACKAGECONFIG_remove_powerpc = "instrumentation"
+
+PACKAGECONFIG[instrumentation] = "--enable-instrumentation,--disable-instrumentation,"
+
 inherit autotools pkgconfig
 
 EXTRA_OECONF = "--with-zlib=${STAGING_EXECPREFIXDIR}"
Signature · 1 line
2.24.0