Bug 12686 - recipe for target 'install_dev' failed (libcrypto.so: file format not recognized)
Summary: recipe for target 'install_dev' failed (libcrypto.so: file format not recogni...
Status: RESOLVED WORKSFORME
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2020.02
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-20 16:34 UTC by Juan
Modified: 2020-05-27 10:03 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
defconfig file that reproduces the issue I'm facing (1.34 KB, text/plain)
2020-03-20 18:52 UTC, Juan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juan 2020-03-20 16:34:54 UTC
Hello,

I'm trying to compile the latest version of buildroot with internal toolchain (I've tried gcc-8.x with c++ support enabled, binutils 2.32 and 2.33.1 with same result), in order to upgrade the system of my embedded hardware based on Sunxi A20 ARM processor, but I'm getting an unexpected error while installing libopenssl-1.1.1d:

install libcrypto.a -> /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.a
install libssl.a -> /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libssl.a
link /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so -> /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so.1.1
install libcrypto.so -> /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so
install libcrypto.so.1.1 -> /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so
/buildrootpath/host/bin/arm-buildroot-linux-gnueabihf-ar: /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so: file format not recognized
/buildrootpath/host/bin/arm-buildroot-linux-gnueabihf-ar: /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so.new: file format not recognized
Makefile:358: recipe for target 'install_dev' failed


Checking files with readelf -hl I obtain next output:

$ readelf -hl libcrypto.so
Encabezado ELF:
  Mágico:  7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Clase:                             ELF32
  Datos:                             complemento a 2, little endian
  Versión:                           1 (current)
  OS/ABI:                            UNIX - System V
  Versión ABI:                       0
  Tipo:                              DYN (Fichero objeto compartido)
  Máquina:                           ARM
  Versión:                           0x1
  Dirección del punto de entrada:    0x50000
  Inicio de encabezados de programa: 52  (bytes en el fichero)
  Inicio de encabezados de sección:  2373548 (bytes en el fichero)
  Opciones:                          0x5000400, Version5 EABI, hard-float ABI
  Tamaño de este encabezado:         52 (bytes)
  Tamaño de encabezados de programa: 32 (bytes)
  Número de encabezados de programa: 6
  Tamaño de encabezados de sección:  40 (bytes)
  Número de encabezados de sección:  37
  Índice de tabla de cadenas de sección de encabezado: 36

Encabezados de Programa:
  Tipo           Desplaz  DirVirt    DirFísica  TamFich TamMem  Opt Alin
  EXIDX          0x1c4b48 0x001c4b48 0x001c4b48 0x00008 0x00008 R   0x4
  LOAD           0x000000 0x00000000 0x00000000 0x1c4b54 0x1c4b54 R E 0x10000
  LOAD           0x1c55f8 0x001d55f8 0x001d55f8 0x16de0 0x1ac6c RW  0x10000
  DYNAMIC        0x1daed8 0x001eaed8 0x001eaed8 0x00128 0x00128 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x1c55f8 0x001d55f8 0x001d55f8 0x15a08 0x15a08 R   0x1

 mapeo de Sección a Segmento:
  Segmento Secciones...
   00     .ARM.exidx 
   01     .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame 
   02     .init_array .fini_array .data.rel.ro .dynamic .got .data .bss 
   03     .dynamic 
   04     
   05     .init_array .fini_array .data.rel.ro .dynamic 

$ readelf -hl libcrypto.so.new 
Encabezado ELF:
  Mágico:  7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Clase:                             ELF32
  Datos:                             complemento a 2, little endian
  Versión:                           1 (current)
  OS/ABI:                            UNIX - System V
  Versión ABI:                       0
  Tipo:                              DYN (Fichero objeto compartido)
  Máquina:                           ARM
  Versión:                           0x1
  Dirección del punto de entrada:    0x50000
  Inicio de encabezados de programa: 52  (bytes en el fichero)
  Inicio de encabezados de sección:  2373548 (bytes en el fichero)
  Opciones:                          0x5000400, Version5 EABI, hard-float ABI
  Tamaño de este encabezado:         52 (bytes)
  Tamaño de encabezados de programa: 32 (bytes)
  Número de encabezados de programa: 6
  Tamaño de encabezados de sección:  40 (bytes)
  Número de encabezados de sección:  37
  Índice de tabla de cadenas de sección de encabezado: 36

Encabezados de Programa:
  Tipo           Desplaz  DirVirt    DirFísica  TamFich TamMem  Opt Alin
  EXIDX          0x1c4b48 0x001c4b48 0x001c4b48 0x00008 0x00008 R   0x4
  LOAD           0x000000 0x00000000 0x00000000 0x1c4b54 0x1c4b54 R E 0x10000
  LOAD           0x1c55f8 0x001d55f8 0x001d55f8 0x16de0 0x1ac6c RW  0x10000
  DYNAMIC        0x1daed8 0x001eaed8 0x001eaed8 0x00128 0x00128 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x1c55f8 0x001d55f8 0x001d55f8 0x15a08 0x15a08 R   0x1

 mapeo de Sección a Segmento:
  Segmento Secciones...
   00     .ARM.exidx 
   01     .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame 
   02     .init_array .fini_array .data.rel.ro .dynamic .got .data .bss 
   03     .dynamic 
   04     
   05     .init_array .fini_array .data.rel.ro .dynamic 



