From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 03 Aug 2022 13:20:59 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oJCQq-009y0n-Tp for lore@lore.pengutronix.de; Wed, 03 Aug 2022 13:20:59 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oJCQs-0007TL-E3; Wed, 03 Aug 2022 13:20:58 +0200 Received: from mail.thorsis.com ([92.198.35.195]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oJCQI-0007Sd-SS; Wed, 03 Aug 2022 13:20:23 +0200 From: Alexander Dahl To: Michael Olbrich Date: Wed, 03 Aug 2022 13:20:21 +0200 Message-ID: <10086649.DBdDmKp7kz@ada> In-Reply-To: References: <15979690.J2xNbxXsf2@ada> <4722212.1oGcgTFBSJ@ada> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Clacks-Overhead: GNU Terry Pratchett X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-2.6 required=4.0 tests=AWL,BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] Build U-Boot against host-openssl fails X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: Alexander Dahl , ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false Hello Michael, I tried building the same U-Boot 2022.04 for a different board in a differe= nt=20 BSP now, which uses ptxdist 2021.06 already. This works at least somehow. M= ore=20 comments below. Am Freitag, 29. Juli 2022, 08:40:19 CEST schrieb Michael Olbrich: > On Tue, Jul 26, 2022 at 09:43:09AM +0200, Alexander Dahl wrote: > > Am Montag, 25. Juli 2022, 21:09:35 CEST schrieb Alexander Dahl: > > > Am Mon, Jul 25, 2022 at 05:36:57PM +0200 schrieb Michael Olbrich: > > > > On Mon, Jul 25, 2022 at 04:41:45PM +0200, Alexander Dahl wrote: > > > > > although claiming it's optional latest U-Boot versions require > > > > > OpenSSL > > > > > on the host.=C2=B9 I added an option to build host-openssl with = commit > > > > > 0c779a60e50c40d522b1e9c20b5c75b2e57fde5a ("u-boot: Add option to > > > > > depend > > > > > on > > > > > host-openssl") but ptxdist u-boot package still fails to link to > > > > > host > > > > > openssl package, message is always missing some openssl symbols. > > > > >=20 > > > > > I tried the same thing as barebox now in rules/u-boot.make like > > > > > this: > > > > >=20 > > > > > +# use host pkg-config for host tools > > > > > +U_BOOT_PATH :=3D PATH=3D$(HOST_PATH) > > > > >=20 > > > > > This does not help. Adding this or not would make a difference in build behaviour if U-Boot wou= ld=20 not have that fallback in its Makefile. =20 If it's present '=E2=80=A6/platform-v7a/sysroot-host/bin/pkg-config' is use= d. If it's _not_ present '=E2=80=A6/platform-v7a/sysroot-cross/bin/pkg-config'= is used. So it seems to be the right thing from a rule file point of view to add thi= s.=20 I will send a patch. > > > > >=20 > > > > > I'm somehow suspecting the wrong pkg-config is called. Affected = is > > > > > not > > > > > the > > > > > target image, but the host tools (like mkimage) built alongside w= ith > > > > > the > > > > > target stuff (which you 1) can not disable to build and 2) need f= or > > > > > certain > > > > > parts of the ptxdist package anyways, so not building those is no > > > > > option). > > > > >=20 > > > > > I tried each combination of PTXCONF_U_BOOT_NEEDS_HOST_OPENSSL and > > > > > CONFIG_TOOLS_LIBCRYPTO in U-Boot kconfig, all fail. With ptxdist 2021.06 and setting both of those to 'yes', build is successfu= l.=20 (Note: At least U-Boot 2022.04 and 2022.07 are buggy and do not allow to bu= ild=20 with CONFIG_TOOLS_LIBCRYPTO disabled and host libssl-dev absent [1].) > > > > >=20 > > > > > buildroot has a fix for building against host-openssl, but I don't > > > > > understand it, and I'm not sure if the same approach would work in > > > > > ptxdist. > > > > >=20 > > > > > Any ideas? > > > > >=20 > > > > > (Disclaimer: this only happens on a quite recent U-Boot, e.g. from > > > > > 2022.) > > > > > (More disclaimer: it does not happen if libssl-dev is installed on > > > > > the > > > > > build host.) Did not try with libssl-dev installed on the host again. It should work=20 against host-openssl package from ptxdist, otherwise I would consider it=20 broken anyways. > > > >=20 > > > > This sounds like u-boot is calling /usr/bin/pkg-config instead of > > > > .../sysroot-host/bin/pkg-config (and not the cross pkg-config eithe= r). > > > >=20 > > > > Maybe /usr/bin/pkg-config is called explicitly with the whole path > > > > somewhere? That could be a "feature" to avoid the cross pkg-config > > > > when > > > > cross-compiling. > > >=20 > > > Sorry, I wanted to paste the actual part from tools/Makefile (u-boot > > > source) and this is it: > > >=20 > > > 174 # MXSImage needs LibSSL > > > 175 ifneq > > > ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCR= YPT > > > O), > > > ) 176 HOSTCFLAGS_kwbimage.o +=3D \ > > > 177 $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || > > > echo > > > "") 178 HOSTLDLIBS_mkimage +=3D \ > > > 179 $(shell pkg-config --libs libssl libcrypto 2> /dev/null || ec= ho > > > "-lssl -lcrypto") 180 > > > 181 # OS X deprecate openssl in favour of CommonCrypto, supress > > > deprecation > > > 182 # warnings on those systems > > > 183 ifeq ($(HOSTOS),darwin) > > > 184 HOSTCFLAGS_mxsimage.o +=3D -Wno-deprecated-declarations > > > 185 HOSTCFLAGS_image-sig.o +=3D -Wno-deprecated-declarations > > > 186 HOSTCFLAGS_rsa-sign.o +=3D -Wno-deprecated-declarations > > > 187 endif > > > 188 endif > > >=20 > > > I'm not sure how I can verify what's actually called here? > >=20 > > Added this line in U-Boot source tools/Makefile to see what's going on: > > $(info HOSTLDLIBS_mkimage is $(HOSTLDLIBS_mkimage)) > >=20 > > (directly after that is assigned) > >=20 > > Output is: > > HOSTLDLIBS_mkimage is -lssl -lcrypto Still gives: HOSTLDLIBS_mkimage is -lssl -lcrypto Even does that if I remove the '|| echo "-lssl -lcrypto"' fallback, so that= 's=20 probably a good thing. (Is empty with removed fallback without the U_BOOT_P= ATH=20 fix from above, then build fails.) > > =20 > > > Just had another look at what buildroot does. Seems like > > > host-pkg-config is required, IIRC that was not used by ptxdist. Not > > > sure how I can let ptxdist use host pkg-config, but I hope I'll find > > > out tomorrow. > >=20 > > Yeah well, it was late yesterday, what the barebox package does is sett= ing > > _PATH and I tried that already (as written before). So I tried > > calling > > pkg-config with that path the same way the U-Boot Makefile does > > (redacted): > >=20 > >=20 > > % p print U_BOOT_PATH > > PATH=3D/home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home= /adah > > l/ Work/bsp/***/***/platform-***/sysroot-host/sbin:/opt/ > > OSELAS.Toolchain-2018.02.0/arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27- > > binutils-2.30-kernel-4.15-sanitized/bin:/usr/local/lib/ptxdist-2018.05.= 0/b > > in:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home/adahl/W= or > > k/ > > bsp/***/***/platform-***/sysroot-host/sbin:/opt/OSELAS.Toolchain-2018.0= 2. > > 0/ arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.= 15- > > sanitized/bin:/usr/local/lib/ptxdist-2022.05.0/bin:/home/adahl/bin:/hom= e/ > > adahl/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gam= es > >=20 > > % > > PATH=3D/home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home= /ada > > hl/ Work/bsp/***/***/platform-***/sysroot-host/sbin:/opt/ > > OSELAS.Toolchain-2018.02.0/arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27- > > binutils-2.30-kernel-4.15-sanitized/bin:/usr/local/lib/ptxdist-2018.05.= 0/b > > in:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home/adahl/W= or > > k/ > > bsp/***/***/platform-***/sysroot-host/sbin:/opt/OSELAS.Toolchain-2018.0= 2. > > 0/ arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.= 15- > > sanitized/bin:/usr/local/lib/ptxdist-2022.05.0/bin:/home/adahl/bin:/hom= e/ > > adahl/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gam= es > > pkg- config --libs libssl libcrypto > > -L/home/adahl/Work/bsp/***/***/platform-***/sysroot-host/lib/pkgconfig/= =2E./ > > ..// lib -lssl -lcrypto > >=20 > >=20 > > Okay this seems to call some pkg-config which gives the right path (see > > the -L output) but U-Boot does not produce that output as you can see > > above. =46ollowing this approach no -L*** anymore, but just '-lssl -lcrypto' as=20 expected. > >=20 > > When calling ptxdist (verbose) the path seems to be slightly different > > however: > >=20 > > % p -v -j1 compile u-boot > >=20 > > ---------------------- > > target: u-boot.compile > > ---------------------- > >=20 > > ptxdist: executing: > > PATH=3D\/home/adahl/Work/bsp/***/***/platform-***/sysroot- > > host/lib/wrapper:/home/adahl/Work/bsp/***/***/platform-***/sysroot-host= /b > > in:/ home/adahl/Work/bsp/***/***/platform-***/sysroot-host/sbin:/opt/ > > OSELAS.Toolchain-2018.02.0/arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27- > > binutils-2.30-kernel-4.15-sanitized/bin:/usr/local/lib/ptxdist-2018.05.= 0/b > > in:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home/adahl/W= or > > k/ > > bsp/***/***/platform-***/sysroot-host/sbin:/opt/OSELAS.Toolchain-2018.0= 2. > > 0/ arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.= 15- > > sanitized/bin:/usr/local/lib/ptxdist-2022.05.0/bin:/home/adahl/bin:/hom= e/ > > adahl/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gam= es > > PKGCONFIG_WHITELIST=3D'' PKGCONFIG_WHITELIST_SRC=3D'u-boot' > > PKG_CONFIG_PATH=3D'' > With an empty whitelist like this, the pkg-config in ptxdist will reject > all requests with error. This has these now, looks fine I guess: PKGCONFIG_WHITELIST_HOST=3D'libcrypto libssl openssl' PKGCONFIG_WHITELIST_TARGET=3D'' PKGCONFIG_WHITELIST_SRC=3D'u-boot-***' >=20 > > PKG_CONFIG_LIBDIR=3D'/home/adahl/Work/bsp/***/***/platform-***/sysroot-= targe > > t/ > > lib/pkgconfig:/home/adahl/Work/bsp/***/***/platform-***/sysroot-target/= us > > r/ > > lib/pkgconfig:/home/adahl/Work/bsp/***/***/platform-***/sysroot-target/= sh > > are/ > > pkgconfig:/home/adahl/Work/bsp/***/***/platform-***/sysroot-target/usr/= sh > > are/ pkgconfig' > > PKG_CONFIG_SYSTEM_LIBRARY_PATH=3D'/home/adahl/Work/bsp/***/***/ > > platform-***/sysroot-target/lib/pkgconfig/../../lib:/home/adahl/Work/bs= p/ > > ***/ > > ***/platform-***/sysroot-target/usr/lib/pkgconfig/../../lib:/home/adahl= /W > > ork/ > > bsp/***/***/platform-***/sysroot-target/share/pkgconfig/../../lib:/home= /a > > dahl/ > > Work/bsp/***/***/platform-***/sysroot-target/usr/share/pkgconfig/../../= li > > b:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-target/lib/pkgconfig/.= =2E/ > > lib:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-target/usr/lib/pkgconf= ig > > /../ lib:/home/adahl/Work/bsp/***/***/platform-***/sysroot-target/share/ > > pkgconfig/../lib:/home/adahl/Work/bsp/***/***/platform-***/sysroot-targ= et > > /usr/ share/pkgconfig/../lib:/usr/lib:/lib' > > PKG_CONFIG_SYSTEM_INCLUDE_PATH=3D'/home/ > > adahl/Work/bsp/***/***/platform-***/sysroot-target/lib/pkgconfig/../../ > > include:/home/adahl/Work/bsp/***/***/platform-***/sysroot-target/usr/li= b/ > > pkgconfig/../../include:/home/adahl/Work/bsp/***/***/platform-***/sysro= ot > > - > > target/share/pkgconfig/../../include:/home/adahl/Work/bsp/***/***/platf= or > > m- > > ***/sysroot-target/usr/share/pkgconfig/../../include:/home/adahl/Work/b= sp > > /***/ > > ***/platform-***/sysroot-target/lib/pkgconfig/../include:/home/adahl/Wo= rk > > /bsp/ > > ***/***/platform-***/sysroot-target/usr/lib/pkgconfig/../include:/home/= ad > > ahl/ > > Work/bsp/***/***/platform-***/sysroot-target/share/pkgconfig/../include= :/ > > home/ > > adahl/Work/bsp/***/***/platform-***/sysroot-target/usr/share/pkgconfig/= =2E. > > / include:/usr/include:/include' PKG_CONFIG=3D'/home/adahl/Work/bsp/***= /***/ > > platform-***/sysroot-cross/bin/arm-v7a-linux-gnueabihf-pkg-config' > > SYSROOT=3D'/ home/adahl/Work/bsp/***/***/platform-***/sysroot-target' V= =3D1 > > VERBOSE=3D1 CROSS_COMPILE=3Darm-v7a-linux-gnueabihf- HOSTCC=3Dgcc make = =2DC > > /home/adahl/Work/ > > bsp/***/***/platform-***/build-target/u-boot-2022.04-build -C > > /home/adahl/ Work/bsp/***/***/platform-***/build-target/u-boot-2022.04 > > O=3D/home/adahl/Work/ > > bsp/***/***/platform-***/build-target/u-boot-2022.04-build V=3D1 -j1 > >=20 > >=20 > > This adds an additional piece to the path (/home/adahl/Work/bsp/***/***/ > > platform-***/sysroot-host/lib/wrapper), but even if I call pkg-config w= ith > > this, the output seems correct: > >=20 > >=20 > > % > > PATH=3D/home/adahl/Work/bsp/***/***/platform-***/sysroot-host/lib/wrapp= er:/ > > home/adahl/Work/bsp/***/***/platform-***/sysroot-host/bin:/home/adahl/W= ork > > / > > bsp/***/***/platform-***/sysroot-host/sbin:/opt/OSELAS.Toolchain-2018.0= 2.0 > > / > > arm-v7a-linux-gnueabihf/gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15- > > sanitized/bin:/usr/local/lib/ptxdist-2018.05.0/bin:/home/adahl/Work/bsp= /** > > */ > > ***/platform-***/sysroot-host/bin:/home/adahl/Work/bsp/***/***/platform= =2D* > > **/ > > sysroot-host/sbin:/opt/OSELAS.Toolchain-2018.02.0/arm-v7a-linux-gnueabi= hf > > / > > gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized/bin:/usr/local= /l > > ib/ > > ptxdist-2022.05.0/bin:/home/adahl/bin:/home/adahl/.local/bin:/usr/local= /b > > in:/ usr/bin:/bin:/usr/local/games:/usr/games pkg-config --libs libssl > > libcrypto > > -L/home/adahl/Work/bsp/***/***/platform-***/sysroot-host/lib/pkgconfig/= =2E. > > /..// lib -lssl -lcrypto > >=20 > >=20 > > I don't understand it. > >=20 > > This is still ptxdist-2018.05.0 =E2=80=A6 can that be a problem here? >=20 > With that ptxdist version pkg-config cannot find host libraries for target > packages. That was introduced in 4c6e7fa28b66dee069d10b514d5e1317173da250. ptxdist-2018.08.0-27-g4c6e7fa28 =E2=80=A6 so ptxdist-2018.09.0 onwards has = it. >=20 > How does this fail anyways? The fall-back ("-lssl -lcrypto" and now search > paths) should just work anyways. I don't know. However I think we don't need to investigate much more time= =20 after proving it works with recent ptxdist versions, at least if you don't = hit=20 any U-Boot build file bugs.=20 Thanks for your support. A [1] https://lore.kernel.org/u-boot/1884029.XjOfZupGQm@ada/T/#u