#2021: let ghc find framework header files and link with frameworks located in
$HOME/Library/Frameworks
--------------------------------+-------------------------------------------
Reporter: maeder | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.2
Severity: normal | Keywords:
Difficulty: Easy (1 hr) | Testcase:
Architecture: Multiple | Os: MacOS X
--------------------------------+-------------------------------------------
As described in ticket #1395 I want ghc to be able to work with my local
frameworks. Therefore I've extended the file
`compiler/main/DriverPipeline.hs`.
In my latest (attached) version I've also removed a few duplications.
I've considered to check if the directory `$HOME/Library/Frameworks`
exists using `doesDirectoryExist`, but that's done anyway by gcc and ld on
mac. I've also considered to only pass
`"-F$HOME/Library/Frameworks"` if there are `-framework` flags on the
command line at all, but this did not work for `HsReadline_cbits.c`:
{{{
../../compiler/stage1/ghc-inplace -Iinclude -package base-3.0.1.0 -package
process-1.0.0.0 -optc-O2 -odir dist/build -c HsReadline_cbits.c -o
dist/build/HsReadline_cbits.o
In file included from HsReadline_cbits.c:1:0:
include/HsReadline.h:7:43:
error: GNUreadline/readline/readline.h: No such file or directory
include/HsReadline.h:8:42:
error: GNUreadline/readline/history.h: No such file or directory
HsReadline_cbits.c: In function 'hs_rl_message':
HsReadline_cbits.c:5:0:
warning: implicit declaration of function 'rl_message'
make[2]: *** [dist/build/HsReadline_cbits.o] Error 1
make[1]: *** [make.library.readline] Error 2
make: *** [stage1] Error 2
}}}
This (single) case may be fixed by passing "`-F$HOME/Library/Frameworks`"
manually, but what is the risk of passing "`-F$HOME/Library/Frameworks`"
always? Well, someone may have spoiled frameworks there, but even that is
no problem as long as they are not used, because dylibs are used instead.
Of course other C-compilers may not like the -F flag (in fact that is a
problem if ghc is used as C-compiler and was actually bad for hsc2hs
#1395).
Maybe configure should check if gcc understands -F on macs? What do others
think? Would you commit my `DriverPipeline.hs` changes?
A `"diff -u -w"` currently looks as follows:
{{{
+++ compiler/main/DriverPipeline.hs 2008-01-07 14:39:12.000000000
+0100
@@ -822,6 +822,9 @@
let include_paths = foldr (\ x xs -> "-I" : x : xs) []
(cmdline_include_paths ++ pkg_include_dirs)
+#ifdef darwin_TARGET_OS
+ framework_path_opts <- getFrameworkPathOpts dflags pkgs
+#endif
let (md_c_flags, md_regd_c_flags) = machdepCCOpts dflags
gcc_extra_viac_flags <- getExtraViaCOpts dflags
let pic_c_flags = picCCOpts dflags
@@ -905,6 +908,9 @@
++ cc_opts
++ split_opt
++ include_paths
+#ifdef darwin_TARGET_OS
+ ++ framework_path_opts
+#endif
++ pkg_extra_cc_opts
))
@@ -1199,17 +1205,10 @@
pkg_link_opts <- getPackageLinkOpts dflags dep_packages
#ifdef darwin_TARGET_OS
- pkg_framework_paths <- getPackageFrameworkPath dflags dep_packages
- let pkg_framework_path_opts = map ("-F"++) pkg_framework_paths
-
- let framework_paths = frameworkPaths dflags
- framework_path_opts = map ("-F"++) framework_paths
-
+ framework_path_opts <- getFrameworkPathOpts dflags dep_packages
pkg_frameworks <- getPackageFrameworks dflags dep_packages
- let pkg_framework_opts = concat [ ["-framework", fw] | fw <-
pkg_frameworks ]
-
- let frameworks = cmdlineFrameworks dflags
- framework_opts = concat [ ["-framework", fw] | fw <- reverse
frameworks ]
+ let framework_opts = concat [ ["-framework", fw]
+ | fw <- pkg_frameworks ++ reverse (cmdlineFrameworks dflags) ]
-- reverse because they're added in reverse order from the cmd
line
#endif
@@ -1264,10 +1263,6 @@
#endif
++ pkg_lib_path_opts
++ pkg_link_opts
-#ifdef darwin_TARGET_OS
- ++ pkg_framework_path_opts
- ++ pkg_framework_opts
-#endif
++ debug_opts
++ thread_opts
))
@@ -1278,6 +1273,15 @@
if success then return ()
else throwDyn (InstallationError ("cannot move
binary to PVM dir")))
+-- options to pass to gcc and ld on macs only
+getFrameworkPathOpts :: DynFlags -> [PackageId] -> IO [String]
+getFrameworkPathOpts dflags pkgs = do
+ ps <- getPackageFrameworkPath dflags pkgs
+ let fps = ps ++ frameworkPaths dflags
+ eitherDir <- IO.try getHomeDirectory
+ return $ map ("-F" ++) $ case eitherDir of
+ Left _ -> fps
+ Right hdir -> (hdir ++ "/Library/Frameworks") : fps
exeFileName :: DynFlags -> FilePath
exeFileName dflags
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2021>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs