-
-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2142 from larskanis/cross-darwin
Cross compile for x86_64-darwin and arm64-darwin per rake-compiler-dock --- This requires latest rake-compiler-dock from master branch. **What problem is this PR intended to solve?** Fat binary gems for MacOS are currently built on MacOS native. This complicates the build and release cycle. It is desirable to build all binary gems per cross compiler. Related to #2079 **Have you included adequate test coverage?** No CI, but I tested the resulting `x86_64-darwin` gem on MacOS-10.14.4 with both the system ruby-2.3.7 (after extending the `required_ruby_version` of nokogiri) and ruby-2.7.2 installed per rvm. The Mac is running on https://github.com/foxlet/macOS-Simple-KVM . I'm unable to execute the `arm64-darwin` on any computer. I just did some static inspection of the built `nokogiri.bundle` file. **Does this change affect the behavior of either the C or the Java implementations?** C only.
- Loading branch information
Showing
10 changed files
with
223 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
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 https://github.com/sparklemotion/nokogiri/pull/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 <[email protected]> | ||
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) | ||
|
||
diff --git a/xpath.c b/xpath.c | ||
index 9f64ab9..5b6d999 100644 | ||
--- a/xpath.c | ||
+++ b/xpath.c | ||
@@ -509,11 +509,7 @@ xmlXPathInit(void) { | ||
*/ | ||
int | ||
xmlXPathIsNaN(double val) { | ||
-#ifdef isnan | ||
- return isnan(val); | ||
-#else | ||
return !(val == val); | ||
-#endif | ||
} | ||
|
||
/** | ||
@@ -524,15 +520,11 @@ xmlXPathIsNaN(double val) { | ||
*/ | ||
int | ||
xmlXPathIsInf(double val) { | ||
-#ifdef isinf | ||
- return isinf(val) ? (val > 0 ? 1 : -1) : 0; | ||
-#else | ||
if (val >= INFINITY) | ||
return 1; | ||
if (val <= -INFINITY) | ||
return -1; | ||
return 0; | ||
-#endif | ||
} | ||
|
||
#endif /* SCHEMAS or XPATH */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.