Skip to content

Commit 7a1bdb7

Browse files
authored
Merge pull request #615 from SasView/tccbox
Use tccbox instead of tinycc
2 parents 8042f91 + d75198f commit 7a1bdb7

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
python -m pip install --upgrade pip
3737
python -m pip install wheel setuptools
3838
python -m pip install mako
39-
python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tinycc siphash24
39+
python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tccbox siphash24
4040
4141
- name: setup pyopencl on Linux + macOS
4242
if: ${{ matrix.os != 'windows-latest' }}

sasmodels/kernel_header.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,8 @@
8989
#else // !__cplusplus
9090
#include <inttypes.h> // C99 guarantees that int32_t types is here
9191
#include <stdio.h>
92-
#if defined(__TINYC__)
93-
typedef int int32_t;
94-
#include <math.h>
95-
// TODO: check isnan is correct
96-
inline double _isnan(double x) { return x != x; } // hope this doesn't optimize away!
97-
#undef isnan
98-
#define isnan(x) _isnan(x)
99-
// Defeat the double->float conversion since we don't have tgmath
100-
inline SAS_DOUBLE trunc(SAS_DOUBLE x) { return x>=0?floor(x):-floor(-x); }
101-
inline SAS_DOUBLE fmin(SAS_DOUBLE x, SAS_DOUBLE y) { return x>y ? y : x; }
102-
inline SAS_DOUBLE fmax(SAS_DOUBLE x, SAS_DOUBLE y) { return x<y ? y : x; }
103-
#define NEED_ERF
104-
#define NEED_EXPM1
105-
#define NEED_TGAMMA
106-
#define NEED_CBRT
107-
// expf missing from windows?
108-
#define expf exp
109-
#else
110-
#include <tgmath.h> // C99 type-generic math, so sin(float) => sinf
111-
#endif
92+
#define NEED_ERF
93+
#include <tgmath.h> // C99 type-generic math, so sin(float) => sinf
11294
// MSVC doesn't support C99, so no need for dllexport on C99 branch
11395
#define kernel
11496
#define SINCOS(angle,svar,cvar) do {const double _t_=angle; svar=sin(_t_);cvar=cos(_t_);} while (0)

sasmodels/kerneldll.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
import numpy as np # type: ignore
8282

8383
try:
84-
import tinycc
84+
import tccbox
8585
except ImportError:
86-
tinycc = None
86+
tccbox = None
8787

8888
from . import generate
8989
from .kernel import KernelModel, Kernel
@@ -112,7 +112,7 @@
112112
if "SAS_COMPILER" in os.environ:
113113
COMPILER = os.environ["SAS_COMPILER"]
114114
elif os.name == 'nt':
115-
if tinycc is not None:
115+
if tccbox is not None:
116116
COMPILER = "tinycc"
117117
elif "VCINSTALLDIR" in os.environ:
118118
# If vcvarsall.bat has been called, then VCINSTALLDIR is in the
@@ -166,7 +166,17 @@ def compile_command(source, output):
166166
return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output]
167167
elif COMPILER == "tinycc":
168168
# TinyCC compiler.
169-
CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split()
169+
CC = [
170+
tccbox.tcc_bin_path(),
171+
"-nostdinc",
172+
"-std=c99",
173+
f"-L{tccbox.tcc_lib_dir()}",
174+
f"-L{joinpath(tccbox.tcc_lib_dir(), 'tcc')}",
175+
f"-I{tccbox.tcc_dist_dir()}/include",
176+
"-shared",
177+
"-rdynamic",
178+
"-Wall",
179+
]
170180
def compile_command(source, output):
171181
"""tinycc compiler command"""
172182
return CC + [source, "-o", output]

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ def find_version(package):
2929
return version[1:-1]
3030
raise RuntimeError("Could not read version from %s/__init__.py"%package)
3131

32-
install_requires = ['numpy', 'scipy']
32+
install_requires = ['numpy', 'scipy', 'tccbox']
3333

3434
with open('README.rst') as fid:
3535
long_description = fid.read()
3636

37-
if sys.platform=='win32' or sys.platform=='cygwin':
38-
install_requires.append('tinycc')
39-
4037
setup(
4138
name='sasmodels',
4239
version=find_version('sasmodels'),

0 commit comments

Comments
 (0)