Search code examples
ubuntugccvmwareglibc

Building Glibc 2.33 for Linux results in unit test failures


I'm currently trying to create a build of Glibc 2.33 to live in parallel to the default system version, but the build process is resulting in a large number of unit test failures. While some of the failures might be safe to ignore, most seem like legitimate problems, but I'm not sure how to fix them. The desired final target system is CentOS 7.9, but I'm currently testing the build steps in Ubuntu Desktop 21.04 (in a VMware 15 VM) since CentOS 7.9 requires creating a bootstrap tool-chain (the default tool-chain is too old). According to the Glibc 2.33 documentation, the --enable-add-ons option is no longer required (and might even be unsupported), so I'm not sure what steps or configuration options I could be missing.

The steps followed to create the build VM

  1. Create a "clean", minimal Ubuntu Desktop 21.04 VM installation
  2. Fully update the VM
  3. Install the following packages
  • build-essential
  • gawk
  • bison
  • texinfo
  • msgfmt
  • gettext

Software versions of the resultant system

  • GCC: Ubuntu 10.3.0-1ubuntu1
  • Binutils: 2.36.1
  • Make: 4.3
  • Bison: 3.7.5
  • Gawk: 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
  • Python 3: 3.9.5
  • PExpect: 4.8.0
  • Perl: 5.32.1
  • Texinfo: 6.7.0
  • Sed: 4.7
  • Gdb: Ubuntu 10.1-2ubuntu2 (10.1.90.20210411-git)

Glibc 2.33 build steps:

  1. Download the Glibc 2.33 source code

     wget https://ftp.gnu.org/gnu/glibc/glibc-2.33.tar.gz -P ${HOME}/Downloads
    
  2. Create directories

     rm -rf ${HOME}/Projects/BuildToolchain && mkdir -p ${HOME}/Projects/BuildToolchain/Build
    
  3. Extract the Glibc 2.33 source code

     tar -xf ${HOME}/Downloads/glibc-2.33.tar.gz -C ${HOME}/Projects/BuildToolchain
    
  4. Enter the (out-of-source) build directory

     cd ${HOME}/Projects/BuildToolchain/Build
    
  5. Configure Glibc 2.33

     ../glibc-2.33/configure --prefix=${HOME}/Projects/BuildToolchain/Install 2>&1 | tee output-configure.txt
    
  6. Build Glibc 2.33

     make -j`nproc` 2>&1 | tee output-make.txt
    
  7. Build and run the unit tests

     make check 2>&1 | tee output-make-check.txt
    

Unit test results

The above steps result in the following unit test results, including 149 failed tests.

