Skip to content

Android x86: undefined reference to __atomic_* (Alpha11) #14083

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

Closed
misery opened this issue Feb 5, 2021 · 33 comments
Closed

Android x86: undefined reference to __atomic_* (Alpha11) #14083

misery opened this issue Feb 5, 2021 · 33 comments
Assignees
Labels
help wanted triaged: bug The issue/pr is/fixes a bug triaged: OTC evaluated This issue/pr was triaged by OTC
Milestone

Comments

@misery
Copy link
Contributor

misery commented Feb 5, 2021

Hi,

we tried alpha11 in our CI. Alpha11 cannot be build for Android x86 - armv7 and arm64 works.

llvm-ar: warning: creating libssl.a
llvm-ar: warning: creating providers/libnonfips.a
llvm-ar: warning: creating libcrypto.a
llvm-ar: warning: creating providers/libimplementations.a
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
clang: ./libcrypto.so: error: undefined reference to '__atomic_load'
error: linker command failed with exit code 1 (use -v to see invocation)
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Our flags

Command line (with current working directory = .):

    /usr/bin/perl ../openssl/Configure --prefix=/home/gov/workspace/default_Review_Libs_Android_x86/build/dist no-ui-console no-filenames no-camellia no-bf no-aria no-seed no-poly1305 no-srp no-gost no-idea no-mdc2 no-rc2 no-rc4 no-rc5 no-srtp no-sm2 no-sm3 no-sm4 no-ct no-dgram no-cast no-chacha no-blake2 no-rmd160 no-scrypt no-siphash no-whirlpool no-md4 no-des no-tls1 no-tls1-method no-tls1_1 no-tls1_1-method no-tls1_3 no-ssl3 no-ssl3-method no-dtls no-dtls1-method no-dtls1_2-method no-engine no-async no-dso no-comp no-ts no-makedepend no-tests no-legacy shared no-stdio android-x86 -Os -fstack-protector-strong -D__ANDROID_API__=21

Perl information:

    /usr/bin/perl
    5.30.0 for x86_64-linux-gnu-thread-multi

Enabled features:

    acvp_tests
    asm
    autoalginit
    autoerrinit
    autoload-config
    bulk
    cmac
    cmp
    cms
    deprecated
    dh
    dsa
    ec
    ec2m
    ecdh
    ecdsa
    err
    fips-securitychecks
    multiblock
    nextprotoneg
    pinshared
    ocb
    ocsp
    pic
    posix-io
    psk
    rdrand
    rfc3779
    secure-memory
    shared
    siv
    sock
    sse2
    ssl
    static-engine
    threads
    tls
    tls1_2
    tls1_2-method

