From 84748ba1d2b97b5f977ebc6e141b1babd793f636 Mon Sep 17 00:00:00 2001 From: Cambridge Yang Date: Sun, 3 Oct 2021 16:36:33 -0400 Subject: [PATCH 1/3] fix macOS barvinok build --- build-with-barvinok.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/build-with-barvinok.sh b/build-with-barvinok.sh index 62b30411..69cd03c5 100755 --- a/build-with-barvinok.sh +++ b/build-with-barvinok.sh @@ -7,9 +7,10 @@ BUILD_DIR=$(mktemp -d -t islpy-barvinok-build-XXXXXXX) echo "BUILDING IN $BUILD_DIR" if test "$1" = ""; then - echo "usage: $0 PREFIX_DIR" + echo "usage: $0 PREFIX_DIR [GMP_PREFIX_DIR]" fi PREFIX="$1" +GMP_PREFIX="${2:-$PREFIX}" NTL_VER="10.5.0" BARVINOK_GIT_REV="barvinok-0.41.5" NPROCS=6 @@ -38,7 +39,7 @@ if true; then curl -L -O --insecure http://shoup.net/ntl/ntl-"$NTL_VER".tar.gz tar xfz ntl-"$NTL_VER".tar.gz cd "$BUILD_DIR/ntl-$NTL_VER/src" - ./configure NTL_GMP_LIP=on PREFIX="$PREFIX" TUNE=x86 SHARED=on + ./configure NTL_GMP_LIP=on DEF_PREFIX="$PREFIX" GMP_PREFIX="$GMP_PREFIX" TUNE=x86 SHARED=on make -j$NPROCS make install @@ -62,10 +63,15 @@ if true; then ./configure \ --prefix="$PREFIX" \ --with-ntl-prefix="$PREFIX" \ + --with-gmp-prefix="$GMP_PREFIX" \ --enable-shared-barvinok \ --with-pet=no - make -j$NPROCS + BARVNOK_ADDITIONAL_MAKE_ARGS="" + if [ "$(uname)" == "Darwin" ]; then + BARVNOK_ADDITIONAL_MAKE_ARGS=CFLAGS="-Wno-error=implicit-function-declaration" + fi + make $BARVNOK_ADDITIONAL_MAKE_ARGS -j$NPROCS make install fi @@ -77,6 +83,10 @@ cd islpy --isl-inc-dir=$PREFIX/include \ --isl-lib-dir=$PREFIX/lib \ --use-barvinok -CC=g++ LDSHARED="g++ -shared" python setup.py install +CPP_LD_EXTRA_FLAGS="" +if [[ "$(uname)" == "Darwin" ]]; then + CPP_LD_EXTRA_FLAGS="-undefined dynamic_lookup" +fi +CC=g++ LDSHARED="g++ -shared ${CPP_LD_EXTRA_FLAGS}" python setup.py install # vim: sw=2 From d1766361b45660b02130dac2389a342b3bf92630 Mon Sep 17 00:00:00 2001 From: Cambridge Yang Date: Sun, 17 Oct 2021 23:41:09 -0400 Subject: [PATCH 2/3] fix invalid python function name --- gen_wrap.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gen_wrap.py b/gen_wrap.py index 61910f22..ab226de8 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -656,6 +656,9 @@ def parse_decl(self, decl): if name in PYTHON_RESERVED_WORDS: name = name + "_" + if name[0].isdigit(): + name = "fun_" + name + if class_name == "options": assert name.startswith("set_") or name.startswith("get_"), (name, c_name) name = f"{name[:4]}option_{name[4:]}" From f93f38ac7934eb528e2533ea4ab9e09477e7c7ec Mon Sep 17 00:00:00 2001 From: Cambridge Yang Date: Tue, 19 Oct 2021 11:38:08 -0400 Subject: [PATCH 3/3] special casing for invalid py identifier --- gen_wrap.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gen_wrap.py b/gen_wrap.py index ab226de8..f1089e25 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -412,6 +412,11 @@ def on_directive_handle(self, directive, toks, ifpassthru, precedingtoks): # {{{ FunctionData (includes parser) class FunctionData: + + INVALID_PY_IDENTIFIER_RENAMING_MAP = { + "2exp": "two_exp" + } + def __init__(self, include_dirs): self.classes_to_methods = {} self.include_dirs = include_dirs @@ -656,8 +661,12 @@ def parse_decl(self, decl): if name in PYTHON_RESERVED_WORDS: name = name + "_" + name = self.INVALID_PY_IDENTIFIER_RENAMING_MAP.get(name, name) + if name[0].isdigit(): - name = "fun_" + name + print(f"SKIP: {class_name} {name} " + "(unhandled invalid python identifier)") + return if class_name == "options": assert name.startswith("set_") or name.startswith("get_"), (name, c_name)