Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 885901

Summary: dev-libs/openssl-3.0.7-r1: ld.lld: error: undefined reference due to --no-allow-shlib-undefined: __atomic_is_lock_free
Product: Gentoo Linux Reporter: nvinson234
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal CC: sam, srcshelton, xtkoba
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/openssl/openssl/pull/16584
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 408963    
Attachments: build.log.gz
gentoo.config.patch
openssl-3.0.7-clang.patch

Description nvinson234 2022-12-14 12:30:29 UTC
openssl-3.0.7-abi_x86_32.x86 fails to build and prints the error when building with clang-15:

${LDCMD:-clang -m32 -mfpmath=sse} -pthread -Wa,--noexecstack -Qunused-arguments -march=native -O2 -pipe -D_FORTIFY_SOURCE=3 -fstack-protector-strong -flto=thin -Qunused-arguments -fno-strict-aliasing -Wa,--noexecstack -L.  -Wl,-O1 -Wl,--as-needed -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind \
	-o apps/openssl \
	apps/lib/openssl-bin-cmp_mock_srv.o apps/openssl-bin-asn1parse.o apps/openssl-bin-ca.o apps/openssl-bin-ciphers.o \
	apps/openssl-bin-cmp.o apps/openssl-bin-cms.o apps/openssl-bin-crl.o apps/openssl-bin-crl2pkcs7.o apps/openssl-bin-dgst.o \
	apps/openssl-bin-dhparam.o apps/openssl-bin-dsa.o apps/openssl-bin-dsaparam.o apps/openssl-bin-ec.o apps/openssl-bin-ecparam.o \
	apps/openssl-bin-enc.o apps/openssl-bin-engine.o apps/openssl-bin-errstr.o apps/openssl-bin-fipsinstall.o apps/openssl-bin-gendsa.o \
	apps/openssl-bin-genpkey.o apps/openssl-bin-genrsa.o apps/openssl-bin-info.o apps/openssl-bin-kdf.o apps/openssl-bin-list.o \
	apps/openssl-bin-mac.o apps/openssl-bin-nseq.o apps/openssl-bin-ocsp.o apps/openssl-bin-openssl.o apps/openssl-bin-passwd.o \
	apps/openssl-bin-pkcs12.o apps/openssl-bin-pkcs7.o apps/openssl-bin-pkcs8.o apps/openssl-bin-pkey.o apps/openssl-bin-pkeyparam.o \
	apps/openssl-bin-pkeyutl.o apps/openssl-bin-prime.o apps/openssl-bin-progs.o apps/openssl-bin-rand.o apps/openssl-bin-rehash.o \
	apps/openssl-bin-req.o apps/openssl-bin-rsa.o apps/openssl-bin-rsautl.o apps/openssl-bin-s_client.o apps/openssl-bin-s_server.o \
	apps/openssl-bin-s_time.o apps/openssl-bin-sess_id.o apps/openssl-bin-smime.o apps/openssl-bin-speed.o apps/openssl-bin-spkac.o \
	apps/openssl-bin-srp.o apps/openssl-bin-storeutl.o apps/openssl-bin-ts.o apps/openssl-bin-verify.o apps/openssl-bin-version.o \
	apps/openssl-bin-x509.o \
	apps/libapps.a -lssl -lcrypto -ldl -pthread 
ld.lld: error: undefined reference due to --no-allow-shlib-undefined: __atomic_is_lock_free
>>> referenced by ./libcrypto.so

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: __atomic_fetch_or_8
>>> referenced by ./libcrypto.so

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: __atomic_load
>>> referenced by ./libcrypto.so
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)


Reproducible: Always

Steps to Reproduce:
1. run emerge =dev-libs/openssl-3.0.7-r1
2. Observe build failure
Actual Results:  
openssl fails to build with stated error

Expected Results:  
openssl should build

Portage 3.0.41 (python 3.10.8-final-0, default/linux/amd64/17.1/desktop, gcc-12, glibc-2.36-r6, 6.0.11-gentoo x86_64)
=================================================================
System uname: Linux-6.0.11-gentoo-x86_64-Intel-R-_Core-TM-_i7-4771_CPU_@_3.50GHz-with-glibc2.36
KiB Mem:    32558032 total,  28410004 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of repository gentoo: Wed, 14 Dec 2022 08:16:51 +0000
Head commit of repository gentoo: e3702b7413b96432663ec600b3bc5702c950a034

Timestamp of repository brother-overlay: Tue, 06 Dec 2022 22:03:33 +0000
Head commit of repository brother-overlay: 68b1a09cd248d2544567fd1f5e3af2750b266349

