Skip to content

Commit 2ff0f93

Browse files
committed
Link against libopenblas.lib on Windows
Without a respective lib, linking would inevitably fail. We also add a check for cblas.h, and if either is not found, disable ext/tensor with a respective warning. See also <RubixML#22>.
1 parent 1f1e761 commit 2ff0f93

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

ext/config.w32

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
ARG_ENABLE("tensor", "enable tensor", "no");
22

33
if (PHP_TENSOR != "no") {
4-
EXTENSION("tensor", "tensor.c", null, "-I"+configure_module_dirname);
5-
ADD_SOURCES(configure_module_dirname + "/kernel", "main.c memory.c exception.c debug.c backtrace.c object.c array.c string.c fcall.c require.c file.c operators.c math.c concat.c variables.c filter.c iterator.c exit.c time.c", "tensor");
6-
/* PCRE is always included on WIN32 */
7-
AC_DEFINE("ZEPHIR_USE_PHP_PCRE", 1, "Whether PHP pcre extension is present at compile time");
8-
if (PHP_JSON != "no") {
9-
ADD_EXTENSION_DEP("tensor", "json");
10-
AC_DEFINE("ZEPHIR_USE_PHP_JSON", 1, "Whether PHP json extension is present at compile time");
4+
if (CHECK_LIB("libopenblas.lib", "tensor", PHP_TENSOR) &&
5+
CHECK_HEADER_ADD_INCLUDE("cblas.h", "CFLAGS_TENSOR")
6+
) {
7+
EXTENSION("tensor", "tensor.c", null, "-I"+configure_module_dirname);
8+
ADD_SOURCES(configure_module_dirname + "/kernel", "main.c memory.c exception.c debug.c backtrace.c object.c array.c string.c fcall.c require.c file.c operators.c math.c concat.c variables.c filter.c iterator.c exit.c time.c", "tensor");
9+
/* PCRE is always included on WIN32 */
10+
AC_DEFINE("ZEPHIR_USE_PHP_PCRE", 1, "Whether PHP pcre extension is present at compile time");
11+
if (PHP_JSON != "no") {
12+
ADD_EXTENSION_DEP("tensor", "json");
13+
AC_DEFINE("ZEPHIR_USE_PHP_JSON", 1, "Whether PHP json extension is present at compile time");
14+
}
15+
ADD_SOURCES(configure_module_dirname + "/include", "arithmetic.c comparison.c linear_algebra.c signal_processing.c settings.c", "tensor");
16+
ADD_SOURCES(configure_module_dirname + "/tensor", "algebraic.zep.c arithmetic.zep.c arraylike.zep.c comparable.zep.c special.zep.c statistical.zep.c trigonometric.zep.c tensor.zep.c vector.zep.c columnvector.zep.c matrix.zep.c settings.zep.c", "tensor");
17+
ADD_SOURCES(configure_module_dirname + "/tensor/exceptions", "tensorexception.zep.c invalidargumentexception.zep.c dimensionalitymismatch.zep.c runtimeexception.zep.c", "tensor");
18+
ADD_SOURCES(configure_module_dirname + "/tensor/decompositions", "cholesky.zep.c eigen.zep.c lu.zep.c svd.zep.c", "tensor");
19+
ADD_SOURCES(configure_module_dirname + "/tensor/reductions", "ref.zep.c rref.zep.c", "tensor");
20+
ADD_FLAG("CFLAGS_TENSOR", "/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL");
21+
ADD_FLAG("CFLAGS", "/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL");
22+
ADD_FLAG("LDFLAGS", "/LTCG");
23+
} else {
24+
WARNING("tensor not enabled; libraries and headers not found");
1125
}
12-
ADD_SOURCES(configure_module_dirname + "/include", "arithmetic.c comparison.c linear_algebra.c signal_processing.c settings.c", "tensor");
13-
ADD_SOURCES(configure_module_dirname + "/tensor", "algebraic.zep.c arithmetic.zep.c arraylike.zep.c comparable.zep.c special.zep.c statistical.zep.c trigonometric.zep.c tensor.zep.c vector.zep.c columnvector.zep.c matrix.zep.c settings.zep.c", "tensor");
14-
ADD_SOURCES(configure_module_dirname + "/tensor/exceptions", "tensorexception.zep.c invalidargumentexception.zep.c dimensionalitymismatch.zep.c runtimeexception.zep.c", "tensor");
15-
ADD_SOURCES(configure_module_dirname + "/tensor/decompositions", "cholesky.zep.c eigen.zep.c lu.zep.c svd.zep.c", "tensor");
16-
ADD_SOURCES(configure_module_dirname + "/tensor/reductions", "ref.zep.c rref.zep.c", "tensor");
17-
ADD_FLAG("CFLAGS_TENSOR", "/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL");
18-
ADD_FLAG("CFLAGS", "/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL");
19-
ADD_FLAG("LDFLAGS", "/LTCG");
2026
}

0 commit comments

Comments
 (0)