Loongarch64 libressl fatal error: bn_arch.h: No such file or directory

Hi,

I am trying to build openwrt on a LoongArch64 machine with Fedora installed. I got error when it builds libressl with error:

bn/bn_add.c:65:10: fatal error: bn_arch.h: No such file or directory
   65 | #include "bn_arch.h"
      |          ^~~~~~~~~~~
compilation terminated.
make[6]: *** [Makefile:6557: bn/libcrypto_la-bn_add.lo] Error 1
make[6]: Leaving directory '/tmp/openwrt/build_dir/host/libressl-3.7.3/crypto'

the reason is that libressl 3.7.3 does not have loongarch64 support, libressl 4.1.0 has experimental support for loongarch64. is it possible to upgrade the libressl 3.7.3 to libressl 4.1.0 locally in my build environment and how? or I need to cross build openwrt loongarch64 image on x86 build machine?

You have to enhance this with loongarch bits...

you mean even most recent libressl really does not have proper loongarch64 support unless similar fixes like mips you mentioned are added.

dunno - check in respective places whether there are loongarch64 specific redirections to no-assembly source files. You can always use openssl and rebase when this one is in shape.

ok, I tried to compile libressl 3.7.3 and libressl 4.2.1 on loongarch64 machine outside of openwrt. libressl 3.7.3 get the same error but libressl 4.2.1 compiles fine, so I think libressl 4.2.1 is fine with loongarch64. the question remains, how I can upgrade the libressl in openwrt locally ? I see openwrt has tools/libressl/Makefile

include $(TOPDIR)/rules.mk

PKG_NAME:=libressl
PKG_VERSION:=3.7.3
PKG_HASH:=7948c856a90c825bd7268b6f85674a8dcd254bae42e221781b24e3f8dc335db3

PKG_CPE_ID:=cpe:/a:openbsd:libressl

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://mirror.ox.ac.uk/pub/OpenBSD/LibreSSL \
        http://ftp.jaist.ac.jp/pub/OpenBSD/LibreSSL \
        https://ftp.openbsd.org/pub/OpenBSD/LibreSSL

can I change the PKG_VERSION to 4.2.1? how to calculate the PKG_HASH for 4.2.1?

I see, I can use sha256sum to generate the PKG_HASH

1 Like

All correct, PR to bump version is welcome.....

ok, I will test locally to see if it works, then I could send PR

1 Like

ok, the libressl build passed, now I got another build error here, not sure if it is still related to libressl

