A modification to the way we build link lines.
Currently the link line is constructed like this, for packages p1, p2 etc.:
libraries p1 ++ extra_libs p1 ++
libraries p2 ++ extra_libs p2 ++
...
extra_ld_opts p1 ++
extra_ld_opts p2 ++
..
This change makes it follow this pattern:
libraries p1 ++ extra_libs p1 ++ extra_ld_opts p1 ++
libraries p2 ++ extra_libs p2 ++ extra_ld_opts p2 ++
...
which seems more useful: in particular it means that using foo-config
(eg. gtk-config) to populate extra_ld_opts should now work properly,
and extra_libs is no longer strictly speaking needed (you can just use
-l options in extra_ld_opts and get the same effect).
Also:
- There's now no difference between -l<lib> and -optl-l<lib>
- GHCi grabs libs from extra_ld_opts as well as extra_libs
import ByteCodeAsm ( CompiledByteCode(..), bcoFreeNames, UnlinkedBCO(..))
import Packages
-import DriverState ( v_Library_paths, v_Cmdline_libraries,
- getPackageConfigMap )
+import DriverState ( v_Library_paths, v_Opt_l, getPackageConfigMap,
+ getStaticOpts )
import Finder ( findModule, findLinkable )
import HscTypes
import Name ( Name, nameModule, isExternalName )
-- specified on the command line.
linkLibraries dflags objs
= do { lib_paths <- readIORef v_Library_paths
- ; minus_ls <- readIORef v_Cmdline_libraries
+ ; opt_l <- getStaticOpts v_Opt_l
+ ; let minus_ls = [ lib | '-':'l':lib <- opt_l ]
; let cmdline_lib_specs = map Object objs ++ map DLL minus_ls
; if (null cmdline_lib_specs) then return ()
= do
let dirs = Packages.library_dirs pkg
let libs = Packages.hs_libraries pkg ++ extra_libraries pkg
+ ++ [ lib | '-':'l':lib <- extra_ld_opts pkg ]
classifieds <- mapM (locateOneObj dirs) libs
#ifdef darwin_TARGET_OS
let fwDirs = Packages.framework_dirs pkg
-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.106 2002/11/20 09:37:48 simonpj Exp $
+-- $Id: DriverFlags.hs,v 1.107 2002/12/12 17:36:18 simonmar Exp $
--
-- Driver flags
--
------- Libraries ---------------------------------------------------
, ( "L" , Prefix (addToDirList v_Library_paths) )
- , ( "l" , Prefix (add v_Cmdline_libraries) )
+ , ( "l" , AnySuffix (\s -> add v_Opt_l s >> add v_Opt_dll s) )
#ifdef darwin_TARGET_OS
------- Frameworks --------------------------------------------------
lib_paths <- readIORef v_Library_paths
let lib_path_opts = map ("-L"++) lib_paths
- pkg_libs <- getPackageLibraries
- let imp = if static then "" else "_imp"
- pkg_lib_opts = map (\lib -> "-l" ++ lib ++ imp) pkg_libs
-
- libs <- readIORef v_Cmdline_libraries
- let lib_opts = map ("-l"++) (reverse libs)
- -- reverse because they're added in reverse order from the cmd line
+ pkg_link_opts <- getPackageLinkOpts
#ifdef darwin_TARGET_OS
pkg_framework_paths <- getPackageFrameworkPath
-- reverse because they're added in reverse order from the cmd line
#endif
- pkg_extra_ld_opts <- getPackageExtraLdOpts
-
-- probably _stub.o files
extra_ld_inputs <- readIORef v_Ld_inputs
- -- opts from -optl-<blah>
+ -- opts from -optl-<blah> (including -l<blah> options)
extra_ld_opts <- getStaticOpts v_Opt_l
[rts_pkg, std_pkg] <- getPackageDetails [rtsPackage, basePackage]
++ extra_os
++ extra_ld_inputs
++ lib_path_opts
- ++ lib_opts
+ ++ extra_ld_opts
#ifdef darwin_TARGET_OS
++ framework_path_opts
++ framework_opts
#endif
++ pkg_lib_path_opts
- ++ pkg_lib_opts
+ ++ pkg_link_opts
#ifdef darwin_TARGET_OS
++ pkg_framework_path_opts
++ pkg_framework_opts
#endif
- ++ pkg_extra_ld_opts
- ++ extra_ld_opts
++ if static && not no_hs_main then
[ "-u", prefixUnderscore "Main_zdmain_closure"]
else []))
lib_paths <- readIORef v_Library_paths
let lib_path_opts = map ("-L"++) lib_paths
- pkg_libs <- getPackageLibraries
- let imp = if static then "" else "_imp"
- pkg_lib_opts = map (\lib -> "-l" ++ lib ++ imp) pkg_libs
-
- libs <- readIORef v_Cmdline_libraries
- let lib_opts = map ("-l"++) (reverse libs)
- -- reverse because they're added in reverse order from the cmd line
-
- pkg_extra_ld_opts <- getPackageExtraLdOpts
+ pkg_link_opts <- getPackageLinkOpts
-- probably _stub.o files
extra_ld_inputs <- readIORef v_Ld_inputs
++ [ "--target=i386-mingw32" ]
++ extra_ld_inputs
++ lib_path_opts
- ++ lib_opts
+ ++ extra_ld_opts
++ pkg_lib_path_opts
- ++ pkg_lib_opts
- ++ pkg_extra_ld_opts
+ ++ pkg_link_opts
++ (if "--def" `elem` (concatMap words extra_ld_opts)
then [ "" ]
else [ "--export-all" ])
- ++ extra_ld_opts
))
-----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.85 2002/10/25 16:54:58 simonpj Exp $
+-- $Id: DriverState.hs,v 1.86 2002/12/12 17:36:19 simonmar Exp $
--
-- Settings for the driver
--
GLOBAL_VAR(v_Include_paths, ["."], [String])
GLOBAL_VAR(v_Library_paths, [], [String])
-GLOBAL_VAR(v_Cmdline_libraries, [], [String])
-
#ifdef darwin_TARGET_OS
GLOBAL_VAR(v_Framework_paths, [], [String])
GLOBAL_VAR(v_Cmdline_frameworks, [], [String])
ps <- getPackageInfo
return (nub (filter notNull (concatMap library_dirs ps)))
-getPackageLibraries :: IO [String]
-getPackageLibraries = do
+getPackageLinkOpts :: IO [String]
+getPackageLinkOpts = do
ps <- getPackageInfo
tag <- readIORef v_Build_tag
- let suffix = if null tag then "" else '_':tag
- return (concat (
- map (\p -> map (++suffix) (hACK (hs_libraries p)) ++ extra_libraries p) ps
- ))
+ static <- readIORef v_Static
+ let
+ imp = if static then "" else "_imp"
+ suffix = if null tag then "" else '_':tag
+ libs p = map (++suffix) (hACK (hs_libraries p)) ++ extra_libraries p
+ imp_libs p = map (++imp) (libs p)
+ all_opts p = map ("-l" ++) (imp_libs p) ++ extra_ld_opts p
+
+ return (concat (map all_opts ps))
where
-- This is a totally horrible (temporary) hack, for Win32. Problem is
-- that package.conf for Win32 says that the main prelude lib is
ps <- getPackageInfo
return (concatMap extra_cc_opts ps)
-getPackageExtraLdOpts :: IO [String]
-getPackageExtraLdOpts = do
- ps <- getPackageInfo
- return (concatMap extra_ld_opts ps)
-
#ifdef darwin_TARGET_OS
getPackageFrameworkPath :: IO [String]
getPackageFrameworkPath = do