Skip to content

Commit db8eac0

Browse files
committed
[GR-16310] Ensure compatibility with musl libc 1.1.21.
PullRequest: graalpython/536
2 parents 9989c3a + 94dc0ca commit db8eac0

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,15 @@ PyObject* PyTruffle_Unicode_FromFormat(const char* fmt, int s, void* v0, void* v
138138
case 19: v19 = value; break; \
139139
}
140140

141-
char* fmtcpy = strdup(fmt);
141+
size_t fmt_size = strlen(fmt) + 1;
142+
// n.b. avoid using 'strdup' for compatiblity with MUSL libc
143+
char* fmtcpy = (char*) malloc(fmt_size*sizeof(char));
142144
char* c = fmtcpy;
143145
char* allocated;
144146
int cnt = 0;
145147

148+
memcpy(fmtcpy, fmt, fmt_size);
149+
146150
while (c[0] && cnt < s) {
147151
if (c[0] == '%') {
148152
switch (c[1]) {

graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,42 @@ def pandas(*args):
376376
377377
dinfo->abstime = (double)(hour * 3600 + minute * 60) + second;
378378
379+
diff --git a/pandas/io/msgpack/_packer.cpp b/pandas/io/msgpack/_packer.cpp
380+
index 8b5b382..7544707 100644
381+
--- a/pandas/io/msgpack/_packer.cpp
382+
+++ b/pandas/io/msgpack/_packer.cpp
383+
@@ -477,10 +477,7 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc
384+
(sizeof(type) == sizeof(Py_ssize_t) &&\\
385+
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\\
386+
v == (type)PY_SSIZE_T_MAX))) )
387+
-#if defined (__cplusplus) && __cplusplus >= 201103L
388+
- #include <cstdlib>
389+
- #define __Pyx_sst_abs(value) std::abs(value)
390+
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
391+
+#if SIZEOF_INT >= SIZEOF_SIZE_T
392+
#define __Pyx_sst_abs(value) abs(value)
393+
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
394+
#define __Pyx_sst_abs(value) labs(value)
395+
diff --git a/pandas/io/msgpack/_unpacker.cpp b/pandas/io/msgpack/_unpacker.cpp
396+
index fa08f53..49f3bf3 100644
397+
--- a/pandas/io/msgpack/_unpacker.cpp
398+
+++ b/pandas/io/msgpack/_unpacker.cpp
399+
@@ -477,10 +477,7 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc
400+
(sizeof(type) == sizeof(Py_ssize_t) &&\\
401+
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\\
402+
v == (type)PY_SSIZE_T_MAX))) )
403+
-#if defined (__cplusplus) && __cplusplus >= 201103L
404+
- #include <cstdlib>
405+
- #define __Pyx_sst_abs(value) std::abs(value)
406+
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
407+
+#if SIZEOF_INT >= SIZEOF_SIZE_T
408+
#define __Pyx_sst_abs(value) abs(value)
409+
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
410+
#define __Pyx_sst_abs(value) labs(value)
411+
379412
"""
380413
cflags = "-allowcpp" if sys.implementation.name == "graalpython" else ""
381-
install_from_url("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz", patch=patch, extra_opts=args, cflags=cflags)
414+
install_from_url("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz", patch=patch, extra_opts=args, add_cflags=cflags)
382415

383416
return locals()
384417

@@ -391,7 +424,7 @@ def xit(msg, status=-1):
391424
exit(-1)
392425

393426

394-
def install_from_url(url, patch=None, extra_opts=[], cflags=""):
427+
def install_from_url(url, patch=None, extra_opts=[], add_cflags=""):
395428
name = url[url.rfind("/")+1:]
396429
tempdir = tempfile.mkdtemp()
397430

@@ -403,6 +436,10 @@ def install_from_url(url, patch=None, extra_opts=[], cflags=""):
403436
elif url.startswith("https://") and "HTTPS_PROXY" in env:
404437
curl_opts += ["--proxy", env["HTTPS_PROXY"]]
405438

439+
# honor env var 'CFLAGS' and 'CPPFLAGS'
440+
cppflags = os.environ.get("CPPFLAGS", "")
441+
cflags = "-v " + os.environ.get("CFLAGS", "") + ((" " + add_cflags) if add_cflags else "")
442+
406443
system("curl %s -o %s/%s %s" % (" ".join(curl_opts), tempdir, name, url))
407444
if name.endswith(".tar.gz"):
408445
system("tar xzf %s/%s -C %s" % (tempdir, name, tempdir))
@@ -420,7 +457,7 @@ def install_from_url(url, patch=None, extra_opts=[], cflags=""):
420457
user_arg = "--user"
421458
else:
422459
user_arg = ""
423-
system("cd %s/%s; %s %s setup.py install %s %s" % (tempdir, bare_name, "CFLAGS=%s" % cflags if cflags else "", sys.executable, user_arg, " ".join(extra_opts)))
460+
system("cd %s/%s; %s %s %s setup.py install %s %s" % (tempdir, bare_name, 'CFLAGS="%s"' % cflags if cflags else "", 'CPPFLAGS="%s"' % cppflags if cppflags else "", sys.executable, user_arg, " ".join(extra_opts)))
424461

425462

426463
def install_from_pypi(package, extra_opts=[]):

0 commit comments

Comments
 (0)