【问题标题】:Building Glibc 2.33 for Linux results in unit test failures为 Linux 构建 Glibc 2.33 导致单元测试失败
【发布时间】:2021-09-21 19:46:15
【问题描述】:

我目前正在尝试创建 Glibc 2.33 的构建以与默认系统版本并行运行,但构建过程导致大量单元测试失败。虽然有些故障可以忽略不计,但大多数似乎是合法的问题,但我不知道如何解决它们。所需的最终目标系统是 CentOS 7.9,但我目前正在 Ubuntu Desktop 21.04 中测试构建步骤(在 VMware 15 虚拟机中)因为 CentOS 7.9 需要创建引导工具链(默认工具链太旧了)。根据 Glibc 2.33 文档,--enable-add-ons 选项不再需要(甚至可能不受支持),所以我不确定我可能缺少哪些步骤或配置选项。

创建构建虚拟机的步骤

  1. 创建一个“干净”的最小 Ubuntu Desktop 21.04 虚拟机安装
  2. 完全更新虚拟机
  3. 安装以下软件包
  • build-essential
  • gawk
  • bison
  • texinfo
  • msgfmt
  • gettext

最终系统的软件版本

  • GCC:Ubuntu 10.3.0-1ubuntu1
  • Binutils:2.36.1
  • 制作:4.3
  • 野牛: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 构建步骤:

  1. 下载Glibc 2.33源代码

     wget https://ftp.gnu.org/gnu/glibc/glibc-2.33.tar.gz -P ${HOME}/Downloads
    
  2. 创建目录

     rm -rf ${HOME}/Projects/BuildToolchain && mkdir -p ${HOME}/Projects/BuildToolchain/Build
    
  3. 提取Glibc 2.33源代码

     tar -xf ${HOME}/Downloads/glibc-2.33.tar.gz -C ${HOME}/Projects/BuildToolchain
    
  4. 进入(源外)构建目录

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

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

     make -j`nproc` 2>&1 | tee output-make.txt
    
  7. 构建并运行单元测试

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

单元测试结果

以上步骤产生以下单元测试结果,包括 149 个失败的测试。

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

选择详细的失败测试结果

  • 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
    
  • 杂项/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(如果未使用--prefix 命令行选项,则此测试通过)

      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)
    

【问题讨论】:

标签: ubuntu gcc vmware glibc


【解决方案1】:

报告的故障似乎都与 Glibc 2.33 测试工具中的错误和限制有关,以及一个与 VM 相关的错误。

详细的测试失败说明

elf/tst-cpu-features-cpuinfo
此测试失败是由于 VM 软件错误而不是因为 Glibc 2.33。错误日志如下所示,在 VM 中执行构建时可以忽略(尽管可能应该在主机上执行构建,以尽量减少禁用优化的可能性)。

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

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

nptl/tst-mutex10
此测试正在超时。

剩余 147 次测试
这些测试失败是由于测试工具中的限制,“当构建配置为非标准前缀(即不是/usr)”(参见 bug-atexit3 和 nptl 测试 https://sourceware.org/glibc/wiki/Testing/Testsuite的部分)

​​解决方法

**** 请注意:创建 Glibc 2.33 的新“独立”版本可能不应该直接遵循以下说明。相反,应将这些指导纳入构建整个工具链的更大步骤集(GCCBinutilsGlibc 等)* ***

以下解决方法可用于使用默认编译器在 Ubuntu 21.04 中构建 Glibc 2.33。 (可选)首先,通过将前缀设置为 /usr 来构建 Glibc 2.33 并仅验证 elf/tst-cpu-features-cpuinfo 测试失败(测试应该仅在以下情况下失败内置在虚拟机中)。然后,使用所需的前缀重建 Glibc 2.33

构建Glibc 2.33,前缀设置为/usr

****警告:请勿执行make install,否则系统将损坏****

以下构建步骤将导致在 VM 上执行时仅出现一次故障 (elf/tst-cpu-features-cpuinfo),并且在直接在 VM 上执行时应该不会导致任何故障一台主机(如问题中所述进行配置)。

    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

以上步骤应产生以下测试结果:

    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

使用所需前缀构建 Glibc 2.33

Glibc 2.33 然后可以使用以下命令构建以使用所需的前缀值。虽然有 2 个测试会失败(如果直接在主机上构建,则有 1 个),但这些失败是测试工具限制的结果,可以放心地忽略。

详细的解决方法说明

解决方法是通过为libstdc++.so.6libgcc_s.so.1 创建符号链接并执行两次测试套件,在第二次执行之前创建额外的符号链接,从而解决除一个前缀相关的测试失败之外的所有问题。前两个符号链接确保所有单元测试都能找到libstdc++.so.6libgcc_s.so.1。首次运行测试套件时,会创建一个名为 testroot.pristine 的目录,用于为每个单元测试提供干净的 chroot。在单个单元测试开始时,testroot.pristine 目录被复制到testroot.root(替换任何现有的testroot.root 目录)并设置 chroot。单个单元测试可以将测试特定文件复制到testroot.root 目录中。

在第一次执行测试套件后,将出现 5 次失败(如果在 VM 之外运行,则为 4 次)。其中三个失败是由于单元测试假设前缀始终为/usr。为了解决这个问题,在testroot.prestine 目录中创建了第二组符号链接,以确保 3 个单元测试能够找到所需的文件。然后删除Build 目录中的所有*.out 文件,以便重新运行完整的测试套件而无需重新创建testroot.prestine 目录。

    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

备注

TIMEOUTFACTOR:此环境变量用于增加测试工具使用的超时值。

第一个make check 命令后的预期测试输出:

    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

第二个make check 命令后的预期测试输出:

    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

详细的测试失败说明

elf/check-abi-libc 此测试失败,因为_nl_default_dirname 符号存储了locale 文件的路径(请参阅https://sourceware.org/pipermail/libc-alpha/2012-December/036816.html)。当前缀设置为/usr 时,locale 文件路径为/usr/share/locale,但按照上述说明,路径为${HOME}/Projects/BuildToolchain/Install/share/locale(扩展了${HOME} 变量)。可以放心地忽略此故障。

    --- ../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

【讨论】:

    猜你喜欢
    • 2017-03-23
    • 1970-01-01
    • 1970-01-01
    • 2018-08-31
    • 2012-08-13
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    相关资源
    最近更新 更多