@@ -2234,6 +2234,44 @@ AS_IF([test x"$with_zstd" != "xno"],
2234
2234
[ [ #include <zstd.h>] ] ) ] ,
2235
2235
[ zstd_status="zstd library not found"] ) ] ) )
2236
2236
2237
+ # When building the mingw-w64 port in Cygwin, it is very easy to have the
2238
+ # library available, but not have the DLL in PATH. This then causes the build to
2239
+ # fail as soon as ocamlrun is first executed. This check avoids automatically
2240
+ # enabling zstd when the resulting executable doesn't actually work.
2241
+ AS_CASE ( [ $host] ,
2242
+ [ *-w64-mingw32*|*-pc-windows] ,
2243
+ [ check_zstd_runs=$host_runnable] ,
2244
+ [ check_zstd_runs=false] )
2245
+
2246
+ AS_IF ( [ test x"$zstd_status" = "xok"] ,[
2247
+ AC_MSG_CHECKING ( [ whether programs can be linked with zstd] )
2248
+ OCAML_CC_SAVE_VARIABLES
2249
+ LIBS="$LIBS $zstd_libs"
2250
+ CFLAGS="$CFLAGS $zstd_flags"
2251
+ AC_LINK_IFELSE (
2252
+ [ AC_LANG_SOURCE ( [ [
2253
+ #include <zstd.h>
2254
+ int main(void) {
2255
+ return (ZSTD_versionNumber() == 0);
2256
+ }
2257
+ ] ] ) ] ,
2258
+ [ AC_MSG_RESULT ( [ yes] )
2259
+ AC_MSG_CHECKING ( [ whether programs linked with zstd can execute] )
2260
+ AS_IF ( [ $check_zstd_runs] ,
2261
+ [ AS_IF ( [ ac_fn_c_try_run LINENO] ,
2262
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
2263
+ [ AC_MSG_RESULT ( [ no] )
2264
+ zstd_libs=''
2265
+ zstd_flags=''
2266
+ zstd_status=\
2267
+ "programs linked with zstd do not appear to be executable."] ) ] ,
2268
+ [ AC_MSG_RESULT ( [ skipped] ) ] ) ] ,
2269
+ [ AC_MSG_RESULT ( [ no] )
2270
+ zstd_libs=''
2271
+ zstd_flags=''
2272
+ zstd_status="zstd found, but programs cannot be linked with it."] )
2273
+ OCAML_CC_RESTORE_VARIABLES] )
2274
+
2237
2275
AS_IF ( [ test x"$zstd_status" = "xok"] ,
2238
2276
[ AC_MSG_NOTICE ( [ compressed compilation artefacts supported] )
2239
2277
internal_cppflags="$internal_cppflags $zstd_flags"
0 commit comments