Skip to content

Commit 3257d87

Browse files
committed
Merge pull request #13100 from dra27/zstd-runs
Fix detection of zstd when compiling with musl-gcc (cherry picked from commit d784a69)
1 parent 18c27bc commit 3257d87

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

configure

+84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+38
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,44 @@ AS_IF([test x"$with_zstd" != "xno"],
22342234
[[#include <zstd.h>]])],
22352235
[zstd_status="zstd library not found"])]))
22362236

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+
22372275
AS_IF([test x"$zstd_status" = "xok"],
22382276
[AC_MSG_NOTICE([compressed compilation artefacts supported])
22392277
internal_cppflags="$internal_cppflags $zstd_flags"

0 commit comments

Comments
 (0)