summaryrefslogtreecommitdiff
path: root/erts/configure.in
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2020-07-08 17:18:54 +0200
committerLukas Larsson <lukas@erlang.org>2020-09-22 07:51:41 +0200
commitb165524c73283edbe8576fd9b8a5ed9ead38364f (patch)
tree668529c86460122ef0a0312ee16d990838bf7919 /erts/configure.in
parente51cbb1dc9001eb03db2bfe527ff467b841e45b5 (diff)
downloaderlang-b165524c73283edbe8576fd9b8a5ed9ead38364f.tar.gz
erts: Implement the BeamAsm JIT
Co-authored-by: John Högberg <john@erlang.org> Co-authored-by: Dan Gudmundsson <dgud@erlang.org> Co-authored-by: Björn Gustavsson <bjorn@erlang.org>
Diffstat (limited to 'erts/configure.in')
-rw-r--r--erts/configure.in177
1 files changed, 160 insertions, 17 deletions
diff --git a/erts/configure.in b/erts/configure.in
index 099784f3b1..f5306581b5 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -112,6 +112,7 @@ AS_HELP_STRING([--enable-bootstrap-only],
with_ssl=no
with_ssl_zlib=no
enable_hipe=no
+ enable_jit=no
enable_sctp=no
fi
])
@@ -177,12 +178,26 @@ AS_HELP_STRING([--disable-sctp], [disable sctp support]),
AC_ARG_ENABLE(hipe,
AS_HELP_STRING([--enable-hipe], [enable hipe support])
-AS_HELP_STRING([--disable-hipe], [disable hipe support]))
+AS_HELP_STRING([--disable-hipe], [disable hipe support]),
+ [ case "$enableval" in
+ no) enable_hipe=no ;;
+ *) enable_hipe=yes ;;
+ esac
+],enable_hipe=auto)
AC_ARG_ENABLE(native-libs,
AS_HELP_STRING([--enable-native-libs],
[compile Erlang libraries to native code]))
+AC_ARG_ENABLE(jit,
+AS_HELP_STRING([--enable-jit], [enable JIT support])
+AS_HELP_STRING([--disable-jit], [disable JIT support]),
+ [ case "$enableval" in
+ no) enable_jit=no ;;
+ *) enable_jit=yes ;;
+ esac
+],enable_jit=auto)
+
AC_ARG_ENABLE(fp-exceptions,
AS_HELP_STRING([--enable-fp-exceptions],
[use hardware floating point exceptions (default if hipe enabled)]),
@@ -704,6 +719,9 @@ else
fi
fi
+dnl Disable pgo for now
+USE_PGO=false
+
AC_SUBST(USE_PGO)
AC_SUBST(PROFILE_COMPILER)
@@ -2852,6 +2870,14 @@ if test X${enable_hipe} != Xno; then
AC_MSG_WARN([HiPE disabled due to lack of mprotect()])
fi
fi
+ if test -z "$M4"; then
+ if test X${enable_hipe} = Xyes; then
+ AC_MSG_ERROR([HiPE needs m4])
+ else
+ enable_hipe=no
+ AC_MSG_NOTICE([HiPE disabled as no valid m4 is found in PATH])
+ fi
+ fi
AC_MSG_CHECKING([for safe signal delivery])
AC_TRY_COMPILE([#include <signal.h>],
[#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__)
@@ -2865,22 +2891,115 @@ if test X${enable_hipe} != Xno; then
#error "HiPE does not work without a libc that can guarantee that sigaltstack works"
#endif /* !(__GLIBC__ || __DARWIN__ || __NetBSD__ || __FreeBSD__ || __sun__) */],
[AC_MSG_RESULT([yes])],
- [enable_hipe=no
- AC_MSG_RESULT([no, musl probably used. Need glibc to work properly])
- AC_MSG_WARN([HiPE disabled due to lack of safe signal delivery])])
+ [if test X${enable_hipe} = Xyes; then
+ AC_MSG_ERROR([HiPE needs glibc to work properly])
+ else
+ enable_hipe=no
+ AC_MSG_RESULT([no, musl probably used. Need glibc to work properly])
+ AC_MSG_WARN([HiPE disabled due to lack of safe signal delivery])
+ fi])
+ case "$ARCH-$OPSYS" in
+ x86-linux|amd64-linux|x86-darwin*|amd64-darwin*|ppc-linux|ppc64-linux|ppc-darwin|arm-linux|amd64-freebsd|x86-freebsd|x86-sol2|amd64-sol2|ultrasparc-linux)
+ ;;
+ *)
+ if test X${enable_hipe} = Xyes; then
+ AC_MSG_ERROR([HiPE is not supported on $ARCH-$OPSYS])
+ else
+ enable_hipe=no
+ AC_MSG_WARN([HiPE disabled due to lack to support on $ARCH-$OPSYS])
+ fi
+ ;;
+ esac
+fi
+
+dnl Test if JIT can be enabled
+if test ${enable_jit} != no; then
+ case "$ARCH" in
+ amd64)
+ ;;
+ *)
+ if test ${enable_jit} = yes; then
+ AC_MSG_ERROR([JIT only works on x86 64-bit])
+ else
+ enable_jit=no
+ AC_MSG_WARN([JIT disabled due to lack to support on $ARCH-$OPSYS])
+ fi
+ ;;
+ esac
+
+ if test ${enable_jit} != no; then
+ if test "$CXX" != false; then
+ AC_LANG_PUSH(C++)
+ old_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS -std=c++17"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([],
+ [#if __cplusplus < 201703L
+ #error "Needs C++17 compiler"
+ #endif])],
+ [AC_MSG_CHECKING([for C++17 support])
+ AC_MSG_RESULT([yes])
+ HAVE_CXX17=true],
+ [AC_MSG_CHECKING([for C++17 support])
+ AC_MSG_RESULT([no])
+ HAVE_CXX17=false])
+ AC_LANG_POP()
+ fi
+ if test "$CXX" = false -o "$HAVE_CXX17" = false; then
+ if test ${enable_jit} = yes; then
+ AC_MSG_ERROR([JIT needs a C++ compiler with C++17 support])
+ else
+ enable_jit=no
+ cat >> $ERL_TOP/erts/CONF_INFO <<EOF
+
+ JIT disabled due to lack of compiler with C++17 support
+EOF
+ AC_MSG_WARN([JIT disable due to lack of C++ compiler with C++17 support])
+ fi
+ fi
+ fi
+
+ if test ${enable_jit} != no -a "$OPSYS" != win32; then
+ AC_MSG_CHECKING([for mprotect with PROT_WRITE|PROT_EXEC support]);
+ if test "$cross_compiling" != yes; then
+ AC_TRY_RUN(
+ [#include <stdlib.h>
+ #include <sys/mman.h>
+ #include <stdio.h>
+ #include <errno.h>
+ int main(void) {
+ void *memory = (void*)(((long)malloc(4096<<2)) & ~4095);
+ int res = mprotect(memory, 4096, PROT_EXEC | PROT_READ | PROT_WRITE);
+ perror("mprotect failed: ");
+ return res;
+ }
+ ], [AC_MSG_RESULT(yes); have_prot_exec=yes], [AC_MSG_RESULT(no)])
+ if test "$have_prot_exec" != yes; then
+ if test ${enable_jit} = yes; then
+ AC_MSG_ERROR([JIT needs mprotect(WRITE|EXEC) to work])
+ else
+ enable_jit=no
+ cat >> $ERL_TOP/erts/CONF_INFO <<EOF
+
+ JIT disabled due to mprotect(WRITE|EXEC) not working
+EOF
+ AC_MSG_WARN([JIT disable due to mprotect(WRITE|EXEC) not working])
+ fi
+ fi
+ else
+ AC_MSG_RESULT(cross, guessed yes)
+ fi
+ fi
+
+ if test ${enable_jit} != no; then
+ enable_jit=yes
+ fi
fi
-dnl check to auto-enable hipe here...
if test "$cross_compiling" != "yes" && test X${enable_hipe} != Xno; then
if test -z "$M4"; then
- enable_hipe=no
- AC_MSG_NOTICE([HiPE disabled as no valid m4 is found in PATH])
- else
- case "$ARCH-$OPSYS" in
- x86-linux|amd64-linux|x86-darwin*|amd64-darwin*|ppc-linux|ppc64-linux|ppc-darwin|arm-linux|amd64-freebsd|x86-freebsd|x86-sol2|amd64-sol2|ultrasparc-linux)
- enable_hipe=yes
- ;;
- esac
+ enable_hipe=no
+ AC_MSG_NOTICE([HiPE disabled as no valid m4 is found in PATH])
fi
fi
@@ -2909,6 +3028,20 @@ AC_MSG_RESULT([unreliable])
AC_DEFINE(NO_FPE_SIGNALS,[],[Define if floating points exceptions are non-existing/not reliable])
dnl
+dnl Check if the `perf` profiler is supported. At the moment it assumes it
+dnl always works on Linux as we're not dependent on it; this is only used to
+dnl to control whether we generate `perf`-compatible memory maps.
+dnl
+case $OPSYS in
+ linux*)
+ AC_DEFINE(HAVE_LINUX_PERF_SUPPORT, 1,
+ [Define if the targeted system supports the `perf` profiler])
+ ;;
+ *)
+ ;;
+esac
+
+dnl
dnl Some operating systems allow you to redefine FD_SETSIZE to be able
dnl to select on more than the default number of file descriptors.
dnl We first discovered this in BSD/OS where the default is ridiculously
@@ -2952,11 +3085,7 @@ if test X${enable_hipe} = Xyes; then
AC_MSG_WARN([HiPE is not supported in 64-bit builds])
else
HIPE_ENABLED=yes
- AC_DEFINE(HIPE,[1],[Define to enable HiPE])
HIPE_HELPERS="xmerl syntax_tools edoc"
- ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS hipe"
- AC_MSG_NOTICE([Enable exec_alloc for hipe code allocation])
- ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS exec_alloc"
fi
fi
AC_SUBST(HIPE_HELPERS)
@@ -2997,6 +3126,20 @@ EOF
fi
AC_SUBST(NATIVE_LIBS_ENABLED)
+JIT_ENABLED=
+FLAVORS="emu jit"
+# Enable jit
+if test X${enable_jit} = Xyes; then
+ JIT_ENABLED=yes
+ PRIMARY_FLAVOR=jit
+else
+ PRIMARY_FLAVOR=emu
+fi
+
+AC_SUBST(JIT_ENABLED)
+AC_SUBST(PRIMARY_FLAVOR)
+AC_SUBST(FLAVORS)
+
#
# Check for working poll().
#