FAIL: debug/tst-backtrace2
FAIL: debug/tst-backtrace3
FAIL: debug/tst-backtrace4
FAIL: debug/tst-backtrace5
FAIL: debug/tst-backtrace6
FAIL: dlfcn/bug-atexit3
FAIL: elf/check-abi-libc
UNSUPPORTED: elf/tst-audit10
UNSUPPORTED: elf/tst-avx512
UNSUPPORTED: elf/tst-cet-legacy-8
UNSUPPORTED: elf/tst-cet-property-2
FAIL: elf/tst-cpu-features-cpuinfo
FAIL: elf/tst-glibc-hwcaps-prepend-cache
FAIL: elf/tst-ldconfig-ld_so_conf-update
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
FAIL: elf/tst-unwind-main
FAIL: iconv/tst-iconv-mt
FAIL: malloc/tst-malloc-stats-cancellation
FAIL: malloc/tst-malloc-stats-cancellation-mcheck
UNSUPPORTED: math/test-double-libmvec-sincos-avx512
UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
FAIL: misc/tst-gettid-kill
UNSUPPORTED: misc/tst-pkey
FAIL: misc/tst-sigcontext-get_pc
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
FAIL: nptl/tst-basic3
FAIL: nptl/tst-basic4
FAIL: nptl/tst-call-once
FAIL: nptl/tst-cancel-self
FAIL: nptl/tst-cancel-self-cancelstate
FAIL: nptl/tst-cancel-self-canceltype
FAIL: nptl/tst-cancel-self-testcancel
FAIL: nptl/tst-cancel1
FAIL: nptl/tst-cancel10
FAIL: nptl/tst-cancel11
FAIL: nptl/tst-cancel12
FAIL: nptl/tst-cancel13
FAIL: nptl/tst-cancel14
FAIL: nptl/tst-cancel15
FAIL: nptl/tst-cancel16
FAIL: nptl/tst-cancel17
FAIL: nptl/tst-cancel18
FAIL: nptl/tst-cancel2
FAIL: nptl/tst-cancel20
FAIL: nptl/tst-cancel21
FAIL: nptl/tst-cancel22
FAIL: nptl/tst-cancel23
FAIL: nptl/tst-cancel24
FAIL: nptl/tst-cancel25
FAIL: nptl/tst-cancel28
FAIL: nptl/tst-cancel3
FAIL: nptl/tst-cancel4
FAIL: nptl/tst-cancel4_1
FAIL: nptl/tst-cancel4_2
FAIL: nptl/tst-cancel5
FAIL: nptl/tst-cancel6
FAIL: nptl/tst-cancel7
FAIL: nptl/tst-cancel8
FAIL: nptl/tst-cancel9
FAIL: nptl/tst-cancelx10
FAIL: nptl/tst-cancelx11
FAIL: nptl/tst-cancelx12
FAIL: nptl/tst-cancelx13
FAIL: nptl/tst-cancelx14
FAIL: nptl/tst-cancelx15
FAIL: nptl/tst-cancelx16
FAIL: nptl/tst-cancelx17
FAIL: nptl/tst-cancelx18
FAIL: nptl/tst-cancelx2
FAIL: nptl/tst-cancelx20
FAIL: nptl/tst-cancelx21
FAIL: nptl/tst-cancelx3
FAIL: nptl/tst-cancelx4
FAIL: nptl/tst-cancelx5
FAIL: nptl/tst-cancelx6
FAIL: nptl/tst-cancelx7
FAIL: nptl/tst-cancelx8
FAIL: nptl/tst-cancelx9
FAIL: nptl/tst-cleanup0
FAIL: nptl/tst-cleanup0-cmp
FAIL: nptl/tst-cleanup1
FAIL: nptl/tst-cleanup3
FAIL: nptl/tst-cleanup4
FAIL: nptl/tst-cleanupx0
FAIL: nptl/tst-cleanupx1
FAIL: nptl/tst-cleanupx3
FAIL: nptl/tst-cleanupx4
FAIL: nptl/tst-cnd-basic
FAIL: nptl/tst-cnd-broadcast
FAIL: nptl/tst-cnd-timedwait
FAIL: nptl/tst-cond-except
FAIL: nptl/tst-cond22
FAIL: nptl/tst-cond25
FAIL: nptl/tst-cond7
FAIL: nptl/tst-cond8
FAIL: nptl/tst-default-attr
FAIL: nptl/tst-exec5
FAIL: nptl/tst-execstack
FAIL: nptl/tst-exit2
FAIL: nptl/tst-exit3
FAIL: nptl/tst-fini1
FAIL: nptl/tst-join1
FAIL: nptl/tst-join10
FAIL: nptl/tst-join11
FAIL: nptl/tst-join12
FAIL: nptl/tst-join13
FAIL: nptl/tst-join5
FAIL: nptl/tst-join6
FAIL: nptl/tst-join8
FAIL: nptl/tst-join9
FAIL: nptl/tst-key3
FAIL: nptl/tst-minstack-cancel
FAIL: nptl/tst-minstack-exit
FAIL: nptl/tst-minstack-throw
FAIL: nptl/tst-mtx-basic
FAIL: nptl/tst-mtx-timedlock
FAIL: nptl/tst-mtx-trylock
FAIL: nptl/tst-mutex10
FAIL: nptl/tst-mutex8
FAIL: nptl/tst-mutexpi8
FAIL: nptl/tst-once3
FAIL: nptl/tst-once4
FAIL: nptl/tst-oncex3
FAIL: nptl/tst-oncex4
FAIL: nptl/tst-robust1
FAIL: nptl/tst-robust2
FAIL: nptl/tst-robust3
FAIL: nptl/tst-robust4
FAIL: nptl/tst-robust5
FAIL: nptl/tst-robust6
FAIL: nptl/tst-robust7
FAIL: nptl/tst-robustpi1
FAIL: nptl/tst-robustpi2
FAIL: nptl/tst-robustpi3
FAIL: nptl/tst-robustpi4
FAIL: nptl/tst-robustpi5
FAIL: nptl/tst-robustpi6
FAIL: nptl/tst-robustpi7
FAIL: nptl/tst-sem11
FAIL: nptl/tst-sem12
FAIL: nptl/tst-sem16
FAIL: nptl/tst-stack4
FAIL: nptl/tst-thrd-detach
FAIL: nptl/tst-thrd-sleep
FAIL: nptl/tst-thread-exit-clobber
FAIL: nptl/tst-thread_local1
FAIL: nptl/tst-tsd5
FAIL: nptl/tst-tss-basic
FAIL: nptl/tst-unwind-thread
FAIL: nss/tst-cancel-getpwuid_r
FAIL: nss/tst-nss-files-hosts-long
UNSUPPORTED: posix/tst-cet-vfork-1
FAIL: posix/tst-getopt-cancel
UNSUPPORTED: resolv/tst-resolv-ai_idn
UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
FAIL: rt/tst-cpuclock2
FAIL: rt/tst-mqueue8
FAIL: rt/tst-mqueue8x
FAIL: rt/tst-shm-cancel
FAIL: stdlib/tst-quick_exit
FAIL: stdlib/tst-thread-quick_exit
Summary of test results:
    149 FAIL
   4202 PASS
     16 UNSUPPORTED
     17 XFAIL
      2 XPASS

