Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid calls to
isinf
or isnan
for musl support
This patch is a result of rake-compiler-dock using centos 7 (manylinux2014) to cross-compile. Centos, for reasons I have not been able to discern, implements `isnan` and `isinf` as a function and not as a macro. Debian knows how to resolve that function at dynamic-link time (despite using a macro at compile time), but musl-based systems (like alpine) do not. Running `nm` on nokogiri.so created on such a centos system shows: ``` U __isinf@@GLIBC_2.2.5 U __isnan@@GLIBC_2.2.5 ``` (see #2142 for more info) This patch avoids using glibc's `isnan` and `isinf` calls, instead using libxml2's fallback implementation. There's history here, see libxml2 commit 8813f39: commit 8813f39 Author: Nick Wellnhofer <wellnhofer@aevum.de> Date: 2017-09-21 00:11:26 +0200 Simplify XPath NaN, inf and -0 handling Use C99 macros NAN, INFINITY, isnan, isinf. If they're not available: - Assume that (0.0 / 0.0) generates a NaN and !(x == x) tests for NaN. - Use C89's HUGE_VAL for INFINITY. Remove manual handling of NaN, infinity and negative zero in functions xmlXPathValueFlipSign and xmlXPathDivValues. Remove xmlXPathGetSign. All the tests for negative zero can be replaced with a test for negative or positive zero. Simplify xmlXPathRoundFunction. Remove Trio dependency. This should work on IEEE 754 compliant implementations even if the C99 macros aren't available, but will likely break some ancient platforms. If problems arise, my plan is to port the relevant trionan.c solution to xpath.c. Note that non-compliant implementations are impossible to fully support, anyway, since XPath requires IEEE 754. This patch would be unnecessary if any of the following was true: * centos implements these as macros, and doesn't generate an unresolved symbol for either in the shared library * we had a way to ensure `__isinf` and `__isnan` resolve on musl (e.g., we implement them locally)
- Loading branch information