Commit b3016a12 authored by simonmar's avatar simonmar

[project @ 2002-12-12 17:36:16 by simonmar]

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
parent 6d353fcb
......@@ -30,8 +30,8 @@ import ByteCodeItbls ( ItblEnv )
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 )
......@@ -384,7 +384,8 @@ linkLibraries :: DynFlags
-- 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 ()
......@@ -671,6 +672,7 @@ linkPackage dflags pkg
= 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
--
......@@ -261,7 +261,7 @@ static_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 --------------------------------------------------
......
......@@ -1145,13 +1145,7 @@ staticLink o_files = do
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
......@@ -1168,12 +1162,10 @@ staticLink o_files = do
-- 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]
......@@ -1194,19 +1186,17 @@ staticLink o_files = do
++ 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 []))
......@@ -1236,15 +1226,7 @@ doMkDLL o_files = do
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
......@@ -1272,12 +1254,10 @@ doMkDLL o_files = do
++ [ "--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
--
......@@ -380,8 +380,6 @@ GLOBAL_VAR(v_Import_paths, ["."], [String])
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])
......@@ -535,14 +533,19 @@ getPackageLibraryPath = do
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
......@@ -584,11 +587,6 @@ getPackageExtraCcOpts = do
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment