[erlang-questions] Building 64-bit Erlang on Solaris 11
Paul Fisher
pfisher@REDACTED
Wed Oct 1 21:54:18 CEST 2008
Joel Reymont wrote:
> ./configure --prefix=/opt/local --enable-64bit CFLAGS='-m64'
> ...
> gmake
> ...
> ld: fatal: file obj/i386-pc-solaris2.11/opt/plain/erl_main.o: wrong
> ELF class: ELFCLASS64
> ld: fatal: File processing errors. No output written to /home/admin/
> otp_src_R12B-4/bin/i386-pc-solaris2.11/beam
>
> What am I doing wrong?
>
> Thanks, Joel
>
> P.S. Omitting CFLAGS='-m64' builds a 32-bit Erlang.
Not so straight forward (esp. if you use linked in drivers as we do).
Here is what it takes
First this patch:
This patch allows 64-bit builds when the target system supports both
32-bit and 64-bit in the same system environment. Specifically, this
works on Solaris 10/Opensolaris, and adjusts the --enable-darwin-64-bit
configure flag to be simply --enable-64bit so that it can be used for
the same purpose on both darwin and solaris (building 64-bit target
environment) without having to introduce another system specific
configure flag.
This cleanly builds with the following configure command line:
~/bld/otp_src_R12B-3$ CFLAGS='-m64' LDFLAGS='-m64' ./configure \
--enable-threads \
--enable-smp-support --enable-kernel-poll --enable-hipe \
--disable-megaco-flex-scanner-drvlineno --without-odbc \
--enable-64bit
on:
~/bld/otp_src_R12B-3$ uname -a
SunOS pfisher-laptop 5.11 snv_94 i86pc i386 i86pc Solaris
This does not fix common_test, which seems to be in its own world, and
I'll send another patch for that. For now I just set it to SKIP.
diff -ru otp_src_R12B-4/configure otp_src_R12B-4.64bit/configure
--- otp_src_R12B-4/configure 2008-09-02 13:03:59.000000000 -0500
+++ otp_src_R12B-4.64bit/configure 2008-10-01 14:20:07.448422739 -0500
@@ -814,7 +814,7 @@
--enable-dynamic-ssl-lib force using dynamic openssl libraries
--disable-erlang-mandir do not install Erlang man pages in a private
directory
--enable-darwin-universal build universal binaries on darwin i386
- --enable-darwin-64bit build 64bit binaries on darwin
+ --enable-64bit build 64bit binaries on 32/64 capable systems
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -2645,23 +2645,23 @@
fi;
-# Check whether --enable-darwin-64bit or --disable-darwin-64bit was given.
-if test "${enable_darwin_64bit+set}" = set; then
- enableval="$enable_darwin_64bit"
+# Check whether --enable-64bit or --disable-64bit was given.
+if test "${enable_64bit+set}" = set; then
+ enableval="$enable_64bit"
case "$enableval" in
- no) enable_darwin_64bit=no ;;
- *) enable_darwin_64bit=yes ;;
+ no) enable_64bit=no ;;
+ *) enable_64bit=yes ;;
esac
else
- enable_darwin_64bit=no
+ enable_64bit=no
fi;
TMPSYS=`uname -s`-`uname -m`
if test X${enable_darwin_universal} = Xyes; then
- if test X${enable_darwin_64bit} = Xyes; then
+ if test X${enable_64bit} = Xyes; then
{ { echo "$as_me:$LINENO: error: --enable-darwin-universal and
--enable-darwin-64bit mutually exclusive" >&5
-echo "$as_me: error: --enable-darwin-universal and
--enable-darwin-64bit mutually exclusive" >&2;}
+echo "$as_me: error: --enable-darwin-universal and --enable-64bit
mutually exclusive" >&2;}
{ (exit 1); exit 1; }; }
fi
enable_hipe=no
@@ -2670,17 +2670,39 @@
LDFLAGS="-arch i386 -arch ppc $LDFLAGS"
export LDFLAGS
fi
-if test X${enable_darwin_64bit} = Xyes; then
- if test X"$TMPSYS" '!=' X"Darwin-i386"; then
- { { echo "$as_me:$LINENO: error: --enable-darwin-64bit only supported
on x86 host" >&5
-echo "$as_me: error: --enable-darwin-64bit only supported on x86 host"
>&2;}
- { (exit 1); exit 1; }; }
- fi
- enable_hipe=no
- CFLAGS="-m64 $CFLAGS"
- export CFLAGS
- LDFLAGS="-m64 $LDFLAGS"
- export LDFLAGS
+if test X${enable_64bit} = Xyes; then
+ case $TMPSYS in
+ Darwin-i386)
+ enable_hipe=no
+ CFLAGS="-m64 $CFLAGS"
+ export CFLAGS
+ LDFLAGS="-m64 $LDFLAGS"
+ export LDFLAGS
+ ;;
+ SunOS-i86pc)
+ case $CFLAGS in
+ *-m64*)
+ ;;
+ *)
+ CFLAGS="-m64 $CFLAGS"
+ export CLAGS
+ ;;
+ esac
+ case $LDLAGS in
+ *-m64*)
+ ;;
+ *)
+ LDLAGS="-m64 $LDLAGS"
+ export LDLAGS
+ ;;
+ esac
+ ;;
+
+ *)
+ echo "$as_me: error: --enable-64bit only supported on x86 host"
+ exit 1
+ ;;
+ esac
fi
export ERL_TOP
diff -ru otp_src_R12B-4/configure.in otp_src_R12B-4.64bit/configure.in
--- otp_src_R12B-4/configure.in 2008-06-10 07:47:35.000000000 -0500
+++ otp_src_R12B-4.64bit/configure.in 2008-10-01 14:19:13.437109172 -0500
@@ -179,20 +179,20 @@
],enable_darwin_universal=no)
-AC_ARG_ENABLE(darwin-64bit,
-[ --enable-darwin-64bit build 64bit binaries on darwin],
+AC_ARG_ENABLE(64bit,
+[ --enable-64bit build 64bit binaries on 32/64 bit capable system],
[ case "$enableval" in
- no) enable_darwin_64bit=no ;;
- *) enable_darwin_64bit=yes ;;
+ no) enable_64bit=no ;;
+ *) enable_64bit=yes ;;
esac
-],enable_darwin_64bit=no)
+],enable_64bit=no)
dnl OK, we might have darwin switches off different kinds, lets
dnl check it all before continuing.
TMPSYS=`uname -s`-`uname -m`
if test X${enable_darwin_universal} = Xyes; then
if test X${enable_darwin_64bit} = Xyes; then
- AC_MSG_ERROR([--enable-darwin-universal and --enable-darwin-64bit
mutually exclusive])
+ AC_MSG_ERROR([--enable-darwin-universal and --enable-64bit mutually
exclusive])
fi
enable_hipe=no
CFLAGS="-arch i386 -arch ppc $CFLAGS"
@@ -200,15 +200,39 @@
LDFLAGS="-arch i386 -arch ppc $LDFLAGS"
export LDFLAGS
fi
-if test X${enable_darwin_64bit} = Xyes; then
- if test X"$TMPSYS" '!=' X"Darwin-i386"; then
- AC_MSG_ERROR([--enable-darwin-64bit only supported on x86 host])
- fi
- enable_hipe=no
- CFLAGS="-m64 $CFLAGS"
- export CFLAGS
- LDFLAGS="-m64 $LDFLAGS"
- export LDFLAGS
+if test X${enable_64bit} = Xyes; then
+ case $TMPSYS in
+ Darwin-i386)
+ enable_hipe=no
+ CFLAGS="-m64 $CFLAGS"
+ export CFLAGS
+ LDFLAGS="-m64 $LDFLAGS"
+ export LDFLAGS
+ ;;
+ SunOS-i86pc)
+ case $CFLAGS in
+ *-m64*)
+ ;;
+ *)
+ CFLAGS="-m64 $CFLAGS"
+ export CLAGS
+ ;;
+ esac
+ case $LDLAGS in
+ *-m64*)
+ ;;
+ *)
+ LDLAGS="-m64 $LDLAGS"
+ export LDLAGS
+ ;;
+ esac
+ ;;
+
+ *)
+ echo "$as_me: error: --enable-64bit only supported on x86 host"
+ exit 1
+ ;;
+ esac
fi
export ERL_TOP
diff -ru otp_src_R12B-4/erts/configure otp_src_R12B-4.64bit/erts/configure
--- otp_src_R12B-4/erts/configure 2008-09-02 13:03:54.000000000 -0500
+++ otp_src_R12B-4.64bit/erts/configure 2008-10-01 14:17:36.145321678 -0500
@@ -863,7 +863,7 @@
--enable-elib-malloc use elib_malloc instead of normal malloc
--enable-fp-exceptions Use hardware floating point exceptions
(default if hipe enabled)
--enable-darwin-universal build universal binaries on darwin i386
- --enable-darwin-64bit build 64bit binaries on darwin
+ --enable-64bit build 64bit binaries on 32/64 capable system
--disable-fixalloc disable the use of fix_alloc
--enable-clock-gettime Use clock-gettime for time correction
--enable-native-ethr-impls enable native ethread implementations
@@ -2665,16 +2665,16 @@
fi;
-# Check whether --enable-darwin-64bit or --disable-darwin-64bit was given.
-if test "${enable_darwin_64bit+set}" = set; then
- enableval="$enable_darwin_64bit"
+# Check whether --enable-64bit or --disable-64bit was given.
+if test "${enable_64bit+set}" = set; then
+ enableval="$enable_64bit"
case "$enableval" in
- no) enable_darwin_64bit=no ;;
- *) enable_darwin_64bit=yes ;;
+ no) enable_64bit=no ;;
+ *) enable_64bit=yes ;;
esac
else
- enable_darwin_64bit=no
+ enable_64bit=no
fi;
@@ -2755,9 +2755,9 @@
TMPSYS=`uname -s`-`uname -m`
if test X${enable_darwin_universal} = Xyes; then
- if test X${enable_darwin_64bit} = Xyes; then
- { { echo "$as_me:$LINENO: error: --enable-darwin-universal and
--enable-darwin-64bit mutually exclusive" >&5
-echo "$as_me: error: --enable-darwin-universal and
--enable-darwin-64bit mutually exclusive" >&2;}
+ if test X${enable_64bit} = Xyes; then
+ { { echo "$as_me:$LINENO: error: --enable-darwin-universal and
--enable-64bit mutually exclusive" >&5
+echo "$as_me: error: --enable-darwin-universal and --enable-64bit
mutually exclusive" >&2;}
{ (exit 1); exit 1; }; }
fi
enable_hipe=no
@@ -2776,20 +2776,35 @@
;;
esac
fi
-if test X${enable_darwin_64bit} = Xyes; then
- if test X"$TMPSYS" '!=' X"Darwin-i386"; then
- { { echo "$as_me:$LINENO: error: --enable-darwin-64bit only supported
on x86 host" >&5
-echo "$as_me: error: --enable-darwin-64bit only supported on x86 host"
>&2;}
- { (exit 1); exit 1; }; }
- fi
- enable_hipe=no
- case $CFLAGS in
+if test X${enable_64bit} = Xyes; then
+ case $TMPSYS in
+ Darwin-i386)
+ enable_hipe=no
+ case $CFLAGS in
*-m64*)
;;
*)
CFLAGS="-m64 $CFLAGS"
+ export CLAGS
;;
- esac
+ esac
+ ;;
+ SunOS-i86pc)
+ case $CFLAGS in
+ *-m64*)
+ ;;
+ *)
+ CFLAGS="-m64 $CFLAGS"
+ export CLAGS
+ ;;
+ esac
+ ;;
+
+ *)
+ echo "$as_me: error: --enable-64bit only supported on x86 host"
+ exit 1
+ ;;
+ esac
fi
@@ -4716,6 +4731,17 @@
esac
fi
;;
+ amd64-sol2*)
+ { echo "$as_me:$LINENO: Adjusting LDFLAGS to cope with 64bit SunOS" >&5
+echo "$as_me: Adjusting LDFLAGS to cope with 64bit SunOS" >&6;}
+ case $LDFLAGS in
+ *-m64*)
+ ;;
+ *)
+ LDFLAGS="-m64 $LDFLAGS"
+ ;;
+ esac
+ ;;
esac
@@ -20430,7 +20456,19 @@
DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
;;
solaris2*|sysv4*)
+ DED_LD=$CC
DED_LDFLAGS="-G"
+ case $CC in
+ gcc)
+ DED_LDFLAGS="-shared $DED_LDFLAGS"
+ ;;
+ esac
+ case $ARCH in
+ amd64)
+ DED_LDFLAGS="-m64 $DED_LDFLAGS"
+ DED_CFLAGS="-m64 $DED_CFLAGS"
+ ;;
+ esac
;;
aix4*)
DED_LDFLAGS="-G -bnoentry -bexpall"
diff -ru otp_src_R12B-4/erts/configure.in
otp_src_R12B-4.64bit/erts/configure.in
--- otp_src_R12B-4/erts/configure.in 2008-09-01 07:51:17.000000000 -0500
+++ otp_src_R12B-4.64bit/erts/configure.in 2008-10-01 14:17:39.750396425
-0500
@@ -172,13 +172,13 @@
],enable_darwin_universal=no)
-AC_ARG_ENABLE(darwin-64bit,
-[ --enable-darwin-64bit build 64bit binaries on darwin],
+AC_ARG_ENABLE(64bit,
+[ --enable-64bit build 64bit binaries on 32/64 capable system],
[ case "$enableval" in
- no) enable_darwin_64bit=no ;;
- *) enable_darwin_64bit=yes ;;
+ no) enable_64bit=no ;;
+ *) enable_64bit=yes ;;
esac
-],enable_darwin_64bit=no)
+],enable_64bit=no)
AC_ARG_ENABLE(fixalloc,
@@ -239,8 +239,8 @@
dnl check it all before continuing.
TMPSYS=`uname -s`-`uname -m`
if test X${enable_darwin_universal} = Xyes; then
- if test X${enable_darwin_64bit} = Xyes; then
- AC_MSG_ERROR([--enable-darwin-universal and --enable-darwin-64bit
mutually exclusive])
+ if test X${enable_64bit} = Xyes; then
+ AC_MSG_ERROR([--enable-darwin-universal and --enable-64bit mutually
exclusive])
fi
enable_hipe=no
case $CFLAGS in
@@ -258,18 +258,35 @@
;;
esac
fi
-if test X${enable_darwin_64bit} = Xyes; then
- if test X"$TMPSYS" '!=' X"Darwin-i386"; then
- AC_MSG_ERROR([--enable-darwin-64bit only supported on x86 host])
- fi
- enable_hipe=no
- case $CFLAGS in
+if test X${enable_64bit} = Xyes; then
+ case $TMPSYS in
+ Darwin-i386)
+ enable_hipe=no
+ case $CFLAGS in
*-m64*)
;;
*)
CFLAGS="-m64 $CFLAGS"
+ export CLAGS
;;
- esac
+ esac
+ ;;
+ SunOS-i86pc)
+ case $CFLAGS in
+ *-m64*)
+ ;;
+ *)
+ CFLAGS="-m64 $CFLAGS"
+ export CLAGS
+ ;;
+ esac
+ ;;
+
+ *)
+ echo "$as_me: error: --enable-64bit only supported on x86 host"
+ exit 1
+ ;;
+ esac
fi
@@ -494,10 +511,10 @@
dnl has a build/configure system re rx-lib that is not compatible
dnl First remove common_tests skip file.
-dnl Adjust LDFLAGS to allow 64bit linkage on DARWIN
+dnl Adjust LDFLAGS to allow 64bit linkage on 32/64 system
case $ARCH-$OPSYS in
- amd64-darwin*)
- AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit Darwin])
+ amd64-darwin*|amd64-sol2*)
+ AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit system])
case $LDFLAGS in
*-m64*)
;;
@@ -526,6 +543,17 @@
esac
fi
;;
+ amd64-sol2*)
+ { echo "$as_me:$LINENO: Adjusting LDFLAGS to cope with 64bit SunOS" >&5
+echo "$as_me: Adjusting LDFLAGS to cope with 64bit SunOS" >&6;}
+ case $LDFLAGS in
+ *-m64*)
+ ;;
+ *)
+ LDFLAGS="-m64 $LDFLAGS"
+ ;;
+ esac
+ ;;
esac
@@ -2732,7 +2760,19 @@
DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
;;
solaris2*|sysv4*)
+ DED_LD=$CC
DED_LDFLAGS="-G"
+ case $CC in
+ gcc)
+ DED_LDFLAGS="-shared $DED_LDFLAGS"
+ ;;
+ esac
+ case $ARCH in
+ amd64)
+ DED_LDFLAGS="-m64 $DED_LDFLAGS"
+ DED_CFLAGS="-m64 $DED_CFLAGS"
+ ;;
+ esac
;;
aix4*)
DED_LDFLAGS="-G -bnoentry -bexpall"
Then a script that configures and builds stuff (the skip of common_test
is important, others are just to avoid building them):
#!/usr/bin/env bash
set -e
cd otp_src_R12B-4
CFLAGS='-m64' LDFLAGS='-m64' LIBS='-lumem' ./configure --enable-threads
--enable-smp-support --enable-kernel-poll --enable-hipe
--disable-megaco-flex-scanner-drvlineno --without-unixodbc --enable-64bit
touch lib/common_test/SKIP
touch lib/cosEvent/SKIP
touch lib/cosEventDomain/SKIP
touch lib/cosFileTransfer/SKIP
touch lib/cosNotification/SKIP
touch lib/cosProperty/SKIP
touch lib/cosTime/SKIP
touch lib/cosTransactions/SKIP
touch lib/megaco/SKIP
touch lib/odbc/SKIP
touch lib/orber/SKIP
make
pfexec make install
--
paul
More information about the erlang-questions
mailing list