[yocto] Unable to cross compile libgfortran for arm64

Sergio Paracuellos sergio.paracuellos at gmail.com
Thu Jan 10 02:38:57 PST 2019


Hi,

A bit more info about this.

On Wed, Jan 9, 2019 at 8:17 AM Sergio Paracuellos
<sergio.paracuellos at gmail.com> wrote:
>
> Hi all,
>
> I am trying to compile a complete system with fortran support using
> yocto and I am having problems cross compiling libgfortran. The target
> architecture is arm64 because the system will run in a xilinx mpsoc
> based board. I need fortran support to compile lapack, openblas, scipy
> and other python stuff that seems to need them. The yocto branch I am
> using is the stable 'sumo'. So I do the following for enable fortran
> support:
>
> 1) Add to my local.conf the following line:
> FORTRAN_forcevariable = ",fortran"
> 2) Add a bbappend file for recipes-devtools/gcc/gcc-runtime_7.3.bb with:
> RUNTIMETARGET += "libgfortran"
>
> With the branch as it is when gcc-runtime is being build I end up with
> an error because libbacktrace headers can't be found so I have to
> apply the following PATCH to solve this first issue:
>
> diff -Naur gcc-7.3.0/libgfortran/Makefile.in
> gcc-7.3.0.modif/libgfortran/Makefile.in
> --- gcc-7.3.0/libgfortran/Makefile.in 2018-01-25 09:17:54.059232055 +0100
> +++ gcc-7.3.0.modif/libgfortran/Makefile.in 2019-01-08 12:42:00.583138367 +0100
> @@ -582,7 +582,7 @@
>  toolexeclib_DATA = libgfortran.spec
>  libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
>  libgfortran_la_LDFLAGS = -version-info `grep -v '^\#'
> $(srcdir)/libtool-version` \
> - $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
> + $(LTLDFLAGS) $(LIBQUADLIB) ../../libbacktrace/libbacktrace.la \
>   $(HWCAP_LDFLAGS) \
>   -lm $(extra_ldflags_libgfortran) \
>   $(version_arg) -Wc,-shared-libgcc
> @@ -603,7 +603,7 @@
>        -I$(MULTIBUILDTOP)../libgcc \
>        -I$(srcdir)/$(MULTISRCTOP)../libbacktrace \
>        -I$(MULTIBUILDTOP)../libbacktrace \
> -      -I../libbacktrace
> +      -I../../libbacktrace
>
> But then I get the following error:
>
> | /home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/ld:
> ../../libbacktrace/.libs/libbacktrace.a(dwarf.o): Relocations in
> generic ELF (EM: 62)
> | /home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/ld:
> ../../libbacktrace/.libs/libbacktrace.a(dwarf.o): Relocations in
> generic ELF (EM: 62)
> | /home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/ld:
> ../../libbacktrace/.libs/libbacktrace.a(dwarf.o): Relocations in
> generic ELF (EM: 62)
> | ../../libbacktrace/.libs/libbacktrace.a(dwarf.o): error adding
> symbols: File in wrong format
> | collect2: error: ld returned 1 exit status
> | Makefile:1364: recipe for target 'libgfortran.la' failed
> | make[1]: *** [libgfortran.la] Error 1
> | make[1]: Leaving directory
> '/home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/gcc-7.3.0/build.aarch64-poky-linux.aarch64-poky-linux/aarch64-poky-linux/libgfortran'
> | Makefile:1242: recipe for target 'all' failed
> | make: *** [all] Error 2
> | ERROR: oe_runmake failed
> | WARNING: exit code 1 from a shell command.
> | ERROR: Function failed: do_compile (log file is located at
> /home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/temp/log.do_compile.24547)
> ERROR: Task (/home/sergio/YOCTO/workspace/poky/meta/recipes-devtools/gcc/gcc-runtime_7.3.bb:do_compile)
> failed with exit code '1'

If instead of this patch I hardcode paths doing something like the
following it seems libgfortran compiles.

diff -Naur gcc-7.3.0/libgfortran/Makefile.am
gcc-7.3.0.modif/libgfortran/Makefile.am
--- gcc-7.3.0/libgfortran/Makefile.am    2017-01-17 10:38:48.048122000 +0100
+++ gcc-7.3.0.modif/libgfortran/Makefile.am    2019-01-10
11:30:55.597424246 +0100
@@ -37,7 +37,7 @@
 toolexeclib_DATA = libgfortran.spec
 libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
 libgfortran_la_LDFLAGS = -version-info `grep -v '^\#'
$(srcdir)/libtool-version` \
-    $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
+    $(LTLDFLAGS) $(LIBQUADLIB)
/home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc/7.3.0-r0/gcc-7.3.0/build.aarch64-poky-linux.aarch64-poky-linux/libbacktrace/libbacktrace.la
\
     $(HWCAP_LDFLAGS) \
     -lm $(extra_ldflags_libgfortran) \
     $(version_arg) -Wc,-shared-libgcc
