Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2005 19:29:39 +0200 (CEST)
From:      Johan van Selst <johans@stack.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        simonmar@microsoft.com
Subject:   ports/81474: lang/ghc5: fix for compilation on FreeBSD 5.x
Message-ID:  <20050525172939.9FFE217039@mud.stack.nl>
Resent-Message-ID: <200505251730.j4PHU2QR018834@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         81474
>Category:       ports
>Synopsis:       lang/ghc5: fix for compilation on FreeBSD 5.x
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 25 17:30:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Johan van Selst
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD mud.stack.nl 5.4-STABLE FreeBSD 5.4-STABLE #3: Mon May 9 19:06:32 CEST 2005 root@mud.stack.nl:/usr/obj/usr/src/sys/mud i386


	
>Description:
	[Cc: maintainer, simonmar@microsoft.com]

	The way Haskell uses backslashes to format multi-line strings
	is not compatible with the latest cpp strictness.

	This patch changes multi-line strings to use string concatenation.
	It introduces no functional changes, but assures compilation
	of ghc5 on FreeBSD-STABLE machines as well.

	
>How-To-Repeat:
	
>Fix:

	

	Multi-line strings are frequently used. This creates 6 patchfiles:
		files/patch-ghc_compiler_ghci_InteractiveUI.hs
		files/patch-ghc_compiler_ndpFlatten_Flattening.hs
		files/patch-ghc_utils_ghc-pkg_Main.hs
		files/patch-ghc_utils_hsc2hs_Main.hs
		files/patch-libraries_base_Data_List.hs
		files/patch-ghc_rts_Profiling.c		# fixes a gcc warning

diff -uNr ghc5/Makefile ghc5/Makefile
--- ghc5/Makefile	Sat Sep 18 19:22:58 2004
+++ ghc5/Makefile	Tue May 24 21:09:21 2005
@@ -20,10 +20,6 @@
 USE_BZIP2=	yes
 .include <bsd.port.pre.mk>
 
-.if ${OSVERSION} >= 502126
-BROKEN=		"Does not compile on FreeBSD >= 5.x"
-.endif
-
 DISTFILES=	${SRC_DIST}
 
 .if ${OSVERSION} < 500000
diff -uNr ghc5/files/patch-ghc-rts-rts.conf.in ghc5/files/patch-ghc-rts-rts.conf.in
--- ghc5/files/patch-ghc-rts-rts.conf.in	Tue Dec 16 11:08:52 2003
+++ ghc5/files/patch-ghc-rts-rts.conf.in	Wed May 25 00:38:26 2005
@@ -1,10 +1,10 @@
---- ghc/rts/rts.conf.in.orig	Thu Dec 11 15:53:05 2003
-+++ ghc/rts/rts.conf.in	Thu Dec 11 16:08:54 2003
+--- ghc/rts/rts.conf.in.orig	Mon Feb 10 11:18:31 2003
++++ ghc/rts/rts.conf.in	Tue May 24 21:03:38 2005
 @@ -134,6 +134,7 @@
           , "-u", "GHCziWeak_runFinalizzerBatch_closure"
           , "-u", "__stginit_Prelude"
  #endif
-+         , "-L%%LOCALBASE%%/lib"
++         , "-L/usr/local/lib"
           ]
  #ifdef HAVE_FRAMEWORK_HASKELLSUPPORT
          , extra_frameworks  = [ "HaskellSupport" ]