Relevant configuration entries are next:

#
# Target options
#
BR2_ARCH_HAS_TOOLCHAIN_BUILDROOT=y
BR2_ARCH="arm"
BR2_ENDIAN="LITTLE"
BR2_GCC_TARGET_ABI="aapcs-linux"
BR2_GCC_TARGET_CPU="cortex-a7"
BR2_GCC_TARGET_FPU="vfpv4-d16"
BR2_GCC_TARGET_FLOAT_ABI="hard"
BR2_GCC_TARGET_MODE="arm"
BR2_BINFMT_SUPPORTS_SHARED=y
BR2_READELF_ARCH_NAME="ARM"
BR2_BINFMT_ELF=y
BR2_ARM_CPU_HAS_NEON=y
BR2_ARM_CPU_HAS_FPU=y
BR2_ARM_CPU_HAS_VFPV2=y
BR2_ARM_CPU_HAS_VFPV3=y
BR2_ARM_CPU_HAS_VFPV4=y
BR2_ARM_CPU_HAS_ARM=y
BR2_ARM_CPU_HAS_THUMB2=y
BR2_ARM_CPU_ARMV7A=y

#
#Toolchain options
#
BR2_TOOLCHAIN=y
BR2_TOOLCHAIN_USES_GLIBC=y
BR2_TOOLCHAIN_BUILDROOT=y

#
# Toolchain Buildroot Options
#
BR2_TOOLCHAIN_BUILDROOT_VENDOR="buildroot"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_TOOLCHAIN_BUILDROOT_LIBC="glibc"

#
# Glibc Options
#
BR2_PACKAGE_GLIBC=y

#
# Binutils Options
#
BR2_PACKAGE_HOST_BINUTILS_SUPPORTS_CFI=y
BR2_BINUTILS_VERSION_2_33_X=y
BR2_BINUTILS_VERSION="2.33.1"
BR2_BINUTILS_EXTRA_CONFIG_OPTIONS=""

#
# GCC Options
#
# BR2_GCC_VERSION_7_X is not set
BR2_GCC_VERSION_8_X=y
BR2_GCC_VERSION="8.3.0"
BR2_EXTRA_GCC_CONFIG_OPTIONS=""
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS=y

#
# Crypto
#
# BR2_PACKAGE_BEECRYPT is not set
BR2_PACKAGE_BOTAN_ARCH_SUPPORTS=y
# BR2_PACKAGE_BOTAN is not set
# BR2_PACKAGE_CA_CERTIFICATES is not set
# BR2_PACKAGE_CRYPTODEV is not set
# BR2_PACKAGE_GCR is not set
BR2_PACKAGE_GNUTLS=y
# BR2_PACKAGE_GNUTLS_OPENSSL is not set
BR2_PACKAGE_GNUTLS_TOOLS=y
# BR2_PACKAGE_LIBARGON2 is not set
# BR2_PACKAGE_LIBASSUAN is not set
# BR2_PACKAGE_LIBGCRYPT is not set
BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS=y
# BR2_PACKAGE_LIBGPG_ERROR is not set
BR2_PACKAGE_LIBGPG_ERROR_SYSCFG="arm-unknown-linux-gnueabi"
# BR2_PACKAGE_LIBGPGME is not set
# BR2_PACKAGE_LIBKCAPI is not set
# BR2_PACKAGE_LIBKSBA is not set
# BR2_PACKAGE_LIBMCRYPT is not set
# BR2_PACKAGE_LIBMHASH is not set
# BR2_PACKAGE_LIBNSS is not set
# BR2_PACKAGE_LIBOLM is not set
# BR2_PACKAGE_LIBP11 is not set
# BR2_PACKAGE_LIBSCRYPT is not set
# BR2_PACKAGE_LIBSECRET is not set
# BR2_PACKAGE_LIBSHA1 is not set
# BR2_PACKAGE_LIBSODIUM is not set
# BR2_PACKAGE_LIBSSH is not set
# BR2_PACKAGE_LIBSSH2 is not set
# BR2_PACKAGE_LIBTOMCRYPT is not set
# BR2_PACKAGE_LIBUECC is not set
# BR2_PACKAGE_MBEDTLS is not set
BR2_PACKAGE_NETTLE=y
BR2_PACKAGE_OPENSSL=y
BR2_PACKAGE_LIBOPENSSL=y
BR2_PACKAGE_LIBOPENSSL_TARGET_ARCH="linux-armv4"
BR2_PACKAGE_LIBOPENSSL_BIN=y
# BR2_PACKAGE_LIBOPENSSL_ENGINES is not set
# BR2_PACKAGE_LIBRESSL is not set
BR2_PACKAGE_HAS_OPENSSL=y
BR2_PACKAGE_PROVIDES_OPENSSL="libopenssl"
BR2_PACKAGE_PROVIDES_HOST_OPENSSL="host-libopenssl"
# BR2_PACKAGE_RHASH is not set
# BR2_PACKAGE_TINYDTLS is not set
# BR2_PACKAGE_TPM2_TSS is not set
BR2_PACKAGE_TROUSERS=y
# BR2_PACKAGE_USTREAM_SSL is not set
# BR2_PACKAGE_WOLFSSL is not set
Comment 1 Peter Seiderer 2020-03-20 17:26:01 UTC
Please try a complete re-build:

    make clean
    make

