gcc: enable poison parameters detection

If not configured with --enable-target-optspace, gcc will report
errors if there is '-Os' optimization in parameters.

This fixes [BUGID #342]

Also add "--enable-target-optspace" option to arm gcc configuration.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
This commit is contained in:
Dongxiao Xu 2010-09-25 10:16:26 +08:00 committed by Saul Wold
parent b3ef7f59e2
commit ce456306da
28 changed files with 147 additions and 27 deletions

View File

@ -48,6 +48,7 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \
file://64bithack.patch \
file://optional_libstdc.patch \
file://disable_relax_pic_calls_flag.patch \
file://gcc-poison-parameters.patch \
"
SRC_URI_append_sh3 = " file://sh3-installfix-fixheaders.patch;patch=1 "

View File

@ -0,0 +1,83 @@
gcc: add poison parameters detection
Add the logic that, if not configured with "--enable-target-optspace",
gcc will meet error when build target app with "-Os" option.
This could avoid potential binary crash.
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
diff --git a/gcc/config.in b/gcc/config.in
index a9e208f..3004321 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -132,6 +132,12 @@
#endif
+/* Define to enable target optspace support. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_TARGET_OPTSPACE
+#endif
+
+
/* Define if you want all operations on RTL (the basic data structure of the
optimizer and back end) to be checked for dynamic type safety at runtime.
This is quite expensive. */
diff --git a/gcc/configure b/gcc/configure
index 2e022ed..004ec0b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -909,6 +909,7 @@ enable_maintainer_mode
enable_version_specific_runtime_libs
with_slibdir
enable_plugin
+enable_target_optspace
'
ac_precious_vars='build_alias
host_alias
@@ -25289,6 +25290,13 @@ $as_echo "#define ENABLE_PLUGIN 1" >>confdefs.h
fi
+if test x"$enable_target_optspace" != x; then :
+
+$as_echo "#define ENABLE_TARGET_OPTSPACE 1" >>confdefs.h
+
+fi
+
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index ac4ca70..18ec0aa 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4434,6 +4434,11 @@ if test x"$enable_plugin" = x"yes"; then
AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
fi
+AC_SUBST(enable_target_optspace)
+if test x"$enable_target_optspace" != x; then
+ AC_DEFINE(ENABLE_TARGET_OPTSPACE, 1, [Define to enable target optspace support.])
+fi
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
diff --git a/gcc/opts.c b/gcc/opts.c
index 139cd26..2fdd96a 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -945,6 +945,11 @@ decode_options (unsigned int argc, const char **argv)
else
set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
+#ifndef ENABLE_TARGET_OPTSPACE
+ if (optimize_size == 1)
+ error ("Do not use -Os option if --enable-target-optspace is not set.");
+#endif
+
if (first_time_p)
{
/* Initialize whether `char' is signed. */

View File

@ -17,7 +17,7 @@ LANGUAGES ?= "c,c++${FORTRAN}${JAVA}"
# hidden symbols in libgcc.a which linker complains
# when linking shared libraries further in the build like (gnutls)
SPECIAL_ARCH_LIST = "powerpc arm"
SPECIAL_ARCH_LIST = "powerpc"
OPTSPACE = ${@base_contains("SPECIAL_ARCH_LIST", "${TARGET_ARCH}", "", "--enable-target-optspace",d)}
EXTRA_OECONF_BASE ?= ""

View File

@ -5,7 +5,7 @@ require gcc-cross-canadian.inc
require gcc-configure-sdk.inc
require gcc-package-sdk.inc
PR = "r18"
PR = "r19"
DEPENDS += "gmp-nativesdk mpfr-nativesdk"
RDEPENDS_${PN} += "mpfr-nativesdk"

View File

@ -5,7 +5,7 @@ require gcc-cross-canadian.inc
require gcc-configure-sdk.inc
require gcc-package-sdk.inc
PR = "r8"
PR = "r9"
DEPENDS += "gmp-nativesdk mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"
RDEPENDS_${PN} += "mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"

View File

@ -1,5 +1,5 @@
require gcc-cross_${PV}.bb
require gcc-cross-initial.inc
PR = "r3"
PR = "r4"

View File

@ -1,5 +1,5 @@
require gcc-cross_${PV}.bb
require gcc-cross-initial.inc
PR = "r8"
PR = "r9"

View File

@ -1,4 +1,4 @@
require gcc-cross_${PV}.bb
require gcc-cross-intermediate.inc
PR = "r3"
PR = "r4"

View File

@ -1,4 +1,4 @@
require gcc-cross_${PV}.bb
require gcc-cross-intermediate.inc
PR = "r8"
PR = "r9"

View File

@ -9,7 +9,7 @@ require gcc-cross-kernel.inc
DEFAULT_PREFERENCE = "-1"
PR = "r3"
PR = "r4"
SRC_URI += "file://gcc-3.4.4-makefile-fix.patch;patch=1"

View File

@ -1,4 +1,4 @@
PR = "r16"
PR = "r17"
require gcc-${PV}.inc
require gcc-cross4.inc

View File

@ -1,4 +1,4 @@
PR = "r9"
PR = "r10"
require gcc-${PV}.inc
require gcc-cross4.inc

View File

@ -1,4 +1,4 @@
PR = "r4"
PR = "r5"
require gcc-csl-arm-2008q1.inc
require gcc-cross4.inc

View File

@ -1,3 +1,3 @@
require gcc-cross-initial_${PV}.bb
require gcc-crosssdk-initial.inc
PR = "r4"
PR = "r5"

View File

@ -1,4 +1,4 @@
require gcc-cross-initial_${PV}.bb
require gcc-crosssdk-initial.inc
PR = "r8"
PR = "r9"

View File

@ -1,3 +1,3 @@
require gcc-cross-intermediate_${PV}.bb
require gcc-crosssdk-intermediate.inc
PR = "r7"
PR = "r8"

View File

@ -1,4 +1,4 @@
require gcc-cross-intermediate_${PV}.bb
require gcc-crosssdk-intermediate.inc
PR = "r8"
PR = "r9"

View File

@ -1,3 +1,3 @@
require gcc-cross_${PV}.bb
require gcc-crosssdk.inc
PR="r2"
PR="r3"

View File

@ -1,4 +1,4 @@
require gcc-cross_${PV}.bb
require gcc-crosssdk.inc
PR = "r8"
PR = "r9"

View File

@ -1,4 +1,4 @@
PR = "r16"
PR = "r17"
require gcc-${PV}.inc
require gcc-configure-runtime.inc

View File

@ -1,4 +1,4 @@
PR = "r8"
PR = "r9"
require gcc-${PV}.inc
require gcc-configure-runtime.inc

View File

@ -1,4 +1,4 @@
PR = "r9"
PR = "r10"
require gcc-${PV}.inc
require gcc-configure-target.inc

View File

@ -1,4 +1,4 @@
PR = "r8"
PR = "r9"
require gcc-${PV}.inc
require gcc-configure-target.inc

View File

@ -1,4 +1,4 @@
PR = "r2"
PR = "r3"
require gcc-${PV}.inc
require gcc-configure-target.inc

View File

@ -0,0 +1,17 @@
Do not set Os optimization in target APP CFLAGS, since it may have potential
error if "--enable-target-optspace" is not set when configuring GCC.
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
diff -ruN Xsettings-client-0.10-orig/configure.ac Xsettings-client-0.10/configure.ac
--- Xsettings-client-0.10-orig/configure.ac 2010-09-21 14:01:47.000000000 +0800
+++ Xsettings-client-0.10/configure.ac 2010-09-21 14:02:01.000000000 +0800
@@ -3,7 +3,7 @@
AM_INIT_AUTOMAKE(Xsettings-client, 0.10)
AM_CONFIG_HEADER(config.h)
-CFLAGS="-Os -Wall"
+CFLAGS="-O2 -Wall"
# Checks for programs.
AC_PROG_CC

View File

@ -9,13 +9,14 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=7cfac9d2d4dc3694cc7eb605cf32a69b \
PRIORITY = "optional"
DEPENDS = "virtual/libx11"
PR = "r3"
PR = "r4"
headers = "xsettings-common.h xsettings-client.h"
SRC_URI = "http://projects.o-hand.com/matchbox/sources/optional-dependencies/Xsettings-client-0.10.tar.gz \
file://MIT-style-license \
file://link-x11.patch;apply=yes"
file://link-x11.patch;apply=yes \
file://disable_Os_option.patch"
S = "${WORKDIR}/Xsettings-client-0.10"

View File

@ -0,0 +1,17 @@
Do not set Os optimization in target APP CFLAGS, since it may have potential
error if "--enable-target-optspace" is not set when configuring GCC.
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
diff -ruN libproxy-0.4.3-orig/CMakeLists.txt libproxy-0.4.3/CMakeLists.txt
--- libproxy-0.4.3-orig/CMakeLists.txt 2010-09-21 17:16:06.000000000 +0800
+++ libproxy-0.4.3/CMakeLists.txt 2010-09-21 17:16:40.000000000 +0800
@@ -61,7 +61,7 @@
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
else()
add_definitions(-D_POSIX_C_SOURCE=1)
- set(CMAKE_CXX_FLAGS "-g -Wall -Werror -fvisibility=hidden -Os ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-g -Wall -Werror -fvisibility=hidden -O2 ${CMAKE_CXX_FLAGS}")
endif()
### Subdirectories

View File

@ -9,16 +9,17 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=7d7044444a7b1b116e8783edcdb44ff4 \
DEPENDS = "virtual/libx11 xmu gconf-dbus"
SRC_URI = "http://libproxy.googlecode.com/files/libproxy-${PV}.tar.gz"
SRC_URI = "http://libproxy.googlecode.com/files/libproxy-${PV}.tar.gz \
file://disable_Os_option.patch"
PR = "r1"
PR = "r2"
inherit cmake pkgconfig
EXTRA_OECMAKE = "-DWITH_WEBKIT=no -DWITH_GNOME=yes -DWITH_KDE4=no \
-DWITH_PYTHON=no -DWITH_PERL=no -DWITH_MOZJS=no -DWITH_NM=no"
FILES_${PN}-dbg += "${libdir}/libproxy/0.4.2/plugins/"
FILES_${PN}-dbg += "${libdir}/libproxy/${PV}/plugins/"
do_configure_prepend() {
export HOST_SYS=${HOST_SYS}