diff -uNr ghc5/files/patch-ghc_compiler_ghci_InteractiveUI.hs ghc5/files/patch-ghc_compiler_ghci_InteractiveUI.hs
--- ghc5/files/patch-ghc_compiler_ghci_InteractiveUI.hs	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-ghc_compiler_ghci_InteractiveUI.hs	Wed May 25 00:38:14 2005
@@ -0,0 +1,98 @@
+--- ghc/compiler/ghci/InteractiveUI.hs.orig	Tue May 24 23:10:08 2005
++++ ghc/compiler/ghci/InteractiveUI.hs	Tue May 24 23:11:37 2005
+@@ -80,12 +80,12 @@ import GHC.Posix	( setNonBlockingFD )
+ 
+ -----------------------------------------------------------------------------
+ 
+-ghciWelcomeMsg = "\ 
+-\   ___         ___ _\n\ 
+-\  / _ \\ /\\  /\\/ __(_)\n\ 
+-\ / /_\\// /_/ / /  | |      GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n\ 
+-\/ /_\\\\/ __  / /___| |      http://www.haskell.org/ghc/\n\ 
+-\\\____/\\/ /_/\\____/|_|      Type :? for help.\n"
++ghciWelcomeMsg = ""++
++ "   ___         ___ _\n"++
++ "  / _ \\ /\\  /\\/ __(_)\n"++
++ " / /_\\// /_/ / /  | |      GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++
++ "/ /_\\\\/ __  / /___| |      http://www.haskell.org/ghc/\n"++
++ "\\____/\\/ /_/\\____/|_|      Type :? for help.\n"
+ 
+ GLOBAL_VAR(commands, builtin_commands, [(String, String -> GHCi Bool)])
+ 
+@@ -118,41 +118,41 @@ keepGoingPaths a str = a (toArgs str) >>
+ shortHelpText = "use :? for help.\n"
+ 
+ -- NOTE: spaces at the end of each line to workaround CPP/string gap bug.
+-helpText = "\ 
+-\ Commands available from the prompt:\n\ 
+-\\n\ 
+-\   <stmt>		       evaluate/run <stmt>\n\ 
+-\   :add <filename> ...        add module(s) to the current target set\n\ 
+-\   :browse [*]<module>	       display the names defined by <module>\n\ 
+-\   :cd <dir>		       change directory to <dir>\n\ 
+-\   :def <cmd> <expr>          define a command :<cmd>\n\ 
+-\   :help, :?		       display this list of commands\n\ 
+-\   :info [<name> ...]         display information about the given names\n\ 
+-\   :load <filename> ...       load module(s) and their dependents\n\ 
+-\   :module [+/-] [*]<mod> ... set the context for expression evaluation\n\ 
+-\   :reload		       reload the current module set\n\ 
+-\\n\ 
+-\   :set <option> ...	       set options\n\ 
+-\   :set args <arg> ...	       set the arguments returned by System.getArgs\n\ 
+-\   :set prog <progname>       set the value returned by System.getProgName\n\ 
+-\\n\ 
+-\   :show modules	       show the currently loaded modules\n\ 
+-\   :show bindings	       show the current bindings made at the prompt\n\ 
+-\\n\ 
+-\   :type <expr>	       show the type of <expr>\n\ 
+-\   :undef <cmd> 	       undefine user-defined command :<cmd>\n\ 
+-\   :unset <option> ...	       unset options\n\ 
+-\   :quit		       exit GHCi\n\ 
+-\   :!<command>		       run the shell command <command>\n\ 
+-\\n\ 
+-\ Options for `:set' and `:unset':\n\ 
+-\\n\ 
+-\    +r			revert top-level expressions after each evaluation\n\ 
+-\    +s                 print timing/memory stats after each evaluation\n\ 
+-\    +t			print type after evaluation\n\ 
+-\    -<flags>		most GHC command line flags can also be set here\n\ 
+-\                         (eg. -v2, -fglasgow-exts, etc.)\n\ 
+-\"
++helpText = ( ""++
++ " Commands available from the prompt:\n"++
++ "\n"++
++ "   <stmt>		       evaluate/run <stmt>\n"++
++ "   :add <filename> ...        add module(s) to the current target set\n"++
++ "   :browse [*]<module>	       display the names defined by <module>\n"++
++ "   :cd <dir>		       change directory to <dir>\n"++
++ "   :def <cmd> <expr>          define a command :<cmd>\n"++
++ "   :help, :?		       display this list of commands\n"++
++ "   :info [<name> ...]         display information about the given names\n"++
++ "   :load <filename> ...       load module(s) and their dependents\n"++
++ "   :module [+/-] [*]<mod> ... set the context for expression evaluation\n"++
++ "   :reload		       reload the current module set\n"++
++ "\n"++
++ "   :set <option> ...	       set options\n"++
++ "   :set args <arg> ...	       set the arguments returned by System.getArgs\n"++
++ "   :set prog <progname>       set the value returned by System.getProgName\n"++
++ "\n"++
++ "   :show modules	       show the currently loaded modules\n"++
++ "   :show bindings	       show the current bindings made at the prompt\n"++
++ "\n"++
++ "   :type <expr>	       show the type of <expr>\n"++
++ "   :undef <cmd> 	       undefine user-defined command :<cmd>\n"++
++ "   :unset <option> ...	       unset options\n"++
++ "   :quit		       exit GHCi\n"++
++ "   :!<command>		       run the shell command <command>\n"++
++ "\n"++
++ " Options for `:set' and `:unset':\n"++
++ "\n"++
++ "    +r			revert top-level expressions after each evaluation\n"++
++ "    +s                 print timing/memory stats after each evaluation\n"++
++ "    +t			print type after evaluation\n"++
++ "    -<flags>		most GHC command line flags can also be set here\n"++
++ "                         (eg. -v2, -fglasgow-exts, etc.)\n"++
++ "" )
+ 
+ interactiveUI :: CmState -> [FilePath] -> [LibrarySpec] -> IO ()
+ interactiveUI cmstate paths cmdline_libs = do
diff -uNr ghc5/files/patch-ghc_compiler_ndpFlatten_Flattening.hs ghc5/files/patch-ghc_compiler_ndpFlatten_Flattening.hs
--- ghc5/files/patch-ghc_compiler_ndpFlatten_Flattening.hs	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-ghc_compiler_ndpFlatten_Flattening.hs	Wed May 25 00:38:18 2005
@@ -0,0 +1,13 @@
+--- ghc/compiler/ndpFlatten/Flattening.hs.orig	Tue May 24 22:10:38 2005
++++ ghc/compiler/ndpFlatten/Flattening.hs	Tue May 24 22:10:56 2005
+@@ -650,8 +650,8 @@ dftbpBinders indexBnds exprBnds =
+ 	return ((fBnd, (newBnd:restBnds)), liftTy ty)
+ 
+     dftbpBinders'  _ _ _ = 
+-      panic "Flattening.dftbpBinders: index and expression binder lists \ 
+-	    \have different length!"
++      panic ("Flattening.dftbpBinders: index and expression binder lists "++
++	    "have different length!")
+ 
+ getExprOfBind:: CoreBind -> CoreExpr
+ getExprOfBind (NonRec _ expr) = expr
diff -uNr ghc5/files/patch-ghc_rts_Profiling.c ghc5/files/patch-ghc_rts_Profiling.c
--- ghc5/files/patch-ghc_rts_Profiling.c	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-ghc_rts_Profiling.c	Wed May 25 00:38:28 2005
@@ -0,0 +1,10 @@
+--- ghc/rts/Profiling.c.orig	Tue May 24 23:15:46 2005
++++ ghc/rts/Profiling.c	Tue May 24 23:15:56 2005
+@@ -713,6 +713,7 @@ reportCCSProfiling( void )
+       gen_XML_logfile();
+       return;
+     default:
++      /* do nothing */;
+     }
+ 
+     fprintf(prof_file, "\t%s Time and Allocation Profiling Report  (%s)\n", 
diff -uNr ghc5/files/patch-ghc_utils_ghc-pkg_Main.hs ghc5/files/patch-ghc_utils_ghc-pkg_Main.hs
--- ghc5/files/patch-ghc_utils_ghc-pkg_Main.hs	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-ghc_utils_ghc-pkg_Main.hs	Wed May 25 00:38:31 2005
@@ -0,0 +1,15 @@
+--- ghc/utils/ghc-pkg/Main.hs.orig	Tue May 24 21:09:06 2005
++++ ghc/utils/ghc-pkg/Main.hs	Tue May 24 21:32:53 2005
+@@ -190,9 +190,9 @@ checkConfigAccess pkgconf = do
+ maybeRestoreOldConfig :: String -> IO () -> IO ()
+ maybeRestoreOldConfig conf_file io
+   = my_catch io (\e -> do
+-        hPutStr stdout "\nWARNING: an error was encountered while the new \n\ 
+-        	       \configuration was being written.  Attempting to \n\ 
+-        	       \restore the old configuration... "
++        hPutStr stdout ("\nWARNING: an error was encountered while the new \n"++
++        	       "configuration was being written.  Attempting to \n"++
++        	       "restore the old configuration... ")
+ 	renameFile (conf_file ++ ".old")  conf_file
+         hPutStrLn stdout "done."
+ 	my_throw e
diff -uNr ghc5/files/patch-ghc_utils_hsc2hs_Main.hs ghc5/files/patch-ghc_utils_hsc2hs_Main.hs
--- ghc5/files/patch-ghc_utils_hsc2hs_Main.hs	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-ghc_utils_hsc2hs_Main.hs	Wed May 25 00:38:34 2005
@@ -0,0 +1,109 @@
+--- ghc/utils/hsc2hs/Main.hs.orig	Tue May 24 21:37:37 2005
++++ ghc/utils/hsc2hs/Main.hs	Tue May 24 21:37:39 2005
+@@ -562,17 +562,17 @@ output flags name toks = do
+         _                 -> return ()
+     
+     when needsH $ writeFile outHName $
+-        "#ifndef "++includeGuard++"\n\ 
+-        \#define "++includeGuard++"\n\ 
+-        \#if " ++
+-	"__GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\ 
+-        \#include <Rts.h>\n\ 
+-        \#endif\n\ 
+-        \#include <HsFFI.h>\n\ 
+-        \#if __NHC__\n\ 
+-        \#undef HsChar\n\ 
+-        \#define HsChar int\n\ 
+-        \#endif\n"++
++        "#ifndef "++includeGuard++"\n"++
++        "#define "++includeGuard++"\n"++
++        "#if " ++
++	"__GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n"++
++        "#include <Rts.h>\n"++
++        "#endif\n"++
++        "#include <HsFFI.h>\n"++
++        "#if __NHC__\n"++
++        "#undef HsChar\n"++
++        "#define HsChar int\n"++
++        "#endif\n"++
+         concatMap outFlagH flags++
+         concatMap outTokenH specials++
+         "#endif\n"
+@@ -615,8 +615,8 @@ outHeaderCProg (pos, key, arg) = case ke
+         (header, _:body) -> case break isSpace header of
+             (name, args) ->
+                 outCLine pos++
+-                "#define hsc_"++name++"("++dropWhile isSpace args++") \ 
+-                \printf ("++joinLines body++");\n"
++                "#define hsc_"++name++"("++dropWhile isSpace args++") "++
++                "printf ("++joinLines body++");\n"
+     _ -> ""
+     where
+     joinLines = concat . intersperse " \\\n" . lines
+@@ -624,11 +624,11 @@ outHeaderCProg (pos, key, arg) = case ke
+ outHeaderHs :: [Flag] -> Maybe String -> [(SourcePos, String, String)] -> String
+ outHeaderHs flags inH toks =
+     "#if " ++
+-    "__GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\ 
+-    \    printf (\"{-# OPTIONS -optc-D" ++
+-    "__GLASGOW_HASKELL__=%d #-}\\n\", \ 
+-    \__GLASGOW_HASKELL__);\n\ 
+-    \#endif\n"++
++    "__GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n"++
++    "    printf (\"{-# OPTIONS -optc-D" ++
++    "__GLASGOW_HASKELL__=%d #-}\\n\", "++
++    "__GLASGOW_HASKELL__);\n"++
++    "#endif\n"++
+     case inH of
+         Nothing -> concatMap outFlag flags++concatMap outSpecial toks
+         Just f  -> outOption ("-#include \""++f++"\"")
+@@ -686,12 +686,12 @@ outEnum arg =
+                     (enum, rest) -> let
+                         this = case break (== '=') $ dropWhile isSpace enum of
+                             (name, []) ->
+-                                "    hsc_enum ("++t++", "++f++", \ 
+-                                \hsc_haskellize (\""++name++"\"), "++
++                                "    hsc_enum ("++t++", "++f++", "++
++                                "hsc_haskellize (\""++name++"\"), "++
+                                 name++");\n"
+                             (hsName, _:cName) ->
+-                                "    hsc_enum ("++t++", "++f++", \ 
+-                                \printf (\"%s\", \""++hsName++"\"), "++
++                                "    hsc_enum ("++t++", "++f++", "++
++                                "printf (\"%s\", \""++hsName++"\"), "++
+                                 cName++");\n"
+                         in this++enums rest
+                 in enums afterF
+@@ -712,9 +712,9 @@ outTokenH (pos, key, arg) =
+             's':'t':'r':'u':'c':'t':' ':_ -> arg++"\n"
+             't':'y':'p':'e':'d':'e':'f':' ':_ -> arg++"\n"
+             'i':'n':'l':'i':'n':'e':' ':_ ->
+-                "#ifdef __GNUC__\n\ 
+-                \extern\n\ 
+-                \#endif\n"++
++                "#ifdef __GNUC__\n"++
++                "extern\n"++
++                "#endif\n"++
+                 arg++"\n"
+             _ -> "extern "++header++";\n"
+             where header = takeWhile (\c -> c /= '{' && c /= '=') arg
+@@ -731,13 +731,13 @@ outTokenC (pos, key, arg) =
+ 		case span (\c -> c /= '{' && c /= '=') arg' of
+ 		(header, body) ->
+ 		    outCLine pos++
+-		    "#ifndef __GNUC__\n\ 
+-		    \extern inline\n\ 
+-		    \#endif\n"++
++		    "#ifndef __GNUC__\n"++
++		    "extern inline\n"++
++		    "#endif\n"++
+ 		    header++
+-		    "\n#ifndef __GNUC__\n\ 
+-		    \;\n\ 
+-		    \#else\n"++
++		    "\n#ifndef __GNUC__\n"++
++		    ";\n"++
++		    "#else\n"++
+ 		    body++
+ 		    "\n#endif\n"
+             _ -> outCLine pos++arg++"\n"
diff -uNr ghc5/files/patch-libraries_base_Data_List.hs ghc5/files/patch-libraries_base_Data_List.hs
--- ghc5/files/patch-libraries_base_Data_List.hs	Thu Jan  1 01:00:00 1970
+++ ghc5/files/patch-libraries_base_Data_List.hs	Wed May 25 00:38:38 2005
@@ -0,0 +1,11 @@
+--- libraries/base/Data/List.hs.orig	Tue May 24 23:25:06 2005
++++ libraries/base/Data/List.hs	Tue May 24 23:37:14 2005
+@@ -144,7 +144,7 @@ import GHC.Show	( lines, words, unlines,
+ import GHC.Base
+ #endif
+ 
+-infix 5 \\ 
++infix 5 \\ -- comment to fool cpp
+ 
+ -- -----------------------------------------------------------------------------
+ -- List functions
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050525172939.9FFE217039>