mirror of https://github.com/exaloop/codon.git
Fix ABI incompatibilities (#119)
* Fix ABI incompatibilities * Fix codon-jit on macOSpull/121/head^2
parent
d49212373c
commit
ac68e1e6f1
|
@ -4,6 +4,7 @@ project(
|
||||||
VERSION "0.15.2"
|
VERSION "0.15.2"
|
||||||
HOMEPAGE_URL "https://github.com/exaloop/codon"
|
HOMEPAGE_URL "https://github.com/exaloop/codon"
|
||||||
DESCRIPTION "high-performance, extensible Python compiler")
|
DESCRIPTION "high-performance, extensible Python compiler")
|
||||||
|
set(CODON_JIT_PYTHON_VERSION "0.1.1")
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
|
||||||
"${PROJECT_SOURCE_DIR}/codon/config/config.h")
|
"${PROJECT_SOURCE_DIR}/codon/config/config.h")
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.py.in"
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.py.in"
|
||||||
|
@ -216,7 +217,7 @@ set(CODON_HPPFILES
|
||||||
codon/sir/var.h
|
codon/sir/var.h
|
||||||
codon/util/common.h
|
codon/util/common.h
|
||||||
extra/jupyter/jupyter.h
|
extra/jupyter/jupyter.h
|
||||||
extra/python/codon/jit.h)
|
codon/compiler/jit_extern.h)
|
||||||
set(CODON_CPPFILES
|
set(CODON_CPPFILES
|
||||||
codon/compiler/compiler.cpp
|
codon/compiler/compiler.cpp
|
||||||
codon/compiler/debug_listener.cpp
|
codon/compiler/debug_listener.cpp
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
__version__ = "0.1"
|
__version__ = "@CODON_JIT_PYTHON_VERSION@"
|
||||||
|
|
||||||
CODON_VERSION = "@PROJECT_VERSION@"
|
CODON_VERSION = "@PROJECT_VERSION@"
|
||||||
CODON_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@
|
CODON_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@
|
||||||
CODON_VERSION_MINOR = @PROJECT_VERSION_MINOR@
|
CODON_VERSION_MINOR = @PROJECT_VERSION_MINOR@
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "codon/sir/transform/manager.h"
|
#include "codon/sir/transform/manager.h"
|
||||||
#include "codon/sir/var.h"
|
#include "codon/sir/var.h"
|
||||||
|
|
||||||
#include "extra/python/codon/jit.h"
|
#include "codon/compiler/jit_extern.h"
|
||||||
|
|
||||||
namespace codon {
|
namespace codon {
|
||||||
namespace jit {
|
namespace jit {
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
include codon/jit.h
|
|
|
@ -3,7 +3,7 @@
|
||||||
from libcpp.string cimport string
|
from libcpp.string cimport string
|
||||||
from libcpp.vector cimport vector
|
from libcpp.vector cimport vector
|
||||||
|
|
||||||
cdef extern from "jit.h" namespace "codon::jit":
|
cdef extern from "codon/compiler/jit_extern.h" namespace "codon::jit":
|
||||||
cdef cppclass JIT
|
cdef cppclass JIT
|
||||||
cdef cppclass JITResult:
|
cdef cppclass JITResult:
|
||||||
void *result
|
void *result
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from Cython.Distutils import build_ext
|
from Cython.Distutils import build_ext
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
@ -45,18 +46,31 @@ print("Codon: " + str(codon_path))
|
||||||
|
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
linker_args = "-Wl,-rpath," + str(codon_path / "lib" / "codon")
|
libraries=["codonrt", "codonc"]
|
||||||
|
linker_args = ["-Wl,-rpath," + str(codon_path / "lib" / "codon")]
|
||||||
else:
|
else:
|
||||||
linker_args = "-Wl,-rpath=" + str(codon_path / "lib" / "codon")
|
libraries=["codonrt"]
|
||||||
|
linker_args = [
|
||||||
|
"-Wl,-rpath=" + str(codon_path / "lib" / "codon"),
|
||||||
|
"-Wl,--no-as-needed",
|
||||||
|
"-lcodonc",
|
||||||
|
]
|
||||||
|
|
||||||
|
# TODO: handle ABI changes better
|
||||||
|
out = subprocess.check_output(["nm", "-g", str(codon_path / "lib" / "codon" / "libcodonc.so")])
|
||||||
|
out = [i for i in out.decode(sys.stdout.encoding).split("\n") if "jitExecuteSafe" in i]
|
||||||
|
if out and "cxx11" not in out[0]:
|
||||||
|
print("CXX11 ABI not detected")
|
||||||
|
os.environ["CFLAGS"] = os.environ.get("CFLAGS", "") + " -D_GLIBCXX_USE_CXX11_ABI=0"
|
||||||
|
|
||||||
jit_extension = Extension(
|
jit_extension = Extension(
|
||||||
"codon.codon_jit",
|
"codon.codon_jit",
|
||||||
sources=["codon/jit.pyx", "codon/jit.pxd"],
|
sources=["codon/jit.pyx", "codon/jit.pxd"],
|
||||||
libraries=["codonc", "codonrt"],
|
libraries=libraries,
|
||||||
language="c++",
|
language="c++",
|
||||||
extra_compile_args=["-w", "-std=c++17"],
|
extra_compile_args=["-w"],
|
||||||
extra_link_args=[linker_args],
|
extra_link_args=linker_args,
|
||||||
|
include_dirs=[str(codon_path / "include")],
|
||||||
library_dirs=[str(codon_path / "lib" / "codon")],
|
library_dirs=[str(codon_path / "lib" / "codon")],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue