Initial support for x86_64-darwin
authorwolfgang.thaller@gmx.net <unknown>
Mon, 27 Nov 2006 13:06:02 +0000 (13:06 +0000)
committerwolfgang.thaller@gmx.net <unknown>
Mon, 27 Nov 2006 13:06:02 +0000 (13:06 +0000)
Basic -fvia-C code generation is there, not much testing.

aclocal.m4
configure.ac
distrib/configure-bin.ac
driver/mangler/ghc-asm.lprl
rts/StgCRun.c

index 9d1e1ca..86fdeaf 100644 (file)
@@ -168,6 +168,10 @@ case $HostPlatform in
 alpha-dec-osf*) fptools_cv_leading_underscore=no;;
 *cygwin32) fptools_cv_leading_underscore=yes;;
 *mingw32) fptools_cv_leading_underscore=yes;;
+
+    # HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries
+x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;;
+
 *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
 #include <nlist.h>
 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
index 7f977cd..8b00e5a 100644 (file)
@@ -317,6 +317,15 @@ x86_64-*-linux*)
         HostVendor_CPP='unknown'
         HostOS_CPP='linux'
         ;;
+x86_64-apple-darwin*)
+        HostPlatform=x86_64-apple-darwin
+        TargetPlatform=x86_64-apple-darwin
+        BuildPlatform=x86_64-apple-darwin
+        HostPlatform_CPP='x86_64_apple_darwin'
+        HostArch_CPP='x86_64'
+        HostVendor_CPP='apple'
+        HostOS_CPP='darwin'
+        ;;
 m68k-*-linux*)
         HostPlatform=m68k-unknown-linux # hack again
         TargetPlatform=m68k-unknown-linux
index a852ec9..cda2cff 100644 (file)
@@ -96,6 +96,8 @@ x86_64-*-openbsd*)
        TargetPlatform=x86_64-unknown-openbsd;;
 x86_64-*-netbsd*)
        TargetPlatform=x86_64-unknown-netbsd;;
+x86_64-apple-darwin*)
+       TargetPlatform=x86_64-apple-darwin;;
 *)
         echo "Unrecognised platform: $TargetPlatform"
         exit 1
index ab43cdc..90b4975 100644 (file)
@@ -344,6 +344,32 @@ sub init_TARGET_STUFF {
     $T_HDR_vector   = "\t\.text\n\t\.align 2\n";
 
     #--------------------------------------------------------#
+    } elsif ( $TargetPlatform =~ /^x86_64-apple-darwin.*/ ) {
+                               # Apple PowerPC Darwin/MacOS X.
+    $T_STABBY      = 0; # 1 iff .stab things (usually if a.out format)
+    $T_US          = '_'; # _ if symbols have an underscore on the front
+    $T_PRE_APP     = 'DOESNT APPLY'; # regexp that says what comes before APP/NO_APP
+    $T_CONST_LBL    = '^\LC\d+:'; # regexp for what such a lbl looks like
+    $T_POST_LBL            = ':';
+
+    $T_MOVE_DIRVS   = '^(\s*(\.align \d+|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
+    $T_COPY_DIRVS   = '\.(globl|lcomm)';
+
+    $T_DOT_WORD            = '\.(quad|long|short|byte|fill|space)';
+    $T_DOT_GLOBAL   = '\.globl';
+    $T_HDR_toc      = "\.toc\n";
+    $T_HDR_literal16= "\t\.literal8\n\t\.align 4\n";
+    $T_HDR_literal  = "\t\.const\n\t\.align 4\n";
+    $T_HDR_misc            = "\t\.text\n\t\.align 2\n";
+    $T_HDR_data            = "\t\.data\n\t\.align 2\n";
+    $T_HDR_rodata   = "\t\.const\n\t\.align 2\n";
+    $T_HDR_relrodata= "\t\.const_data\n\t\.align 2\n";
+    $T_HDR_closure  = "\t\.data\n\t\.align 2\n";
+    $T_HDR_info            = "\t\.text\n\t\.align 2\n";
+    $T_HDR_entry    = "\t\.text\n\t\.align 2\n";
+    $T_HDR_vector   = "\t\.text\n\t\.align 2\n";
+
+    #--------------------------------------------------------#
     } elsif ( $TargetPlatform =~ /^powerpc-.*-linux/ ) {
                                # PowerPC Linux
     $T_STABBY      = 0; # 1 iff .stab things (usually if a.out format)
@@ -1730,6 +1756,20 @@ sub rev_tbl {
        }
     }
 
+    if ( $TargetPlatform =~ /x86_64-apple-darwin/ ) {
+        # Tack a label to the front of the info table, too.
+        # For now, this just serves to work around a crash in Apple's new
+        # 64-bit linker (it seems to assume that there is no data before the
+        # first label in a section).
+        
+        # The plan for the future is to do this on all Darwin platforms, and
+        # to add a reference to this label after the entry code, just as the
+        # NCG does, so we can enable dead-code-stripping in the linker without
+        # losing our info tables. (Hence the name _dsp, for dead-strip preventer)
+        
+        $before .= "\n${infoname}_dsp:\n";    
+    }
+
     $tbl = $before
         . (($TargetPlatform !~ /^hppa/) ? '' : join("\n", @imports) . "\n")
         . join("\n", @words) . "\n"
index 9d80bdb..5138851 100644 (file)
@@ -107,6 +107,12 @@ StgFunPtr StgReturn(void)
 #else /* !USE_MINIINTERPRETER */
 
 #ifdef LEADING_UNDERSCORE
+#define STG_RUN "_StgRun"
+#else
+#define STG_RUN "StgRun"
+#endif
+
+#ifdef LEADING_UNDERSCORE
 #define STG_RETURN "_StgReturn"
 #else
 #define STG_RETURN "StgReturn"
@@ -207,8 +213,8 @@ StgRunIsImplementedInAssembler(void)
        /*
         * save callee-saves registers on behalf of the STG code.
         */
-       ".globl StgRun\n"
-       "StgRun:\n\t"
+       ".globl " STG_RUN "\n"
+       STG_RUN ":\n\t"
        "subq %0, %%rsp\n\t"
        "movq %%rsp, %%rax\n\t"
        "addq %0-48, %%rax\n\t"
@@ -228,7 +234,7 @@ StgRunIsImplementedInAssembler(void)
         "movq %%rdi,%%rax\n\t"
         "jmp *%%rax\n\t"
 
-       ".global " STG_RETURN "\n"
+       ".globl " STG_RETURN "\n"
                STG_RETURN ":\n\t"
 
        "movq %%rbx, %%rax\n\t"   /* Return value in R1  */