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

            Bug ID: 123406
           Summary: [16 Regression] 27_io/print/1.cc 27_io/print/2.cc
                    27_io/print/3.cc on newlib targets since r16-4350
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: testsuite-fail
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hp at gcc dot gnu.org
                CC: tkaminsk at gcc dot gnu.org
  Target Milestone: ---
            Target: cris-elf, arm-unknown-eabi,

Since r16-4350-g8bd872f1ea7414 (per
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122172#c31 and according to own
observations) these tests fail for newlib targets at link-time, with unresolved
symbol references for the system file-locking/unlocking functions whose use was
introduced in that commit. Quoting an edited libstdc++.log for cris-elf at
r16-6493-ge77ba7ef8c75:

/PATH/bin/ld: /tmp/ccbBvkyH.o: in function `ZNSt8__format10_File_sinkD2Ev':
/gccobj/cris-elf/libstdc++-v3/include/print:219: undefined reference to
`funlockfile'
/PATH/bin/ld: /gccobj/cris-elf/libstdc++-v3/include/print:219: undefined
reference to `funlockfile'
/PATH/bin/ld: /tmp/ccbBvkyH.o: in function
`ZNSt8__format10_File_sinkC4EP7__sFILEb':
/gccobj/cris-elf/libstdc++-v3/include/print:212: undefined reference to
`flockfile'
[... more similar messages elited]
collect2: error: ld returned 1 exit status
compiler exited with status 1
FAIL: 27_io/print/1.cc  -std=gnu++23 (test for excess errors)

and similarly for 2.cc and 3.cc

Looking at archives, this seems to happen also for arm-unknown-eabi.  Before,
just 2.cc:
gcc-16-4275-gf4b60fe6d6a
https://gcc.gnu.org/pipermail/gcc-testresults/2025-October/859047.html

After, all three:
gcc-16-4418-g599d2902b0af
https://gcc.gnu.org/pipermail/gcc-testresults/2025-October/859586.html

A glance at newlib shows that the declarations of the tested stdio functions
are always present, with no easy way to check whether the functions are only
declared or if actual symbols are present and code referencing them being
linkable.  (N.B. to the casual reader: libstdc++ must NOT use link-tests at
configure-time.)

Another look at current newlib sources shows that among those systems, only
cygwin implements the declared-but-missing functions.  So, it seems safe to
assume for now, that no other newlib target actually implements them, and that
it'd be valid to hardcode a "no" for non-cygwin newlib targets.  Though, a
patch should preferably leave room for a manually added exception list, should
such a target appear.

Reply via email to