Permalink
Browse files

Misc windows fixes (#1261)

* Windows compile error in markup.c

* Fix a warning and bug in mingw builds of timer.c

* Fix some build settings for Windows platforms

Compiling with -fstack-protector was breaking Mingw builds.
Compiling with PCRE2 JIT was breaking Cygwin. Fixes #1257

* Add a --disable-jit option to configure to always disable JIT checks.
  • Loading branch information...
shawnw committed Oct 23, 2018
1 parent 8965e11 commit d4a0cb04537628759f48ac239c31e418d9be8989
Showing with 147 additions and 16 deletions.
  1. +109 −3 configure
  2. +28 −3 configure.in
  3. +4 −2 src/markup.c
  4. +6 −8 src/timer.c
112 configure
@@ -742,6 +742,7 @@ with_openssl
enable_sql
with_mysql
with_postgresql
enable_jit
enable_ipv6
enable_nls
enable_info_slave
@@ -1386,6 +1387,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-sql Don't use SQL support
--disable-jit Don't use JIT optimizations
--disable-ipv6 Don't use IPv6 networking
--disable-nls Don't use message-translation
--disable-info_slave Don't use a separate process for hostname lookups
@@ -4059,7 +4061,7 @@ fi
# Detects FreeBSD
# Detects OS
case "${build_os}" in
*freebsd*)
USING_FREEBSD=yes
@@ -4069,6 +4071,13 @@ case "${build_os}" in
;;
*openbsd*)
USING_OPENBSD=yes
;;
*mingw*)
USING_WINDOWS=yes
;;
*cygwin*)
USING_CYGWIN=yes
;;
esac
# Adds additional paths potentially needed or BSD compilation
@@ -4324,7 +4333,84 @@ done
for flag in -funsigned-char -fstack-protector -Wa,--noexecstack; do
for flag in -funsigned-char -Wa,--noexecstack; do
as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$CLANGFLAGS_$flag" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5
$as_echo_n "checking whether C compiler accepts $flag... " >&6; }
if eval \${$as_CACHEVAR+:} false; then :
$as_echo_n "(cached) " >&6
else
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS $CLANGFLAGS $flag"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$as_CACHEVAR=yes"
else
eval "$as_CACHEVAR=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
eval ac_res=\$$as_CACHEVAR
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then :
if ${CFLAGS+:} false; then :
case " $CFLAGS " in #(
*" $flag "*) :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5
(: CFLAGS already contains $flag) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append CFLAGS " $flag"
{ { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS\""; } >&5
(: CFLAGS="$CFLAGS") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else
CFLAGS=$flag
{ { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS\""; } >&5
(: CFLAGS="$CFLAGS") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
fi
else
:
fi
done
if test -z "$USING_WINDOWS"; then
# -fstack-protector always segfaults on MSYS2/Mingw-w64 builds.
for flag in -fstack-protector; do
as_CACHEVAR=`$as_echo "ax_cv_check_cflags_$CLANGFLAGS_$flag" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5
$as_echo_n "checking whether C compiler accepts $flag... " >&6; }
@@ -4395,6 +4481,7 @@ fi
done
fi
@@ -11075,7 +11162,26 @@ _ACEOF
### PCRE2 config
PCRE2_OPTIONS="--prefix=$(pwd)/pcre2/ --disable-shared --enable-never-backslash-C --enable-jit=auto"
# Check whether --enable-jit was given.
if test "${enable_jit+set}" = set; then :
enableval=$enable_jit; enable_jit=$enableval
else
enable_jit=yes
fi
PCRE2_OPTIONS="--prefix=$(pwd)/pcre2/ --disable-shared --enable-never-backslash-C"
if test "x${USING_CYGWIN}" = "xyes"; then
# pcre jit crashes Cygwin builds; don't use it there.
PCRE2_OPTIONS="${PCRE2_OPTIONS} --disable-jit"
else
# Otherwise use it if supported on this platform unless explicitly requested
# not to.
if test "x${enable_jit}" = "xyes"; then
PCRE2_OPTIONS="${PCRE2_OPTIONS} --enable-jit=auto"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuring PCRE2" >&5
$as_echo "$as_me: Configuring PCRE2" >&6;}
PCRE2_VERSION="pcre2-10.32"
@@ -52,7 +52,7 @@ fi
AC_PATH_PROG(GPERF, gperf)
# Detects FreeBSD
# Detects OS
case "${build_os}" in
*freebsd*)
USING_FREEBSD=yes
@@ -62,6 +62,13 @@ case "${build_os}" in
;;
*openbsd*)
USING_OPENBSD=yes
;;
*mingw*)
USING_WINDOWS=yes
;;
*cygwin*)
USING_CYGWIN=yes
;;
esac
# Adds additional paths potentially needed or BSD compilation
@@ -86,7 +93,11 @@ AX_IS_RELEASE([always])
AX_APPEND_COMPILE_FLAGS([-Werror=unknown-warning-option], [CLANGFLAGS])
AX_APPEND_COMPILE_FLAGS([-pipe -Og -march=native], [CFLAGS], [$CLANGFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wpedantic -Wno-comment -Wno-char-subscripts], [CFLAGS], [$CLANGFLAGS])
AX_APPEND_COMPILE_FLAGS([-funsigned-char -fstack-protector -Wa,--noexecstack], [CFLAGS], [$CLANGFLAGS])
AX_APPEND_COMPILE_FLAGS([-funsigned-char -Wa,--noexecstack], [CFLAGS], [$CLANGFLAGS])
if test -z "$USING_WINDOWS"; then
# -fstack-protector always segfaults on MSYS2/Mingw-w64 builds.
AX_APPEND_COMPILE_FLAGS([-fstack-protector], [CFLAGS], [$CLANGFLAGS])
fi
m4_define(AM_LDFLAGS)
AX_COMPILER_FLAGS_LDFLAGS()
LDFLAGS="$LDFLAGS $WARN_LDFLAGS"
@@ -383,7 +394,21 @@ AC_CHECK_FILE(/dev/urandom, [AC_DEFINE(HAVE_DEV_URANDOM)])
AX_ZONEINFO()
### PCRE2 config
PCRE2_OPTIONS="--prefix=$(pwd)/pcre2/ --disable-shared --enable-never-backslash-C --enable-jit=auto"
AC_ARG_ENABLE(jit, AS_HELP_STRING([--disable-jit],
[Don't use JIT optimizations]), enable_jit=$enableval, enable_jit=yes)
PCRE2_OPTIONS="--prefix=$(pwd)/pcre2/ --disable-shared --enable-never-backslash-C"
if test "x${USING_CYGWIN}" = "xyes"; then
# pcre jit crashes Cygwin builds; don't use it there.
PCRE2_OPTIONS="${PCRE2_OPTIONS} --disable-jit"
else
# Otherwise use it if supported on this platform unless explicitly requested
# not to.
if test "x${enable_jit}" = "xyes"; then
PCRE2_OPTIONS="${PCRE2_OPTIONS} --enable-jit=auto"
fi
fi
AC_MSG_NOTICE([Configuring PCRE2])
PCRE2_VERSION="pcre2-10.32"
PCRE2_TARBALL="${PCRE2_VERSION}.tar.gz"
@@ -7,8 +7,9 @@
*/
#include "copyrite.h"
#include "markup.h"
#ifdef WIN32
#include <Windows.h>
#endif
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -28,6 +29,7 @@
#include "mushsql.h"
#include "charconv.h"
#include "map_file.h"
#include "markup.h"
#define ANSI_BEGIN "\x1B["
#define ANSI_FINISH "m"
@@ -294,10 +294,7 @@ signal_cpu_limit(int signo)
}
#elif defined(WIN32)
#if _MSC_VER <= 1100 && !defined(UINT_PTR)
#define UINT_PTR UINT
#endif
UINT_PTR timer_id;
UINT_PTR timer_id = 0;
VOID CALLBACK
win32_timer(HWND hwnd __attribute__((__unused__)),
UINT uMsg __attribute__((__unused__)),
@@ -352,11 +349,12 @@ start_cpu_timer(void)
timer_set = 0;
}
#elif defined(WIN32) /* Windoze way */
if (options.queue_entry_cpu_time > 0)
timer_id = SetTimer(NULL, 0, (unsigned) options.queue_entry_cpu_time,
(TIMERPROC) win32_timer);
else
if (options.queue_entry_cpu_time > 0) {
timer_set = timer_id =
SetTimer(NULL, 0, (UINT) options.queue_entry_cpu_time, win32_timer);
} else {
timer_set = 0;
}
#endif /* HAVE_SETITIMER / WIN32 */
#endif /* PROFILING */
}

0 comments on commit d4a0cb0

Please sign in to comment.