Mantis - OCaml
Viewing Issue Advanced Details
4670 OCaml general feature always 2008-12-09 05:55 2009-03-28 16:21
xiey  
xleroy  
normal  
resolved 3.11.0+beta  
fixed  
none    
none  
0004670: patch for compiling on Solaris x86-64
With minor tweaks to the configure script, ocaml 3.11.0 can be compiled on Solaris x86-64.

Can the following patch be accepted into future releases?

Thanks,
yichen
--- configure 2008-11-07 05:34:16.000000000 -0500
+++ ../configure 2008-12-08 23:42:01.636000000 -0500
@@ -617,7 +617,11 @@
   i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;;
   i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;;
   i[3456]86-*-nextstep*) arch=i386; system=nextstep;;
- i[3456]86-*-solaris*) arch=i386; system=solaris;;
+ i[3456]86-*-solaris*) if $arch64; then
+ arch=amd64; system=solaris
+ else
+ arch=i386; system=solaris
+ fi;;
   i[3456]86-*-beos*) arch=i386; system=beos;;
   i[3456]86-*-cygwin*) arch=i386; system=cygwin;;
   i[3456]86-*-darwin*) if $arch64; then
@@ -686,6 +690,7 @@
                        if $arch64; then partialld="ld -r -arch ppc64"; fi;;
   *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
   amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
+ amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
   *,gcc*,*,*) nativecccompopts="$gcc_warnings";;
 esac
 
@@ -699,6 +704,8 @@
                     aspp='gcc -c';;
   amd64,*,macosx) as='as -arch x86_64'
                     aspp='gcc -arch x86_64 -c';;
+ amd64,*,solaris) as='as --64'
+ aspp='gcc -m64 -c';;
   amd64,*,*) as='as'
                     aspp='gcc -c';;
   arm,*,*) as='as';

Issue History
2008-12-09 05:55 xiey New Issue
2008-12-12 09:49 xleroy Status new => assigned
2008-12-12 09:49 xleroy Assigned To => xleroy
2008-12-14 19:43 xleroy Note Added: 0004801
2008-12-14 19:43 xleroy Status assigned => feedback
2008-12-21 23:18 xiey Note Added: 0004807
2009-03-28 16:19 xleroy Note Added: 0004865
2009-03-28 16:19 xleroy Status feedback => resolved
2009-03-28 16:21 xleroy Resolution open => fixed

Notes
(0004801)
xleroy   
2008-12-14 19:43   
Thanks for testing under Solaris x86-64 and for preparing the patch. However, for ocamlopt to be fully operational under this OS, some changes to asmrun/signals_osdep.h are required to get signals to work properly. There is some OS- and processor-dependent black magic there to access hardware registers from signal handlers. I don't have access yet to a Solaris x86 installation, otherwise I'd try to figure this out myself.
(0004807)
xiey   
2008-12-21 23:18   
Thanks, Xavier. I looked into signals_osdep.h and came up with the following patch. Things seem to be quite straightforward but maybe I was deceived. :)

With this patch, I think (but haven't had a chance to test this yet) one could also potentially turn on HAS_STACK_OVERFLOW_DETECTION for Solaris i386 and amd64.

Regards,
Yichen

--- signals_osdep.h-orig 2008-11-07 05:34:16.000000000 -0500
+++ signals_osdep.h 2008-12-21 16:53:13.248197000 -0500
@@ -76,6 +76,38 @@
   #define CONTEXT_SP (CONTEXT_STATE.CONTEXT_REG(rsp))
   #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
 
+/****************** AMD64, Solaris x86 */
+
+#elif defined(TARGET_amd64) && defined (SYS_solaris)
+
+ #include <ucontext.h>
+
+ #define DECLARE_SIGNAL_HANDLER(name) \
+ static void name(int sig, siginfo_t * info, ucontext_t * context)
+
+ #define SET_SIGACT(sigact,name) \
+ sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name); \
+ sigact.sa_flags = SA_SIGINFO
+
+ typedef greg_t context_reg;
+ #define CONTEXT_PC (context->uc_mcontext.gregs[REG_RIP])
+ #define CONTEXT_EXCEPTION_POINTER (context->uc_mcontext.gregs[REG_R14])
+ #define CONTEXT_YOUNG_PTR (context->uc_mcontext.gregs[REG_R15])
+ #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
+
+/****************** I386, Solaris x86 */
+
+#elif defined(TARGET_i386) && defined(SYS_solaris)
+
+ #define DECLARE_SIGNAL_HANDLER(name) \
+ static void name(int sig, siginfo_t * info, void * context)
+
+ #define SET_SIGACT(sigact,name) \
+ sigact.sa_sigaction = (name); \
+ sigact.sa_flags = SA_SIGINFO
+
+ #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
+
 /****************** I386, Linux */
 
 #elif defined(TARGET_i386) && defined(SYS_linux_elf)
(0004865)
xleroy   
2009-03-28 16:19   
Merged the two proposed patches in 3.11 release branch. Should go in 3.11.1.