[PATCH] configure: Move --with-binutils early

Stefan Liebler stli@linux.ibm.com
Fri May 23 13:29:40 GMT 2025


On 5/16/25 09:50, Stefan Liebler wrote:
> When using configure --with-binutils, there is e.g. the test "checking for
> suffix of object files" which invokes CC before adding -B$path_binutils.
> 
> This leads to configure errors if the system assembler lacks support
> for e.g. CFLAGS which can be used by specified --with-binutils assembler.
> In my case, this was CFLAGS="-march=z17" where gcc propagates it to the
> assembler.
> 
> This patch moves the --with-binutils handling before AC_PROG_CC.
> 
> Furthermore for building support/links-dso-program.cc g++ is used,
> which also needs to use the -B$path_binutils flag.
Sorry for this patch. It turned out to be the wrong approach.

In my "glibc-build-script", I always set CC. Then it works fine to move
LIBC_PROG_BINUTILS before AC_PROG_CC. I had also successfully tested
this patch with build-many-glibcs.py (which also sets CC).

But both linaro-tcwg-bot/tcwg_glibc_build--master-arm and
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 are failing. This can
also be seen with simply calling configure without any arguments/variables:
$ <glibc>/configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
# The following errors come from LIBC_PROG_BINUTILS where CC is asked to
print the program names for ld & co (e.g. "LD=`$CC
-print-prog-name=$LDNAME`"):
<glibc>/configure: line 3028: -print-prog-name=ld: command not found
<glibc>/configure: line 3031: -print-prog-name=ar: command not found
<glibc>/configure: line 3035: -print-prog-name=objcopy: command not found
<glibc>/configure: line 3039: -print-prog-name=gprof: command not found
<glibc>/configure: line 3043: -print-prog-name=readelf: command not found
<glibc>/configure: line 3047: -print-prog-name=objdump: command not found
<glibc>/configure: line 3051: -print-prog-name=nm: command not found
checking for gcc... gcc
...
configure: error:
*** These critical programs are missing or too old: GNU ld
*** Check the INSTALL file for required versions.


Thus without explicitly setting CC, LIBC_PROG_BINUTILS depends on
AC_PROG_CC.

AC_PROG_CC searches and sets CC if not already done. It also invokes CC
with the specified CFLAGS while "checking for suffix of object files":
checking for gcc... gcc
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed


In my desired case, I want to exchange gcc (by setting CC/CPP/CXX
variables) and binutils (with configure --with-bintuils=path/to/bintuils
argument) and of course setting CFLAGS (like "-march=z17", which needs
support in gcc and binutils), which are not yet supported by system
gcc/binutils.
Thus in this case, AC_PROG_CC also depends on LIBC_PROG_BINUTILS in
order to get: CC="$CC -B$path_binutils".


Does anybody have an idea how to solve this dependency issue?

Bye,
Stefan


More information about the Libc-alpha mailing list