SOURCES: ghc-gcc42.patch (NEW) - fix build with gcc 4.2.x - http:/...

baggins baggins at pld-linux.org
Mon Sep 10 16:30:55 CEST 2007


Author: baggins                      Date: Mon Sep 10 14:30:55 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- fix build with gcc 4.2.x
- http://hackage.haskell.org/trac/ghc/ticket/1427
- http://www.haskell.org/pipermail/cvs-ghc/2007-August/037480.html

---- Files affected:
SOURCES:
   ghc-gcc42.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/ghc-gcc42.patch
diff -u /dev/null SOURCES/ghc-gcc42.patch:1.1
--- /dev/null	Mon Sep 10 16:30:55 2007
+++ SOURCES/ghc-gcc42.patch	Mon Sep 10 16:30:50 2007
@@ -0,0 +1,271 @@
+diff -urN ghc-6.7.20070820/Makefile ghc-6.7.20070821/Makefile
+--- ghc-6.7.20070820/Makefile	2007-08-20 19:14:10.000000000 +0200
++++ ghc-6.7.20070821/Makefile	2007-08-21 19:18:28.000000000 +0200
+@@ -199,6 +199,11 @@
+ endif
+ endif
+ 
++# Install gcc-extra-opts
++install ::
++	@$(INSTALL_DIR) $(libdir)
++	$(INSTALL_DATA) $(INSTALL_OPTS) extra-gcc-opts $(libdir)
++
+ install-docs ::
+ 	@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
+ 	for i in $(SUBDIRS); do \
+@@ -262,6 +267,7 @@
+ 	      LICENSE \
+ 	      utils/mkdirhier/mkdirhier \
+ 	      install-sh \
++	      extra-gcc-opts.in \
+ 	      config.guess \
+ 	      config.sub   \
+ 	      aclocal.m4
+diff -urN ghc-6.7.20070820/aclocal.m4 ghc-6.7.20070821/aclocal.m4
+--- ghc-6.7.20070820/aclocal.m4	2007-08-20 19:14:10.000000000 +0200
++++ ghc-6.7.20070821/aclocal.m4	2007-08-21 19:18:28.000000000 +0200
+@@ -936,45 +936,47 @@
+ ])# 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],
++# -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 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],
+-[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])
+-
+-# 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])
++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_SETUP_PROJECT_VERSION
+ # ---------------------
+diff -urN ghc-6.7.20070820/compiler/main/DriverPipeline.hs ghc-6.7.20070821/compiler/main/DriverPipeline.hs
+--- ghc-6.7.20070820/compiler/main/DriverPipeline.hs	2007-08-20 19:14:11.000000000 +0200
++++ ghc-6.7.20070821/compiler/main/DriverPipeline.hs	2007-08-21 19:18:28.000000000 +0200
+@@ -811,6 +811,7 @@
+ 			      (cmdline_include_paths ++ pkg_include_dirs)
+ 
+ 	let (md_c_flags, md_regd_c_flags) = machdepCCOpts dflags
++        gcc_extra_viac_flags <- getExtraViaCOpts dflags
+         let pic_c_flags = picCCOpts dflags
+ 
+         let verb = getVerbFlag dflags
+@@ -877,6 +878,13 @@
+ 		       ++ (if hcc && mangle
+ 		  	     then md_regd_c_flags
+ 		  	     else [])
++		       ++ (if hcc
++		  	     then if mangle 
++                                     then gcc_extra_viac_flags
++                                     else filter (=="-fwrapv")
++                                                gcc_extra_viac_flags
++                                -- still want -fwrapv even for unreg'd
++		  	     else [])
+ 		       ++ (if hcc 
+ 			     then more_hcc_opts
+ 			     else [])
+@@ -886,10 +894,6 @@
+ 		       ++ split_opt
+ 		       ++ include_paths
+ 		       ++ pkg_extra_cc_opts
+-#ifdef HAVE_GCC_HAS_WRAPV
+-                  -- We need consistent integer overflow (trac #952)
+-               ++ ["-fwrapv"]
+-#endif
+ 		       ))
+ 
+ 	return (next_phase, dflags, maybe_loc, output_fn)
+diff -urN ghc-6.7.20070820/compiler/main/DynFlags.hs ghc-6.7.20070821/compiler/main/DynFlags.hs
+--- ghc-6.7.20070820/compiler/main/DynFlags.hs	2007-08-20 19:14:11.000000000 +0200
++++ ghc-6.7.20070821/compiler/main/DynFlags.hs	2007-08-21 19:18:28.000000000 +0200
+@@ -1503,6 +1515,18 @@
+ -----------------------------------------------------------------------------
+ -- Via-C compilation stuff
+ 
++-- There are some options that we need to pass to gcc when compiling
++-- Haskell code via C, but are only supported by recent versions of
++-- gcc.  The configure script decides which of these options we need,
++-- and puts them in the file "extra-gcc-opts" in $topdir, which is
++-- read before each via-C compilation.  The advantage of having these
++-- in a separate file is that the file can be created at install-time
++-- depending on the available gcc version, and even re-generated  later
++-- if gcc is upgraded.
++--
++-- The options below are not dependent on the version of gcc, only the
++-- platform.
++
+ machdepCCOpts :: DynFlags -> ([String], -- flags for all C compilations
+ 			      [String]) -- for registerised HC compilations
+ machdepCCOpts dflags
+@@ -1545,20 +1569,6 @@
+ --                    , if "mingw32" `isSuffixOf` cTARGETPLATFORM then "-mno-cygwin" else "" 
+ 		      ],
+ 		      [ "-fno-defer-pop",
+-#ifdef HAVE_GCC_MNO_OMIT_LFPTR
+-			-- Some gccs are configured with
+-			-- -momit-leaf-frame-pointer on by default, and it
+-			-- apparently takes precedence over 
+-			-- -fomit-frame-pointer, so we disable it first here.
+-			"-mno-omit-leaf-frame-pointer",
+-#endif
+-#ifdef HAVE_GCC_HAS_NO_UNIT_AT_A_TIME
+-		 	"-fno-unit-at-a-time",
+-			-- unit-at-a-time doesn't do us any good, and screws
+-			-- up -split-objs by moving the split markers around.
+-			-- It's only turned on with -O2, but put it here just
+-			-- in case someone uses -optc-O2.
+-#endif
+ 			"-fomit-frame-pointer",
+ 			-- we want -fno-builtin, because when gcc inlines
+ 			-- built-in functions like memcpy() it tends to
+@@ -1577,13 +1587,6 @@
+ 			-- and get in the way of -split-objs.  Another option
+ 			-- would be to throw them away in the mangler, but this
+ 			-- is easier.
+-#ifdef HAVE_GCC_HAS_NO_UNIT_AT_A_TIME
+-		 "-fno-unit-at-a-time",
+-			-- unit-at-a-time doesn't do us any good, and screws
+-			-- up -split-objs by moving the split markers around.
+-			-- It's only turned on with -O2, but put it here just
+-			-- in case someone uses -optc-O2.
+-#endif
+ 		 "-fno-builtin"
+ 			-- calling builtins like strlen() using the FFI can
+ 			-- cause gcc to run out of regs, so use the external
+diff -urN ghc-6.7.20070820/compiler/main/SysTools.lhs ghc-6.7.20070821/compiler/main/SysTools.lhs
+--- ghc-6.7.20070820/compiler/main/SysTools.lhs	2007-08-20 19:14:11.000000000 +0200
++++ ghc-6.7.20070821/compiler/main/SysTools.lhs	2007-08-21 19:18:28.000000000 +0200
+@@ -22,6 +22,7 @@
+ 	copy,
+         copyWithHeader,
+ 	normalisePath,          -- FilePath -> FilePath
++        getExtraViaCOpts,
+ 	
+ 	-- Temporary-file management
+ 	setTmpDir,
+@@ -536,6 +537,10 @@
+   hPutStr h ls
+   hClose h
+ 
++getExtraViaCOpts :: DynFlags -> IO [String]
++getExtraViaCOpts dflags = do
++  f <- readFile (topDir dflags `joinFileName` "extra-gcc-opts")
++  return (words f)
+ \end{code}
+ 
+ %************************************************************************
+diff -urN ghc-6.7.20070820/configure.ac ghc-6.7.20070821/configure.ac
+--- ghc-6.7.20070820/configure.ac	2007-08-20 19:14:11.000000000 +0200
++++ ghc-6.7.20070821/configure.ac	2007-08-21 19:18:28.000000000 +0200
+@@ -876,9 +876,7 @@
+ dnl
+ FP_HAVE_GCC
+ FP_MINGW_GCC
+-FP_GCC_NEEDS_NO_OMIT_LFPTR
+-FP_GCC_HAS_NO_UNIT_AT_A_TIME
+-FP_GCC_HAS_WRAPV
++FP_GCC_EXTRA_FLAGS
+ 
+ dnl ** figure out how to invoke cpp directly (gcc -E is no good)
+ AC_PROG_CPP
+@@ -1230,6 +1228,6 @@
+ fi
+ AC_SUBST(HavePapi)
+ 
+-AC_CONFIG_FILES([mk/config.mk ghc.spec docs/users_guide/ug-book.xml])
++AC_CONFIG_FILES([mk/config.mk ghc.spec extra-gcc-opts docs/users_guide/ug-book.xml])
+ AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
+ AC_OUTPUT
+diff -urN ghc-6.7.20070820/distrib/configure-bin.ac ghc-6.7.20070821/distrib/configure-bin.ac
+--- ghc-6.7.20070820/distrib/configure-bin.ac	2007-08-20 19:14:02.000000000 +0200
++++ ghc-6.7.20070821/distrib/configure-bin.ac	2007-08-21 19:18:28.000000000 +0200
+@@ -148,7 +148,13 @@
+ AC_PROG_CPP
+ 
+ #
+-AC_OUTPUT(Makefile)
++dnl ** Check gcc version and flags we need to pass it **
++#
++FP_GCC_EXTRA_FLAGS
++
++#
++AC_CONFIG_FILES(Makefile extra-gcc-opts)
++AC_OUTPUT
+ 
+ echo "****************************************************"
+ echo "Configuration done, ready to either 'make install'"
+diff -urN ghc-6.7.20070822/extra-gcc-opts.in ghc-6.8.20070908/extra-gcc-opts.in
+--- ghc-6.7.20070822/extra-gcc-opts.in	1970-01-01 01:00:00.000000000 +0100
++++ ghc-6.8.20070908/extra-gcc-opts.in	2007-09-08 19:13:19.000000000 +0200
+@@ -0,0 +1 @@
++ at GccExtraViaCOpts@
================================================================


More information about the pld-cvs-commit mailing list