Select detailed failed test results

  • tst-backtrace2

      Obtained backtrace with 0 functions
      Failure on line 44
    
  • tst-backtrace3

      Obtained backtrace with 0 functions
      Failure on line 49
    
  • dlfcn/bug-atexit3

      dlopen failed: libstdc++.so.6: cannot open shared object file: No such file or directory
    
  • elf/check-abi-libc

      --- ../sysdeps/unix/sysv/linux/x86_64/64/libc.abilist   2021-02-01 12:15:33.000000000 -0500
      +++ /home/sandy/Projects/BuildToolchain/Build/libc.symlist      2021-07-12 11:42:58.693499635 -0400
      @@ -499 +499 @@ GLIBC_2.2.5 _mcount F
      -GLIBC_2.2.5 _nl_default_dirname D 0x12
      +GLIBC_2.2.5 _nl_default_dirname D 0x39
    
  • misc/tst-gettid-kill

      Didn't expect signal from child: got `Aborted'
    
  • nptl/tst-basic3

      starting 20 + 1 threads
      20 left
      Incorrect signal from child: got `Aborted', need `User defined signal 1'
    
  • nss/tst-nss-files-hosts-long (This test passes if the --prefix commandline option is not used)

      error: tst-nss-files-hosts-long.c:35: ahostsv4 failed
      error: 1 test failures
    
  • posix/tst-getopt-cancel

      begin: no errors
      Didn't expect signal from child: got `Aborted'
    
  • rt/tst-cpuclock2

      live thread clock ffffffffff031f26 resolution 0.000000001
      live thread before sleep => 0.000115540
      self thread before sleep => 0.000294453
      live thread after sleep => 0.500264022
      self thread after sleep => 0.000336234
      Didn't expect signal from child: got `Aborted'
    
  • stdlib/tst-quick_exit

       (empty)
    
  • stdlib/tst-thread-quick_exit

      (empty)
    

