Patchwork gcc: changed multilib options handling

login
register
mail settings
Submitter Alexandru-Cezar Sardan
Date Nov. 15, 2013, 11:51 a.m.
Message ID <1384516296-7330-1-git-send-email-alexandru.sardan@freescale.com>
Download mbox | patch
Permalink /patch/61775/
State New
Headers show

Comments

Alexandru-Cezar Sardan - Nov. 15, 2013, 11:51 a.m.
Duplicate parameters in the tune args are repeated in the
MULTILIB_OPTIONS variable. This leads to incorrect configurations
if the order of the parameters is bad.
(Eg. "mhard-float m32/mhard-float m64" leads to an incorrect config)
This patch finds the common parameters and removes the duplicates.
Also the mcpu parameter is ignored.

Signed-off-by: Alexandru-Cezar Sardan <alexandru.sardan@freescale.com>
---
 meta/recipes-devtools/gcc/gcc-multilib-config.inc |   26 +++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-multilib-config.inc b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
index 005aa6b..3a2b8c8 100644
--- a/meta/recipes-devtools/gcc/gcc-multilib-config.inc
+++ b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
@@ -109,6 +109,7 @@  python gcc_multilib_setup() {
         'i586'      : ['gcc/config/i386/t-linux64'],
         'mips'      : ['gcc/config/mips/t-linux64'],
         'powerpc'   : ['gcc/config/rs6000/t-linux64'],
+        'powerpc64' : ['gcc/config/rs6000/t-linux64'],
     }
 
     gcc_header_config_files = {
@@ -116,6 +117,7 @@  python gcc_multilib_setup() {
         'i586'      : ['gcc/config/i386/linux64.h'],
         'mips'      : ['gcc/config/mips/linux64.h'],
         'powerpc'   : ['gcc/config/rs6000/linux64.h'],
+        'powerpc64' : ['gcc/config/rs6000/linux64.h'],
     }
 
     target_arch = (d.getVar('TARGET_ARCH_MULTILIB_ORIGINAL', True) if mlprefix
@@ -148,6 +150,7 @@  python gcc_multilib_setup() {
     options = []
     dirnames = []
     osdirnames = []
+    optsets = []
 
     for ml in ml_list:
         tune = d.getVar(ml, True)
@@ -172,16 +175,31 @@  python gcc_multilib_setup() {
         else:
             bb.error('Unknown libdir (%s) of the tune : %s' % (tune_baselib, tune))
 
-        # take out '-' and march='s from parameters
-        options.append(re.sub(r'march=[^ ]+ *', '',
-                            re.sub(r' +\-+', ' ',
-                                re.sub(r'^ *\-+', '', tune_parameters['ccargs']))))
+        # take out '-' mcpu='s and march='s from parameters
+        options.append(re.sub(r'mcpu=[^ ]+ *', '',
+                         re.sub(r'march=[^ ]+ *', '',
+                           re.sub(r' +\-+', ' ',
+                             re.sub(r'^ *\-+', '', tune_parameters['ccargs'])))))
         if tune_baselib == 'lib':
             dirnames.append('32')  # /lib => 32bit lib
         else:
             dirnames.append(tune_baselib.replace('lib', ''))
         osdirnames.append('../' + tune_baselib)
 
+    if len(options) > 1:
+        for optstr in options:
+            optsets.append(optstr.split())
+	
+        #get common options present in all the tune parameters
+        common_opt_set = set.intersection(*map(set, optsets))
+
+        #common options will be added at the end of the options string only once
+        if (len(common_opt_set) > 0):
+            rex = re.compile(''.join(['\\b(', '|'.join(common_opt_set), ')\\W']), re.I)
+            options = [rex.sub("", optstr) for optstr in options]
+            options = [optstr.strip() for optstr in options]
+            options[len(options)-1] = ' '.join((options[len(options)-1], ' '.join(common_opt_set)))
+
     write_config(builddir, target_config_files, options, dirnames, osdirnames)
     write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32)
 }