From 448cf0cfe686c5bd6c1d28c08807c6c99b4c49d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 15 Nov 2011 16:40:49 +0100 Subject: MacOS X: Completely remove obsolete -no-cpp-precomp option clang does not recognize the -no-cpp-precomp option and generates a warning. -no-cpp-precomp is an obsolete Apple-specific gcc option, which last had any effect in gcc 3.1 for Jaguar. Since we cannot build for Jaguar anyway, the configure test added in 8412a400e92d5cbcd is not needed. --- erts/configure.in | 13 ------------- lib/erl_interface/configure.in | 6 ------ lib/megaco/configure.in | 2 +- lib/wx/configure.in | 13 ------------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/erts/configure.in b/erts/configure.in index e3eb6034e6..1d07c74f5f 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -490,19 +490,6 @@ CFLAG_RUNTIME_LIBRARY_PATH="-Wl,-R" case $host_os in darwin*) CFLAG_RUNTIME_LIBRARY_PATH= - AC_TRY_COMPILE([],[ - #if __GNUC__ >= 4 - ; - #else - #error old or no gcc - #endif - ], - gcc_need_no_cpp_precomp=no, - gcc_need_no_cpp_precomp=yes) - - if test x$gcc_need_no_cpp_precomp = xyes; then - CFLAGS="$CFLAGS -no-cpp-precomp" - fi ;; win32) CFLAG_RUNTIME_LIBRARY_PATH= diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in index 72ac8c7bbf..abe1602be1 100644 --- a/lib/erl_interface/configure.in +++ b/lib/erl_interface/configure.in @@ -338,12 +338,6 @@ AC_SUBST(LIB_CFLAGS) if test "X$host" = "Xwin32"; then LIB_CFLAGS="$CFLAGS" else - case $host_os in - darwin*) - CFLAGS="$CFLAGS -no-cpp-precomp" - ;; - esac - if test "x$GCC" = xyes; then LIB_CFLAGS="$CFLAGS -fPIC" else diff --git a/lib/megaco/configure.in b/lib/megaco/configure.in index b88e17ec85..42c50b8961 100644 --- a/lib/megaco/configure.in +++ b/lib/megaco/configure.in @@ -208,7 +208,7 @@ if test "X$host" = "Xwin32"; then else case $host_os in darwin*) - CFLAGS="$CFLAGS -no-cpp-precomp -fno-common" + CFLAGS="$CFLAGS -fno-common" ;; esac diff --git a/lib/wx/configure.in b/lib/wx/configure.in index 78c3f0d3d2..e5dc83b27e 100755 --- a/lib/wx/configure.in +++ b/lib/wx/configure.in @@ -219,19 +219,6 @@ AC_SUBST(OBJC_CFLAGS) case $host_os in darwin*) - AC_TRY_COMPILE([],[ - #if __GNUC__ >= 4 - ; - #else - #error old or no gcc - #endif - ], - gcc_need_no_cpp_precomp=no, - gcc_need_no_cpp_precomp=yes) - - if test x$gcc_need_no_cpp_precomp = xyes; then - CFLAGS="-no-cpp-precomp $CFLAGS" - fi LDFLAGS="-bundle -flat_namespace -undefined warning -fPIC $LDFLAGS" # Check sizof_void_p as future will hold 64bit MacOS wx if test $ac_cv_sizeof_void_p = 4; then -- cgit v1.2.3 From cbfee47d852cbf8a8502e5aaffeddb95258b5442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 25 Oct 2011 10:24:05 +0200 Subject: beam_emu.c: Use the correct void* type for computed gotos gcc don't care about the type, but clang does and will issue a warning. --- erts/emulator/beam/beam_emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 68e6383f7f..f440c2e376 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -53,7 +53,7 @@ #else # define OpCase(OpCode) lb_##OpCode # define CountCase(OpCode) lb_count_##OpCode -# define Goto(Rel) goto *(Rel) +# define Goto(Rel) goto *((void *)Rel) # define LabelAddr(Label) &&Label # define OpCode(OpCode) (&&lb_##OpCode) #endif -- cgit v1.2.3 From 743eae551552a51703fc5d44a0ce5f634f33740d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 25 Oct 2011 10:31:30 +0200 Subject: beam_emu.c: Eliminate warnings when NO_JUMP_TABLE is defined --- erts/emulator/beam/beam_emu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index f440c2e376..9b2b47ffb7 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -45,7 +45,7 @@ /* #define HARDDEBUG 1 */ #if defined(NO_JUMP_TABLE) -# define OpCase(OpCode) case op_##OpCode: lb_##OpCode +# define OpCase(OpCode) case op_##OpCode # define CountCase(OpCode) case op_count_##OpCode # define OpCode(OpCode) ((Uint*)op_##OpCode) # define Goto(Rel) {Go = (int)(Rel); goto emulator_loop;} @@ -199,7 +199,7 @@ do { \ } \ } while (0) -#define ClauseFail() goto lb_jump_f +#define ClauseFail() goto jump_f #define SAVE_CP(X) \ do { \ @@ -2540,6 +2540,7 @@ void process_main(void) lb_Cl_error: { if (Arg(0) != 0) { OpCase(jump_f): { + jump_f: SET_I((BeamInstr *) Arg(0)); Goto(*I); } @@ -3113,7 +3114,7 @@ void process_main(void) /* Fall through */ OpCase(error_action_code): { - no_error_handler: + handle_error: reg[0] = r(0); SWAPOUT; I = handle_error(c_p, NULL, reg, NULL); @@ -3274,7 +3275,7 @@ void process_main(void) OpCase(i_func_info_IaaI): { c_p->freason = EXC_FUNCTION_CLAUSE; c_p->current = I + 2; - goto lb_error_action_code; + goto handle_error; } OpCase(try_case_end_s): @@ -4960,7 +4961,7 @@ void process_main(void) if (I) { Goto(*I); } - goto no_error_handler; + goto handle_error; } -- cgit v1.2.3 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(-) 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 From 687dfb57c61ef9a777f706b73b14da93aa3ea448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 15 Nov 2011 15:59:44 +0100 Subject: Fix clang linking problem Inlining was not done in a portable way. clang follows the C99 semantics for inlining ('inline' essentially implies 'static' in C99, but not in GCC), so bp_sched2ix() was not visible outside beam_bp.c. Since the function need to be used from more than one source file, put the function definition in the beam_bp.h header file. Also, give it an 'erts_' prefix since it is globally visible. --- erts/emulator/beam/beam_bp.c | 12 +----------- erts/emulator/beam/beam_bp.h | 17 +++++++++++++++-- erts/emulator/beam/erl_nif.c | 2 +- erts/emulator/beam/utils.c | 1 + 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/erts/emulator/beam/beam_bp.c b/erts/emulator/beam/beam_bp.c index dd31376a2d..692fa61fe8 100644 --- a/erts/emulator/beam/beam_bp.c +++ b/erts/emulator/beam/beam_bp.c @@ -495,16 +495,6 @@ erts_find_local_func(Eterm mfa[3]) { return NULL; } -/* bp_hash */ -ERTS_INLINE Uint bp_sched2ix() { -#ifdef ERTS_SMP - ErtsSchedulerData *esdp; - esdp = erts_get_scheduler_data(); - return esdp->no - 1; -#else - return 0; -#endif -} static void bp_hash_init(bp_time_hash_t *hash, Uint n) { Uint size = sizeof(bp_data_time_item_t)*n; Uint i; @@ -1347,7 +1337,7 @@ static BpData *is_break(BeamInstr *pc, BeamInstr break_op) { return NULL; } - bd = ebd = rs[bp_sched2ix()]; + bd = ebd = rs[erts_bp_sched2ix()]; ASSERT(bd); if ( (break_op == 0) || (bd->this_instr == break_op)) { return bd; diff --git a/erts/emulator/beam/beam_bp.h b/erts/emulator/beam/beam_bp.h index 2ec5818688..167069552f 100644 --- a/erts/emulator/beam/beam_bp.h +++ b/erts/emulator/beam/beam_bp.h @@ -144,8 +144,6 @@ extern erts_smp_spinlock_t erts_bp_lock; #define ErtsSmpBPUnlock(BDC) #endif -ERTS_INLINE Uint bp_sched2ix(void); - #ifdef ERTS_SMP #define bp_sched2ix_proc(p) ((p)->scheduler_data->no - 1) #else @@ -247,4 +245,19 @@ BpData *erts_get_time_break(Process *p, BeamInstr *pc); BeamInstr *erts_find_local_func(Eterm mfa[3]); +ERTS_GLB_INLINE Uint erts_bp_sched2ix(void); + +#if ERTS_GLB_INLINE_INCL_FUNC_DEF +ERTS_GLB_INLINE Uint erts_bp_sched2ix(void) +{ +#ifdef ERTS_SMP + ErtsSchedulerData *esdp; + esdp = erts_get_scheduler_data(); + return esdp->no - 1; +#else + return 0; +#endif +} +#endif + #endif /* _BEAM_BP_H */ diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 62798bb2c1..740a1b853e 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -1669,7 +1669,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) } else { /* Function traced, patch the original instruction word */ BpData** bps = (BpData**) code_ptr[1]; - BpData* bp = (BpData*) bps[bp_sched2ix()]; + BpData* bp = (BpData*) bps[erts_bp_sched2ix()]; bp->orig_instr = (BeamInstr) BeamOp(op_call_nif); } code_ptr[5+1] = (BeamInstr) entry->funcs[i].fptr; diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index e4ad7dcb24..7c3de9da42 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -45,6 +45,7 @@ #include "erl_thr_progress.h" #include "erl_thr_queue.h" #include "erl_sched_spec_pre_alloc.h" +#include "beam_bp.h" #undef M_TRIM_THRESHOLD #undef M_TOP_PAD -- cgit v1.2.3 From 3c36d2c5f75827f098a691dfcf534ab3b95d7bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 29 Nov 2011 10:19:15 +0100 Subject: INSTALL.md: Update build instructions for Lion --- INSTALL.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 8a3b71e4ec..50d1aec2c4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -674,6 +674,44 @@ test on). Universal binaries and 64bit binaries are mutually exclusive options. +Building a fast Erlang VM on Mac OS Lion +---------------------------------------- + +Starting with XCode 4.2, Apple no longer includes a "real" `gcc` +compiler (not based on the LLVM). Building with `llvm-gcc` or `clang` +will work, but the performance of the Erlang run-time system will not +be the best possible. + +Note that if you have `gcc-4.2` installed and included in `PATH` +(from a previous version of XCode), `configure` will automatically +make sure that `gcc-4.2` will be used to compile `beam_emu.c` +(the source file most in need of `gcc`). + +If you don't have `gcc-4.2.` and want to build a run-time system with +the best possible performance, do like this: + +Install XCode from the AppStore if it is not already installed. + +Install MacPorts (). Then: + + $ sudo port selfupdate + $ sudo port install gcc45 +universal + +If you want to build the `wx` application, get wxMac-2.8.12 +(`wxMac-2.8.12.tar.gz` from +) and build: + + $ arch_flags="-arch i386" ./configure CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags" --prefix=/usr/local --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6 --enable-unicode --with-opengl --disable-shared + $ make + $ sudo make install + +Build Erlang with the MacPorts GCC as the main compiler (using `clang` +for the Objective-C Cocoa code in the `wx` application): + + $ PATH=/usr/local/bin:$PATH CC=/opt/local/bin/gcc-mp-4.5 CXX=/opt/local/bin/g++-mp-4.5 ./configure --enable-m32-build make + $ sudo make install + + How to Build a Debug Enabled Erlang RunTime System -------------------------------------------------- -- cgit v1.2.3