Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openssl-3.0.0: -latomic missing from linux-x86-clang #16572

Closed
DirtYiCE opened this issue Sep 9, 2021 · 6 comments
Closed

openssl-3.0.0: -latomic missing from linux-x86-clang #16572

DirtYiCE opened this issue Sep 9, 2021 · 6 comments
Labels
branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch triaged: bug The issue/pr is/fixes a bug

Comments

@DirtYiCE
Copy link

DirtYiCE commented Sep 9, 2021

Trying to build openssl-3.0.0 with ./Configure linux-x86-clang && make fails with undefined references:

${LDCMD:-clang} -pthread -m32 -Wa,--noexecstack -Qunused-arguments -Wall -O3 -fomit-frame-pointer -L.   \
        -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 
/usr/bin/x86_64-pc-linux-gnu-ld: ./libcrypto.so: undefined reference to `__atomic_is_lock_free'
/usr/bin/x86_64-pc-linux-gnu-ld: ./libcrypto.so: undefined reference to `__atomic_fetch_or_8'
/usr/bin/x86_64-pc-linux-gnu-ld: ./libcrypto.so: undefined reference to `__atomic_load'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

Interestingly, using ./Configure linux-x86, which uses gcc instead of clang works correctly. So does ./Configure linux-x86-clang -latomic, it looks like clang needs libatomic while gcc doesn't. I see that there were changes with the handling of -latomic, #15086, but partially reverted in #15640, the latter suggesting simply documenting the incomplete handling of this library, so I'm not sure what would be the correct action to fix this.

OS: Gentoo Linux
Clang: 12.0.0
Gcc: 9.3.0
perl configdata.pm --dump

@DirtYiCE DirtYiCE added the issue: bug report The issue was opened to report a bug label Sep 9, 2021
@mattcaswell mattcaswell added triaged: bug The issue/pr is/fixes a bug branch: 3.0 Merge to openssl-3.0 branch branch: master Merge to master branch and removed issue: bug report The issue was opened to report a bug labels Sep 10, 2021
@t8m
Copy link
Member

t8m commented Sep 10, 2021

The question is whether if we add it to the linux-x86-clang target it won't break on later clang versions. 12.0.0 is quite old. I can do a tentative PR.

t8m added a commit to t8m/openssl that referenced this issue Sep 10, 2021
@t8m
Copy link
Member

t8m commented Sep 10, 2021

Fix in #16578

@paulidale
Copy link
Contributor

The compiler zoo is on merge not PR.

@xtkoba
Copy link
Contributor

xtkoba commented Sep 10, 2021

FWIW, Clang 13.0.0-rc2 (Gentoo) still emits atomic libcalls for i686-linux:

$ cat openssl-atomic-test.c

#include <stdint.h>

uint64_t foo(uint64_t *val, uint64_t op)
{
    return __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
}

$ clang -m32 openssl-atomic-test.c -S -emit-llvm -o - 2>/dev/null | grep '@__atomic_'
  %11 = call i64 @__atomic_fetch_or_8(i8* %9, i64 %10, i32 4)
declare dso_local i64 @__atomic_fetch_or_8(i8*, i64, i32) #1

@t8m
Copy link
Member

t8m commented Sep 10, 2021

The compiler zoo is on merge not PR.

Good point, I can temporarily enable it.

@ngg
Copy link
Contributor

ngg commented Sep 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants