[MacPorts] #54820: missing std::trunc and other std:: math functions when building webkit2-gtk on 10.6 using macports-libsdtc++ and libgcc headers
MacPorts
noreply at macports.org
Tue Sep 12 05:18:40 UTC 2017
#54820: missing std::trunc and other std:: math functions when building webkit2-gtk
on 10.6 using macports-libsdtc++ and libgcc headers
-------------------------+-------------------------
Reporter: kencu | Owner:
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version:
Keywords: snowleopard | Port: webkit2-gtk
-------------------------+-------------------------
Sorry for the long title -- try to be precise. I recently fixed
`webkit2-gtk` to build on older systems, but it failed on the buildbot on
the setup described above, which I believe may have uncovered a `cmath`
flaw on that system. `10.6/libc++` worked fine, `10.6/macports-libstdc++`
did not.
Initially the error was a single missing definition for `std::trunc` but
when I edited that in the source file to `trunc()` a number of other
`std:: math` functions came up missing so it was a more general issue. I
then tried building with `gcc6` instead `clang-4.0`, but same exact error
in the same file (full log enclosed, clang-4.0 error was essentially
identical).
Looking through the math headers, the missing function was indeed
available in `/opt/local/include/gcc6/c++/cmath`, but guarded by this:
{{{
#ifdef _GLIBCXX_USE_C99_MATH_TR1
}}}
Adding that definition like so
{{{add_definitions(-D_GLIBCXX_USE_C99_MATH_TR1)}}} to the CMakeLists.txt
file quickly ran into errors for missing definitions for {{{llrint}}} and
similar long long definitions. This is exactly the same issue Jeremy had
to fix in the libc++ math headers on 10.6, I recalled.
I took the same block from Jeremy's clang/libc++ fix, and pasted it into
{{{/opt/local/include/gcc6/c++/cmath}}} like so:
{{{
....
#ifndef _GLIBCXX_CMATH
#define _GLIBCXX_CMATH 1
+# if __has_include(<Availability.h>)
+# include <Availability.h>
+# if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+# define __APPLE_BAD_MATH_H 1
+# else
+# define __APPLE_BAD_MATH_H 0
+# endif
+# else
+# define __APPLE_BAD_MATH_H 1
+# endif
+
+# if __APPLE_BAD_MATH_H
+/* These prototypes are incorrectly omitted from <math.h> on Snow Leopard
despite being available */
+extern "C" {
+ extern long long int llrintl(long double);
+ extern long long int llrint(double);
+ extern long long int llrintf(float);
+
+ extern long long int llroundl(long double);
+ extern long long int llround(double);
+ extern long long int llroundf(float);
+}
+# endif
+#endif // __APPLE__
// Get rid of those macros defined in <math.h> in lieu of real functions.
#undef abs
#undef div
....
}}}
and then webkit2-gtk proceeded to build through to completion.
1. I'm not fully clear why 10.6 would need
{{{-D_GLIBCXX_USE_C99_MATH_TR1}}} defined and not the others similarly
building with gcc6's cmath. I can't seem to find any test or reference for
this in the {{{webkit2-gtk}}} configure logic.
2. it appears 10.6 and lower will probably need Jeremy's fix as above in
{{{/opt/local/include/gcc6/c++/cmath}}}
These are easy enough to add, if this is indeed the right thing to do, in
the end.
--
Ticket URL: <https://trac.macports.org/ticket/54820>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list