Disabled features:

    afalgeng            [cascade]                OPENSSL_NO_AFALGENG
    aria                [option]                 OPENSSL_NO_ARIA (skip crypto/aria)
    asan                [default]                OPENSSL_NO_ASAN
    async               [option]                 OPENSSL_NO_ASYNC
    bf                  [option]                 OPENSSL_NO_BF (skip crypto/bf)
    blake2              [option]                 OPENSSL_NO_BLAKE2
    buildtest-c++       [default]                
    camellia            [option]                 OPENSSL_NO_CAMELLIA (skip crypto/camellia)
    capieng             [cascade]                OPENSSL_NO_CAPIENG
    cast                [option]                 OPENSSL_NO_CAST (skip crypto/cast)
    chacha              [option]                 OPENSSL_NO_CHACHA (skip crypto/chacha)
    comp                [option]                 OPENSSL_NO_COMP (skip crypto/comp)
    crypto-mdebug       [default]                OPENSSL_NO_CRYPTO_MDEBUG
    ct                  [option]                 OPENSSL_NO_CT (skip crypto/ct)
    des                 [option]                 OPENSSL_NO_DES (skip crypto/des)
    devcryptoeng        [default]                OPENSSL_NO_DEVCRYPTOENG
    dgram               [option]                 OPENSSL_NO_DGRAM
    dso                 [option]                 OPENSSL_NO_DSO
    dtls                [option(dtls)]           OPENSSL_NO_DTLS
    dynamic-engine      [cascade]                
    ec_nistp_64_gcc_128 [default]                OPENSSL_NO_EC_NISTP_64_GCC_128
    egd                 [default]                OPENSSL_NO_EGD
    engine              [option]                 OPENSSL_NO_ENGINE (skip engines, crypto/engine)
    external-tests      [default]                OPENSSL_NO_EXTERNAL_TESTS
    filenames           [option]                 OPENSSL_NO_FILENAMES
    fips                [cascade]                
    fuzz-libfuzzer      [default]                OPENSSL_NO_FUZZ_LIBFUZZER
    fuzz-afl            [default]                OPENSSL_NO_FUZZ_AFL
    gost                [option]                 OPENSSL_NO_GOST
    idea                [option]                 OPENSSL_NO_IDEA (skip crypto/idea)
    ktls                [default]                OPENSSL_NO_KTLS
    legacy              [option]                 
    makedepend          [option]                 
    md2                 [default]                OPENSSL_NO_MD2 (skip crypto/md2)
    md4                 [option]                 OPENSSL_NO_MD4 (skip crypto/md4)
    mdc2                [option]                 OPENSSL_NO_MDC2 (skip crypto/mdc2)
    module              [cascade]                
    msan                [default]                OPENSSL_NO_MSAN
    padlockeng          [cascade]                OPENSSL_NO_PADLOCKENG
    poly1305            [option]                 OPENSSL_NO_POLY1305 (skip crypto/poly1305)
    rc2                 [option]                 OPENSSL_NO_RC2 (skip crypto/rc2)
    rc4                 [option]                 OPENSSL_NO_RC4 (skip crypto/rc4)
    rc5                 [option]                 OPENSSL_NO_RC5 (skip crypto/rc5)
    rmd160              [option]                 OPENSSL_NO_RMD160 (skip crypto/ripemd)
    scrypt              [option]                 OPENSSL_NO_SCRYPT
    sctp                [default]                OPENSSL_NO_SCTP
    seed                [option]                 OPENSSL_NO_SEED (skip crypto/seed)
    siphash             [option]                 OPENSSL_NO_SIPHASH (skip crypto/siphash)
    sm2                 [option]                 OPENSSL_NO_SM2 (skip crypto/sm2)
    sm3                 [option]                 OPENSSL_NO_SM3 (skip crypto/sm3)
    sm4                 [option]                 OPENSSL_NO_SM4 (skip crypto/sm4)
    srp                 [option]                 OPENSSL_NO_SRP (skip crypto/srp)
    srtp                [option]                 OPENSSL_NO_SRTP
    ssl-trace           [default]                OPENSSL_NO_SSL_TRACE
    stdio               [option]                 OPENSSL_NO_STDIO
    tests               [option]                 OPENSSL_NO_TESTS
    trace               [default]                OPENSSL_NO_TRACE
    ts                  [option]                 OPENSSL_NO_TS (skip crypto/ts)
    ubsan               [default]                OPENSSL_NO_UBSAN
    ui-console          [option]                 OPENSSL_NO_UI_CONSOLE
    unit-test           [default]                OPENSSL_NO_UNIT_TEST
    uplink              [no uplink_arch]         OPENSSL_NO_UPLINK
    whirlpool           [option]                 OPENSSL_NO_WHIRLPOOL (skip crypto/whrlpool)
    weak-ssl-ciphers    [default]                OPENSSL_NO_WEAK_SSL_CIPHERS
    zlib                [default]                
    zlib-dynamic        [default]                
    ssl3                [option(ssl3-method)]    OPENSSL_NO_SSL3
    ssl3-method         [option]                 OPENSSL_NO_SSL3_METHOD
    tls1                [option(tls1-method)]    OPENSSL_NO_TLS1
    tls1-method         [option]                 OPENSSL_NO_TLS1_METHOD
    tls1_1              [option(tls1_1-method)]  OPENSSL_NO_TLS1_1
    tls1_1-method       [option]                 OPENSSL_NO_TLS1_1_METHOD
    tls1_3              [option]                 OPENSSL_NO_TLS1_3
    dtls1               [option(dtls1-method)]   OPENSSL_NO_DTLS1
    dtls1-method        [option]                 OPENSSL_NO_DTLS1_METHOD
    dtls1_2             [option(dtls1_2-method)] OPENSSL_NO_DTLS1_2
    dtls1_2-method      [option]                 OPENSSL_NO_DTLS1_2_METHOD