make[3]: Entering directory '/tmp/openwrt/tools/mkimage'
make -C /tmp/openwrt/build_dir/host/u-boot-2024.07 HOSTCFLAGS="-O2 -I/tmp/openwrt/staging_dir/host/include " HOSTLDFLAGS="-L/tmp/openwrt/staging_dir/host/lib " PKG_CONFIG_EXTRAARGS="--static" V= tools-only
make[4]: Entering directory '/tmp/openwrt/build_dir/host/u-boot-2024.07'
  HOSTCC  scripts/basic/fixdep
  HOSTCC  tools/img2srec
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTCC  tools/mkenvimage.o
  HOSTCC  tools/os_support.o
  HOSTCC  tools/generated/lib/crc32.o
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTLD  tools/mkenvimage
  HOSTCC  tools/aisimage.o
  HOSTCC  tools/atmelimage.o
  HOSTCC  tools/fit_common.o
  HOSTCC  tools/fit_image.o
  HOSTCC  tools/image-host.o
  HOSTCC  tools/generated/boot/image-fit.o
  HOSTCC  tools/image-sig-host.o
  HOSTCC  tools/generated/boot/image-fit-sig.o
  HOSTCC  tools/generated/boot/image-cipher.o
  HOSTCC  tools/generated/boot/fdt_region.o
  HOSTCC  tools/generated/boot/bootm.o
  HOSTCC  tools/default_image.o
  HOSTCC  tools/generated/lib/fdtdec_common.o
  HOSTCC  tools/generated/lib/fdtdec.o
  HOSTCC  tools/generated/boot/image.o
  HOSTCC  tools/generated/boot/image-host.o
  HOSTCC  tools/imagetool.o
  HOSTCC  tools/imximage.o
  HOSTCC  tools/imx8image.o
  HOSTCC  tools/imx8mimage.o
  HOSTCC  tools/kwbimage.o
  HOSTCC  tools/generated/lib/md5.o
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTCC  tools/lpc32xximage.o
  HOSTCC  tools/mxsimage.o
  HOSTCC  tools/omapimage.o
  HOSTCC  tools/pblimage.o
  HOSTCC  tools/pbl_crc32.o
  HOSTCC  tools/renesas_spkgimage.o
  HOSTCC  tools/sfspl.o
  HOSTCC  tools/vybridimage.o
  HOSTCC  tools/stm32image.o
  HOSTCC  tools/generated/lib/rc4.o
  HOSTCC  tools/rkcommon.o
  HOSTCC  tools/rkimage.o
  HOSTCC  tools/rksd.o
  HOSTCC  tools/rkspi.o
  HOSTCC  tools/socfpgaimage.o
  HOSTCC  tools/sunxi_egon.o
  HOSTCC  tools/generated/lib/crc16-ccitt.o
  HOSTCC  tools/generated/lib/hash-checksum.o
  HOSTCC  tools/generated/lib/sha1.o
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTCC  tools/generated/lib/sha256.o
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTCC  tools/generated/lib/sha512.o
In file included from ././include/compiler.h:47,
                 from <command-line>:
/tmp/openwrt/staging_dir/host/include/byteswap.h:2:2: warning: #include_next is a GCC extension
    2 | #include_next <byteswap.h>
      |  ^~~~~~~~~~~~
  HOSTCC  tools/generated/common/hash.o
  HOSTCC  tools/ublimage.o
  HOSTCC  tools/zynqimage.o
  HOSTCC  tools/zynqmpimage.o
  HOSTCC  tools/zynqmpbif.o
  HOSTCC  tools/generated/lib/fdt-libcrypto.o
  HOSTCC  tools/sunxi_toc0.o
tools/sunxi_toc0.c: In function 'toc0_verify_cert_item':
tools/sunxi_toc0.c:447:12: warning: 'nonnull' argument 'digest' compared to NULL [-Wnonnull-compare]
  447 |         if (digest && memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
      |            ^
  HOSTCC  tools/libfdt/fdt.o
  HOSTCC  tools/libfdt/fdt_ro.o
  HOSTCC  tools/libfdt/fdt_wip.o
  HOSTCC  tools/libfdt/fdt_sw.o
  HOSTCC  tools/libfdt/fdt_rw.o
  HOSTCC  tools/libfdt/fdt_strerror.o
  HOSTCC  tools/libfdt/fdt_empty_tree.o
  HOSTCC  tools/libfdt/fdt_addresses.o
  HOSTCC  tools/libfdt/fdt_overlay.o
  HOSTCC  tools/gpimage.o
  HOSTCC  tools/gpimage-common.o
  HOSTCC  tools/mtk_image.o
  HOSTCC  tools/mtk_nand_headers.o
  HOSTCC  tools/generated/lib/ecdsa/ecdsa-libcrypto.o
  HOSTCC  tools/generated/lib/rsa/rsa-sign.o
  HOSTCC  tools/generated/lib/rsa/rsa-verify.o
  HOSTCC  tools/generated/lib/rsa/rsa-mod-exp.o
  HOSTCC  tools/generated/lib/aes/aes-encrypt.o
  HOSTCC  tools/generated/lib/aes/aes-decrypt.o
  HOSTCC  tools/dumpimage.o
  HOSTLD  tools/dumpimage
/usr/bin/ld: /tmp/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-ecdsa.o): in function `ecdsa_sign':
ecdsa.c:(.text+0xea0): multiple definition of `ecdsa_sign'; tools/generated/lib/ecdsa/ecdsa-libcrypto.o:ecdsa-libcrypto.c:(.text+0x4e8): first defined here
/usr/bin/ld: /tmp/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-ecdsa.o): in function `ecdsa_verify':
ecdsa.c:(.text+0x14f8): multiple definition of `ecdsa_verify'; tools/generated/lib/ecdsa/ecdsa-libcrypto.o:ecdsa-libcrypto.c:(.text+0x64c): first defined here
collect2: error: ld returned 1 exit status
make[5]: *** [scripts/Makefile.host:104: tools/dumpimage] Error 1
make[4]: *** [Makefile:2167: tools-only] Error 2
make[4]: Leaving directory '/tmp/openwrt/build_dir/host/u-boot-2024.07'
make[3]: *** [Makefile:54: /tmp/openwrt/build_dir/host/u-boot-2024.07/.built] Error 2
make[3]: Leaving directory '/tmp/openwrt/tools/mkimage'
time: tools/mkimage/compile#8.99#0.75#9.72
    ERROR: tools/mkimage failed to build.
