X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=aclocal.m4;h=d30b10146d9c10fdb698089c970789bd8bf975eb;hp=ce8e58511e6020dc08f8ba561d0d6a947c344ea3;hb=235edf36cc202bb21c00d0e5e05ebf076fb0542e;hpb=4d2457071327bc82898b2c974d0d2e03747537c9 diff --git a/aclocal.m4 b/aclocal.m4 index ce8e585..d30b101 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -936,45 +936,47 @@ AC_SUBST([GhcHasReadline], [`echo $fp_cv_ghc_has_readline | sed 'y/yesno/YESNO/' ])# FP_GHC_HAS_READLINE -# FP_GCC_NEEDS_NO_OMIT_LFPTR -# -------------------------- +# FP_GCC_EXTRA_FLAGS +# ------------------ +# Determine which extra flags we need to pass gcc when we invoke it +# to compile .hc code. +# # Some OSs (Mandrake Linux, in particular) configure GCC with -# -momit-leaf-frame-pointer on by default. If this is the case, we need to turn -# it off for mangling to work. The test is currently a bit crude, using only the -# version number of gcc. Defines HAVE_GCC_MNO_OMIT_LFPTR. -AC_DEFUN([FP_GCC_NEEDS_NO_OMIT_LFPTR], -[AC_REQUIRE([FP_HAVE_GCC]) -AC_CACHE_CHECK([whether gcc needs -mno-omit-leaf-frame-pointer], [fp_cv_gcc_needs_no_omit_lfptr], -[FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.2], - [fp_cv_gcc_needs_no_omit_lfptr=yes], - [fp_cv_gcc_needs_no_omit_lfptr=no])]) -if test "$fp_cv_gcc_needs_no_omit_lfptr" = "yes"; then - AC_DEFINE([HAVE_GCC_MNO_OMIT_LFPTR], [1], [Define to 1 if gcc supports -mno-omit-leaf-frame-pointer.]) -fi])# FP_GCC_NEEDS_NO_OMIT_LFPTR - -# FP_GCC_HAS_NO_UNIT_AT_A_TIME -# -------------------------- -AC_DEFUN([FP_GCC_HAS_NO_UNIT_AT_A_TIME], +# -momit-leaf-frame-pointer on by default. If this is the case, we +# need to turn it off for mangling to work. The test is currently a +# bit crude, using only the version number of gcc. +# +# -fwrapv is needed for gcc to emit well-behaved code in the presence of +# integer wrap around. (Trac #952) +# +# -fno-unit-at-a-time or -fno-toplevel-reoder is necessary to avoid gcc +# reordering things in the module and confusing the manger and/or splitter. +# (eg. Trac #1427) +# +AC_DEFUN([FP_GCC_EXTRA_FLAGS], [AC_REQUIRE([FP_HAVE_GCC]) -AC_CACHE_CHECK([whether gcc has -fno-unit-at-a-time], [fp_cv_gcc_has_no_unit_at_a_time], -[FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4], - [fp_cv_gcc_has_no_unit_at_a_time=yes], - [fp_cv_gcc_has_no_unit_at_a_time=no])]) -if test "$fp_cv_gcc_has_no_unit_at_a_time" = "yes"; then - AC_DEFINE([HAVE_GCC_HAS_NO_UNIT_AT_A_TIME], [1], [Define to 1 if gcc supports -fno-unit-at-a-time.]) -fi]) +AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts], +[fp_cv_gcc_extra_opts= + FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4], + [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fwrapv"], + []) + case $TargetPlatform in + i386-*|x86_64-*) + FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.2], + [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -mno-omit-leaf-frame-pointer"], + []) + FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4], + [FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [4.2], + [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-toplevel-reorder"], + [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-unit-at-a-time"] + )], + []) + ;; + esac +]) +AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts) +]) -# FP_GCC_HAS_WRAPV -# -------------------------- -AC_DEFUN([FP_GCC_HAS_WRAPV], -[AC_REQUIRE([FP_HAVE_GCC]) -AC_CACHE_CHECK([whether gcc has -fwrapv], [fp_cv_gcc_has_wrapv], -[FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4], - [fp_cv_gcc_has_wrapv=yes], - [fp_cv_gcc_has_wrapv=no])]) -if test "$fp_cv_gcc_has_wrapv" = "yes"; then - AC_DEFINE([HAVE_GCC_HAS_WRAPV], [1], [Define to 1 if gcc supports -fwrapv.]) -fi]) # FP_SETUP_PROJECT_VERSION # --------------------- @@ -1096,54 +1098,30 @@ AC_REQUIRE([AC_PROG_CC]) AC_DEFUN([FP_FIND_ROOT],[ AC_MSG_CHECKING(for path to top of build tree) -hardtop=`pwd` +dnl This would be +dnl make -C utils/pwd clean && make -C utils/pwd +dnl except we don't want to have to know what make is called. Sigh. +if test ! -f utils/pwd/pwd && test ! -f utils/pwd/pwd.exe; then + cd utils/pwd + rm -f *.o + rm -f *.hi + rm -f pwd + rm -f pwd.exe + $WithGhc -v0 --make pwd -o pwd + cd ../.. +fi + +hardtop=`utils/pwd/pwd forwardslash` + +if ! test -d "$hardtop"; then + AC_MSG_ERROR([cannot determine current directory]) +fi dnl Remove common automounter nonsense dnl -hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^//\(.\)/|\1:/|' ` +hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'` -dnl Find 'hardtop_plat', the native format for 'hardtop' -dnl (i.e., right kind of \dnl slashes on a Win32 box, but with b-slashes -dnl being escaped). -dnl -dnl Note OSTYPE: On Cygwin we need to use 'cygpath' to convert -dnl /cygdrive/c/foo to c:/foo but we must not do that if we -dnl aren't building using Cygwin (notably msys), because -dnl cygpath doesn't exist. It seems that 'bash' sets -dnl OSTYPE to 'cygwin' or 'msys' respectively, but cygwin's -dnl 'sh' does not. So we hackily assume that if the shell -dnl hasn't set it to 'msys' then we must be in Cygwin. -dnl Sigh. -dnl -dnl The Right Thing is probably to test $BuildPlatform -dnl instead, but we are sloppy about setting that correctly -dnl at the moment, so we just work around for now. -dnl -dnl The quotes round "$(OSTYPE)" are essential, for the -dnl Cygwin-sh case where OSTYPE is not set. -case $HostPlatform in - i386-unknown-mingw32 | i386-unknown-cygwin32) - if test "${OSTYPE}" != "msys" - then - # convert $hardtop to a path that mingw will understand too - cyghardtop=${hardtop} - hardtop=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@/@g'` - hardtop_plat=`cygpath -w ${cyghardtop} | sed -e 's@\\\\@\\\\\\\\@g'` - else -dnl OK, so we're in the MSYS case. hardtop looks like /c/.... -dnl We want to make hardtop_plat into c:/... -dnl Stop using [] for quotes temporarily, so we can use [] in the sed regexp -changequote(, )dnl - hardtop_plat=`echo ${hardtop} | sed -e 's@^/\\([a-zA-Z]\\)/@\\1:/@g'` -changequote([, ])dnl - fi - ;; - *) - hardtop_plat=${hardtop} - ;; -esac AC_SUBST(hardtop) -AC_SUBST(hardtop_plat) AC_MSG_RESULT(${hardtop})