Config target attributes:

    AR => "ar",
    ARFLAGS => "qc",
    CC => "gcc",
    CFLAGS => "-Wall -O3 -fomit-frame-pointer",
    CXX => "g++",
    CXXFLAGS => "-Wall -O3",
    HASHBANGPERL => "/usr/bin/env perl",
    RANLIB => "ranlib",
    RC => "windres",
    asm_arch => "x86",
    bin_cflags => "-fPIE",
    bin_lflags => "-pie",
    bn_ops => "BN_LLONG RC4_INT",
    build_file => "Makefile",
    build_scheme => [ "unified", "unix" ],
    cflags => "-pthread  -target i686-linux-android -gcc-toolchain \$(ANDROID_NDK_ROOT)/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=\$(ANDROID_NDK_ROOT)/platforms/android-21/arch-x86",
    cppflags => "-D__ANDROID_API__=21 -isystem \$(ANDROID_NDK_ROOT)/sysroot/usr/include/i686-linux-android -isystem \$(ANDROID_NDK_ROOT)/sysroot/usr/include",
    cxxflags => "-std=c++11 -pthread  -target i686-linux-android -gcc-toolchain \$(ANDROID_NDK_ROOT)/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=\$(ANDROID_NDK_ROOT)/platforms/android-21/arch-x86",
    defines => [ "OPENSSL_BUILDING_OPENSSL" ],
    disable => [  ],
    dso_ldflags => "-Wl,-z,defs",
    dso_scheme => "dlfcn",
    enable => [  ],
    ex_libs => "-ldl -pthread",
    includes => [  ],
    lflags => "",
    lib_cflags => "",
    lib_cppflags => "-DOPENSSL_USE_NODELETE",
    lib_defines => [  ],
    module_cflags => "-fPIC",
    module_cxxflags => undef,
    module_ldflags => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
    perl_platform => "Unix",
    perlasm_scheme => "android",
    shared_cflag => "-fPIC",
    shared_defflag => "-Wl,--version-script=",
    shared_defines => [  ],
    shared_extension => ".so",
    shared_ldflag => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
    shared_rcflag => "",
    shared_sonameflag => "-Wl,-soname=",
    shared_target => "linux-shared",
    shlib_variant => "_x86",
    thread_defines => [  ],
    thread_scheme => "pthreads",
    unistd => "<unistd.h>",

Recorded environment:

    AR = 
    BUILDFILE = 
    CC = clang
    CFLAGS = 
    CPPFLAGS = 
    CROSS_COMPILE = 
    CXX = clang++
    CXXFLAGS = 
    HASHBANGPERL = 
    LDFLAGS = 
    LDLIBS = 
    OPENSSL_LOCAL_CONFIG_DIR = 
    PERL = 
    RANLIB = 
    RC = 
    RCFLAGS = 
    WINDRES = 
    __CNF_CFLAGS = 
    __CNF_CPPDEFINES = 
    __CNF_CPPFLAGS = 
    __CNF_CPPINCLUDES = 
    __CNF_CXXFLAGS = 
    __CNF_LDFLAGS = 
    __CNF_LDLIBS = 

Makevars:

    AR              = llvm-ar
    ARFLAGS         = rs
    CC              = clang
    CFLAGS          = -Wall -O3 -fomit-frame-pointer -Os -fstack-protector-strong
    CPPDEFINES      = __ANDROID_API__=21
    CPPFLAGS        = 
    CPPINCLUDES     = 
    CXX             = clang++
    CXXFLAGS        = -Wall -O3 -Os -fstack-protector-strong
    HASHBANGPERL    = /usr/bin/env perl
    LDFLAGS         = 
    LDLIBS          = 
    PERL            = /usr/bin/perl
    RANLIB          = :
    RC              = windres
    RCFLAGS         = 
