diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9889b242..568e1bcb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: python -m pip install --upgrade pip python -m pip install wheel setuptools python -m pip install mako - python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tinycc siphash24 + python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tccbox siphash24 - name: setup pyopencl on Linux + macOS if: ${{ matrix.os != 'windows-latest' }} diff --git a/sasmodels/kernel_header.c b/sasmodels/kernel_header.c index a65b1d7d..7ad27903 100644 --- a/sasmodels/kernel_header.c +++ b/sasmodels/kernel_header.c @@ -89,26 +89,8 @@ #else // !__cplusplus #include // C99 guarantees that int32_t types is here #include - #if defined(__TINYC__) - typedef int int32_t; - #include - // TODO: check isnan is correct - inline double _isnan(double x) { return x != x; } // hope this doesn't optimize away! - #undef isnan - #define isnan(x) _isnan(x) - // Defeat the double->float conversion since we don't have tgmath - inline SAS_DOUBLE trunc(SAS_DOUBLE x) { return x>=0?floor(x):-floor(-x); } - inline SAS_DOUBLE fmin(SAS_DOUBLE x, SAS_DOUBLE y) { return x>y ? y : x; } - inline SAS_DOUBLE fmax(SAS_DOUBLE x, SAS_DOUBLE y) { return x // C99 type-generic math, so sin(float) => sinf - #endif + #define NEED_ERF + #include // C99 type-generic math, so sin(float) => sinf // MSVC doesn't support C99, so no need for dllexport on C99 branch #define kernel #define SINCOS(angle,svar,cvar) do {const double _t_=angle; svar=sin(_t_);cvar=cos(_t_);} while (0) diff --git a/sasmodels/kerneldll.py b/sasmodels/kerneldll.py index 97e7b752..f919ce6c 100644 --- a/sasmodels/kerneldll.py +++ b/sasmodels/kerneldll.py @@ -81,9 +81,9 @@ import numpy as np # type: ignore try: - import tinycc + import tccbox except ImportError: - tinycc = None + tccbox = None from . import generate from .kernel import KernelModel, Kernel @@ -112,7 +112,7 @@ if "SAS_COMPILER" in os.environ: COMPILER = os.environ["SAS_COMPILER"] elif os.name == 'nt': - if tinycc is not None: + if tccbox is not None: COMPILER = "tinycc" elif "VCINSTALLDIR" in os.environ: # If vcvarsall.bat has been called, then VCINSTALLDIR is in the @@ -147,6 +147,7 @@ pass def compile_command(source, output): """unix compiler command""" + print(compiler + [source, "-o", output] + LIBS) return compiler + [source, "-o", output] + LIBS elif COMPILER == "msvc": # Call vcvarsall.bat before compiling to set path, headers, libs, etc. @@ -166,7 +167,18 @@ def compile_command(source, output): return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output] elif COMPILER == "tinycc": # TinyCC compiler. - CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split() + include = tccbox.tcc_dist_dir() + CC = [ + tccbox.tcc_bin_path(), + "-nostdinc", + "-std=c99", + f"-L{tccbox.tcc_lib_dir()}", + f"-L{joinpath(tccbox.tcc_lib_dir(), 'tcc')}", + f"-I{tccbox.tcc_dist_dir()}/include", + "-shared", + "-rdynamic", + "-Wall", + ] def compile_command(source, output): """tinycc compiler command""" return CC + [source, "-o", output] @@ -291,7 +303,7 @@ def make_dll(source, model_info, dtype=F64, system=False): # Comment the following to keep the generated C file. # Note: If there is a syntax error then compile raises an error # and the source file will not be deleted. - os.unlink(filename) + # os.unlink(filename) #print("saving compiled file in %r"%filename) else: logging.debug("make_dll: cache hit for %s", dll) diff --git a/setup.py b/setup.py index 1356c579..6d43e7b5 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def find_version(package): long_description = fid.read() if sys.platform=='win32' or sys.platform=='cygwin': - install_requires.append('tinycc') + install_requires.append('tccbox') setup( name='sasmodels',