Skip to contentSkip to conversation

gcc: explicitly use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace

PATCH Superseded Alexey Brodkin 2 participants 3 messages Sep 1, 2014

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gcc: explicitly use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace

From: Alexey Brodkin <[email protected]>

The gcc.mk file is passing --enable-target-optspace to gcc configure script, to ask for space-optimized (-Os) target libraries. However, passing this option has the effect of overriding any custom CFLAGS_FOR_TARGET or CXXFLAGS_FOR_TARGET values that may be passed.

These are some situations when it is required to pass custom flags on buildong of libgcc:
* Default flags "-g -Os" lead to build isses as with PowerPC on gcc 4.5
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810)
* Particular CPU requires specific instructions for HW support
* Deep optimizations

Cc Anton Kolesov <[email protected]>
Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>
Cc Gustavo Zacarias <[email protected]>

---

Compared to v2 use GCC_COMMON_xxx variables to escape changes in globally visible variables TARGET_C{XX}FLAGS.

---
 package/gcc/gcc.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/gcc/gcc.mk +9 -3
index b344a14..6016c57 100644
@@ -107,16 +107,22 @@ HOST_GCC_COMMON_CONF_OPT = \
 HOST_GCC_COMMON_CONF_ENV = \
 	MAKEINFO=missing
 
+GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS)
+GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
+
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810
 # Workaround until it's fixed in 4.5.4 or later
 ifeq ($(ARCH),powerpc)
 ifeq ($(findstring x4.5.,x$(GCC_VERSION)),x4.5.)
-HOST_GCC_COMMON_CONF_OPT += --disable-target-optspace
+GCC_COMMON_TARGET_CFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CFLAGS))
+GCC_COMMON_TARGET_CXXFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CXXFLAGS))
 endif
-else
-HOST_GCC_COMMON_CONF_OPT += --enable-target-optspace
 endif
 
+# Propagate options used for target software building to GCC target libs
+HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
+HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
+
 # gcc 4.6.x quadmath requires wchar
 ifneq ($(BR2_TOOLCHAIN_BUILDROOT_WCHAR),y)
 HOST_GCC_COMMON_CONF_OPT += --disable-libquadmath
Signature · 1 line
1.9.3
#1 lore raw

PATCH v3 1/1 gcc: explicitly use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace

Dear Alexey Brodkin,

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPT = \ · line 118

Quoted 7 lines · Alexey Brodkin

# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810
# Workaround until it's fixed in 4.5.4 or later ifeq ($(ARCH),powerpc)
ifeq ($(findstring x4.5.,x$(GCC_VERSION)),x4.5.)

package/gcc/gcc.mk +2 -1
-HOST_GCC_COMMON_CONF_OPT += --disable-target-optspace
+GCC_COMMON_TARGET_CFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CFLAGS))
+GCC_COMMON_TARGET_CXXFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CXXFLAGS))

Is there any reason to use := instead of = here? We normally use = except when it's really necessary to use :=.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 gcc: explicitly use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace

Hi Thomas,

Quoted 4 lines · Thomas Petazzoni

Dear Alexey Brodkin,

On Mon, 1 Sep 2014 10:32:45 +0400, Alexey Brodkin wrote:

Quoted 10 lines

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPT = \ · line 118

Quoted 7 lines

# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810
# Workaround until it's fixed in 4.5.4 or later ifeq ($(ARCH),powerpc)
ifeq ($(findstring x4.5.,x$(GCC_VERSION)),x4.5.)

package/gcc/gcc.mk +2 -1
-HOST_GCC_COMMON_CONF_OPT += --disable-target-optspace
+GCC_COMMON_TARGET_CFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CFLAGS))
+GCC_COMMON_TARGET_CXXFLAGS := $(filter-out -Os,$(GCC_COMMON_TARGET_CXXFLAGS))

Is there any reason to use := instead of = here? We normally use = except when it's really necessary to use :=.

Nope I think I just copy-pasted it here - which is not the best thing I could have done. Looks like in this particular case there's no need to use ":=" and "=" will work well.

So will fix this tiny "misspelling" shortly in v4.

-Alexey