If it fails again, please provide a complete .config file (or defconfig - after make savedefconfig)...
Comment 2 Juan 2020-03-20 18:50:20 UTC
I attach a defconfig file for one of the Sunxi A20 boards that gives me the same error.
Comment 3 Juan 2020-03-20 18:52:12 UTC
Created attachment 8411 [details]
defconfig file that reproduces the issue I'm facing
Comment 4 Peter Seiderer 2020-03-20 21:35:35 UTC
Given defconfig compiles without failure here (host: openSUSE Tumbleweed), anything special with your build system?
Comment 5 Juan 2020-03-23 09:32:39 UTC
Hi,

My build system is old but compliant with requirements:

- gcc/gcc++ 4.9.2-6.fc21
- make 4.0-3.fc21

except perl version (5.18.4-310.fc21), but 2019.02 compiles well in my system and perl requirements are the same... and this error does not appear to be related with perl.


Best Regards
Comment 6 Peter Seiderer 2020-03-23 18:50:27 UTC
Two last (from my side) options/suggestions:

- maybe a parallel build issue, try to re-build libopenssl with BR2_JLEVEL=1 set in the .config file

- check your environment variables, your log excerpt shows something
with

    Makefile:358: recipe for target 'install_dev' failed

and 

    buildrootpath/host/bin/arm-buildroot-linux-gnueabihf-ar: /buildrootpath/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypto.so: file format not recognized

In my Makefile (build/libopenssl-1.1.1d/Makefile) the target install_dev
is form line 310 to 355 and contains install/cp/$(RANLIB)/chmod/mv commands for .new files....no 'ar' call...and RANLIB is specified as

    RANLIB=$(CROSS_COMPILE)<my_working_dir>/host/bin/arm-buildroot-linux-gnueabihf-ranlib
Comment 7 Juan 2020-03-24 10:13:17 UTC
Hi again,

I tried changing value for the variable BR2_JLEVEL from 0 to 1 with no success. About Makefile, the 358 line is next one:

357: install_dev: install_runtime_libs
358:	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
359:	@$(ECHO) "*** Installing development files"
360:	@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
361:	@ : 

If you want I can attach the whole Makefile (1.2 MB), but my point is that only will serve to waste disk space on server.

About environment variables, I see no other value related to building environment except PATH including entry to perl5, also PERL_LOCAL_LIB_ROOT and PERL_LOCAL_LIB_ROOT entries.


Thank you and best regards
Comment 8 Thomas Petazzoni 2020-05-17 20:20:34 UTC
The issue you are pointing to seems to be known in OpenSSL upstream:
 - https://github.com/openssl/openssl/issues/6641
 - https://github.com/openssl/openssl/issues/9086

So, I setup a Docker container with CentOS 7, checked out Buildroot 2020.02 and built OpenSSL 1.1.1d, without any problem.

The first issue mentioned above indicates that the problem came from a perl module called Text::Template, which I do not have installed in my Docker container:

# perl -e 'use Text::Template; print $Text::Template::VERSION,"\n";'
Can't locate Text/Template.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Since you mentioned you had some Perl-related environment variables defined, perhaps there is an issue with this ?

Since we're not able to reproduce, we won't be able to help a lot here. Could you work on some way of reproducing this?
Comment 9 Juan 2020-05-27 10:03:13 UTC
Hello Thomas,

I'm sorry to answer too late, but due to the COVID-19 I have been compelled to spend my time on other matters.

Today I've uninstalled the perl module and its dependencies and now I'm compiling again buildroot 2020.02 without experiencing any error from libopenssl.

Prior to post the bug I've searched a lot looking for the error, but i've got no result about perl-Text-Template issues.

Let me to say your commitment with this issue exceeded the one that could be expected. You had the possibility to answer saying it is an external issue to buildroot and only related with libopenssl. Your answer could have been shorter, but you made a test and provided the solution.


Thanks a lot

Juan