https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121458

            Bug ID: 121458
           Summary: HAVE_LD_SOL2_EMULATION check broken
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
                CC: ro at gcc dot gnu.org
  Target Milestone: ---

In gcc/configure.ac:
```
# In binutils 2.21, GNU ld gained support for new emulations fully
# supporting the Solaris 2 ABI.  Detect their presence in the linker used.
AC_CACHE_CHECK(linker *_sol2 emulation support,
  gcc_cv_ld_sol2_emulation,
  [gcc_cv_ld_sol2_emulation=no
  if test $in_tree_ld = yes ; then
    if test "$gcc_cv_gld_major_version" -eq 2 -a \
       "$gcc_cv_gld_minor_version" -ge 21 -o \
       "$gcc_cv_gld_major_version" -gt 2 \
       && test $in_tree_ld_is_elf = yes; then
      gcc_cv_ld_sol2_emulation=yes
    fi
  elif test x$gcc_cv_ld != x; then
    if $gcc_cv_ld -V 2>/dev/null | sed -e '1,/Supported emulations/d;q' | \
       grep _sol2 > /dev/null; then
      gcc_cv_ld_sol2_emulation=yes
    fi
  fi])
if test x"$gcc_cv_ld_sol2_emulation" = xyes; then
  AC_DEFINE(HAVE_LD_SOL2_EMULATION, 1,
  [Define if your linker supports the *_sol2 emulations.])
fi
```

This is broken for me on x86_64-pc-linux-gnu with binutils trunk at least
(surely a long time though) and --enable-targets=all:

$ ld -V 2>/dev/null | sed -e '1,/Supported emulations/d;q'
   aix5ppc

$ ld -V 2>/dev/null | grep _sol2
   elf32_sparc_sol2
   elf_i386_sol2
   elf64_sparc_sol2
   elf_x86_64_sol2

We shouldn't assume the output ordering is sorted like that. This leads to
gcc_cv_ld_sol2_emulation=no.

(Admittedly, I have no idea how much this matters in practice. I suspect not at
all, but if the check *did* work, we could use it to fix PR121457.)

Reply via email to