Skip to contentSkip to conversation

toolchain-wrapper.mk: refactor additional flags into TARGET_FLAGS

PATCH New Arnout Vandecappelle (Essensium/Mind) 2 participants 4 messages Oct 18, 2016 – Oct 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 toolchain-wrapper.mk: refactor additional flags into TARGET_FLAGS

Currently, the additional flags encoded in the toolchain wrapper are limited to BR2_TARGET_OPTIMIZATION. However, we are going to add more flags to it, so it is convenient to have a TARGET_FLAGS variable that collects all of them and do the list-to-array conversion on all of them together.

The variable is called TARGET_FLAGS because later it will be modified to include all the flags that we pass to the toolchain wrapper, and it will also be used as the base for TARGET_CFLAGS etc.

---
 toolchain/toolchain-wrapper.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
toolchain/toolchain-wrapper.mk +4 -3
index af39071..8939650 100644
@@ -9,14 +9,15 @@ else
 TOOLCHAIN_WRAPPER_HASH_STYLE = both
 endif
 
+TARGET_FLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
+
 TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
 
 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
 # separate argument when used in execv() by the toolchain wrapper.
-TOOLCHAIN_WRAPPER_OPTS = \
-	$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)"$(comma))
-TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(TOOLCHAIN_WRAPPER_OPTS)'
+TOOLCHAIN_WRAPPER_ARGS += \
+	-DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TARGET_FLAGS),"$(f)"$(comma))'
 
 ifeq ($(BR2_CCACHE),y)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
Signature · 1 line
2.9.3
#3 lore raw

PATCH 2/2 MIPS: add support for MSA

From: Vicente Olivert Riera <[email protected]>

[Arnout: use the TARGET_FLAGS variable]

---
v2: use the TARGET_FLAGS variable introduced by the previous patch
(Arnout)

---
 arch/Config.in.mips            | 17 +++++++++++++++++
 toolchain/toolchain-wrapper.mk |  7 +++++++
 2 files changed, 24 insertions(+)
arch/Config.in.mips +17 -0
index f7bfa21..fb9053c 100644
@@ -16,6 +16,14 @@ config BR2_MIPS_CPU_MIPS64R5
 config BR2_MIPS_CPU_MIPS64R6
 	bool
 
+# mips cpu features
+config BR2_MIPS_CPU_HAS_MSA
+	bool
+
+# for some cores, MSA support is optional
+config BR2_MIPS_CPU_MAYBE_HAS_MSA
+	bool
+
 choice
 	prompt "Target Architecture Variant"
 	depends on BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
@@ -113,6 +121,15 @@ config BR2_MIPS_SOFT_FLOAT
 	  floating point functions, then everything will need to be
 	  compiled with soft floating point support (-msoft-float).
 
+config BR2_MIPS_ENABLE_MSA
+	bool "Enable MIPS SIMD Architecture (MSA) support"
+	depends on BR2_MIPS_CPU_MAYBE_HAS_MSA && !BR2_SOFT_FLOAT
+	select BR2_MIPS_CPU_HAS_MSA
+	help
+	  For some CPU cores, the MSA extension is optional.
+	  Select this option if you are certain your particular
+	  implementation has MSA support and you want to use it.
+
 config BR2_ARCH
 	default "mips"		if BR2_mips
 	default "mipsel"	if BR2_mipsel
toolchain/toolchain-wrapper.mk +7 -0
index 8939650..76fd557 100644
@@ -9,6 +9,13 @@ else
 TOOLCHAIN_WRAPPER_HASH_STYLE = both
 endif
 
+# MIPS optimization flags
+ifeq ($(BR2_MIPS_CPU_HAS_MSA),y)
+TARGET_FLAGS += -mmsa
+endif
+
+# Keep BR2_TARGET_OPTIMIZATION as the last one since it may be used
+# to override the automatically added options above.
 TARGET_FLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
 
 TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/2 toolchain-wrapper.mk: refactor additional flags into TARGET_FLAGS

In reply to Arnout Vandecappelle (Essensium/Mind)

Oops, I forgot to add a cover letter...

Quoted 9 lines · Arnout Vandecappelle (Essensium/Mind)

Currently, the additional flags encoded in the toolchain wrapper are limited to BR2_TARGET_OPTIMIZATION. However, we are going to add more flags to it, so it is convenient to have a TARGET_FLAGS variable that collects all of them and do the list-to-array conversion on all of them together.

The variable is called TARGET_FLAGS because later it will be modified to include all the flags that we pass to the toolchain wrapper, and it will also be used as the base for TARGET_CFLAGS etc.

So this is a part of a series I'm trying to build that will sanitize the flags
passed to the wrapper and passed to the build systems. The idea is that all the flags that are currently hardcoded in toolchain-wrapper.c will move into TARGET_FLAGS, and that all flags that are currently added to TARGET_CFLAGS but not to the wrapper get added to TARGET_FLAGS as well.

I have only lightly tested this; Vincent, please include this in your series
and test for real.

I wanted to push this patch fast so Vicente can use it in his series. However,
the idea is to move all this setting of flags into a new .mk file. I was thinking of toolchain/toolchain-flags.mk. If anyone has better ideas, please speak up!

Regards,
Arnout

Quoted 30 lines
---
 toolchain/toolchain-wrapper.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
toolchain/toolchain-wrapper.mk +4 -3
index af39071..8939650 100644
@@ -9,14 +9,15 @@ else
 TOOLCHAIN_WRAPPER_HASH_STYLE = both
 endif
 
+TARGET_FLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
+
 TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
 
 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
 # separate argument when used in execv() by the toolchain wrapper.
-TOOLCHAIN_WRAPPER_OPTS = \
-	$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)"$(comma))
-TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(TOOLCHAIN_WRAPPER_OPTS)'
+TOOLCHAIN_WRAPPER_ARGS += \
+	-DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TARGET_FLAGS),"$(f)"$(comma))'
 
 ifeq ($(BR2_CCACHE),y)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#2 lore raw

PATCH 1/2 toolchain-wrapper.mk: refactor additional flags into TARGET_FLAGS

Hello,

Quoted 6 lines · Arnout Vandecappelle

So this is a part of a series I'm trying to build that will sanitize the flags
passed to the wrapper and passed to the build systems. The idea is that all the flags that are currently hardcoded in toolchain-wrapper.c will move into TARGET_FLAGS, and that all flags that are currently added to TARGET_CFLAGS but not to the wrapper get added to TARGET_FLAGS as well.

Quoted 7 lines

I have only lightly tested this; Vincent, please include this in your series
and test for real.

I wanted to push this patch fast so Vicente can use it in his series. However,
the idea is to move all this setting of flags into a new .mk file. I was thinking of toolchain/toolchain-flags.mk. If anyone has better ideas, please speak up!

Following Vicente's feedback on -mmsa being unsuitable hardcoded in the wrapper as it breaks the kernel build, I guess your PATCH 2/2 is not suitable. And therefore, it makes PATCH 1/2 a bit useless.

Until we figure out the appropriate way of solving this problem, I've marked those two patches as Changes Requested.

Thanks,

Thomas

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