Commit 75036aac authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺 Committed by Ben Gamari

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

Depends on D1501

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, erikd

Differential Revision:
parent c5d8162d
......@@ -587,6 +587,20 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
$3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
$4="$$4 -z noexecstack"
# On IBM AIX, we need to workaround XCOFF's limitations. Specifically,
# there's a TOC which only supports at most 16k entries (see
# 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/` 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"
# If gcc knows about the stack protector, turn it off.
......@@ -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
ifeq "$(TargetOS_CPP)" "aix"
compiler/stage2/build/Parser_HC_OPTS += -optc-mfull-toc
compiler/stage3/build/Parser_HC_OPTS += -optc-mfull-toc
ifeq "$(GhcProfiled)" "YES"
# If we're profiling GHC then we want SCCs. However, adding -auto-all
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment