gcc: Add support for nativesdk-gcc
PATCH 3/4 gcc: Add support for nativesdk-gcc
Being able to build a nativesdk gcc is useful, particularly in cases where the host compiler may be of an incompatible version (or a 32 bit compiler is needed).
Sadly, building nativesdk-gcc is not straight forward. We install nativesdk-gcc into a relocatable location and this means that its library locations can change. "Normal" sysroot support doesn't help in this case since the values of paths like "libdir" change, not just base root directory of the system.
In order to handle this we do two things:
a) Add %r into spec file markup which can be used for injected paths such as SYSTEMLIBS_DIR (see gcc_multilib_setup()).
b) Add other paths which need relocation into a .gccrelocprefix section which the relocation code will notice and adjust automatically.
This patch adds tweaks to the relocation script to handle the new section too.
meta/recipes-devtools/gcc/gcc-4.9.inc +1 -0
@@ -78,6 +78,7 @@ SRC_URI = "\ file://0060-Only-allow-e500-double-in-SPE_SIMD_REGNO_P-registers.patch \ file://0061-target-gcc-includedir.patch \ file://0062-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \ + file://0063-nativesdk-gcc-support.patch \ " SRC_URI[md5sum] = "6f831b4d251872736e8e9cc09746f327" SRC_URI[sha256sum] = "2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e"
meta/recipes-devtools/gcc/gcc-4.9/0063-nativesdk-gcc-support.patch new file +204 -0
204 lines not on this page · raw message
meta/recipes-devtools/gcc/gcc-5.2.inc +1 -0
@@ -71,6 +71,7 @@ SRC_URI = "\ file://0037-pr65779.patch \ file://0038-fix-g++-sysroot.patch \ file://0039-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ + file://0040-nativesdk-gcc-support.patch \ " BACKPORTS = ""
meta/recipes-devtools/gcc/gcc-5.2/0040-nativesdk-gcc-support.patch new file +204 -0
204 lines not on this page · raw message
meta/recipes-devtools/gcc/gcc-multilib-config.inc +16 -9
@@ -39,13 +39,14 @@ python gcc_multilib_setup() { bb.utils.mkdirhier('%s/%s' % (build_conf_dir, parent_dir)) bb.utils.copyfile(fn, '%s/%s' % (build_conf_dir, rel_path)) + pn = d.getVar('PN', True) multilibs = (d.getVar('MULTILIB_VARIANTS', True) or '').split() - if not multilibs: + if not multilibs and pn != "nativesdk-gcc": return mlprefix = d.getVar('MLPREFIX', True) - pn = d.getVar('PN', True) - if ('%sgcc' % mlprefix) != pn and (not pn.startswith('gcc-cross-canadian')): + + if ('%sgcc' % mlprefix) != pn and (not pn.startswith('gcc-cross-canadian')) and pn != "nativesdk-gcc": return
@@ -74,7 +75,7 @@ python gcc_multilib_setup() { def write_headers(root, files, libdir32, libdir64, libdirx32, libdirn32): def wrap_libdir(libdir): if libdir.find('SYSTEMLIBS_DIR') != -1: - return libdir + return '"%r"' else: return '"/%s/"' % libdir
@@ -135,17 +136,23 @@ python gcc_multilib_setup() { 'powerpc64' : ['gcc/config/rs6000/linux64.h'], } + libdir32 = 'SYSTEMLIBS_DIR' + libdir64 = 'SYSTEMLIBS_DIR' + libdirx32 = 'SYSTEMLIBS_DIR' + libdirn32 = 'SYSTEMLIBS_DIR' + + target_arch = (d.getVar('TARGET_ARCH_MULTILIB_ORIGINAL', True) if mlprefix else d.getVar('TARGET_ARCH', True)) + if pn == "nativesdk-gcc": + header_config_files = gcc_header_config_files[d.getVar("SDK_ARCH", True)] + write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32) + return + if target_arch not in gcc_target_config_files: bb.warn('gcc multilib setup is not supported for TARGET_ARCH=' + target_arch) return - libdir32 = 'SYSTEMLIBS_DIR' - libdir64 = 'SYSTEMLIBS_DIR' - libdirx32 = 'SYSTEMLIBS_DIR' - libdirn32 = 'SYSTEMLIBS_DIR' - target_config_files = gcc_target_config_files[target_arch] header_config_files = gcc_header_config_files[target_arch]
meta/recipes-devtools/gcc/gcc_4.8.bb +2 -0
@@ -5,3 +5,5 @@ require gcc-target.inc # | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7438:(.text.unlikely+0x2fa): relocation truncated to fit: R_ARM_THM_CALL against symbol `fancy_abort(char const*, int, char const*)' defined in .glue_7 section in linker stubs # | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7442:(.text.unlikely+0x318): additional relocation overflows omitted from the output ARM_INSTRUCTION_SET_armv4 = "arm" + +BBCLASSEXTEND = "nativesdk"
meta/recipes-devtools/gcc/gcc_4.9.bb +7 -0
@@ -5,3 +5,10 @@ require gcc-target.inc # | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7438:(.text.unlikely+0x2fa): relocation truncated to fit: R_ARM_THM_CALL against symbol `fancy_abort(char const*, int, char const*)' defined in .glue_7 section in linker stubs # | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7442:(.text.unlikely+0x318): additional relocation overflows omitted from the output ARM_INSTRUCTION_SET_armv4 = "arm" + +BBCLASSEXTEND = "nativesdk" + +#SYSTEMHEADERS_class-nativesdk = "${@'${target_includedir}'.replace(d.getVar('SDKPATH', True),'%r')}" +#SYSTEMLIBS_class-nativesdk = "${@'${target_base_libdir}'.replace(d.getVar('SDKPATH', True),'%r')}/" +#SYSTEMLIBS1_class-nativesdk = "${@'${target_libdir}'.replace(d.getVar('SDKPATH', True),'%r')}/" +
meta/recipes-devtools/gcc/gcc_5.2.bb +2 -0
@@ -11,3 +11,5 @@ do_configure_prepend() { # broken libtool here sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${S}/libcc1/configure } + +BBCLASSEXTEND = "nativesdk"
scripts/relocate_sdk.py +13 -1
@@ -161,7 +161,19 @@ def change_dl_sysdirs(): # write it back f.seek(sh_offset) f.write(new_ldsocache_path) - + elif name == b(".gccrelocprefix"): + offset = 0 + while (offset + 4096) <= sh_size: + path = f.read(4096) + new_path = old_prefix.sub(new_prefix, path) + # pad with zeros + new_path += b("\0") * (4096 - len(new_path)) + #print "Changing %s to %s at %s" % (str(path), str(new_path), str(offset)) + # write it back + f.seek(sh_offset + offset) + f.write(new_path) + offset = offset + 4096 + print "size is" + str(sh_size) if sysdirs != "" and sysdirslen != "": paths = sysdirs.split(b("\0")) sysdirs = b("")