From 843824c94e2c5d9518e30a54c32b1dcf81154a7b Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 11 Dec 2019 13:58:46 -0700 Subject: [PATCH] build with musl Skip libunwind support for musl-based Linux environments, and avoid `__FLOAT_BITS`, etc., in xform. --- racket/collects/compiler/private/xform.rkt | 1 + racket/src/cfg-racket | 32 ++++++++++++++++++++++ racket/src/racket/configure.ac | 19 +++++++++++++ racket/src/racket/mzconfig.h.in | 3 ++ racket/src/racket/sconfig.h | 8 ++++-- 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/racket/collects/compiler/private/xform.rkt b/racket/collects/compiler/private/xform.rkt index 1a23cde8a2..a48753d9b8 100644 --- a/racket/collects/compiler/private/xform.rkt +++ b/racket/collects/compiler/private/xform.rkt @@ -915,6 +915,7 @@ __inline_isnanl __inline_isnan __inline_signbit __inline_signbitf __inline_signbitd __inline_signbitl __builtin_popcount __builtin_clz __builtin_isnan __builtin_isinf __builtin_signbit __builtin_signbitf __builtin_signbitd __builtin_signbitl __builtin_isinf_sign __builtin_trap + __FLOAT_BITS __DOUBLE_BITS _Generic __inline_isinff __inline_isinfl __inline_isinfd __inline_isnanf __inline_isnand __inline_isinf floor floorl ceil ceill round roundl fmod fmodl modf modfl fabs fabsl __maskrune _errno __errno diff --git a/racket/src/cfg-racket b/racket/src/cfg-racket index a02a288dc0..c1f618fbfc 100755 --- a/racket/src/cfg-racket +++ b/racket/src/cfg-racket @@ -3419,6 +3419,7 @@ mzrt_needs_pthread=yes skip_iconv_check=no check_page_size=yes try_no_nullability_completeness=no +check_for_unwind=no if test "${enable_cify}" = "yes" ; then STARTUP_AS_BYTECODE=_bytecode @@ -4866,6 +4867,7 @@ case "$host_os" in x86_64) enable_parallel_by_default=yes CGC_X86_64="1" + check_for_unwind=REG_RSP ;; ppc|powerpc) ;; @@ -4875,6 +4877,7 @@ case "$host_os" in ;; i386|i486|i586|i686) enable_parallel_by_default=yes + check_for_unwind=REG_ESP ;; arm*) EXTRA_GMP_OBJ="gmp_arm_gcc.o" @@ -5795,6 +5798,35 @@ $as_echo "$can_mprotect_exec" >&6; } fi fi +if test "${check_for_unwind}" != "no" ; then + msg="for unwind support" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking $msg" >&5 +$as_echo_n "checking $msg... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #define __USE_GNU + #include + int main() { + return ${check_for_unwind}; + } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + can_unwind=yes +else + can_unwind=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$can_unwind" = "no" ; then + +$as_echo "#define MZ_NO_UNWIND_SUPPORT 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_unwind" >&5 +$as_echo "$can_unwind" >&6; } +fi + if test "${check_page_size}" = "yes" ; then msg="for large page size" { $as_echo "$as_me:${as_lineno-$LINENO}: checking $msg" >&5 diff --git a/racket/src/racket/configure.ac b/racket/src/racket/configure.ac index e37bdef30c..cd839482b2 100644 --- a/racket/src/racket/configure.ac +++ b/racket/src/racket/configure.ac @@ -305,6 +305,7 @@ mzrt_needs_pthread=yes skip_iconv_check=no check_page_size=yes try_no_nullability_completeness=no +check_for_unwind=no if test "${enable_cify}" = "yes" ; then STARTUP_AS_BYTECODE=_bytecode @@ -607,6 +608,7 @@ case "$host_os" in x86_64) enable_parallel_by_default=yes CGC_X86_64="1" + check_for_unwind=REG_RSP ;; ppc|powerpc) ;; @@ -616,6 +618,7 @@ case "$host_os" in ;; i386|i486|i586|i686) enable_parallel_by_default=yes + check_for_unwind=REG_ESP ;; arm*) EXTRA_GMP_OBJ="gmp_arm_gcc.o" @@ -955,6 +958,22 @@ if test "${check_for_mprotect}" = "yes" ; then fi fi +if test "${check_for_unwind}" != "no" ; then + [ msg="for unwind support" ] + AC_MSG_CHECKING($msg) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include + #define __USE_GNU + #include + int main() { + return ${check_for_unwind}; + }])], can_unwind=yes, can_unwind=no) + if test "$can_unwind" = "no" ; then + AC_DEFINE(MZ_NO_UNWIND_SUPPORT,1,[Missing ucontext support]) + fi + AC_MSG_RESULT($can_unwind) +fi + if test "${check_page_size}" = "yes" ; then [ msg="for large page size" ] AC_MSG_CHECKING($msg) diff --git a/racket/src/racket/mzconfig.h.in b/racket/src/racket/mzconfig.h.in index 2a3bfa7409..f0519d7cbc 100644 --- a/racket/src/racket/mzconfig.h.in +++ b/racket/src/racket/mzconfig.h.in @@ -95,4 +95,7 @@ typedef unsigned long uintptr_t; /* Use Generations with the GC */ #undef USE_GC_GENS +/* For platforms like Linux, where context info may not be available: */ +#undef MZ_NO_UNWIND_SUPPORT + #endif diff --git a/racket/src/racket/sconfig.h b/racket/src/racket/sconfig.h index c03e20ae3a..7e03958201 100644 --- a/racket/src/racket/sconfig.h +++ b/racket/src/racket/sconfig.h @@ -147,12 +147,16 @@ #if defined(__i386__) # define MZ_USE_JIT_I386 # define MZ_JIT_USE_MPROTECT -# define MZ_USE_DWARF_LIBUNWIND +# ifndef MZ_NO_UNWIND_SUPPORT +# define MZ_USE_DWARF_LIBUNWIND +# endif #endif #if defined(__x86_64__) # define MZ_USE_JIT_X86_64 # define MZ_JIT_USE_MPROTECT -# define MZ_USE_DWARF_LIBUNWIND +# ifndef MZ_NO_UNWIND_SUPPORT +# define MZ_USE_DWARF_LIBUNWIND +# endif #endif #if defined(__powerpc__) && !defined(__powerpc64__) # define MZ_USE_JIT_PPC