@misery misery added the issue: bug report The issue was opened to report a bug label Feb 5, 2021
@mattcaswell
Copy link
Member

Is this new with alpha11? Have you tried previous alphas?

@mattcaswell mattcaswell added triaged: bug The issue/pr is/fixes a bug and removed issue: bug report The issue was opened to report a bug labels Feb 5, 2021
@misery
Copy link
Contributor Author

misery commented Feb 5, 2021

Alpha9 was the last version we tried - that worked. We did not try Alpha10.

@misery misery changed the title Android 86: undefined reference to __atomic_* Android x86: undefined reference to __atomic_* (Alpha11) Feb 5, 2021
@mattcaswell
Copy link
Member

Almost certainly this is related to commit d5e742d.

@mattcaswell
Copy link
Member

Although strangely __atomic_is_lock_free is one of the functions that it is complaining it can't find, and that was present even in alpha 9 (and in fact for a long time).

@mattcaswell mattcaswell added this to the 3.0.0 beta1 milestone Feb 5, 2021
@mattcaswell mattcaswell added triaged: OTC evaluated This issue/pr was triaged by OTC help wanted labels Feb 16, 2021
@mattcaswell
Copy link
Member

OTC: Could be related to ifdef issues. We could do with some help on this platform.

@misery
Copy link
Contributor Author

misery commented Feb 19, 2021

Tried alpha12 today.... same CI works again. Maybe fixed "by accident"?

@misery misery closed this as completed Feb 19, 2021
@mattcaswell
Copy link
Member

Tried alpha12 today.... same CI works again. Maybe fixed "by accident"?

Strange!!! Ok - thanks for letting us know.

@macvk
Copy link

macvk commented Feb 26, 2021

I've bumped into the same issue. I copied build options used by @misery and was able to avoid the errors,
After testing the build I found out that the following options can not be removed:

no-dso
no-stdio

removing one of these options lead to the errors "undefined reference to 'atomic...."
my working build options now:

./Configure no-dso no-tests no-legacy no-stdio android-x86 -D__ANDROID_API__=16 --release ...

@mattcaswell
Copy link
Member

@macvk - what alpha version were you using? Was it alpha11 (the same as failed for @misery) or alpha12 (which @misery says is working)?

@macvk
Copy link

macvk commented Feb 26, 2021

@mattcaswell, it is alpha12

@macvk
Copy link

macvk commented Feb 26, 2021

./Configure no-dso no-tests no-stdio android-x86 -D__ANDROID_API__=16 --release ...

have no errors

./Configure no-dso no-tests android-x86 -D__ANDROID_API__=16 --release ...

"atomic" errors:

llvm-ar: creating apps/libapps.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating libcrypto.a
ssl/t1_enc.c:567:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
llvm-ar: creating libssl.a
llvm-ar: creating providers/libcommon.a
llvm-ar: creating providers/libimplementations.a
llvm-ar: creating providers/liblegacy.a
llvm-ar: creating providers/libnonfips.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
ssl/t1_enc.c:567:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [build_sw] Error 2
./libcrypto.so: error: undefined reference to '__atomic_fetch_or_8'
./libcrypto.so: error: undefined reference to '__atomic_is_lock_free'
./libcrypto.so: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1

@mattcaswell
Copy link
Member

Since this affects alpha12 I'm reopening this

@sahanaprasad07
Copy link
Contributor

@macvk Hi, do you observe the same issue on alpha 13 as well?

@macvk
Copy link

macvk commented Mar 24, 2021

Yes. Here is the configuration params (alpha 13)

./Configure no-tests android-x86 -D__ANDROID_API__=16 --release ...

Here is the build result

llvm-ar: creating apps/libapps.a

crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating libcrypto.a
ssl/t1_enc.c:566:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
llvm-ar: creating libssl.a
llvm-ar: creating providers/libcommon.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating providers/libfips.a
llvm-ar: creating providers/libimplementations.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating providers/liblegacy.a
llvm-ar: creating providers/libnonfips.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
ssl/t1_enc.c:566:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_or: error: undefined reference to '__atomic_is_lock_free'
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_or: error: undefined reference to '__atomic_fetch_or_8'
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_load: error: undefined reference to '__atomic_is_lock_free'providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_load: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [providers/fips.so] Error 1

