From 6e7de55f346e632b3f29835f7678a7ecfb464d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 25 Oct 2011 10:11:24 +0200 Subject: configure: Define NO_JUMP_TABLE if all we have is llvm-gcc Commit dd24ca1cb76d attempts to fix the problem that LLVM-based compilers (such as llvm-gcc-4.2 and clang) miscompiles beam_emu.c. The idea was to force the use of gcc-4.2 if the default compiler was LLVM-based. Since that fix, Apple released Xcode 4.2 that does not include any version of gcc, only llvm-gcc-4.2 and clang. We could require gcc in order to be the system, but it would be nice if Erlang/OTP could be built out-of-box on MacOS X, albeit with reduced performance. Therefore, make sure that we set NO_JUMP_TABLE (use a switch statement instead of computed gotos in beam_emu.c) if no compiler that correctly handles computed gotos can be found. We know that clang based on the upcoming LLVM 3.0 will work, but older LLVM-based compilers will not, so we can test the version of clang. llvm-gcc has been discontinued in LLVM 3.0, so if the compiler is LLVM-based but not clang, we can assume that it does not handles computed gotos correctly. --- erts/aclocal.m4 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'erts/aclocal.m4') diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index bd228a2d1f..ea5cc67fbe 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -125,8 +125,10 @@ AC_DEFUN(LM_FIND_EMU_CC, ac_cv_prog_emu_cc, [ AC_TRY_COMPILE([],[ -#ifdef __llvm__ -#error "llvm is currently unable to compile beam_emu.c" +#if defined(__clang_major__) && __clang_major__ >= 3 + /* clang 3.x or later is fine */ +#elif defined(__llvm__) +#error "this version of llvm is unable to correctly compile beam_emu.c" #endif __label__ lbl1; __label__ lbl2; @@ -168,6 +170,11 @@ if test $ac_cv_prog_emu_cc != no; then CFLAGS="" CPPFLAGS="" AC_TRY_COMPILE([],[ +#if defined(__clang_major__) && __clang_major__ >= 3 + /* clang 3.x or later is fine */ +#elif defined(__llvm__) +#error "this version of llvm is unable to correctly compile beam_emu.c" +#endif __label__ lbl1; __label__ lbl2; int x = magic(); -- cgit v1.2.3