On-target multilib gcc enhancement
cover On-target multilib gcc enhancement
This patchset enables the user to build gcc with configurable multilib options. The following changes since commit 7e1f8faad0c4b6f490c26f87acc698dd6e002b15:
perl: Remove bashism from perl-tests.inc (2013-01-07 22:37:37 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib cmuscax/gcc_enhan
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=cmuscax/gcc_enhan
Constantin Musca (3):
gcc: add missing dependency (zlib)
gcc: remove the 64bithack patch
gcc: enable multilib for target gcc
meta/recipes-devtools/gcc/gcc-4.7.inc | 5 +- meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch | 63 ---------- meta/recipes-devtools/gcc/gcc-common.inc | 23 ++++ meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +- meta/recipes-devtools/gcc/gcc-configure-target.inc | 1 + meta/recipes-devtools/gcc/gcc-multilib-config.inc | 132 +++++++++++++++++++++ meta/recipes-devtools/gcc/libgcc_4.7.bb | 44 +++++++ 7 files changed, 203 insertions(+), 67 deletions(-) delete mode 100644 meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch create mode 100644 meta/recipes-devtools/gcc/gcc-multilib-config.inc
Signature · 1 line
1.7.11.7
PATCH 1/3 gcc: add missing dependency (zlib)
- add zlib to DEPENDS (it fails otherwise)
--- meta/recipes-devtools/gcc/gcc-4.7.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-devtools/gcc/gcc-4.7.inc +2 -2
@@ -1,6 +1,6 @@ require gcc-common.inc -PR = "r13" +PR = "r14" # Third digit in PV should be incremented after a minor release # happens from this branch on gcc e.g. currently its 4.7.1
@@ -20,7 +20,7 @@ BINV = "4.7.2" FILESPATH = "${@base_set_filespath([ '${FILE_DIRNAME}/gcc-4.7' ], d)}" -DEPENDS =+ "mpfr gmp libmpc" +DEPENDS =+ "mpfr gmp libmpc zlib" NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native" LICENSE="GPL-3.0-with-GCC-exception & GPLv3"
Signature · 1 line
1.7.11.7
PATCH 2/3 gcc: remove the 64bithack patch
In reply to Constantin Musca--- meta/recipes-devtools/gcc/gcc-4.7.inc | 1 - meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch | 63 ----------------------- 2 files changed, 64 deletions(-) delete mode 100644 meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch
meta/recipes-devtools/gcc/gcc-4.7.inc +0 -1
@@ -50,7 +50,6 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://gcc-poison-system-directories.patch \ file://gcc-poison-dir-extend.patch \ file://gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \ - file://64bithack.patch \ file://optional_libstdc.patch \ file://disable_relax_pic_calls_flag.patch \ file://COLLECT_GCC_OPTIONS.patch \
meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch deleted +0 -63
63 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [PATCH 2/3] gcc: remove the 64bithack patch
Quoted 6 lines · Constantin Musca
Signed-off-by Constantin Musca <[email protected]>--- meta/recipes-devtools/gcc/gcc-4.7.inc | 1 - meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch | 63 ----------------------- 2 files changed, 64 deletions(-) delete mode 100644 meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch
Does removing this break multilib builds? For example, with different libdir layouts?
Note that gcc has a shared source tree so patches cannot by applied in say the cross case when we need this yet not in the target case when we probably don't want it. We need to make a patch which works in all cases.
Cheers,
Richard
Re: [PATCH 2/3] gcc: remove the 64bithack patch
Quoted 9 lines · Richard Purdie
Quoted 6 lines · Constantin Musca
Signed-off-by Constantin Musca <[email protected]>--- meta/recipes-devtools/gcc/gcc-4.7.inc | 1 - meta/recipes-devtools/gcc/gcc-4.7/64bithack.patch | 63 ----------------------- 2 files changed, 64 deletions(-)delete mode 100644
meta/recipes-devtools/gcc/gcc-4.7/64bithack.patchDoes removing this break multilib builds? For example, with different libdir layouts?
I think it's going to break other multilib builds. The solution is to keep the 64bithack.patch for setting the default multilib options. The 3/3 patch can be used without PATCH 2/3.
Quoted 4 lines
Note that gcc has a shared source tree so patches cannot by applied in say the cross case when we need this yet not in the target case when we probably don't want it. We need to make a patch which works in all cases.
The other gcc variants (e.g. gcc-cross) are configured using --disable-multilib as option and they will not be influenced if we modify the multilib files.
Quoted 6 lines
Cheers,
Richard
Cheers,
Constantin
PATCH 3/3 gcc: enable multilib for target gcc
In reply to Constantin Musca- add a task to setup multilib configuration for target gcc
- this commit adapts Nitin Kamble's work to gcc 4.7
Tests:
root@qemux86-64:~# gcc -m64 t.c -o t root@qemux86-64:~# file t t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World ! root@qemux86-64:~# gcc -m32 t.c -o t root@qemux86-64:~# file t t: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World !
[YOCTO #1369]
--- meta/recipes-devtools/gcc/gcc-4.7.inc | 2 +- meta/recipes-devtools/gcc/gcc-common.inc | 23 ++++ meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +- meta/recipes-devtools/gcc/gcc-configure-target.inc | 1 + meta/recipes-devtools/gcc/gcc-multilib-config.inc | 132 +++++++++++++++++++++ meta/recipes-devtools/gcc/libgcc_4.7.bb | 44 +++++++ 6 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/gcc/gcc-multilib-config.inc
meta/recipes-devtools/gcc/gcc-4.7.inc +1 -1
@@ -1,6 +1,6 @@ require gcc-common.inc -PR = "r14" +PR = "r15" # Third digit in PV should be incremented after a minor release # happens from this branch on gcc e.g. currently its 4.7.1
meta/recipes-devtools/gcc/gcc-common.inc +23 -0
@@ -34,6 +34,29 @@ def get_gcc_multiarch_setting(bb, d): return multiarch_options[target_arch] return "" +# this is used by the multilib setup of gcc +def get_tune_parameters(tune, d): + availtunes = d.getVar('AVAILTUNES', True) + if tune not in availtunes.split(): + bb.error('The tune: %s is not one of the available tunes: %s', tune, availtunes) + + localdata = bb.data.createCopy(d) + override = ':tune-' + tune + localdata.setVar('OVERRIDES', localdata.getVar('OVERRIDES', False) + override) + bb.data.update_data(localdata) + + retdict = {} + retdict['tune'] = tune + retdict['ccargs'] = localdata.getVar('TUNE_CCARGS', True) + retdict['features'] = localdata.getVar('TUNE_FEATURES', True) + retdict['baselib'] = localdata.getVar('BASE_LIB', True) + retdict['arch'] = localdata.getVar('TUNE_ARCH', True) + retdict['abiextension'] = localdata.getVar('ABIEXTENSION', True) + retdict['target_fpu'] = localdata.getVar('TARGET_FPU', True) + retdict['pkgarch'] = localdata.getVar('TUNE_PKGARCH', True) + retdict['package_extra_archs'] = localdata.getVar('PACKAGE_EXTRA_ARCHS', True) + return retdict + # 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"
meta/recipes-devtools/gcc/gcc-configure-common.inc +1 -1
@@ -25,7 +25,7 @@ EXTRA_OECONF_PATHS ?= "" EXTRA_OECONF_INITIAL ?= "" EXTRA_OECONF_INTERMEDIATE ?= "" -GCCMULTILIB = "--disable-multilib" +GCCMULTILIB ?= "--disable-multilib" GCCTHREADS ?= "posix" EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', True) != 'no']} \
meta/recipes-devtools/gcc/gcc-configure-target.inc +1 -0
@@ -1,4 +1,5 @@ require gcc-configure-common.inc +require gcc-multilib-config.inc EXTRA_OECONF_PATHS = " \ --with-sysroot=/ \
meta/recipes-devtools/gcc/gcc-multilib-config.inc new file +132 -0
132 lines not on this page · raw message
meta/recipes-devtools/gcc/libgcc_4.7.bb +44 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [PATCH 3/3] gcc: enable multilib for target gcc
Quoted 18 lines · Constantin Musca
- add a task to setup multilib configuration for target gcc
- this commit adapts Nitin Kamble's work to gcc 4.7Tests:
root@qemux86-64:~# gcc -m64 t.c -o t root@qemux86-64:~# file t t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World ! root@qemux86-64:~# gcc -m32 t.c -o t root@qemux86-64:~# file t t: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World ![YOCTO #1369]
Signed-off-by Constantin Musca <[email protected]>
Quoted 9 lines
--- meta/recipes-devtools/gcc/gcc-4.7.inc | 2 +- meta/recipes-devtools/gcc/gcc-common.inc | 23 ++++ meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +- meta/recipes-devtools/gcc/gcc-configure-target.inc | 1 + meta/recipes-devtools/gcc/gcc-multilib-config.inc | 132 +++++++++++++++++++++ meta/recipes-devtools/gcc/libgcc_4.7.bb | 44 +++++++ 6 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/gcc/gcc-multilib-config.inc
This triggered some build failures:
http://autobuilder.yoctoproject.org:8010/builders/nightly-mips/builds/769/steps/shell_29/logs/stdio
Quoted 266 lines
meta/recipes-devtools/gcc/gcc-4.7.inc +1
-1@@ -1,6 +1,6 @@ require gcc-common.inc -PR = "r14" +PR = "r15" # Third digit in PV should be incremented after a minor release # happens from this branch on gcc e.g. currently its 4.7.1meta/recipes-devtools/gcc/gcc-common.inc +23
-0@@ -34,6 +34,29 @@ def get_gcc_multiarch_setting(bb, d): return multiarch_options[target_arch] return "" +# this is used by the multilib setup of gcc +def get_tune_parameters(tune, d): + availtunes = d.getVar('AVAILTUNES', True) + if tune not in availtunes.split(): + bb.error('The tune: %s is not one of the available tunes: %s', tune, availtunes) + + localdata = bb.data.createCopy(d) + override = ':tune-' + tune + localdata.setVar('OVERRIDES', localdata.getVar('OVERRIDES', False) + override) + bb.data.update_data(localdata) + + retdict = {} + retdict['tune'] = tune + retdict['ccargs'] = localdata.getVar('TUNE_CCARGS', True) + retdict['features'] = localdata.getVar('TUNE_FEATURES', True) + retdict['baselib'] = localdata.getVar('BASE_LIB', True) + retdict['arch'] = localdata.getVar('TUNE_ARCH', True) + retdict['abiextension'] = localdata.getVar('ABIEXTENSION', True) + retdict['target_fpu'] = localdata.getVar('TARGET_FPU', True) + retdict['pkgarch'] = localdata.getVar('TUNE_PKGARCH', True) + retdict['package_extra_archs'] = localdata.getVar('PACKAGE_EXTRA_ARCHS', True) + return retdict + # 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"meta/recipes-devtools/gcc/gcc-configure-common.inc +1
-1@@ -25,7 +25,7 @@ EXTRA_OECONF_PATHS ?= "" EXTRA_OECONF_INITIAL ?= "" EXTRA_OECONF_INTERMEDIATE ?= "" -GCCMULTILIB = "--disable-multilib" +GCCMULTILIB ?= "--disable-multilib" GCCTHREADS ?= "posix" EXTRA_OECONF = "${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', True) != 'no']} \meta/recipes-devtools/gcc/gcc-configure-target.inc +1
-0@@ -1,4 +1,5 @@ require gcc-configure-common.inc +require gcc-multilib-config.inc EXTRA_OECONF_PATHS = " \ --with-sysroot=/ \meta/recipes-devtools/gcc/gcc-multilib-config.inc new file +132
-0@@ -0,0 +1,132 @@ +GCCMULTILIB = "--enable-multilib" + +addtask gcc_multilib_setup after do_patch before do_configure + +# following code modifies these definitions in the gcc config +# MULTILIB_OPTIONS +# MULTILIB_DIRNAMES +# MULTILIB_OSDIRNAMES +# GLIBC_DYNAMIC_LINKER32 +# GLIBC_DYNAMIC_LINKER64 +# GLIBC_DYNAMIC_LINKERX32 +# GLIBC_DYNAMIC_LINKERN32 +# For more information on use of these variables look at these files in the gcc source code +# gcc/config/i386/t-linux64 +# gcc/config/mips/t-linux64 +# gcc/config/rs6000/t-linux64 +# gcc/config/i386/linux64.h +# gcc/config/mips/linux64.h +# gcc/config/rs6000/linux64.h + +python do_gcc_multilib_setup() { + import re + + # do this only for target recipe + if d.getVar('PN', True) != 'gcc': + return + + srcdir = d.getVar('S', True) + multilibs = d.getVar('MULTILIB_VARIANTS', True) + target_arch = d.getVar('TARGET_ARCH', True) + + gcc_target_config_files = { + 'x86_64' : ['gcc/config/i386/t-linux64'], + 'mips' : ['gcc/config/mips/t-linux64'], + 'ppc' : ['gcc/config/rs6000/t-linux64'] + } + + gcc_header_config_files = { + 'x86_64' : ['gcc/config/i386/linux64.h'], + 'mips' : ['gcc/config/mips/linux64.h'], + 'ppc' : ['gcc/config/rs6000/linux64.h'] + } + + if target_arch not in gcc_target_config_files: + if multilibs: + bb.warn('gcc multilib setup is not supported for TARGET_ARCH=' + target_arch) + return + + gcc_multilib_target_config_files = gcc_target_config_files[target_arch] + gcc_multilib_header_config_files = gcc_header_config_files[target_arch] + + ml_list = ['DEFAULTTUNE'] + if multilibs != '': + for ml in multilibs.split(' '): + ml_list.append('DEFAULTTUNE_virtclass-multilib-' + ml) + + libdir32 = 'SYSTEMLIBS_DIR' + libdir64 = 'SYSTEMLIBS_DIR' + libdirx32 = 'SYSTEMLIBS_DIR' + libdirn32 = 'SYSTEMLIBS_DIR' + + multilib_options = [] + multilib_dirnames = [] + multilib_osdirnames = [] + + for ml in ml_list: + tune = d.getVar(ml, True) + tune_parameters = get_tune_parameters(tune, d) + + tune_baselib = tune_parameters['baselib'] + + if tune_baselib == 'lib64': + libdir64 = tune_baselib + elif tune_baselib == 'libx32': + libdirx32 = tune_baselib + elif tune_baselib == 'lib32': + libdirn32 = tune_baselib + elif tune_baselib == 'lib': + libdir32 = tune_baselib + else: + bb.error('Unknown libdir (%s) of the tune : %s' % (tune_baselib, tune)) + + # take out '-' in parameters + multilib_options.append(re.sub(r' +\-+', ' ', re.sub(r'^ *\-+', '', tune_parameters['ccargs']))) + if tune_baselib == 'lib': + multilib_dirnames.append('32') # /lib => 32bit lib + else: + multilib_dirnames.append(tune_baselib.replace('lib', '')) + multilib_osdirnames.append('../' + tune_baselib) + + # go over t-linux64 kind target files + for ml_conf_file in gcc_multilib_target_config_files: + # recreate multilib configuration variables + lines = [] + + lines.append('MULTILIB_OPTIONS = ' + '/'.join(multilib_options)) + lines.append('MULTILIB_DIRNAMES = ' + ' '.join(multilib_dirnames)) + lines.append('MULTILIB_OSDIRNAMES = ' + ' '.join(multilib_osdirnames)) + + with open(srcdir + '/' + ml_conf_file, 'w') as f: + f.write('\n'.join(lines)) + + # go over linux64.h kind header files + for ml_conf_file in gcc_multilib_header_config_files: + with open(srcdir + '/' + ml_conf_file, 'r') as f: + filelines = f.read() + + # replace lines like + # #define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2" + # by + # #define GLIBC_DYNAMIC_LINKER32 "/lib/" "ld-linux.so.2" + # this is needed to put the correct dynamic loader path in the generated binaries + + filelines = re.sub(r'^(#define\s*GLIBC_DYNAMIC_LINKER32\s*)(SYSTEMLIBS_DIR)(\s*\".*\")$', + r'\1"/' + libdir32 + r'/"\3', + filelines, flags=re.MULTILINE) + + filelines = re.sub(r'^(#define\s*GLIBC_DYNAMIC_LINKER64\s*)(SYSTEMLIBS_DIR)(\s*\".*\")$', + r'\1"/' + libdir64 + r'/"\3', + filelines, flags=re.MULTILINE) + + filelines = re.sub(r'^(#define\s*GLIBC_DYNAMIC_LINKERX32\s*)(SYSTEMLIBS_DIR)(\s*\".*\")$', + r'\1"/' + libdirx32 + r'/"\3', + filelines, flags=re.MULTILINE) + + filelines = re.sub(r'^(#define\s*GLIBC_DYNAMIC_LINKERN32\s*)(SYSTEMLIBS_DIR)(\s*\".*\")$', + r'\1"/' + libdirn32 + r'/"\3', + filelines, flags=re.MULTILINE) + + with open(srcdir + '/' + ml_conf_file, 'w') as f: + f.write(filelines) +}meta/recipes-devtools/gcc/libgcc_4.7.bb +44
-0@@ -15,6 +15,10 @@ FILES_${PN} = "${base_libdir}/libgcc*.so.*" FILES_${PN}-dev = " \ ${base_libdir}/libgcc*.so \ ${libdir}/${TARGET_SYS}/${BINV}/*crt* \ + ${libdir}/${TARGET_SYS}/${BINV}/64 \ + ${libdir}/${TARGET_SYS}/${BINV}/32 \ + ${libdir}/${TARGET_SYS}/${BINV}/x32 \ + ${libdir}/${TARGET_SYS}/${BINV}/n32 \ ${libdir}/${TARGET_SYS}/${BINV}/libgcc*" FILES_libgcov-dev = " \ ${libdir}/${TARGET_SYS}/${BINV}/libgcov.a \@@ -70,3 +74,43 @@ BBCLASSEXTEND = "nativesdk" INSANE_SKIP_${PN}-dev = "staticdev" INSANE_SKIP_${MLPREFIX}libgcov-dev = "staticdev" + +addtask multilib_install after do_install before do_package +# this makes multilib gcc files findable for target gcc +# e.g. +# /usr/lib/i586-pokymllib32-linux/4.7/ +# by creating this symlink to it +# /usr/lib64/x86_64-poky-linux/4.7/32 + +python do_multilib_install() { + import re + # do this only for multilib extended recipe + if d.getVar('PN', True) != 'libgcc': + return + + multilibs = d.getVar('MULTILIB_VARIANTS', True) or '' + if multilibs == '': + return + + binv = d.getVar('BINV', True) or '' + + for ml in multilibs.split(' '): + tune = d.getVar('DEFAULTTUNE_virtclass-multilib-' + ml, True) or '' + tune_parameters = get_tune_parameters(tune, d) + tune_baselib = tune_parameters['baselib'] + tune_arch = tune_parameters['arch'] + tune_bitness = tune_baselib.replace('lib', '') + if tune_bitness == '' : + tune_bitness = '32' # /lib => 32bit lib + + src = '../../../' + tune_baselib + '/' + \ + tune_arch + d.getVar('TARGET_VENDOR', True) + 'ml' + ml + \ + '-' + d.getVar('TARGET_OS', True) + '/' + binv + '/' + + dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + \ + d.getVar('TARGET_SYS', True) + '/' + binv + '/' + tune_bitness + + if os.path.lexists(dest): + os.unlink(dest) + os.symlink(src, dest) +}
Re: [PATCH 3/3] gcc: enable multilib for target gcc
Quoted 29 lines · Richard Purdie
Quoted 18 lines · Constantin Musca
- add a task to setup multilib configuration for target gcc
- this commit adapts Nitin Kamble's work to gcc 4.7Tests:
root@qemux86-64:~# gcc -m64 t.c -o t root@qemux86-64:~# file t t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World ! root@qemux86-64:~# gcc -m32 t.c -o t root@qemux86-64:~# file t t: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped root@qemux86-64:~# ./t Hello World ![YOCTO #1369]
Signed-off-by Constantin Musca <[email protected]>Quoted 9 lines
--- meta/recipes-devtools/gcc/gcc-4.7.inc | 2 +- meta/recipes-devtools/gcc/gcc-common.inc | 23 ++++ meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +- meta/recipes-devtools/gcc/gcc-configure-target.inc | 1 + meta/recipes-devtools/gcc/gcc-multilib-config.inc | 132 +++++++++++++++++++++ meta/recipes-devtools/gcc/libgcc_4.7.bb | 44 +++++++ 6 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/gcc/gcc-multilib-config.inc
Quoted 3 lines
This triggered some build failures:
http://autobuilder.yoctoproject.org:8010/builders/nightly-mips/builds/769/steps/shell_29/logs/stdio
and a different more subtle issue in:
which I suspect is related since a build of master just before this without the patch worked.
Cheers,
Richard