@mattcaswell
Copy link
Member

I wonder if this impacts all Android API levels. I guess 16 is quite old now. We might need to add some android specific detection here to avoid this - but it would be a shame to cripple all android versions if only some are affected.

@macvk
Copy link

macvk commented Mar 24, 2021

there is no correlation between this issue and API level.

./Configure no-tests android-x86 -D__ANDROID_API__=29 --release ...
llvm-ar: creating apps/libapps.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating libcrypto.a
ssl/t1_enc.c:566:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
llvm-ar: creating libssl.a
llvm-ar: creating providers/libcommon.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating providers/libfips.a
llvm-ar: creating providers/libimplementations.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
llvm-ar: creating providers/liblegacy.a
llvm-ar: creating providers/libnonfips.a
crypto/threads_pthread.c:214:16: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        *ret = __atomic_or_fetch(val, op, __ATOMIC_ACQ_REL);
               ^
crypto/threads_pthread.c:239:9: warning: misaligned atomic operation may incur significant performance penalty [-Watomic-alignment]
        __atomic_load(val, ret, __ATOMIC_ACQUIRE);
        ^
2 warnings generated.
ssl/t1_enc.c:566:56: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
        BIO_printf(trc_out, "key block length: %ld\n", num);
                                               ~~~     ^~~
                                               %zu
1 warning generated.
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_or: error: undefined reference to '__atomic_is_lock_free'
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_or: error: undefined reference to '__atomic_fetch_or_8'
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_load: error: undefined reference to '__atomic_is_lock_free'
providers/libfips.a(libfips-lib-threads_pthread.o):threads_pthread.c:function CRYPTO_atomic_load: error: undefined reference to '__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [providers/fips.so] Error 1
make: *** [build_sw] Error 2

@mattcaswell
Copy link
Member

Could you try configuring like this:

LDFLAGS="-latomic" ./Configure no-tests android-x86 -D__ANDROID_API__=16 --release ...

@macvk
Copy link

macvk commented Mar 24, 2021

I've tried this way and it works

./Configure --release -latomic ...

I should say, there is no possibility to make libraries libcrypto.so and libssl.so without prefix 3 (libcrypto.so.3). this is important as the Android loads lib only with so extension. I have had to modify the Makefile by hand to remove the prefix.

@mattcaswell
Copy link
Member

I've tried this way and it works

Great!

@levitte....how should the above be reflected in .conf file updates?

@t8m
Copy link
Member

t8m commented Mar 24, 2021

I suppose something like this should help?

diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf
index f3075e4b79..b2a01023e3 100644
--- a/Configurations/15-android.conf
+++ b/Configurations/15-android.conf
@@ -190,6 +190,7 @@ my %targets = (
         bn_ops           => sub { android_ndk()->{bn_ops} },
         bin_cflags       => "-fPIE",
         bin_lflags       => "-pie",
+        ex_libs          => add(threads("-latomic")),
         enable           => [ ],
     },
     "android-arm" => {

@macvk
Copy link

macvk commented Mar 24, 2021

Reports lack information for clang / ndk versions used. @petrovr

Guys, you can build the openssl for Android yourself

https://github.com/macvk/openssl-android

Just download the script and run it. Enjoy.

P.S. The 'sed' is needed for removing the prefix .3

@petrovr
Copy link

petrovr commented Mar 25, 2021

I confirm that master fail for android i686 hosts . In same time 1.1.1 stable builds fine.
At momment I have no idea why master fails. Build failure in master is not related to API level, neither release build, nor some disabled features.

@petrovr
Copy link

petrovr commented Mar 26, 2021

After compare pthread source between master and 1.1.1 I note one significant difference - 1.1.1 uses is_lock_free only with integer argument. In master is_lock_free is used in addition with 64-bit integer argument.

So question is possible code to be updated to use 32-bit argument as maximum on 32 bit OS-ses.

I'm not familiar with "atomic locks".
Usually compiler generates code if argument size if up to pointer size.
After this could be used external library.

Compiler could be tested at configuration time but OpenSSL build system does not use such functionality.

What about 32-bit linux?

@petrovr
Copy link

petrovr commented Mar 28, 2021

macvk wrote:
I've tried this way and it works ./Configure --release -latomic ... I should say, there is no possibility to make libraries libcrypto.so and libssl.so without prefix 3 (libcrypto.so.3). this is important as the Android loads lib only with so extension. I have had to modify the Makefile by hand to remove the prefix.
Long story ;)#3902 #5143 ... Perhaps shared_extension => ".so", is still valid for master.

