【问题标题】:Debugging glibc build process调试 glibc 构建过程
【发布时间】:2023-03-23 18:05:01
【问题描述】:

我正在尝试在 Clear Linux 上安装 glibc,但在调试时遇到了困难(或者甚至是要调试的许多 makefile 中的哪一个)。 我之前的尝试是在这两个线程中: How do I build into a specified directory using the "prefix" option of configure? Errors building glibc: what is wrong with the make/confgure files?

所以现在我的问题是,当我运行 make 时,构建会停止:

  -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/float128  -I../sysdeps/ieee754/ldbl-96/include -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.   -D_LIBC_REENTRANT -include /home/james/Downloads/glibc-build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc -I../soft-fp -o /home/james/Downloads/glibc-build/math/s_modfl.o -MD -MP -MF /home/james/Downloads/glibc-build/math/s_modfl.o.dt -MT /home/james/Downloads/glibc-build/math/s_modfl.o
cc1: error: -fassociative-math disabled; other options take precedence [-Werror]
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:791: /home/james/Downloads/glibc-build/math/s_modfl.o] Error 1
make[2]: Leaving directory '/home/james/Downloads/glibc/math'
make[1]: *** [Makefile:215: math/subdir_lib] Error 2
make[1]: Leaving directory '/home/james/Downloads/glibc'
make: *** [Makefile:9: all] Error 2

我怀疑这个线程中可能有一个线索,但这有点超出我的想象。 associative-math with GCC

我还猜测,makefile 中后来出现的错误是关联数学出现问题的结果。

编辑 按照要求,我跑了

james@clr ~/Downloads/glibc-build $ make -j

这就是输出的结尾

 -I../sysdeps/ieee754/ldbl-96/include -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.   -D_LIBC_REENTRANT -include /home/james/Downloads/glibc-build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED     -DTOP_NAMESPACE=glibc -I../soft-fp -DASSEMBLER  -g -Werror=undef -Wa,--noexecstack   -o /home/james/Downloads/glibc-build/math/s_signbit.os -MD -MP -MF /home/james/Downloads/glibc-build/math/s_signbit.os.dt -MT /home/james/Downloads/glibc-build/math/s_signbit.os
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:791: /home/james/Downloads/glibc-build/math/s_modfl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:825: /home/james/Downloads/glibc-build/math/s_modf.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:893: /home/james/Downloads/glibc-build/math/s_modff.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:757: /home/james/Downloads/glibc-build/math/s_modff128.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:807: /home/james/Downloads/glibc-build/math/s_modfl.os] Error 1
cc1: all warnings being treated as errors
make[2]: *** [/home/james/Downloads/glibc-build/sysd-rules:841: /home/james/Downloads/glibc-build/math/s_modf.os] Error 1
make[2]: Leaving directory '/home/james/Downloads/glibc/math'
make[1]: *** [Makefile:215: math/subdir_lib] Error 2
make[1]: Leaving directory '/home/james/Downloads/glibc'
make: *** [Makefile:9: all] Error 2

编辑 2:Basile 回应 cmets 的更多信息: 我需要 glibc 来为 Phoronix 测试套件运行一些模块,将来我可能需要它来为 R 构建库。据我所知,它不包含在 Clear Linux 中(至少 PTS 不认为我已安装),并且我在可用捆绑包列表中没有看到它。 版本:

    james@clr ~/Downloads $ uname -r
    4.17.1-582.native
    james@clr ~/Downloads $ gcc --version
    gcc (Clear Linux OS for Intel Architecture) 8.1.1 20180514
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Configure commands

james@clr ~/Downloads $ git clone git://sourceware.org/git/glibc.git
james@clr ~/Downloads $ cd glibc
james@clr ~/Downloads/glibc $ git checkout --track -b local_glibc-2.27 origin/release/2.27/master
Branch 'local_glibc-2.27' set up to track remote branch 'release/2.27/master' from 'origin'.
Switched to a new branch 'local_glibc-2.27'
james@clr ~/Downloads/glibc $ mkdir /home/james/Downloads/glibc-build/
james@clr ~/Downloads/glibc $ cd /home/james/Downloads/glibc-build/
james@clr ~/Downloads/glibc-build $ ~/Downloads/glibc/configure --prefix=/home/james/Downloads/glibc-build
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for readelf... readelf
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ can link programs... yes
checking for sysdeps preconfigure fragments... aarch64 alpha arm hppa i386 m68k microblaze mips nios2 powerpc riscv s390 sh sparc tile x86_64 checking whether gcc compiles in -mx32 mode by default... no

