guix: migrate to native GCC 10 toolchain for Linux builds #24701

issue fanquake opened this issue on March 29, 2022
  1. fanquake commented at 8:34 AM on March 29, 2022: member

    Currently, our Linux Guix builds differ from macOS and Windows, in that they use a native GCC 7 toolchain (i.e to build glibc) and then GCC 10 to build depends and Bitcoin Core. Migrating the Linux builds to a native GCC 10 toolchain will unify us on a single native compiler.

    The main issue with performing this migration is building older glibcs (2.24, 2.27) with GCC 10. When I last tried, it was apparent that either warnings produced by the newer GCC would need to be suppressed (as glibc is built -Werror), or patches to glibc would need to be backported to address any issues. For example:

    x86_64-linux-gnu-gcc ../sysdeps/unix/sysv/linux/x86_64/sysdep.S -c     -I../include -I/tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/csu  -I/tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /gnu/store/r2h1g2vg7j36rqwyraf5wghm10ykq055-gcc-cross-sans-libc-x86_64-linux-gnu-10.3.0-lib/lib/gcc/x86_64-linux-gnu/10.3.0/include -isystem /gnu/store/r2h1g2vg7j36rqwyraf5wghm10ykq055-gcc-cross-sans-libc-x86_64-linux-gnu-10.3.0-lib/lib/gcc/x86_64-linux-gnu/10.3.0/include-fixed -isystem /gnu/store/5fhhr33nilcyi1k3s1xwcmibdhc1l39c-linux-libre-headers-cross-x86_64-linux-gnu-4.9.306/include -D_LIBC_REENTRANT -include /tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED     -DASSEMBLER -I/tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/csu/. -g -Werror=undef -Wa,--noexecstack   -o /tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/csu/sysdep.os -MD -MP -MF /tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/csu/sysdep.os.dt -MT /tmp/guix-build-glibc-cross-x86_64-linux-gnu-2.24.drv-0/build/csu/sysdep.os
    libc-tls.c: In function ‘__libc_setup_tls’:
    libc-tls.c:208:30: error: array subscript 1 is outside the bounds of an interior zero-length array ‘struct dtv_slotinfo[0]’ [-Werror=zero-length-bounds]
      208 |   static_slotinfo.si.slotinfo[1].map = main_map;
          |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
    In file included from ../sysdeps/x86_64/ldsodefs.h:54,
                     from ../sysdeps/gnu/ldsodefs.h:46,
                     from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                     from libc-tls.c:20:
    ../sysdeps/generic/ldsodefs.h:398:7: note: while referencing ‘slotinfo’
      398 |     } slotinfo[0];
          |       ^~~~~~~~
    cc1: all warnings being treated as errors
    

    This branch could be used as a starting point: https://github.com/fanquake/bitcoin/tree/native_gcc_10_linux (3974ac565ad575d8d4216bcac39b46a6dcd254d5). Builds for x86_64-w64-mingw32 x86_64-apple-darwin x86_64-apple-darwin will all work as expected. A Linux build, i.e HOSTS="x86_64-linux-gnu" ./contrib/guix/guix-build will not, and will fail with the error displayed above.

    Useful skills:

    • Guix
    • Build system

    Want to work on this issue?

    For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

  2. fanquake added the label Build system on Mar 29, 2022
  3. fanquake added the label good first issue on Mar 29, 2022
  4. prusnak commented at 9:51 AM on March 29, 2022: contributor

    HOSTS="x86_64-pc-linux-gnu"

    Probably off-topic but related: Which one is (more) correct? x86_64-pc-linux-gnu or x86_64-linux-gnu. It seems we are using both?

    ❯ rg x86_64-pc-linux-gnu | wc -l
           4
    ❯ rg x86_64-linux-gnu | wc -l   
          25
    
  5. fanquake commented at 9:55 AM on March 29, 2022: member

    Yea, that was just a copy-paste mistake, which I've amended. Both are fine how we are currently using them in our codebase.

  6. hebasto commented at 11:44 AM on March 29, 2022: member

    On the one hand:

    $ build-aux/config.guess 
    x86_64-pc-linux-gnu
    

    On the other hand, cross-compiling tools are prefixed with x86_64-linux-gnu-.

  7. laanwj commented at 10:52 AM on April 5, 2022: member

    Probably off-topic but related: Which one is (more) correct? x86_64-pc-linux-gnu or x86_64-linux-gnu. It seems we are using both?

    I would guess they are 100% equivalent. The -pc- (sometimes) or -unknown- (othertimes) is the "manufacturer" part of the architecture tuple. It's an optional, basically freeform field that everyone ignores.

    Personally I have a slight preference for leaving it out.

  8. MarcoFalke removed the label good first issue on May 10, 2022
  9. dongcarl commented at 3:40 PM on May 11, 2022: member

    Just want to point out in case it gets lost to time that -pc- or no -pc- has an effect on autoconf's cross-compilation detection... See the paragraph in #21671 (comment) starting with "Prior to canonicalizing..."

  10. fanquake closed this on May 18, 2022

  11. DrahtBot locked this on May 18, 2023

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:13 UTC

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