Commit 2909e6fb authored by sof's avatar sof
Browse files

[project @ 2005-10-27 01:39:40 by sof]

[mingw/msys only]
Undo long-standing workaround for buggy GNU ld's on mingw/msys; i.e.,
the linker wasn't correctly generating relocatable object files when
the number of relocs exceeded 2^16. Worked around the issue by
hackily splitting up the GHCi object file for the larger packages
('base', 'ObjectIO' and 'win32') into a handful of object files,
each with a manageable number of relocs. Tiresome and error-prone
(but the hack has served us well!)

This commit imposes a restriction on the 'ld' you use to compile
up GHC with; it now has to be ld-2.15.x or later (something GHC
binary dists have shipped with since 6.2.2)
parent 53068b73
......@@ -363,6 +363,12 @@ case $HostPlatform in
LdCmd="`cygpath -w ${fp_prog_ld_raw} | sed -e 's@\\\\@/@g'`"
AC_MSG_NOTICE([normalized ld command to $LdCmd])
# Insist on >= ld-2.15.x, since earlier versions doesn't handle
# the generation of relocatable object files with large amounts
# of relocations correctly. (cf. HSbase.o splittage-hack)
fp_prog_ld_version=`${LdCmd} --version | sed -n '/GNU ld/p' | tr -cd 0-9 | cut -b1-3`
[AC_MSG_ERROR([GNU ld version later than 2.14 required to compile GHC on Windows.])])[]dnl
......@@ -559,7 +559,7 @@ getPackageLinkOpts dflags pkgs = do
rts_tag = rtsBuildTag dflags
imp = if opt_Static then "" else "_dyn"
libs p = map ((++imp) . addSuffix) (hACK (hsLibraries p))
libs p = map ((++imp) . addSuffix) (hsLibraries p)
++ hACK_dyn (extraLibraries p)
all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
......@@ -570,7 +570,8 @@ getPackageLinkOpts dflags pkgs = do
addSuffix other_lib = other_lib ++ suffix
-- This is a hack that's even more horrible (and hopefully more temporary)
-- than the one below. HSbase_cbits and friends require the _dyn suffix
-- than the one below [referring to previous splittage of HSbase into chunks
-- to work around GNU ld bug]. HSbase_cbits and friends require the _dyn suffix
-- for dynamic linking, but not _p or other 'way' suffix. So we just add
-- _dyn to extraLibraries if they already have a _cbits suffix.
......@@ -579,41 +580,6 @@ getPackageLinkOpts dflags pkgs = do
| otherwise = lib
return (concat (map all_opts ps))
-- This is a totally horrible (temporary) hack, for Win32. Problem is
-- that package.conf for Win32 says that the main prelude lib is
-- split into HSbase1, HSbase2 and HSbase3, which is needed due to a bug
-- in the GNU linker (PEi386 backend). However, we still only
-- have HSbase.a for static linking, not HSbase{1,2,3}.a
-- getPackageLibraries is called to find the .a's to add to the static
-- link line. On Win32, this hACK detects HSbase{1,2,3} and
-- replaces them with HSbase, so static linking still works.
-- Libraries needed for dynamic (GHCi) linking are discovered via
-- different route (in InteractiveUI.linkPackage).
-- See driver/PackageSrc.hs for the HSbase1/HSbase2 split definition.
-- THIS IS A STRICTLY TEMPORARY HACK (famous last words ...)
-- JRS 04 Sept 01: Same appalling hack for HSwin32[1,2]
-- KAA 29 Mar 02: Same appalling hack for HSobjectio[1,2,3,4]
-- [sof 03/05: Renamed the (moribund) HSwin32 to HSwin_32 so as to
-- avoid filename conflicts with the 'Win32' package on a case-insensitive filesystem]
hACK libs
# if !defined(mingw32_TARGET_OS) && !defined(cygwin32_TARGET_OS)
= libs
# else
= if "HSbase1" `elem` libs && "HSbase2" `elem` libs && "HSbase3" `elem` libs
then "HSbase" : filter (not.(isPrefixOf "HSbase")) libs
if "HSwin_321" `elem` libs && "HSwin_322" `elem` libs
then "HSwin_32" : filter (not.(isPrefixOf "HSwin_32")) libs
if "HSobjectio1" `elem` libs && "HSobjectio2" `elem` libs && "HSobjectio3" `elem` libs && "HSobjectio4" `elem` libs
then "HSobjectio" : filter (not.(isPrefixOf "HSobjectio")) libs
# endif
getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String]
getPackageExtraCcOpts dflags pkgs = do
......@@ -2258,8 +2258,14 @@ ocResolve_PEi386 ( ObjectCode* oc )
COFF_reloc* rel = (COFF_reloc*)
myindex ( sizeof_COFF_reloc, reltab, 0 );
noRelocs = rel->VirtualAddress;
/* 10/05: we now assume (and check for) a GNU ld that is capable
* of handling object files with (>2^16) of relocs.
#if 0
debugBelch("WARNING: Overflown relocation field (# relocs found: %u)\n",
j = 1;
} else {
noRelocs = sectab_i->NumberOfRelocations;
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