build: unable to use sanitizers on macOS Catalina #17114

issue Sjors opened this issue on October 12, 2019
  1. Sjors commented at 9:55 AM on October 12, 2019: member

    On macOS 10.15 Catalina I get a linker error when trying to use sanitizers. Using Apple clang version 11.0.0 (clang-1100.0.33.8). The CC=clang is probably redundant.

    ./configure --disable-bip70 --disable-bench --enable-debug CFLAGS="-fno-stack-check" CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=address,integer,undefined CC=clang CXX=clang++ --disable-asm
    ...
    Build Options:
      with endomorphism   = no
      with ecmult precomp = yes
      with jni            = no
      with benchmarks     = no
      with coverage       = no
      module ecdh         = no
      module recovery     = yes
    
      asm                 = x86_64
      bignum              = no
      field               = 64bit
      scalar              = 64bit
    
      CC                  = clang
      CFLAGS              = -fno-stack-check -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -O3
      CPPFLAGS            = -DDEBUG_LOCKORDER
      LDFLAGS             = 
    
    
    Options used to compile and link:
      with wallet   = yes
      with gui / qt = yes
        with bip70  = no
        with qr     = yes
      with zmq      = yes
      with test     = yes
        with prop   = no
        with fuzz   = no
      with bench    = no
      with upnp     = yes
      use asm       = no
      sanitizers    = address,integer,undefined
      debug enabled = yes
      gprof enabled = no
      werror        = no
    
      target os     = darwin
      build os      = darwin
    
      CC            = /usr/local/bin/ccache clang
      CFLAGS        = -fno-stack-check
      CPPFLAGS      =  -DDEBUG -DDEBUG_LOCKORDER  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Qunused-arguments -DDEBUG_LOCKORDER -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -I/usr/local/opt/berkeley-db@4/include -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0
      CXX           = /usr/local/bin/ccache clang++ -std=c++11
      CXXFLAGS      =  -O0 -g3 -ftrapv  -Wstack-protector -fstack-protector-all  -Wall -Wextra -Wformat -Wvla -Wswitch -Wformat-security -Wthread-safety-analysis -Wrange-loop-analysis -Wredundant-decls  -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register -Wno-implicit-fallthrough   
      LDFLAGS       = -pthread    -Wl,-headerpad_max_install_names -Wl,-dead_strip
      ARFLAGS       = cr
    

    When running make I get a flood of errors along these lines:

      "___asan_register_image_globals", referenced from:
          _asan.module_ctor in libbitcoinconsensus_la-cleanse.o
          _asan.module_ctor in libbitcoinconsensus_la-aes.o
          _asan.module_ctor in libbitcoinconsensus_la-chacha_poly_aead.o
          _asan.module_ctor in libbitcoinconsensus_la-chacha20.o
          _asan.module_ctor in libbitcoinconsensus_la-hkdf_sha256_32.o
          _asan.module_ctor in libbitcoinconsensus_la-poly1305.o
          _asan.module_ctor in libbitcoinconsensus_la-ripemd160.o
          ...
      "___ubsan_handle_pointer_overflow", referenced from:
          AES_setup(AES_state*, unsigned char const*, int, int) in libbitcoinconsensus_la-aes.o
          _AES128_encrypt in libbitcoinconsensus_la-aes.o
          AES_encrypt(AES_state const*, int, unsigned char*, unsigned char const*) in libbitcoinconsensus_la-aes.o
          _AES128_decrypt in libbitcoinconsensus_la-aes.o
          AES_decrypt(AES_state const*, int, unsigned char*, unsigned char const*) in libbitcoinconsensus_la-aes.o
          _AES192_encrypt in libbitcoinconsensus_la-aes.o
          _AES192_decrypt in libbitcoinconsensus_la-aes.o
          ...
      "___asan_version_mismatch_check_apple_clang_1100", referenced from:
          _asan.module_ctor in libbitcoinconsensus_la-cleanse.o
          _asan.module_ctor in libbitcoinconsensus_la-aes.o
          _asan.module_ctor in libbitcoinconsensus_la-chacha_poly_aead.o
          _asan.module_ctor in libbitcoinconsensus_la-chacha20.o
          _asan.module_ctor in libbitcoinconsensus_la-hkdf_sha256_32.o
          _asan.module_ctor in libbitcoinconsensus_la-hmac_sha256.o
          _asan.module_ctor in libbitcoinconsensus_la-hmac_sha512.o
          ...
      "___ubsan_handle_implicit_conversion", referenced from:
          AES_setup(AES_state*, unsigned char const*, int, int) in libbitcoinconsensus_la-aes.o
          int CBCEncrypt<AES256Encrypt>(AES256Encrypt const&, unsigned char const*, unsigned char const*, int, bool, unsigned char*) in libbitcoinconsensus_la-aes.o
          int CBCDecrypt<AES256Decrypt>(AES256Decrypt const&, unsigned char const*, unsigned char const*, int, bool, unsigned char*) in libbitcoinconsensus_la-aes.o
          LoadByte(AES_state*, unsigned char, int, int) in libbitcoinconsensus_la-aes.o
          GetOneColumn(AES_state*, AES_state const*, int) in libbitcoinconsensus_la-aes.o
          SubBytes(AES_state*, int) in libbitcoinconsensus_la-aes.o
          KeySetupTransform(AES_state*, AES_state const*) in libbitcoinconsensus_la-aes.o
          ...
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [libbitcoinconsensus.la] Error 1
    
  2. Sjors added the label Bug on Oct 12, 2019
  3. fanquake added the label macOS on Oct 12, 2019
  4. laanwj removed the label Bug on Oct 15, 2019
  5. laanwj added the label Tests on Oct 15, 2019
  6. rodentrabies commented at 1:51 PM on October 22, 2019: contributor

    Was able to build successfully (same clang version):

    Build Options:
      with endomorphism   = no
      with ecmult precomp = yes
      with jni            = no
      with benchmarks     = no
      with coverage       = no
      module ecdh         = no
      module recovery     = yes
    
      asm                 = x86_64
      bignum              = no
      field               = 64bit
      scalar              = 64bit
    
      CC                  = clang
      CFLAGS              = -fno-stack-check -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -O3
      CPPFLAGS            = -DDEBUG_LOCKORDER
      LDFLAGS             =
    
    
    Options used to compile and link:
      with wallet   = yes
      with gui / qt = yes
        with bip70  = no
        with qr     = yes
      with zmq      = no
      with test     = yes
        with prop   = no
        with fuzz   = no
      with bench    = no
      with upnp     = yes
      use asm       = no
      sanitizers    = address,integer,undefined
      debug enabled = yes
      gprof enabled = no
      werror        = no
    
      target os     = darwin
      build os      = darwin
    
      CC            = clang
      CFLAGS        = -fno-stack-check
      CPPFLAGS      =  -DDEBUG -DDEBUG_LOCKORDER  -DDEBUG_LOCKORDER -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -I/usr/local/opt/berkeley-db@4/include -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0
      CXX           = clang++ -std=c++11
      CXXFLAGS      =  -O0 -g3 -ftrapv  -Wstack-protector -fstack-protector-all  -Wall -Wextra -Wformat -Wvla -Wswitch -Wformat-security -Wthread-safety-analysis -Wrange-loop-analysis -Wredundant-decls  -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register -Wno-implicit-fallthrough
      LDFLAGS       = -pthread    -Wl,-headerpad_max_install_names -Wl,-dead_strip
      ARFLAGS       = cr
    

    The main difference in ./configure output is the CPPFLAGS and CXX lines. Maybe it's the ccache issue?

  7. fanquake commented at 1:03 AM on February 3, 2020: member

    This looks more like an issue with Apple Clangs sanitizer support, which isn't comprehensive, and not related to Catalina (I can repro on 10.14). I'd suggest using LLVM Clang instead.

  8. fanquake closed this on Feb 3, 2020

  9. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 09:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me