[OE-core] [OE-Core][PATCH 2/2] binutils: Speed up and fix native builds

Khem Raj raj.khem at gmail.com
Sat Jan 12 15:27:21 UTC 2019


On Sat, Jan 12, 2019 at 2:12 AM Serhey Popovych
<serhe.popovych at gmail.com> wrote:
>
> We need only libbfd, libiberty and libopcodes from binutils native.
> To get them we build entire binutils with --enable-targets=all to
> include all possible output targets support and then remove all but
> these three libs.
>
> This has two side effects:
>
>   1) it wastes build time
>   2) may cause errors caused by --enable-targets=all on some exotics
>      build hosts like PowerPC 32bit
>
> To address both of these effects we can configure binutils in general
> and only required libs and their dependencies (zlib and intl at the
> time). Then build only build these libs and their dependencies.
>
> Regarding to PowerPC 32-bit build host issues we get following errors
> when building on Ubuntu 16.04 LTS for PowerPC with command:
>
>   MACHINE=qemuppc setarch ppc bitbake binutils-native
>
> <output omitted>
> | /usr/lib/gcc/powerpc-linux-gnu/5/../../../powerpc-linux-gnu/crti.o: In function `_init':
> | (.init+0x22): relocation truncated to fit: R_PPC_GOT16 against undefined symbol `__gmon_start__'
> | dwarf.o: In function `parse_gnu_debuglink':
> | dwarf.c:(.text+0x482): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.o: In function `fetch_indexed_string':
> | dwarf.c:(.text+0x8fa): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.o: In function `read_debug_line_header':
> | dwarf.c:(.text+0x114a): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.c:(.text+0x12c6): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.o: In function `display_debug_ranges_list':
> | dwarf.c:(.text+0x187e): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.c:(.text+0x18a2): relocation truncated to fit: R_PPC_GOT16 against symbol `stdout@@GLIBC_2.0' defined in .sdata section in /lib/powerpc-linux-gnu/libc.so.6
> | dwarf.o: In function `display_debug_rnglists_list':
> | dwarf.c:(.text+0x1bf2): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.c:(.text+0x1c06): relocation truncated to fit: R_PPC_GOT16 against symbol `stdout@@GLIBC_2.0' defined in .sdata section in /lib/powerpc-linux-gnu/libc.so.6
> | dwarf.o: In function `display_block':
> | dwarf.c:(.text+0x2486): relocation truncated to fit: R_PPC_GOT16 against symbol `byte_get' defined in .sbss section in elfcomm.o
> | dwarf.o: In function `introduce.isra.2':
> | dwarf.c:(.text+0x2556): additional relocation overflows omitted from the output
> | collect2: error: ld returned 1 exit status
> | Makefile:909: recipe for target 'objdump' failed
> | make[4]: *** [objdump] Error 1
> | make[4]: *** Waiting for unfinished jobs....
> <output omitted>
>
> While 'byte_get' is defined in small bss section in elfcomm.o and
> generally can be fixed, symbol from host glibc 'stdout@@GLIBC_2.0' in
> small data section can't be moved without recompile of Ubuntu 16.04 LTS
> glibc.
>

Can you try to add -fPIC to CFLAGS ? this should help in fixing the
relocation spill.


> Signed-off-by: Serhey Popovych <serhe.popovych at gmail.com>
> ---
>  meta/recipes-devtools/binutils/binutils_2.31.bb | 33 ++++++++++++++-----------
>  1 file changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/meta/recipes-devtools/binutils/binutils_2.31.bb b/meta/recipes-devtools/binutils/binutils_2.31.bb
> index 51a9748..6796749 100644
> --- a/meta/recipes-devtools/binutils/binutils_2.31.bb
> +++ b/meta/recipes-devtools/binutils/binutils_2.31.bb
> @@ -20,26 +20,31 @@ EXTRA_OECONF_class-native = "--enable-targets=all \
>                               --enable-install-libbfd \
>                               --disable-werror"
>
> +do_configure_append_class-native () {
> +       for l in zlib intl bfd libiberty opcodes; do
> +               oe_runmake configure-${l}
> +       done
> +}

lets use --disable-<DIR> instead in EXTRA_OECONF

> +
> +do_compile_class-native () {
> +       for l in zlib intl bfd libiberty opcodes; do
> +               cd "${l}"
> +               autotools_do_compile
> +               cd - >/dev/null
> +       done
> +}
> +

not needed

>  do_install_class-native () {
> -       autotools_do_install
> +       for l in bfd libiberty opcodes; do
> +               cd "${l}"
> +               autotools_do_install
> +               cd - >/dev/null
> +       done
>

not needed


>         # Install the libiberty header
>         install -d ${D}${includedir}
>         install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
>         install -m 644 ${S}/include/libiberty.h ${D}${includedir}
> -
> -       # We only want libiberty, libbfd and libopcodes
> -       rm -rf ${D}${bindir}
> -       rm -rf ${D}${prefix}/${TARGET_SYS}
> -       rm -rf ${D}${prefix}/lib/ldscripts
> -       rm -rf ${D}${prefix}/share/info
> -       rm -rf ${D}${prefix}/share/locale
> -       rm -rf ${D}${prefix}/share/man
> -       rmdir ${D}${prefix}/share || :
> -       rmdir ${D}/${libdir}/gcc-lib || :
> -       rmdir ${D}/${libdir}64/gcc-lib || :
> -       rmdir ${D}/${libdir} || :
> -       rmdir ${D}/${libdir}64 || :
>  }
>
>  # Split out libbfd-*.so so including perf doesn't include extra stuff
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


More information about the Openembedded-core mailing list