public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/111638] New: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work
@ 2023-09-29 13:17 redi at gcc dot gnu.org
  2023-11-11  0:43 ` [Bug libstdc++/111638] " cvs-commit at gcc dot gnu.org
  2023-11-12 21:38 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-09-29 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111638
           Summary: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't
                    work
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

In linkage.m4 we have:

dnl 
dnl Define autoheader template for using the underscore functions
dnl For each parameter, create a macro where if func doesn't exist,
dnl but _func does, then it will "#define func _func".
dnl
dnl GLIBCXX_MAYBE_UNDERSCORED_FUNCS
AC_DEFUN([GLIBCXX_MAYBE_UNDERSCORED_FUNCS], 
[AC_FOREACH([glibcxx_ufunc], [$1],
  [AH_VERBATIM(_[]glibcxx_ufunc,
[#if defined (]AS_TR_CPP(HAVE__[]glibcxx_ufunc)[) && ! defined
(]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[)
# define ]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[ 1
# define ]glibcxx_ufunc[ _]glibcxx_ufunc[
#endif])])
])


dnl
dnl Check to see if the (math function) argument passed is
dnl 1) declared when using the c++ compiler
dnl 2) has "C" linkage
dnl 3) if not, see if 1) and 2) for argument prepended with '_'
dnl
dnl Define HAVE_CARGF etc if "cargf" is declared and links
dnl
dnl argument 1 is name of function to check
dnl
dnl ASSUMES argument is a math function with ONE parameter
dnl
dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [
  GLIBCXX_CHECK_MATH_DECL_1($1)
  if test x$glibcxx_cv_func_$1_use = x"yes"; then
    AC_CHECK_FUNCS($1)
  else
    GLIBCXX_CHECK_MATH_DECL_1(_$1)
    if test x$glibcxx_cv_func__$1_use = x"yes"; then
      AC_CHECK_FUNCS(_$1)
    fi
  fi
  GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
])


Which results in output like this in c++config.h

#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF)
# define _GLIBCXX_HAVE_ACOSF 1
# define acosf _acosf
#endif

But this is completely incompatible with the logic in <cmath>.

For a target where _acosf is present, c++config.h will do:

# define _GLIBCXX_HAVE_ACOSF 1
# define acosf _acosf

Then <cmath> will do something like:

#undef acosf
#ifdef _GLIBCXX_HAVE_ACOSF
  using ::acosf;
#endif

So HAVE_ACOSF is defined, but the using-declaration will fail, because acosf
was actually just a macro for _acosf which has been undefined.

If the macros in linkage.m4 still have any value, we would need to output
something like this to c++config.h:

#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF)
# define _GLIBCXX_HAVE_ACOSF 1
inline __decltype(_acosf(0)) acosf(__decltype(_acosf(0)) __x) { return
::_acosf(__x); }
#endif

That would define a real function that <cmath> can refer to.

But maybe we should just remove it all.

The #define acosf _acosf stuff was added in 2000 by
g:54fa741538eaf41ed84093cc5245f41119a8e969 so maybe it's no longer even needed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/111638] GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work
  2023-09-29 13:17 [Bug libstdc++/111638] New: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work redi at gcc dot gnu.org
@ 2023-11-11  0:43 ` cvs-commit at gcc dot gnu.org
  2023-11-12 21:38 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-11  0:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:898fd81b831c106859bc99e65c7c1cbb642320c8

commit r14-5342-g898fd81b831c106859bc99e65c7c1cbb642320c8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 29 14:29:16 2023 +0100

    libstdc++: Remove handling for underscore-prefixed libm functions
[PR111638]

    The checks in linkage.m4 try to support math functions prefixed with
    underscores, like _acosf and _isinf. However, that doesn't work because
    they're renamed to the standard names using a macro, but then <cmath>
    undefines that macro again.

    This simply removes everything related to those underscored functions.

    libstdc++-v3/ChangeLog:

            PR libstdc++/111638
            * config.h.in: Regenerate.
            * configure: Regenerate.
            * linkage.m4 (GLIBCXX_MAYBE_UNDERSCORED_FUNCS): Remove.
            (GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1): Do not check for _foo.
            (GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1): Likewise.
            (GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2): Likewise.
            (GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3): Likewise.
            (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2): Do not use
            GLIBCXX_MAYBE_UNDERSCORED_FUNCS.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/111638] GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work
  2023-09-29 13:17 [Bug libstdc++/111638] New: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work redi at gcc dot gnu.org
  2023-11-11  0:43 ` [Bug libstdc++/111638] " cvs-commit at gcc dot gnu.org
@ 2023-11-12 21:38 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-12 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for gcc 14.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-12 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-29 13:17 [Bug libstdc++/111638] New: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work redi at gcc dot gnu.org
2023-11-11  0:43 ` [Bug libstdc++/111638] " cvs-commit at gcc dot gnu.org
2023-11-12 21:38 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).