guix: libsecp256k1 build failure on aarch64 (M1) #22441

issue fanquake opened this issue on July 14, 2021
  1. fanquake commented at 5:55 AM on July 14, 2021: member

    Performing a Guix build of master (d8f1e1327f9c2f9fcc804468f6a981580acdf30a), for either x86_64-linux-gnu or x86_64-w64-mingw32 using:

    time BASE_CACHE="/guix/base_cache" SOURCES_PATH="/guix/sources" SDK_PATH="/guix/SDKs" HOSTS="x86_64-linux-gnu" ./contrib/guix/guix-build
    

    inside an Alpine Docker container, running on an mac mini (M1) currently fails with the following:

    === configuring in src/secp256k1 (/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src/secp256k1)
    configure: running /bin/sh ./configure --disable-option-checking '--prefix=/'  '--disable-ccache' '--disable-maintainer-mode' '--disable-dependency-tracking' '--enable-reduce-exports' '--disable-bench' '--disable-gui-tests' '--disable-fuzz-binary' '--disable-threadlocal' 'CFLAGS=-O2 -g -ffile-prefix-map=/bitcoin=.' 'CXXFLAGS=-O2 -g -ffile-prefix-map=/bitcoin=.' 'LDFLAGS=-Wl,--as-needed -Wl,--dynamic-linker=/lib64/ld-linux-x86-64.so.2 -static-libstdc++ -Wl,-O2' 'PKG_CONFIG_PATH=/root/.guix-profile/lib/pkgconfig' 'PYTHONPATH=/root/.guix-profile/lib/python3.8/site-packages' '--disable-shared' '--with-pic' '--enable-benchmark=no' '--enable-module-recovery' '--enable-module-schnorrsig' '--enable-experimental' --cache-file=/dev/null --srcdir=.
    configure: loading site script /bitcoin/depends/x86_64-linux-gnu/share/config.site
    checking build system type... aarch64-unknown-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking for a BSD-compatible install... /root/.guix-profile/bin/install -c
    checking whether build environment is sane... yes
    checking for x86_64-linux-gnu-strip... x86_64-linux-gnu-strip
    checking for a thread-safe mkdir -p... /root/.guix-profile/bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking how to print strings... printf
    checking whether make supports the include directive... yes (GNU style)
    checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... yes
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether x86_64-linux-gnu-gcc accepts -g... yes
    checking for x86_64-linux-gnu-gcc option to accept ISO C89... none needed
    checking whether x86_64-linux-gnu-gcc understands -c and -o together... yes
    checking dependency style of x86_64-linux-gnu-gcc... none
    checking for a sed that does not truncate output... /root/.guix-profile/bin/sed
    checking for grep that handles long lines and -e... /root/.guix-profile/bin/grep
    checking for egrep... /root/.guix-profile/bin/grep -E
    checking for fgrep... /root/.guix-profile/bin/grep -F
    checking for ld used by x86_64-linux-gnu-gcc... /gnu/store/fzwlmgg54z0iqkhvs74v60zfx64x62gr-gcc-cross-x86_64-linux-gnu-8.4.0/libexec/gcc/x86_64-linux-gnu/ld
    checking if the linker (/gnu/store/fzwlmgg54z0iqkhvs74v60zfx64x62gr-gcc-cross-x86_64-linux-gnu-8.4.0/libexec/gcc/x86_64-linux-gnu/ld) is GNU ld... yes
    checking for BSD- or MS-compatible name lister (nm)... x86_64-linux-gnu-nm
    checking the name lister (x86_64-linux-gnu-nm) interface... BSD nm
    checking whether ln -s works... yes
    checking the maximum length of command line arguments... 1572864
    checking how to convert aarch64-unknown-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
    checking how to convert aarch64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
    checking for /gnu/store/fzwlmgg54z0iqkhvs74v60zfx64x62gr-gcc-cross-x86_64-linux-gnu-8.4.0/libexec/gcc/x86_64-linux-gnu/ld option to reload object files... -r
    checking for x86_64-linux-gnu-objdump... x86_64-linux-gnu-objdump
    checking how to recognize dependent libraries... pass_all
    checking for x86_64-linux-gnu-dlltool... no
    checking for dlltool... no
    checking how to associate runtime and link libraries... printf %s\n
    checking for x86_64-linux-gnu-ar... x86_64-linux-gnu-ar
    checking for archiver [@FILE](/bitcoin-bitcoin/contributor/file/) support... @
    checking for x86_64-linux-gnu-strip... (cached) x86_64-linux-gnu-strip
    checking for x86_64-linux-gnu-ranlib... x86_64-linux-gnu-ranlib
    checking command to parse x86_64-linux-gnu-nm output from x86_64-linux-gnu-gcc object... ok
    checking for sysroot... no
    checking for a working dd... /root/.guix-profile/bin/dd
    checking how to truncate binary pipes... /root/.guix-profile/bin/dd bs=4096 count=1
    checking for x86_64-linux-gnu-mt... no
    checking for mt... no
    checking if : is a manifest tool... no
    checking how to run the C preprocessor... x86_64-linux-gnu-gcc -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for dlfcn.h... yes
    checking for objdir... .libs
    checking if x86_64-linux-gnu-gcc supports -fno-rtti -fno-exceptions... no
    checking for x86_64-linux-gnu-gcc option to produce PIC... -fPIC -DPIC
    checking if x86_64-linux-gnu-gcc PIC flag -fPIC -DPIC works... yes
    checking if x86_64-linux-gnu-gcc static flag -static works... yes
    checking if x86_64-linux-gnu-gcc supports -c -o file.o... yes
    checking if x86_64-linux-gnu-gcc supports -c -o file.o... (cached) yes
    checking whether the x86_64-linux-gnu-gcc linker (/gnu/store/fzwlmgg54z0iqkhvs74v60zfx64x62gr-gcc-cross-x86_64-linux-gnu-8.4.0/libexec/gcc/x86_64-linux-gnu/ld -m elf_x86_64) supports shared libraries... yes
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... no
    checking whether to build static libraries... yes
    checking whether make supports nested variables... (cached) yes
    checking for x86_64-linux-gnu-pkg-config... /root/.guix-profile/bin/pkg-config --static
    checking pkg-config is at least version 0.9.0... yes
    checking for x86_64-linux-gnu-ar... /root/.guix-profile/bin/x86_64-linux-gnu-ar
    checking for x86_64-linux-gnu-ranlib... /root/.guix-profile/bin/x86_64-linux-gnu-ranlib
    checking for x86_64-linux-gnu-strip... /root/.guix-profile/bin/x86_64-linux-gnu-strip
    checking for x86_64-linux-gnu-gcc option to accept ISO C89... (cached) none needed
    checking dependency style of x86_64-linux-gnu-gcc... none
    checking if x86_64-linux-gnu-gcc supports -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings... yes
    checking if x86_64-linux-gnu-gcc supports -Wconditional-uninitialized... no
    checking if x86_64-linux-gnu-gcc supports -fvisibility=hidden... yes
    checking valgrind/memcheck.h usability... no
    checking valgrind/memcheck.h presence... no
    checking for valgrind/memcheck.h... no
    checking for x86_64 assembly availability... yes
    checking for libcrypto... no
    checking openssl/crypto.h usability... no
    checking openssl/crypto.h presence... no
    checking for openssl/crypto.h... no
    checking for gcc... gcc
    checking whether we are using the GNU C compiler... (cached) yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... (cached) none needed
    checking whether gcc understands -c and -o together... (cached) yes
    checking dependency style of gcc... (cached) none
    checking how to run the C preprocessor... gcc -E
    checking if native gcc supports -Wall -Wextra -Wno-unused-function... yes
    checking for working native compiler: gcc... yes
    configure: ******
    configure: WARNING: experimental build
    configure: Experimental features do not have stable APIs or properties, and may not be safe for production use.
    configure: Building extrakeys module: yes
    configure: Building schnorrsig module: yes
    configure: ******
    checking that generated files are newer than configure... done
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating libsecp256k1.pc
    config.status: creating src/libsecp256k1-config.h
    config.status: executing depfiles commands
    config.status: executing libtool commands
    
    Build Options:
      with ecmult precomp     = yes
      with external callbacks = no
      with benchmarks         = no
      with tests              = yes
      with openssl tests      = no
      with coverage           = no
      module ecdh             = no
      module recovery         = yes
      module extrakeys        = yes
      module schnorrsig       = yes
    
      asm                     = x86_64
      ecmult window size      = 15
      ecmult gen prec. bits   = 4
    
      valgrind                = no
      CC                      = x86_64-linux-gnu-gcc
      CFLAGS                  = -O2 -fvisibility=hidden -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -pipe -O2 -O2 -g -ffile-prefix-map=/bitcoin=.
      CPPFLAGS                =  -I/bitcoin/depends/x86_64-linux-gnu/include/ 
      LDFLAGS                 = -L/bitcoin/depends/x86_64-linux-gnu/lib -Wl,--as-needed -Wl,--dynamic-linker=/lib64/ld-linux-x86-64.so.2 -static-libstdc++ -Wl,-O2
    
      CC_FOR_BUILD            = gcc
      CFLAGS_FOR_BUILD        = -Wall -Wextra -Wno-unused-function -g -O2
      CPPFLAGS_FOR_BUILD      = 
      LDFLAGS_FOR_BUILD       = 
    
    # <snip>
    
    make[3]: Entering directory '/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src/secp256k1'
    gcc -I. -I./src -Wall -Wextra -Wno-unused-function -g -O2 -c src/gen_context.c -o gen_context.o
      CXX      bitcoin_cli-bitcoin-cli.o
    In file included from src/field_5x52_impl.h:19:0,
                     from src/field_impl.h:17,
                     from src/gen_context.c:19:
    src/field_5x52_asm_impl.h: In function 'secp256k1_fe_mul_inner':
    src/field_5x52_asm_impl.h:28:1: error: unknown register name '%rdx' in 'asm'
     __asm__ __volatile__(
     ^~~~~~~
    src/field_5x52_asm_impl.h:28:1: error: unknown register name '%rcx' in 'asm'
    src/field_5x52_asm_impl.h:28:1: error: unknown register name '%rax' in 'asm'
    src/field_5x52_asm_impl.h:28:1: error: output number 0 not directly addressable
    src/field_5x52_asm_impl.h:28:1: warning: asm operand 6 probably doesn't match constraints
    src/field_5x52_asm_impl.h: In function 'secp256k1_fe_sqr_inner':
    src/field_5x52_asm_impl.h:298:1: error: unknown register name '%rdx' in 'asm'
     __asm__ __volatile__(
     ^~~~~~~
    
    # <snip>
    
    src/field_5x52_asm_impl.h:28:1: error: unknown register name '%rcx' in 'asm'
    src/field_5x52_asm_impl.h:28:1: error: unknown register name '%rax' in 'asm'
    src/field_5x52_asm_impl.h:28:1: error: output number 0 not directly addressable
    src/field_5x52_asm_impl.h:28:1: warning: asm operand 6 probably doesn't match constraints
    make[3]: *** [Makefile:1775: gen_context.o] Error 1
    make[3]: Leaving directory '/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src/secp256k1'
    make[2]: *** [Makefile:17987: secp256k1/libsecp256k1.la] Error 2
    make[2]: *** Waiting for unfinished jobs....
      CXX      lib/libunivalue_la-univalue_write.lo
      CXXLD    libunivalue.la
    x86_64-linux-gnu-ar: `u' modifier ignored since `D' is the default (see `U')
    make[3]: Leaving directory '/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src/univalue'
    make[2]: Leaving directory '/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src'
    make[1]: *** [Makefile:16160: all-recursive] Error 1
    make[1]: Leaving directory '/distsrc-base/distsrc-d8f1e1327f9c-x86_64-linux-gnu/src'
    make: *** [Makefile:820: all-recursive] Error 1
    

    Building libsecp256k1 directly in the Alpine container works as expected, and building when running a guix environment, and installing the needed packages (autoconf automake gcc libtool make pkg-config ) also seems to work ok. So I'm assuming the failure here is due to something we are doing in our Guix environment.

    Additional build output here. @real-or-random @jonasnick you might be interested here.

  2. fanquake added the label Bug on Jul 14, 2021
  3. fanquake added the label Build system on Jul 14, 2021
  4. sipa commented at 6:00 AM on July 14, 2021: member

    Depending on how fast this needs to be resolved, with https://github.com/bitcoin-core/secp256k1/pull/956 (and a presumed follow-up to apply the same to the other table) we'll remove cross-compilation issues by having the generated static context data be part of the source tree.

  5. real-or-random commented at 9:08 AM on July 14, 2021: member

    What's going on here:

    • configure detects that we're compiling for x86_64 and enables the x86_64 ASM
    • Then make tries to build an executable for the aarch64 build machine (for doing precomputations during the build procress) but the x86_64 ASM is enabled...

    We fixed a similar thing for ARM assembly upstream in https://github.com/bitcoin-core/secp256k1/commit/99f47c20ec41279075d6b3ae64c9c1a84b40a6f8 but unfortunately that fix does not apply because we have different macros USE_EXTERNAL_ASM and USE_ASM_X86_64. @fanquake Can you test if adding #undef USE_ASM_X86_64 at the top of gen_context.c fixes this? Alternatively, you can configure with CPPFLAGS_FOR_BUILD=-UUSE_ASM_X86_64.

  6. fanquake referenced this in commit be68a78bd7 on Jul 14, 2021
  7. fanquake commented at 1:19 PM on July 14, 2021: member

    @real-or-random thanks for taking a look. I've done a Guix build using HOSTS="x86_64-linux-gnu x86_64-w64-mingw32" with this branch: https://github.com/fanquake/bitcoin/commit/be68a78bd7e149917ee8b48c7b09c25e1050d39d, and the builds have completed successfully. The full build log is here: https://gist.github.com/fanquake/ec23884762b843f7e911f0b2ae4734c4.

  8. real-or-random referenced this in commit be8d9c262f on Jul 14, 2021
  9. real-or-random commented at 5:03 PM on July 14, 2021: member

    Okay, we merged the fix upstream. So the easiest way to solve this issue is to update the secp256k1 tree.

  10. sipa commented at 5:06 PM on July 14, 2021: member

    On it.

  11. sipa commented at 5:22 PM on July 14, 2021: member

    See #22448.

  12. fanquake closed this on Aug 3, 2021

  13. sidhujag referenced this in commit ce5d5632a3 on Aug 4, 2021
  14. UdjinM6 referenced this in commit 54f3b66902 on Aug 10, 2021
  15. 5tefan referenced this in commit 235da293a2 on Aug 12, 2021
  16. DrahtBot locked this on Aug 18, 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-26 06:14 UTC

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