Permalink
Browse files

teach linux build to distinguish 32- and 64-bit erlang

Change Linux build to check whether the Erlang system available is
32-bit or 64-bit and use the right build flags for c_src to
match. This support is mostly the same as changes added some time ago
to distinguish 32- and 64-bit builds on OS X.

Also change configure script to use "host" where "target" used to be
used, since according to autotools documentation "host" is what was
really meant.
  • Loading branch information...
1 parent 3aac349 commit 3cdb6453912e1ea4160dc3c646d2f0ccc500d6c8 @vinoski vinoski committed Jan 18, 2011
Showing with 22 additions and 7 deletions.
  1. +22 −7 configure.in
View
@@ -6,7 +6,7 @@ AC_INIT(Makefile)
dnl work out who the cpu, vendor and OS are
AC_CANONICAL_SYSTEM
-AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$target")
+AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$host")
AC_ERLANG_NEED_ERL
AC_PATH_PROG(ERL, erl)
@@ -118,7 +118,7 @@ dnl ===============================================================
-case "$target_os" in
+case "$host_os" in
*cygwin*)
WIN32=win32
cat >> confdefs.h << EOF
@@ -200,10 +200,25 @@ dnl or use --with-extrainclude=....
CFLAGS="$CFLAGS -I/usr/include/security"
HAVE_SENDFILE=false
-case "$target_os" in
+case "$host_os" in
*linux*)
AC_DEFINE(LINUX)
- LD_SHARED="$CC -shared"
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([],[dnl
+ halt(case erlang:system_info(wordsize) of
+ 8 -> 0; 4 -> 1 end)])],
+ [AC_MSG_NOTICE(found 64-bit Erlang)
+ case "$host_cpu" in
+ x86_64) CBIT= ;;
+ *) CBIT=-m64 ;;
+ esac],
+ [AC_MSG_NOTICE(found 32-bit Erlang)
+ case "$host_cpu" in
+ i?86) CBIT= ;;
+ *) CBIT=-m32 ;;
+ esac])
+ CFLAGS="$CFLAGS $CBIT"
+ LD_SHARED="$CC $CBIT -shared"
AC_SUBST(LD_SHARED)
FPIC=-fpic
AC_SUBST(FPIC)
@@ -222,7 +237,7 @@ case "$target_os" in
*bsd*)
AC_DEFINE(BSD)
- case "$target_os" in
+ case "$host_os" in
freebsd*)
HAVE_SENDFILE=true
;;
@@ -239,7 +254,7 @@ case "$target_os" in
;;
*darwin*)
AC_CHECK_LIB([c],[sendfile],[HAVE_SENDFILE=true])
- case "$target_os" in
+ case "$host_os" in
darwin10*)
AC_LANG(Erlang)
AC_RUN_IFELSE(
@@ -271,7 +286,7 @@ case "$target_os" in
;;
*)
AC_MSG_RESULT(unknown)
- AC_MSG_ERROR(Non-supported target OS!)
+ AC_MSG_ERROR(Unsupported host OS!)
;;
esac

1 comment on commit 3cdb645

@yrashk
Contributor
yrashk commented on 3cdb645 Feb 14, 2011

Apparently this doesn't always work well. I have a 64-bit Erlang on a Linux box:

  $ erl
  Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]

  Eshell V5.8.3  (abort with ^G)
  1> erlang:system_info(wordsize).
  8

  $ uname -a
  Linux agner 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux

Yet on this system yaws' configure decides it is a 32-bit Erlang:

  configure: found 32-bit Erlang

Investigating what's the cause, hopefully will be able to submit a pull request with a fix; but not yet sure why this is happening.

Please sign in to comment.