Head commit of repository magpie: 24b38928a0cc68807288fe87f72f8db6a371502a

sh bash 5.2_p12
ld GNU ld (Gentoo 2.39 p5) 2.39.0
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.2_p12::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           3.10.8_p3::gentoo, 3.11.0_p2::gentoo
dev-lang/rust:             1.65.0::gentoo
dev-util/cmake:            3.25.1::gentoo
dev-util/meson:            0.64.1::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/openrc:           0.45.2-r2::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.39-r4::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/clang:           15.0.6::gentoo
sys-devel/gcc:             12.2.1_p20221203::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/lld:             15.0.6::gentoo
sys-devel/llvm:            15.0.6::gentoo
sys-devel/make:            4.4::gentoo
sys-kernel/linux-headers:  6.0::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000
    sync-git-verify-commit-signature: true

brother-overlay
    location: /var/db/repos/brother-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/brother-overlay.git
    masters: gentoo

magpie
    location: /var/db/repos/magpie
    sync-type: git
    sync-uri: https://github.com/nvinson/magpie.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
AR="llvm-ar"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-march=native -O2 -pipe -D_FORTIFY_SOURCE=3 -fstack-protector-strong -flto=thin"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /opt/brother/scanner/brscan4/brsanenetdevice4.cfg /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXX="clang++"
CXXFLAGS="-march=native -O2 -pipe -D_FORTIFY_SOURCE=3 -fstack-protector-strong -flto=thin"
DISTDIR="/var/cache/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind"
LEX="flex"
MAKEOPTS="-j8"
NM="llvm-nm"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RANLIB="llvm-ranlib"
SHELL="/bin/zsh"
USE="X a52 aac acl acpi alsa amd64 branding bzip2 cairo cdda cdr clang cleartype cli corefonts crypt cups dbus dri dts dvd dvdr elogind encode exif flac fortran gdbm gif glamor gpm gtk gui iconv icu ipv6 jpeg lcms libglvnd libnotify libtirpc mad mng mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds qt5 readline sdl seccomp spell split-usr ssl startup-notification svg test-rust theora tiff truetype udev udisks unicode upower usb vaapi vorbis vpx wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en-US en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, ARFLAGS, AS, ASFLAGS, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 nvinson234 2022-12-14 12:34:45 UTC
Created attachment 842633 [details]
build.log.gz

Uncompressed log was too big to attach. Had to gzip.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-28 20:48:49 UTC
For now, we need linux-latomic when building with Clang.

Easy reproducer:
CC=clang CFLAGS="-O2 -fuse-ld=lld" ebuild openssl-3.0.7-r2.ebuild clean instal

We can do it based on checking CC in the config file, I think.
Comment 3 jon R-B 2022-12-28 21:41:58 UTC
talking with sam_ on irc, this "works" for now to at least build on a clang system 

--- openssl-3.0.7-r2.ebuild	2022-12-28 21:37:19.499923686 +0000
+++ openssl-3.0.7-r3.ebuild	2022-12-28 21:30:41.620317139 +0000
@@ -145,6 +145,7 @@
 	# Don't remove the no strict aliasing bits below!
 	filter-flags -fstrict-aliasing
 	append-flags -fno-strict-aliasing
+	append-flags -latomic
 
 	append-flags $(test-flags-CC -Wa,--noexecstack)
Comment 4 nvinson234 2023-02-05 03:45:08 UTC
Created attachment 849876 [details, diff]
gentoo.config.patch

Patch to gentoo-config to build openssl with *-clang profiles.
Comment 5 nvinson234 2023-02-05 03:46:00 UTC
Created attachment 849878 [details, diff]
openssl-3.0.7-clang.patch

patch to openssl to define update existing clang profiles and add missing clang profiles.
Comment 6 nvinson234 2023-02-05 04:30:08 UTC
Please ignore openssl-3.0.7-clang.patch. Further testing, shows this patch not needed.
Comment 7 Larry the Git Cow gentoo-dev 2023-02-22 19:34:57 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d9d631a188bd27b62082fd93a7f434b00e458b1b

commit d9d631a188bd27b62082fd93a7f434b00e458b1b
Author:     Nicholas Vinson <nvinson234@gmail.com>
AuthorDate: 2023-02-22 00:57:55 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-02-22 19:29:31 +0000

    dev-libs/openssl: gentoo.config-1.0.4 clang fix
    
    Update gentoo.config-1.0.4 to better support clang compiler toolchains
    
    Closes: https://bugs.gentoo.org/885901
    Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/29711
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 dev-libs/openssl/files/gentoo.config-1.0.4 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Comment 8 tt_1 2023-02-22 19:51:30 UTC
is only x86 affected by this?