[erlang-bugs] Building R13B01 on IRIX problems

Mikael Pettersson mikpe@REDACTED
Fri Jun 26 11:33:54 CEST 2009


Patrick Baggett writes:
 > > Correct, using GCC should be optional.
 > >
 > > Prior to the linkage error there ought to be some compile-time warnings
 > > about calling undeclared functions (those __builtin_*()s).
 > > Can you see if these warnings are present and if so where they occur and
 > > if the compiler identifies their origin? (typically .h files)
 > >
 > 
 > I did not see any warning about it, surprisingly. The only thing that I
 > found was in erts/emulator/sys/erl_sys_unix.h about __builtin_expect, but
 > nothing about __builtin_return_address. Anyone help here?

I found two cases where these builtins could be called without
prior checks that GCC was being used. Try the patch below.

/Mikael

--- otp-0622/erts/emulator/sys/unix/sys_float.c.~1~	2009-02-26 11:45:48.000000000 +0100
+++ otp-0622/erts/emulator/sys/unix/sys_float.c	2009-06-26 11:14:15.000000000 +0200
@@ -792,6 +792,8 @@ sys_chars_to_double(char* buf, double* f
 int
 matherr(struct exception *exc)
 {
+#if !defined(NO_FPE_SIGNALS)
     set_current_fp_exception((unsigned long)__builtin_return_address(0));
+#endif
     return 1;
 }
--- otp-0622/erts/include/internal/ethread.h.~1~	2009-02-26 11:45:54.000000000 +0100
+++ otp-0622/erts/include/internal/ethread.h	2009-06-26 11:24:24.000000000 +0200
@@ -681,11 +681,13 @@ ETHR_INLINE_FUNC_NAME_(ethr_write_lock)(
 
 #endif
 
+/* __builtin_expect() is needed by both native atomics code and the fallback code */
+#if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#define __builtin_expect(X, Y) (X)
+#endif
+
 /* For CPU-optimised atomics, spinlocks, and rwlocks. */
 #if !defined(ETHR_DISABLE_NATIVE_IMPLS) && defined(__GNUC__)
-#  if __GNUC__ < 3 && (__GNUC__ != 2 || __GNUC_MINOR__ < 96)
-#    define __builtin_expect(X, Y) (X)
-#  endif
 #  if ETHR_SIZEOF_PTR == 4
 #    if defined(__i386__)
 #      include "i386/ethread.h"


More information about the erlang-bugs mailing list