Message ID | 20220809162714.1915094-1-fontaine.fabrice@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/1] utils/genrandconfig: disable libopenssl without atomics | expand |
Hello Fabrice, On Tue, 9 Aug 2022 18:27:14 +0200 Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote: > libopenssl needs atomic or the build will fail (e.g. on sparcv8 without > libatomic): > > ${LDCMD:-/nvmedata/autobuild/instance-7/output-1/host/bin/sparc-buildroot-linux-uclibc-gcc} -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O0 -g2 -g2 -L. \ > -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \ > apps/libapps.a -lssl -lcrypto -ldl > /nvmedata/autobuild/instance-7/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: ./libssl.so: undefined reference to `__atomic_fetch_sub_4' Why don't we link openssl with libatomic? libatomic provides atomic builtins on all architectures. It is normally already the case: $(if $(BR2_TOOLCHAIN_HAS_LIBATOMIC),-latomic) \ in LIBOPENSSL_CONFIGURE_CMDS. But I see this linker flag is missing in the compile command line that causes the error. Best regards, Thomas
Hello Thomas, Le mer. 10 août 2022 à 23:07, Thomas Petazzoni <thomas.petazzoni@bootlin.com> a écrit : > Hello Fabrice, > > On Tue, 9 Aug 2022 18:27:14 +0200 > Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote: > > > libopenssl needs atomic or the build will fail (e.g. on sparcv8 without > > libatomic): > > > > > ${LDCMD:-/nvmedata/autobuild/instance-7/output-1/host/bin/sparc-buildroot-linux-uclibc-gcc} > -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 > -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O0 -g2 > -g2 -L. \ > > -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o > apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o > apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o > apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o > apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o > apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o > apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o > apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o > apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o > apps/verify.o apps/version.o apps/x509.o \ > > apps/libapps.a -lssl -lcrypto -ldl > > > /nvmedata/autobuild/instance-7/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: > ./libssl.so: undefined reference to `__atomic_fetch_sub_4' > > Why don't we link openssl with libatomic? > > libatomic provides atomic builtins on all architectures. > Indeed, but libatomic is not available/enabled on all those autobuilder build failures. For example, BR2_TOOLCHAIN_HAS_LIBATOMIC can't be found in http://autobuild.buildroot.org/results/bce526d538f43a541fdfbc0c9b4a7cecebbbc539/config > > It is normally already the case: > > $(if $(BR2_TOOLCHAIN_HAS_LIBATOMIC),-latomic) \ > > in LIBOPENSSL_CONFIGURE_CMDS. But I see this linker flag is missing in > the compile command line that causes the error. > > Best regards, > > Thomas > -- > Thomas Petazzoni, co-owner and CEO, Bootlin > Embedded Linux and Kernel engineering and training > https://bootlin.com > Best Regards, Fabrice
On Wed, 10 Aug 2022 23:17:01 +0200 Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote: > Indeed, but libatomic is not available/enabled on all those autobuilder > build failures. > For example, BR2_TOOLCHAIN_HAS_LIBATOMIC can't be found in > http://autobuild.buildroot.org/results/bce526d538f43a541fdfbc0c9b4a7cecebbbc539/config Gah, indeed, configurations without threads, or with FLAT binaries don't have libatomic. And indeed, propagating this dependency to all reverse dependencies of openssl seems like a nightmare... On the other hand, openssl is really a base library, one could see it being enabled on a noMMU system. So real users could encounter this build issue, if we simply avoid the problem at the autobuilder level. I don't really have a clever idea here :-/ Thomas
diff --git a/utils/genrandconfig b/utils/genrandconfig index fb20dedcbf..a00ff8ee8b 100755 --- a/utils/genrandconfig +++ b/utils/genrandconfig @@ -246,6 +246,11 @@ def fixup_config(sysinfo, configfile): if 'BR2_ARM_CPU_ARMV7M=y\n' in configlines and \ 'BR2_PACKAGE_LIBFFI=y\n' in configlines: return False + # libopenssl needs atomic, but propagating this dependency in + # Buildroot is really too much work, so we handle this here. + if 'BR2_PACKAGE_LIBOPENSSL=y\n' in configlines and \ + not 'BR2_TOOLCHAIN_HAS_ATOMIC=y\n' in configlines: + return False if 'BR2_PACKAGE_SUNXI_BOARDS=y\n' in configlines: configlines.remove('BR2_PACKAGE_SUNXI_BOARDS_FEX_FILE=""\n') configlines.append('BR2_PACKAGE_SUNXI_BOARDS_FEX_FILE="a10/hackberry.fex"\n')
libopenssl needs atomic or the build will fail (e.g. on sparcv8 without libatomic): ${LDCMD:-/nvmedata/autobuild/instance-7/output-1/host/bin/sparc-buildroot-linux-uclibc-gcc} -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O0 -g2 -g2 -L. \ -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \ apps/libapps.a -lssl -lcrypto -ldl /nvmedata/autobuild/instance-7/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: ./libssl.so: undefined reference to `__atomic_fetch_sub_4' It should be noted that openssl3 has added OPENSSL_DEV_NO_ATOMICS but "this is intended for internal development only, to check the refcounting is properly coded. It should never become a configuration option, hence the name of the macro.": https://github.com/openssl/openssl/commit/503d4745a115b82db01c1fb22baaddb153d27cdb Fixes: - http://autobuild.buildroot.org/results/bce526d538f43a541fdfbc0c9b4a7cecebbbc539 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> --- Changes v1 -> v2 (after review of Arnout Vandecappelle and Yann E. Morin): - Update utils/genrandconfig instead of trying to propagate this dependency utils/genrandconfig | 5 +++++ 1 file changed, 5 insertions(+)