This still works for me: #7295

Perhaps - #14711 .

@petrovr
Copy link

petrovr commented Apr 4, 2021

It seems to me nobody use 32-bit linux!
I did tests with multilib gcc (linux-x86 target) . Even v5.5 with -m32 emits atomic code.
Unfortunately on same system clang cannot recognise 32-target and fails to link. Anyway clang -m32 could compile crypto/threads_pthread.c and nm command shows undefined extra atomic symbols.

In conclusion issue is only with 32-bit clang. Test above shows maximum Android NDK r21e, i.e. clang up to 9.0.9.

I wonder why code uses same integer to manage initialisation flags for deprecated engine.
It seems to me 32-bit is enough for non deprecated functionality.

@petrovr
Copy link

petrovr commented Apr 4, 2021

Another #14766 list a number of 32-bit hosts and mention is one case extra library dependency to libatomic.

@t8m t8m self-assigned this Apr 21, 2021
t8m added a commit to t8m/openssl that referenced this issue Apr 29, 2021
It might not be necessary with the most recent toolchain versions
but apparently many 32bit linux architectures and commonly used
toolchain versions require this.

It is also harmless to include even on architectures that do not
need it.

Fixes openssl#14083
@t8m
Copy link
Member

t8m commented Apr 29, 2021

@misery Could you please try current alpha with #15086 applied?

@misery
Copy link
Contributor Author

misery commented Apr 30, 2021

@t8m I tried alpha15 with and without #15086. I have no problems here with both. Maybe @macvk or @petrovr have some problems?

Using

ANDROID_BUILD_TOOLS_REVISION: 30.0.3
ANDROID_NDK_REVISION: 21.4.7075529 (Clang 9.0.9)
ANDROID_SDK_REVISION: 26.1.1

@t8m
Copy link
Member

t8m commented Apr 30, 2021

@misery Ah, I did not notice that you've already reported this as fixed.

So anybody who still sees a problem with Android builds due to missing -latomic, please try #15086 if it solves the problem.

devnexen pushed a commit to devnexen/openssl that referenced this issue Jul 7, 2021
It might not be necessary with the most recent toolchain versions
but apparently many 32bit linux architectures and commonly used
toolchain versions require this.

It is also harmless to include even on architectures that do not
need it.

Fixes openssl#14083

Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#15086)
kraj added a commit to YoeDistro/meta-clang that referenced this issue Oct 21, 2021
Clang runs into this issue
openssl/openssl#14083

Link with -libatomic on x86

Signed-off-by: Khem Raj <[email protected]>
kraj added a commit to kraj/meta-clang that referenced this issue Oct 21, 2021
Clang runs into this issue
openssl/openssl#14083

Link with -libatomic on x86

Signed-off-by: Khem Raj <[email protected]>
MarcelRaad added a commit to MarcelRaad/openssl that referenced this issue Mar 8, 2022
Fixes openssl#14083 again after being
broken by openssl#15640.

CLA: trivial
openssl-machine pushed a commit that referenced this issue Mar 9, 2022
Fixes #14083 again after being
broken by #15640.

CLA: trivial

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #17833)
openssl-machine pushed a commit that referenced this issue Mar 9, 2022
Fixes #14083 again after being
broken by #15640.

CLA: trivial

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #17833)

(cherry picked from commit b420e24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted triaged: bug The issue/pr is/fixes a bug triaged: OTC evaluated This issue/pr was triaged by OTC
Projects
None yet
6 participants