summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolfgang.thaller@gmx.net <unknown>2006-11-27 13:06:02 +0000
committerwolfgang.thaller@gmx.net <unknown>2006-11-27 13:06:02 +0000
commitffdbb302967a147550113251e47b9d98a7affdc0 (patch)
tree9d3f3e67c928c92b1ef23ba30b1524e131007239
parent08560cf0e3a2a1928650ca5d5d0bb44fbac2ea44 (diff)
downloadhaskell-ffdbb302967a147550113251e47b9d98a7affdc0.tar.gz
Initial support for x86_64-darwin
Basic -fvia-C code generation is there, not much testing.
-rw-r--r--aclocal.m44
-rw-r--r--configure.ac9
-rw-r--r--distrib/configure-bin.ac2
-rw-r--r--driver/mangler/ghc-asm.lprl40
-rw-r--r--rts/StgCRun.c12
5 files changed, 64 insertions, 3 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 9d1e1cab9b..86fdeaf76f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -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}};
diff --git a/configure.ac b/configure.ac
index 7f977cd654..8b00e5af02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/distrib/configure-bin.ac b/distrib/configure-bin.ac
index a852ec9ba9..cda2cffecf 100644
--- a/distrib/configure-bin.ac
+++ b/distrib/configure-bin.ac
@@ -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
diff --git a/driver/mangler/ghc-asm.lprl b/driver/mangler/ghc-asm.lprl
index ab43cdcd7d..90b49751b6 100644
--- a/driver/mangler/ghc-asm.lprl
+++ b/driver/mangler/ghc-asm.lprl
@@ -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"
diff --git a/rts/StgCRun.c b/rts/StgCRun.c
index 9d80bdbf64..51388510c6 100644
--- a/rts/StgCRun.c
+++ b/rts/StgCRun.c
@@ -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 */