diff options
author | Joel Brobecker <brobecker@adacore.com> | 2023-06-16 03:23:44 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-06-16 03:23:44 -0300 |
commit | c6c428196d4c76208a0d34aacfa80b57a20f5097 (patch) | |
tree | 5ef799a407d2b113cc3812e8785f635bd180fb2d /gcc | |
parent | 57446d1bc9757ee1fb030600d38fa9487231f2a4 (diff) | |
download | gcc-c6c428196d4c76208a0d34aacfa80b57a20f5097.zip gcc-c6c428196d4c76208a0d34aacfa80b57a20f5097.tar.gz gcc-c6c428196d4c76208a0d34aacfa80b57a20f5097.tar.bz2 |
libstdc++-v3: do not duplicate some math functions when using newlib
When running the libstdc++ testsuite on AArch64 RTEMS, we noticed
that about 25 tests are failing during the link, due to the "sqrtl"
function being defined twice:
- once inside RTEMS' libm;
- once inside our libstdc++.
One test that fails, for instance, would be 26_numerics/complex/13450.cc.
In comparing libm and libstdc++, we found that libstc++ also
duplicates "hypotf", and "hypotl".
For "sqrtl" and "hypotl", the symbosl come a unit called
from math_stubs_long_double.cc, while "hypotf" comes from
the equivalent unit for the float version, called math_stubs_float.cc.
Those units are always compiled in libstdc++ and provide our own
version of various math routines when those are missing from
the target system. The definition of those symbols is predicated
on the existance of various macros provided by c++config.h, which
themselves are predicated by the corresponding HAVE_xxx macros
in config.h.
One key element behind what's happening, here, is that the target
uses newlib, and therefore GCC was configured --with-newlib.
The section of libstdc++v3's configure script that handles which math
functions are available has a newlib-specific section, and that
section provides a hardcoded list of symbols.
For "hypotf", this commit fixes the issue by doing the same
as for the other routines already declared in that section.
I verified by inspection in the newlib code that this function
should always be present, so hardcoding it in our configure
script should not be an issue.
For the math routines handling doubles ("sqrtl" and "hypotl"),
however, I do not believe we can assume that newlib's libm
will always provide them. Therefore, this commit fixes that
part of the issue by ading a compile-check for "sqrtl" and "hypotl".
And while at it, we also include checks for all the other math
functions that math_stubs_long_double.cc re-implements, allowing
us to be resilient to future newlib enhancements adding support
for more functions.
libstdc++-v3/ChangeLog:
* configure.ac ["x${with_newlib}" = "xyes"]: Define
HAVE_HYPOTF. Add compile-checks for various long double
math functions as well.
* configure: Regenerate.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions