[commit: ghc] master: Set AIX specific CFLAGS flags (75036aa)

git at git.haskell.org git at git.haskell.org
Thu Nov 19 12:24:45 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/75036aacb492886a7c65035127ee11fec11ee7ce/ghc

>---------------------------------------------------------------

commit 75036aacb492886a7c65035127ee11fec11ee7ce
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Thu Nov 19 12:56:48 2015 +0100

    Set AIX specific CFLAGS flags
    
    First of all, we need to use -mminimal-toc on IBM AIX
    
    AIX's XCOFF is limited to 16k entries in its TOC for 32bit compilation,
    which quickly overflows with GHC's code generation.
    
    Otoh, the Parser.hs module contains more entries than fit into a
    minimal-toc, so we need to switch back to `-mfull-toc` for that single
    module again.
    
    Then, we also need to set the `THREAD_SAFE` CPP #define in order to
    unlock the thread-safe `errno` which is essential for the threaded
    runtime.
    
    Depends on D1501
    
    Reviewers: austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie, erikd
    
    Differential Revision: https://phabricator.haskell.org/D1502


>---------------------------------------------------------------

75036aacb492886a7c65035127ee11fec11ee7ce
 aclocal.m4      | 14 ++++++++++++++
 compiler/ghc.mk | 13 +++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/aclocal.m4 b/aclocal.m4
index e816e09..4bd8198 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -587,6 +587,20 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
         $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
         $4="$$4 -z noexecstack"
         ;;
+
+    powerpc-ibm-aix*)
+        # On IBM AIX, we need to workaround XCOFF's limitations. Specifically,
+        # there's a TOC which only supports at most 16k entries (see
+        # http://www.ibm.com/developerworks/rational/library/overview-toc-aix/
+        # for more details), and by using `-mminimal-toc` we use up only one TOC
+        # entry per translation unit, at the cost of an additional pointer
+        # indirection. However, see note in `compiler/ghc.mk` about `Parser.hs`.
+        # Finally, we need `-D_THREAD_SAFE` to unlock a thread-local `errno`.
+        $2="$$2 -mminimal-toc -D_THREAD_SAFE"
+        $3="$$3 -mminimal-toc -D_THREAD_SAFE"
+        $5="$$5 -D_THREAD_SAFE"
+        ;;
+
     esac
 
     # If gcc knows about the stack protector, turn it off.
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 887a876..6fde5c0 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -380,6 +380,19 @@ endif
 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
 
+# On IBM AIX we need to wrokaround XCOFF's TOC limitations (see also
+# comment in `aclocal.m4` about `-mminimal-toc` for more details)
+# However, Parser.hc defines so many symbols that `-mminimal-toc`
+# generates instructions with offsets exceeding the PPC offset
+# addressing limits.  So we need to counter-act this via `-mfull-toc`
+# which disables a preceding `-mminimal-toc` again.
+ifeq "$(HostOS_CPP)" "aix"
+compiler/stage1/build/Parser_HC_OPTS += -optc-mfull-toc
+endif
+ifeq "$(TargetOS_CPP)" "aix"
+compiler/stage2/build/Parser_HC_OPTS += -optc-mfull-toc
+compiler/stage3/build/Parser_HC_OPTS += -optc-mfull-toc
+endif
 
 ifeq "$(GhcProfiled)" "YES"
 # If we're profiling GHC then we want SCCs.  However, adding -auto-all



More information about the ghc-commits mailing list