@@ -64,7 +64,7 @@
           -I$(MULTIBUILDTOP)../libgcc \
           -I$(srcdir)/$(MULTISRCTOP)../libbacktrace \
           -I$(MULTIBUILDTOP)../libbacktrace \
-          -I../libbacktrace
+          -I../../libbacktrace

 # Fortran rules for complex multiplication and division
 AM_CFLAGS += -fcx-fortran-rules
diff -Naur gcc-7.3.0/libgfortran/Makefile.in
gcc-7.3.0.modif/libgfortran/Makefile.in
--- gcc-7.3.0/libgfortran/Makefile.in    2018-01-25 09:17:54.059232055 +0100
+++ gcc-7.3.0.modif/libgfortran/Makefile.in    2019-01-10
11:31:11.089394763 +0100
@@ -582,7 +582,7 @@
 toolexeclib_DATA = libgfortran.spec
 libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
 libgfortran_la_LDFLAGS = -version-info `grep -v '^\#'
$(srcdir)/libtool-version` \
-    $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \
+    $(LTLDFLAGS) $(LIBQUADLIB)
/home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc/7.3.0-r0/gcc-7.3.0/build.aarch64-poky-linux.aarch64-poky-linux/libbacktrace/libbacktrace.la
\
     $(HWCAP_LDFLAGS) \
     -lm $(extra_ldflags_libgfortran) \
     $(version_arg) -Wc,-shared-libgcc
@@ -603,7 +603,7 @@
           -I$(MULTIBUILDTOP)../libgcc \
           -I$(srcdir)/$(MULTISRCTOP)../libbacktrace \
           -I$(MULTIBUILDTOP)../libbacktrace \
-          -I../libbacktrace
+          -I../../libbacktrace

 gfor_io_src = io/size_from_kind.c $(am__append_2)
 gfor_io_headers = \

But task do_package gets QA warnings:

ERROR: gcc-runtime-7.3.0-r0 do_package: QA Issue: gcc-runtime:
Files/directories were installed but not shipped in any package:
  /usr/lib/libgfortran.spec
  /usr/lib/libgfortran.a
  /usr/lib/libgfortran.so.4.0.0
  /usr/lib/libgfortran.so
  /usr/lib/libgfortran.so.4
  /usr/lib/gcc/aarch64-poky-linux/7.3.0/libcaf_single.a
  /usr/lib/gcc/aarch64-poky-linux/7.3.0/finclude
  /usr/lib/gcc/aarch64-poky-linux/7.3.0/finclude/ieee_exceptions.mod
  /usr/lib/gcc/aarch64-poky-linux/7.3.0/finclude/ieee_arithmetic.mod
  /usr/lib/gcc/aarch64-poky-linux/7.3.0/finclude/ieee_features.mod
Please set FILES such that these items are packaged. Alternatively if
they are unneeded, avoid installing them or delete them within
do_install.
gcc-runtime: 10 installed and not shipped files. [installed-vs-shipped]
ERROR: gcc-runtime-7.3.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: gcc-runtime-7.3.0-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in:
/home/sergio/YOCTO/build/tmp/work/aarch64-poky-linux/gcc-runtime/7.3.0-r0/temp/log.do_package.12772
ERROR: Task (/home/sergio/YOCTO/workspace/poky/meta/recipes-devtools/gcc/gcc-runtime_7.3.bb:do_package)
failed with exit code '1'

IS there a clean way of resolv properly all of this? I mean, the
hardcoded PATHS and all of this QA issues.  I don't have problems to
send PATCHES if neccessary.

Thanks in advance.

Best regards,
    Sergio Paracuellos

>
> So It seems that libbacktrace is always built for my host architecture
> instead of for arm64 bits...
> Is this a known problem? Am I doing something wrong?
>
> Thanks in advance for your time.
>
> Best regards,
>     Sergio Paracuellos
>
> PD: I updated this info also in a bug related here which seems to be
> fixed https://bugzilla.yoctoproject.org/show_bug.cgi?id=12394


More information about the yocto mailing list