checking for use of fpu sysdeps directories... yes
checking for -fstack-protector... yes
checking for -fstack-protector-strong... yes
checking for -fstack-protector-all... yes
checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... yes
checking if compiler warns about alias for function with incompatible types... yes
checking sysdep dirs... sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64 sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86 sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754 sysdeps/generic
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether as is GNU as... yes
checking whether ld is GNU ld... yes
checking for as... as
checking version of as... 2.30, ok
checking for ld... ld
checking version of ld... 2.30, ok
checking for gnumake... no
checking for gmake... no
checking for make... make
checking version of make... 4.2.1, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... msgfmt
checking version of msgfmt... 0.19.8.1, ok
checking for makeinfo... makeinfo
checking version of makeinfo... 6.5, ok
checking for sed... sed
checking version of sed... 4.5, ok
checking for gawk... gawk
checking version of gawk... 4.2.1, ok
checking for bison... bison
checking version of bison... 3.0.5, ok
checking if gcc is sufficient to build libc... yes
checking for nm... gcc-nm
checking for python3... python3
checking LD_LIBRARY_PATH variable... ok
checking for bash... /usr/bin/bash
checking for perl... /usr/bin/perl
checking for install-info... /usr/bin/install-info
checking for .set assembler directive... yes
checking linker support for protected data symbol... yes
checking linker support for INSERT in linker script... yes
checking for broken __attribute__((alias()))... no
checking whether to put _rtld_local into .sdata section... no
checking whether to use .ctors/.dtors header and trailer... no
checking for libunwind-support in compiler... no
checking whether --noexecstack is desirable for .S files... yes
checking for -z combreloc... yes
checking for linker that supports -z execstack... yes
checking for linker that supports --no-dynamic-linker... yes
checking for -static-pie... yes
checking for -fpie... yes
checking for --hash-style option... yes
checking for sufficient default -shared layout... no
checking for GLOB_DAT reloc... yes
checking linker output format... elf64-x86-64
checking for -fno-toplevel-reorder -fno-section-anchors... yes
checking for -mtls-dialect=gnu2... yes
checking whether cc puts quotes around section names... no
checking for __builtin_memset... no
checking for redirection of built-in functions... yes
checking for compiler option to disable generation of FMA instructions... -ffp-contract=off
checking if gcc accepts -fno-tree-loop-distribute-patterns with __attribute__ ((__optimize__))... yes
checking for libgd... yes
checking for is_selinux_enabled in -lselinux... no
checking for _FORTIFY_SOURCE predefine... yes
checking whether the linker provides working __ehdr_start... yes
checking for __builtin_trap with no external dependencies... yes
checking whether the C++ compiler supports thread_local... yes
running configure fragment for sysdeps/unix/sysv/linux/x86_64/64
running configure fragment for sysdeps/unix/sysv/linux/x86_64
running configure fragment for sysdeps/unix/sysv/linux
checking installed Linux kernel header files... 3.2.0 or later
checking for kernel header at least 3.2.0... ok
checking for symlinks in /home/james/Downloads/glibc-build/include... ok
running configure fragment for sysdeps/gnu
running configure fragment for sysdeps/unix/inet
running configure fragment for sysdeps/x86_64
checking for AVX512DQ support in assembler... yes
checking for AVX512 support... yes
checking for Intel MPX support... yes
checking whether -fPIC is default... no
checking whether -fPIE is default... no
configure: creating ./config.status
config.status: creating config.make
config.status: creating Makefile
config.status: creating config.h
config.status: executing default commands

编辑 3:make 的 FULL 输出太长而无法包含,所以我把它放在 pastebin 上: https://pastebin.com/H3yGC5aj

【问题讨论】:

  • 您已经在每个 Linux 发行版上都有一个 libc。您无需安装新的
  • 如果有用于 glibc 的 Clear Linux 包,请链接到它。
  • 你需要在你的问题中解释为什么你需要在你的发行版上编译 glibc。在极少数情况下需要这样做。所有 Linux 发行版都附带一些 libc(通常是 glibc 一个,也许是 musl-libc...),它们通常是兼容的。 Libc 是每个 Linux 系统的基石,您的发行版制造商已经编译了它。
  • 顺便说一句,您是否考虑过使用一些chroot-ed 环境?也许这会有所帮助。但是你真的应该在你的问题中解释你编译glibc的动机。我们无法猜测它们,它们非常重要。解释为什么你的发行版的libc 对你来说不够用。所以编辑你的问题来改进它(否则,不清楚)。
  • 另外,给出你用过的精确的configure命令......并详细说明你的系统(libc它本身有什么,gcc版本是什么,内核版本等...)。但是,我倾向于认为(除非另有说明)您不需要编译 glibc

标签: gcc makefile gnu-make glibc cc


【解决方案1】:

您提出的编译器命令行包含这些标志:

-fassociative-math -fasynchronous-unwind-tables -feliminate-unused-debug-types -fexceptions -ffat-lto-objects -fmerge-all-constants -fno-semantic-interposition -fno-signed-zeros -fno-stack-protector -fno-trapping-math -frounding-math -fstack-protector -ftree-loop-distribute-patterns

但是,-fassociative-math 是不安全的数学优化之一,并且 glibc 无法使用它们构建,因为使用此类优化,数学库会产生错误的结果 - 正如您发现的那样,部件的一些必需的编译器标志的数学库甚至与它们不兼容。

您没有将这些标志显式传递给configuremake,因此它们很可能来自CFLAGS 环境变量。您需要在调用 configuremake 之前取消设置。

【讨论】:

    猜你喜欢
    • 2016-05-31
    • 2019-08-03
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-16
    • 2021-09-21
    • 1970-01-01
    相关资源
    最近更新 更多