jq: set -D_REENTRANT for builds on darwin (#34691)

This commit is contained in:
David Zmick 2022-12-29 03:49:09 -06:00 committed by GitHub
parent b145085fff
commit ca6e178890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 51 deletions

View File

@ -1,48 +0,0 @@
diff --git a/src/builtin.c b/src/builtin.c
old mode 100644
new mode 100755
index c6c8c2e..e336472
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -185,7 +185,7 @@ static jv f_modf(jq_state *jq, jv input) {
return jv_array_append(ret, jv_number(i));
}
#endif
-#ifdef HAVE_LGAMMA_R
+#if defined(HAVE_LGAMMA_R) && !(defined(__APPLE__) && defined(__GNUC__) && !defined(_REENTRANT))
static jv f_lgamma_r(jq_state *jq, jv input) {
if (jv_get_kind(input) != JV_KIND_NUMBER) {
return type_error(input, "number required");
@@ -1581,7 +1581,7 @@ static const struct cfunction function_list[] = {
#ifdef HAVE_MODF
{(cfunction_ptr)f_modf,"modf", 1},
#endif
-#ifdef HAVE_LGAMMA_R
+#if defined(HAVE_LGAMMA_R) && !(defined(__APPLE__) && defined(__GNUC__) && !defined(_REENTRANT))
{(cfunction_ptr)f_lgamma_r,"lgamma_r", 1},
#endif
{(cfunction_ptr)f_plus, "_plus", 3},
diff --git a/src/builtin.c b/src/builtin.c
old mode 100644
new mode 100755
index c6c8c2e..e336472
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -185,7 +185,7 @@ static jv f_modf(jq_state *jq, jv input) {
return jv_array_append(ret, jv_number(i));
}
#endif
-#ifdef HAVE_LGAMMA_R
+#if defined(HAVE_LGAMMA_R) && !(defined(__APPLE__) && defined(__GNUC__) && !defined(_REENTRANT))
static jv f_lgamma_r(jq_state *jq, jv input) {
if (jv_get_kind(input) != JV_KIND_NUMBER) {
return type_error(input, "number required");
@@ -1581,7 +1581,7 @@ static const struct cfunction function_list[] = {
#ifdef HAVE_MODF
{(cfunction_ptr)f_modf,"modf", 1},
#endif
-#ifdef HAVE_LGAMMA_R
+#if defined(HAVE_LGAMMA_R) && !(defined(__APPLE__) && defined(__GNUC__) && !defined(_REENTRANT))
{(cfunction_ptr)f_lgamma_r,"lgamma_r", 1},
#endif
{(cfunction_ptr)f_plus, "_plus", 3},

View File

@ -6,7 +6,6 @@
import os.path
import sys
from spack.operating_systems.mac_os import macos_version
from spack.package import *
@ -22,8 +21,13 @@ class Jq(AutotoolsPackage):
depends_on("oniguruma")
depends_on("bison@3.0:", type="build")
if sys.platform == "darwin" and macos_version() >= Version("10.15"):
patch("builtinc.patch", when="@1.5:")
def configure_args(self):
# on darwin, required math functions like lgammaf_r are gated behind
# explicit reentrant flag
if sys.platform == "darwin":
return ["CPPFLAGS=-D_REENTRANT"]
else:
return []
@run_after("install")
@on_package_attributes(run_tests=True)