Solution

  • The reported failures all seem to be related to bugs and limitations in the Glibc 2.33 test harness, plus one VM-related bug.

    Detailed test failure explanations

    elf/tst-cpu-features-cpuinfo
    This test is failing due to a VM software bug and not because of Glibc 2.33. The error log is shown below and can be ignored when the build is performed in a VM (although the build should probably be performed on a host to minimize any chance of optimizations getting disabled).

        [snip]
        Checking HAS_CPU_FEATURE (ERMS):
          HAS_CPU_FEATURE (ERMS): 1
          cpuinfo (erms): 0
         *** failure ***
        [snip]
        1 differences between /proc/cpuinfo and glibc code.
    

    See https://sourceware.org/bugzilla/show_bug.cgi?id=26823, https://bugzilla.redhat.com/show_bug.cgi?id=1128638 and https://sourceware.org/bugzilla/show_bug.cgi?id=24080

    nptl/tst-mutex10
    This test is timing out.

    Remaining 147 tests
    These tests are failing due to a limitation in the test harness related "to when a build is configured for a non-standard prefix (i.e. not /usr)" (see the bug-atexit3 and nptl tests section of https://sourceware.org/glibc/wiki/Testing/Testsuite)

    Workaround

    **** Please note: The following directions should probably not be directly followed to create a new "stand-alone" build of Glibc 2.33. Instead, these directions should be incorporated into a larger set of steps that build an entire toolchain (GCC, Binutils, Glibc, etc.) ****

    The following workaround can be used to build Glibc 2.33 in Ubuntu 21.04 with the default compiler. Optionally first, build Glibc 2.33 by setting the prefix to /usr and verify only the elf/tst-cpu-features-cpuinfo test fails (the test should only fail when built in a VM). Then, rebuild Glibc 2.33 with the desired prefix.

    Build Glibc 2.33 with prefix set to /usr

    **** WARNING: DO NOT PERFORM A make install OR THE SYSTEM WILL BE CORRUPTED ****

    The following build steps will result in a build with only a single failure (elf/tst-cpu-features-cpuinfo) when performed on a VM and should result in no failures when performed directly on a host computer (configured as described in the question).

        wget https://ftp.gnu.org/gnu/glibc/glibc-2.33.tar.gz -P ${HOME}/Downloads
        rm -rf ${HOME}/Projects/BuildToolchainUsr && mkdir -p ${HOME}/Projects/BuildToolchainUsr/Build
        tar -xf ${HOME}/Downloads/glibc-2.33.tar.gz -C ${HOME}/Projects/BuildToolchainUsr
        cd ${HOME}/Projects/BuildToolchainUsr/Build
        ../glibc-2.33/configure --prefix=/usr 2>&1 | tee output-configure.txt
        make -j`nproc` 2>&1 | tee output-make.txt
        make check 2>&1 | tee output-make-check.txt
    

    The above steps should result the following test results:

        UNSUPPORTED: elf/tst-audit10
        UNSUPPORTED: elf/tst-avx512
        UNSUPPORTED: elf/tst-cet-legacy-8
        UNSUPPORTED: elf/tst-cet-property-2
        FAIL: elf/tst-cpu-features-cpuinfo
        XPASS: elf/tst-protected1a
        XPASS: elf/tst-protected1b
        UNSUPPORTED: math/test-double-libmvec-sincos-avx512
        UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
        UNSUPPORTED: misc/tst-pkey
        UNSUPPORTED: nptl/test-cond-printers
        UNSUPPORTED: nptl/test-condattr-printers
        UNSUPPORTED: nptl/test-mutex-printers
        UNSUPPORTED: nptl/test-mutexattr-printers
        UNSUPPORTED: nptl/test-rwlock-printers
        UNSUPPORTED: nptl/test-rwlockattr-printers
        UNSUPPORTED: posix/tst-cet-vfork-1
        Summary of test results:
              1 FAIL
           4352 PASS
             14 UNSUPPORTED
             17 XFAIL
              2 XPASS
    

    Build Glibc 2.33 with the desired prefix

    Glibc 2.33 can then be built with the following commands to use the desired prefix value. While 2 tests will fail (1 if built directly on a host), the failures are a result of the test harness's limitations and can be safely ignored.

    Detailed workaround explanation

    The workaround resolves all but one of the prefix related test failures by creating symlinks for libstdc++.so.6 and libgcc_s.so.1 plus executing the test suite twice, creating additional symlinks before the second execution. The first two symlinks ensure all unit tests are able to find both libstdc++.so.6 and libgcc_s.so.1. When the test suite is first run, a directory named testroot.pristine is created, which is used to provide a clean chroot for each unit test. At the start of an individual unit test, the testroot.pristine directory is copied to testroot.root (replacing any existing testroot.root directories) and a chroot is setup. Individual unit test can have test specific files that get copied into the testroot.root directory.

    After the first execution of the test suite, there will be 5 failures (4 if run outside of a VM). Three of these failures are due to the unit tests assuming the prefix is always /usr. To resolve this, a second set of symlinks are created in the testroot.prestine directory, to ensure the 3 unit tests are able to find the required files. All of the *.out files in the Build directory are then deleted so the full test suite can be rerun without recreating the testroot.prestine directory.

        rm -rf ${HOME}/Projects/BuildToolchain && mkdir -p ${HOME}/Projects/BuildToolchain/Build
        tar -xf ${HOME}/Downloads/glibc-2.33.tar.gz -C ${HOME}/Projects/BuildToolchain
        cd ${HOME}/Projects/BuildToolchain/Build
        ../glibc-2.33/configure --prefix=${HOME}/Projects/BuildToolchain/Install 2>&1 | tee output-configure.txt
        make -j`nproc` 2>&1 | tee output-make.txt
        ln -s /lib/x86_64-linux-gnu/libstdc++.so.6
        ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1
        TIMEOUTFACTOR=16 make check 2>&1 | tee output-make-checkA.txt
        mkdir testroot.pristine/usr
        ln -s ${HOME#/}/Projects/BuildToolchain/Install/etc testroot.pristine/etc
        ln -s ${HOME#/}/Projects/BuildToolchain/Install/lib testroot.pristine/lib64
        ln -s ${HOME#/}/Projects/BuildToolchain/Install/sbin testroot.pristine/sbin
        ln -s ${HOME#/}/Projects/BuildToolchain/Install/var testroot.pristine/var
        ln -s ..${HOME}/Projects/BuildToolchain/Install/bin testroot.pristine/usr/bin
        ln -s ..${HOME}/Projects/BuildToolchain/Install/include testroot.pristine/usr/include
        ln -s ..${HOME}/Projects/BuildToolchain/Install/lib testroot.pristine/usr/lib
        ln -s ..${HOME}/Projects/BuildToolchain/Install/lib testroot.pristine/usr/lib64
        ln -s ..${HOME}/Projects/BuildToolchain/Install/libexec testroot.pristine/usr/libexec
        ln -s ..${HOME}/Projects/BuildToolchain/Install/sbin testroot.pristine/usr/sbin
        ln -s ..${HOME}/Projects/BuildToolchain/Install/share testroot.pristine/usr/share
        find -name "*.out" -delete
        TIMEOUTFACTOR=16 make check 2>&1 | tee output-make-checkB.txt
    

    Notes

    TIMEOUTFACTOR: This environment variable is used to increase the timeout value used by the test harness.

    The expected test output after the first make check command:

        FAIL: elf/check-abi-libc
        UNSUPPORTED: elf/tst-audit10
        UNSUPPORTED: elf/tst-avx512
        UNSUPPORTED: elf/tst-cet-legacy-8
        UNSUPPORTED: elf/tst-cet-property-2
        FAIL: elf/tst-cpu-features-cpuinfo
        FAIL: elf/tst-glibc-hwcaps-prepend-cache
        FAIL: elf/tst-ldconfig-ld_so_conf-update
        XPASS: elf/tst-protected1a
        XPASS: elf/tst-protected1b
        UNSUPPORTED: math/test-double-libmvec-sincos-avx512
        UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
        UNSUPPORTED: misc/tst-pkey
        UNSUPPORTED: nptl/test-cond-printers
        UNSUPPORTED: nptl/test-condattr-printers
        UNSUPPORTED: nptl/test-mutex-printers
        UNSUPPORTED: nptl/test-mutexattr-printers
        UNSUPPORTED: nptl/test-rwlock-printers
        UNSUPPORTED: nptl/test-rwlockattr-printers
        FAIL: nss/tst-nss-files-hosts-long
        UNSUPPORTED: posix/tst-cet-vfork-1
        UNSUPPORTED: resolv/tst-resolv-ai_idn
        UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
        Summary of test results:
              5 FAIL
           4346 PASS
             16 UNSUPPORTED
             17 XFAIL
              2 XPASS
    

    The expected test output after the second make check command:

        FAIL: elf/check-abi-libc
        UNSUPPORTED: elf/tst-audit10
        UNSUPPORTED: elf/tst-avx512
        UNSUPPORTED: elf/tst-cet-legacy-8
        UNSUPPORTED: elf/tst-cet-property-2
        FAIL: elf/tst-cpu-features-cpuinfo
        XPASS: elf/tst-protected1a
        XPASS: elf/tst-protected1b
        UNSUPPORTED: math/test-double-libmvec-sincos-avx512
        UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
        UNSUPPORTED: misc/tst-pkey
        UNSUPPORTED: nptl/test-cond-printers
        UNSUPPORTED: nptl/test-condattr-printers
        UNSUPPORTED: nptl/test-mutex-printers
        UNSUPPORTED: nptl/test-mutexattr-printers
        UNSUPPORTED: nptl/test-rwlock-printers
        UNSUPPORTED: nptl/test-rwlockattr-printers
        UNSUPPORTED: posix/tst-cet-vfork-1
        UNSUPPORTED: resolv/tst-resolv-ai_idn
        UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
        Summary of test results:
              2 FAIL
           4349 PASS
             16 UNSUPPORTED
             17 XFAIL
              2 XPASS
    

    Detailed test failure explanations

    elf/check-abi-libc This test fails because the _nl_default_dirname symbol stores the path to the locale file (see https://sourceware.org/pipermail/libc-alpha/2012-December/036816.html). When the prefix is set to /usr, the locale file path is /usr/share/locale but with the above directions, the path is ${HOME}/Projects/BuildToolchain/Install/share/locale (with the ${HOME} variable expanded). This failure can safely be ignored.

        --- ../sysdeps/unix/sysv/linux/x86_64/64/libc.abilist   2021-02-01 12:15:33.000000000 -0500
        +++ /home/sandy/Projects/BuildToolchain/Build/libc.symlist      2021-07-14 18:18:50.040682543 -0400
        @@ -499 +499 @@ GLIBC_2.2.5 _mcount F
        -GLIBC_2.2.5 _nl_default_dirname D 0x12
        +GLIBC_2.2.5 _nl_default_dirname D 0x39