Bug 279531 - sysutils/u-boot-rpi4: Cannot build, errors with ecdsa and rsa
Summary: sysutils/u-boot-rpi4: Cannot build, errors with ecdsa and rsa
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-uboot (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-05 00:19 UTC by Naram Qashat
Modified: 2024-06-13 09:44 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (uboot)


Attachments
u-boot.diff to fix building against ports OpenSSL (1.50 KB, patch)
2024-06-09 22:48 UTC, Naram Qashat
cyberbotx: maintainer-approval? (uboot)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Naram Qashat 2024-06-05 00:19:41 UTC
I don't know what is causing this, but when I try to build sysutils/u-boot-rpi4, I get errors about EVP_PKEY_id and EVP_PKEY_size being undefined. Assuming it matters, I am using OpenSSL 3.2 from ports when compiling.

Specifically the messages are:

[00:00:28] ld: error: undefined symbol: EVP_PKEY_id
[00:00:28] >>> referenced by ecdsa-libcrypto.c
[00:00:28] >>>               tools/generated/lib/ecdsa/ecdsa-libcrypto.o:(prepare_ctx)

[00:00:28] ld: error: undefined symbol: EVP_PKEY_size
[00:00:28] >>> referenced by rsa-sign.c
[00:00:28] >>>               tools/generated/lib/rsa/rsa-sign.o:(rsa_sign)

A full build log can be found here: https://poudriere.cyberbotx.com:8768/data/13amd64-default/2024-06-03_12h27m51s/logs/errors/u-boot-rpi4-2024.04.log
Comment 1 Emmanuel Vadot freebsd_committer freebsd_triage 2024-06-05 07:43:03 UTC
Works fine here so the problem is likely that you use openssl from ports.
Comment 2 Emmanuel Vadot freebsd_committer freebsd_triage 2024-06-05 07:46:01 UTC
I don't think that one port can specify using ssl from base so adjust your make.conf so DEFAULT_VERSIONS=ssl=base is set for u-boot-*
Comment 3 Naram Qashat 2024-06-09 22:48:17 UTC
Created attachment 251332 [details]
u-boot.diff to fix building against ports OpenSSL

I am going to re-open this, as I found the cause and the fix.

Firstly: u-boot-tools APPEARED to not be affected by this problem, but in reality, it only was making it. It never uses the SSL choice by the user and always uses base OpenSSL.

The cause: u-boot-tools and all the u-boot firmware ports that rely on u-boot-master never have the -I or -L flags needed for OpenSSL passed into the u-boot build system. Something in u-boot-master made it use -L/usr/local/lib anyways and that was causing my build failure. The build system also does not respect externally set CFLAGS and LDFLAGS.

The fix: In order to get u-boot's build system to respect the user's wish as to what OpenSSL to use (as well as any other CFLAGS or LDFLAGS the user sets), add HOSTCFLAGS and HOSTLDFLAGS to the MAKE_ENV.

Additionally: u-boot-master did not put compiler:c11 or ssl into USES like u-boot-tools did, so I added those. Also, I moved V=1 from MAKE_ENV to MAKE_ARGS as u-boot's build system ignore it when set in the former, and CC=clang was being completely ignored so I removed that.
Comment 4 Naram Qashat 2024-06-09 22:48:44 UTC
See the above diff for why I'm reopening this.
Comment 5 Mark Millard 2024-06-09 23:39:06 UTC
(In reply to Naram Qashat from comment #3)

Note that u-boot-tools installs host commands:

	/usr/local/bin/dumpimage
	/usr/local/bin/fit_info
	/usr/local/bin/mkenvimage
	/usr/local/bin/mkimage

As I understand, that is why its build involves HOSTCFLAGS and HOSTLDFLAGS .

The likes of sysutils/u-boot-rpi4 do not install any host command or libraries
or such. As I understand, that is why they do not involve HOSTCFLAGS
and do not involve HOSTLDFLAGS.

So, I expect at least part of your changes to be inappropriate.
Comment 6 Mark Millard 2024-06-09 23:47:41 UTC
(In reply to Mark Millard from comment #5)

Never mind: There is a bunch of HOSTCC in the sysutils/u-boot-rpi4
build: it does make host software that is used but not installed.

Sorry for the noise.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-06-13 09:43:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=df65ca710c5f3a2ab709549607ea169015fc9bb4

commit df65ca710c5f3a2ab709549607ea169015fc9bb4
Author:     Naram Qashat <cyberbotx@cyberbotx.com>
AuthorDate: 2024-06-13 08:44:10 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2024-06-13 09:42:08 +0000

    sysutils/u-boot: Allow building with different openssl

    Add ssl to USES and export the needed variables so u-boot can be built
    with openssl from ports.

    PR:     279531

 sysutils/u-boot-master/Makefile | 8 +++++---
 sysutils/u-boot-tools/Makefile  | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
Comment 8 Emmanuel Vadot freebsd_committer freebsd_triage 2024-06-13 09:44:03 UTC
Thanks, commited.