Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Make hang when compiling glibc?

I'm trying to build an aarch64 cross compiler to build stuff for my Raspberry Pi 3B. I've been using a helpful script to build gcc for me (original script, mine filled in - note this contains the versions of libraries I'm using). When building glibc, it makes it to:

...
make  subdir=setjmp -C setjmp ..=../ subdir_lib
make  subdir=signal -C signal ..=../ subdir_lib
make  subdir=stdlib -C stdlib ..=../ subdir_lib
make  subdir=stdio-common -C stdio-common ..=../ subdir_lib

...and then proceeds to hang indefinitely. I've let the thing sit overnight and it still doesn't complete. make just seems to be taking up a whole core, occasionally giving memory back to the OS and taking some again. No gcc process or anything is running.

Because it seems that libc.so somehow still ended up being built anyway, I tried manually running make all in the GCC build folder (build-gcc) but I get:

checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.

Unsure if that's related or not.

What's going on here? Any help would be appreciated. Thanks.

  • Host OS: Artix Linux x64
  • Host gcc: 13.1.1
  • make: GNU make 4.4.1
like image 260
TheGag96 Avatar asked Jul 31 '26 20:07

TheGag96


1 Answers

TL;DR This is an issue with older glibc Makefiles and Make v4.4+, where the build graph gets perturbed and stdio-common gets continuously re-evaluated and rebuilt. So either downgrade make or upgrade the glibc version to a much newer one.

I am experiencing this with Buildroot and with crosstools-NG as well.

Modifying glibc's Makefile so that stdio-common make is traced:

# The action for each of those is to cd into the directory and make the
# target there.
$(all-subdirs-targets):
        @if [ "$@" = "stdio-common/subdir_lib" ]; then \
                echo "Running debug command for $@"; \
                $(MAKE) -d $(PARALLELMFLAGS) $(subdir-target-args) $(@F); \
        else \
                echo "Running default command for $@"; \
                $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F); \
        fi

I could see that the following in the output, signalling the same build is re-executed over and over:

 Considering target file '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.d'.
 File '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.d' was considered already.
Re-executing[48]: make -d subdir=stdio-common -C stdio-common ..=../ subdir_lib

This is happening with subdir_lib, others and subdir_install rules visit to stdio-common, that's why you get a libc.so out as this is all post-build.

Using a less verbose output, we can see (for the stdio-common/others target that some files get restammped and force a rebuild): I have some more info, from stdio-common/others. It genuinely seems that .stmp and .st files are being created for every invocation.

Re-executing[30]: /usr/bin/make --debug=Makefile subdir=stdio-common -C stdio-common ..=../ others
GNU Make 4.4.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
  Prerequisite '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/versions.stmp' is newer than target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/sysd-versions'.
     Prerequisite '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/libc-modules.stmp' is newer than target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/libc-modules.h'.
    Must remake target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/libc-modules.h'.
    Successfully remade target file '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/libc-modules.h'.
     Prerequisite '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/dl-tunable-list.stmp' is newer than target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/dl-tunable-list.h'.
    Must remake target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/dl-tunable-list.h'.
    Successfully remade target file '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/dl-tunable-list.h'.
     Prerequisite '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.st' is newer than target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.h'.
    Must remake target '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.h'.
    Successfully remade target file '/home/boran/git/buildroot-2020.02.3/output/build/glibc-2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427/build/bits/stdio_lim.h'.
Re-executing[31]: /usr/bin/make --debug=Makefile subdir=stdio-common
-C stdio-common ..=../ others

I am trying to figure out why...

As a resolution, here's the changed rule that succeeds building it all, but you have to let each step hang first once (apparently, steps hang at a re-run):

# The action for each of those is to cd into the directory and make the
# target there.
$(all-subdirs-targets):
        @if [ "$@" = "stdio-common/subdir_lib" ]; then \
                echo "Skipping make command for $@"; \
        elif [ "$@" = "stdio-common/others" ]; then \
                echo "Skipping make command for $@"; \
        elif [ "$@" = "stdio-common/subdir_install" ]; then \
                touch stdio-common/stubs \
                echo "Skipping make command for $@"; \
        else \
                $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F); \
        fi
like image 176
borancar Avatar answered Aug 02 '26 10:08

borancar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!