diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-04-02 11:52:47 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-05 05:42:38 -0400 |
commit | 7ffbdc3fa603c6411249ba9b758cf8f109c5fb30 (patch) | |
tree | 8a05d6e03ce2790e6e59651c824e569fee088d33 /m4/fptools_set_c_ld_flags.m4 | |
parent | 6acadb79afe685c635fd255f90551a0fbfcbe3dc (diff) | |
download | haskell-7ffbdc3fa603c6411249ba9b758cf8f109c5fb30.tar.gz |
Break up aclocal.m4
Diffstat (limited to 'm4/fptools_set_c_ld_flags.m4')
-rw-r--r-- | m4/fptools_set_c_ld_flags.m4 | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/m4/fptools_set_c_ld_flags.m4 b/m4/fptools_set_c_ld_flags.m4 new file mode 100644 index 0000000000..9cea4a832e --- /dev/null +++ b/m4/fptools_set_c_ld_flags.m4 @@ -0,0 +1,101 @@ +# FPTOOLS_SET_C_LD_FLAGS +# ---------------------------------- +# Set the C, LD and CPP flags for a given platform. +# $1 is the platform +# $2 is the name of the CC flags variable +# $3 is the name of the linker flags variable when linking with gcc +# $4 is the name of the linker flags variable when linking with ld +# $5 is the name of the CPP flags variable +AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS], +[ + AC_REQUIRE([FP_PROG_LD_IS_GNU]) + AC_MSG_CHECKING([Setting up $2, $3, $4 and $5]) + case $$1 in + i386-*) + # Workaround for #7799 + $2="$$2 -U__i686" + ;; + esac + + case $$1 in + i386-unknown-mingw32) + $2="$$2 -march=i686" + ;; + i386-portbld-freebsd*) + $2="$$2 -march=i686" + ;; + x86_64-unknown-solaris2) + # Solaris is a multi-lib platform, providing both 32- and 64-bit + # user-land. It appears to default to 32-bit builds but we of course want to + # compile for 64-bits on x86-64. + # + # On OpenSolaris uses gnu ld whereas SmartOS appears to use the Solaris + # implementation, which rather uses the -64 flag. + $2="$$2 -m64" + $3="$$3 -m64" + $5="$$5 -m64" + if test "$fp_cv_gnu_ld" = "yes"; then + $4="$$4 -m64" + else + $4="$$4 -64" + fi + ;; + alpha-*) + # For now, to suppress the gcc warning "call-clobbered + # register used for global register variable", we simply + # disable all warnings altogether using the -w flag. Oh well. + $2="$$2 -w -mieee -D_REENTRANT" + $3="$$3 -w -mieee -D_REENTRANT" + $5="$$5 -w -mieee -D_REENTRANT" + ;; + hppa*) + # ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi! + # (very nice, but too bad the HP /usr/include files don't agree.) + $2="$$2 -D_HPUX_SOURCE" + $3="$$3 -D_HPUX_SOURCE" + $5="$$5 -D_HPUX_SOURCE" + ;; + + arm*freebsd*) + # On arm/freebsd, tell gcc to generate Arm + # instructions (ie not Thumb). + $2="$$2 -marm" + $3="$$3 -Wl,-z,noexecstack" + $4="$$4 -z noexecstack" + ;; + arm*linux*) + # On arm/linux and arm/android, tell gcc to generate Arm + # instructions (ie not Thumb). + $2="$$2 -marm" + $3="$$3 -Wl,-z,noexecstack" + $4="$$4 -z noexecstack" + ;; + + aarch64*freebsd*) + $3="$$3 -Wl,-z,noexecstack" + $4="$$4 -z noexecstack" + ;; + aarch64*linux*) + $3="$$3 -Wl,-z,noexecstack" + $4="$$4 -z noexecstack" + ;; + + powerpc-ibm-aix*) + # We need `-D_THREAD_SAFE` to unlock the thread-local `errno`. + $2="$$2 -D_THREAD_SAFE" + $3="$$3 -D_THREAD_SAFE -Wl,-bnotextro" + $4="$$4 -bnotextro" + $5="$$5 -D_THREAD_SAFE" + ;; + + x86_64-*-openbsd*) + # We need -z wxneeded at least to link ghc-stage2 to workaround + # W^X issue in GHCi on OpenBSD current (as of Aug 2016) + $3="$$3 -Wl,-z,wxneeded" + $4="$$4 -z wxneeded" + ;; + + esac + + AC_MSG_RESULT([done]) +]) |