return "--with-float=soft"
     return ""
 
+def get_gcc_mips_plt_setting(bb, d):
+    if bb.data.getVar('TARGET_ARCH', d, 1) in [ 'mips', 'mipsel' ] and 'mplt' in bb.data.getVar('DISTRO_FEATURES',d,1).split() :
+        return "--with-mips-plt"
+    return ""
+
 # We really need HOST_SYS here for some packages and TARGET_SYS for others.
 # For now, libgcc is most important so we fix for that - RP.
 SHLIBSDIR = "${STAGING_DIR_TARGET}/shlibs"
 
 # gcc 3.x expects 'f77', 4.0 expects 'f95', 4.1 and 4.2 expect 'fortran'
 FORTRAN ?= ",f77"
 LANGUAGES ?= "c,c++${FORTRAN}${JAVA}"
+# disable --enable-target-optspace for powerpc SPE
+# at -Os libgcc.so.1 creates references into
+# hidden symbols in libgcc.a which linker complains
+# when linking shared libraries further in the build like (gnutls)
+
+OPTSPACE = "${@base_contains('TARGET_ARCH', 'powerpc', '', '--enable-target-optspace',d)}"
 
 EXTRA_OECONF_BASE ?= ""
 EXTRA_OECONF_PATHS ?= ""
 EXTRA_OECONF = "${@['--enable-clocale=generic', ''][bb.data.getVar('USE_NLS', d, 1) != 'no']} \
                 --with-gnu-ld \
                 --enable-shared \
-                --enable-target-optspace \
                 --enable-languages=${LANGUAGES} \
                 --enable-threads=posix \
                 ${GCCMULTILIB} \
                 --enable-symvers=gnu \
                 --enable-libstdcxx-pch \
                 --program-prefix=${TARGET_PREFIX} \
+                ${OPTSPACE} \
                 ${EXTRA_OECONF_BASE} \
                 ${EXTRA_OECONF_FPU} \
-                ${EXTRA_OECONF_PATHS}"
+                ${EXTRA_OECONF_PATHS} \
+                ${@get_gcc_mips_plt_setting(bb, d)}"
 
 # Build uclibc compilers without cxa_atexit support
 EXTRA_OECONF_append_linux               = " --enable-__cxa_atexit"
 
 require gcc-configure-sdk.inc
 require gcc-package-sdk.inc
 
-PR = "r3"
+PR = "r4"
 
 DEPENDS += "gmp-nativesdk mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"
 RDEPENDS_${PN} += "mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"
 
                --disable-multilib \
                --disable-__cxa_atexit \
                --enable-languages=c \
-               --enable-target-optspace \
+                ${OPTSPACE} \
                --program-prefix=${TARGET_PREFIX} \
                --with-sysroot=${STAGING_DIR_TARGET} \
                --with-build-sysroot=${STAGING_DIR_TARGET} \
 
 require gcc-cross_${PV}.bb
 require gcc-cross-initial.inc
 
-PR = "r3"
+PR = "r4"
 
 
                --disable-multilib \
                --disable-threads \
                --enable-languages=c \
-               --enable-target-optspace \
+                ${OPTSPACE} \
                --program-prefix=${TARGET_PREFIX} \
                --with-sysroot=${STAGING_DIR_TARGET} \
                --with-build-sysroot=${STAGING_DIR_TARGET} \
 
 require gcc-cross_${PV}.bb
 require gcc-cross-intermediate.inc
-PR = "r3"
+PR = "r4"
 
 
-PR = "r3"
+PR = "r4"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
 require gcc-cross-initial_${PV}.bb
 require gcc-crosssdk-initial.inc
 
-PR = "r3"
+PR = "r4"
 
 require gcc-cross-intermediate_${PV}.bb
 require gcc-crosssdk-intermediate.inc
 
-PR = "r3"
+PR = "r4"
 
 require gcc-cross_${PV}.bb
 require gcc-crosssdk.inc
 
-PR = "r3"
+PR = "r4"
 
-PR = "r3"
+PR = "r4"
 
 require gcc-${PV}.inc
 require gcc-configure-runtime.inc
 
-PR = "r3"
+PR = "r4"
 
 require gcc-${PV}.inc
 require gcc-configure-target.inc