make[2]: *** [tools/Makefile:232: tools/mkimage/compile] Error 1
make[2]: Leaving directory '/tmp/openwrt'
make[1]: *** [tools/Makefile:228: /tmp/openwrt/staging_dir/host/stamp/.tools_compile_nyyynyynnnyyynynyyyyyyynyyynynyynnynnyyyyyynyyyyyyyyyyynynnyyyyynyyy] Error 2
make[1]: Leaving directory '/tmp/openwrt'
make: *** [/tmp/openwrt/include/toplevel.mk:233: world] Error 2

That comes likely from latest compiler upgrades, get back to gcc14 or wait for al edges to be polished up?

My build machine host has gcc 14.2.1 or does openwrt uses its own gcc? also I checkout out openwrt-24.10 to build following the https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem , not the main branch

first is a sled of warnings, then static objects from ~ openssl missing.

it complains tools/generated/lib/ecdsa/ecdsa-libcrypto.o has definition for ecdsa_sign that exists in staging_dir/host/lib/libcrypto.a but I do not see tools/generated directory, it seems tools/generated is a temporary directory during build?

Try to break openssl build for aarch64 or x86 in a similar way, you are walking paths maybe nobody went recently.....

1 Like

do you really need the dumpimage package included in the build ?? if not unset it and the conflict should gone

Utilities --> Boot Loaders --> dumpimage

that is good idea, but oddly from make menuconfig, I could not put N to exclude the dumpimage when I type N, Y and M works, can you manually edit the .config? which CONFIG item it would be for dumpimage in .config?

                          < > dumpimage.......... dumpimage lists and extracts data from U-Boot images.                    │ │  
  │ │                          < > fconfig..................................... RedBoot configuration editor                    │ │  
  │ │                          < > fit-check-sign......................................... verify uImage.FIT                    │ │  
  │ │                          < > uboot-envtools................. read/modify U-Boot bootloader environment                    │ │  
  │ │                                                                                                                           │ │  
  │ │                                                                          

there is no option n ... as far as i know anyway. to unset remove * or m

<*> - include in the image
<m> - make but don't include
<>  - unset

to manually check if its set

openwrt:~/ cat .config | grep dumpimage
CONFIG_PACKAGE_dumpimage=y

use nano or the like to edit it and change it to

# CONFIG_PACKAGE_dumpimage is not set

when I run make menuconfig the dumpimage is already <> no * or m in <>

here is the content from .config by default already

#
# Boot Loaders
#
# CONFIG_PACKAGE_dumpimage is not set
# CONFIG_PACKAGE_fconfig is not set
# CONFIG_PACKAGE_fit-check-sign is not set
# CONFIG_PACKAGE_uboot-envtools is not set
# end of Boot Loaders

not sure whats up with your config but its definitely trying to build it. I think mkimage builds it as a dependency ... perhaps there is something else that depends on it in your build