Commit f5448f5c authored by simonmar's avatar simonmar

[project @ 2000-11-07 10:42:55 by simonmar]

merge before-ghci -> before-ghci-branch-merged into the ghc
(non-compiler) parts of the tree.
parent 6cf31336
{-# OPTIONS -W -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
-- $Id: Main.hs,v 1.68 2000/10/11 16:06:38 simonmar Exp $
-- $Id: Main.hs,v 1.69 2000/11/07 10:42:55 simonmar Exp $
--
-- GHC Driver program
--
......@@ -13,6 +13,8 @@
module Main (main) where
import Utils
import GetImports
import Package
import Config
......@@ -773,7 +775,6 @@ GLOBAL_VAR(build_tag, "", String)
data WayName
= WayProf
| WayUnreg
| WayDll
| WayTicky
| WayPar
| WayGran
......@@ -800,12 +801,9 @@ data WayName
GLOBAL_VAR(ways, [] ,[WayName])
-- ToDo: allow WayDll with any other allowed combination
allowed_combinations =
[ [WayProf,WayUnreg],
[WayProf,WaySMP] -- works???
]
allowed_combination ways = ways `elem` combs
where -- the sub-lists must be ordered according to WayName, because findBuildTag sorts them
combs = [ [WayProf,WayUnreg], [WayProf,WaySMP] ]
findBuildTag :: IO [String] -- new options
findBuildTag = do
......@@ -818,7 +816,7 @@ findBuildTag = do
writeIORef build_tag (wayTag details)
return (wayOpts details)
ws -> if ws `notElem` allowed_combinations
ws -> if allowed_combination ws
then throwDyn (OtherError $
"combination not supported: " ++
foldr1 (\a b -> a ++ '/':b)
......@@ -862,9 +860,6 @@ way_details =
, "-funregisterised"
, "-fvia-C" ]),
(WayDll, Way "dll" "DLLized"
[ ]),
(WayPar, Way "mp" "Parallel"
[ "-fparallel"
, "-D__PARALLEL_HASKELL__"
......@@ -952,9 +947,10 @@ machdepCCOpts
-- the fp (%ebp) for our register maps.
= do n_regs <- readState stolen_x86_regs
sta <- readIORef static
return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" ],
return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "",
if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" ],
[ "-fno-defer-pop", "-fomit-frame-pointer",
"-DSTOLEN_X86_REGS="++show n_regs ]
"-DSTOLEN_X86_REGS="++show n_regs]
)
| prefixMatch "mips" cTARGETPLATFORM
......@@ -1190,7 +1186,7 @@ main =
-----------------------------------------------------------------------------
-- Which phase to stop at
data ToDo = DoMkDependHS | DoMkDLL | StopBefore Phase | DoLink
data ToDo = DoMkDependHS | StopBefore Phase | DoLink
deriving (Eq)
GLOBAL_VAR(v_todo, error "todo", ToDo)
......@@ -1785,7 +1781,8 @@ run_phase Hsc basename suff input_fn output_fn
-- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless.
do_recomp <- readIORef recomp
todo <- readIORef v_todo
o_file <- odir_ify (basename ++ '.':phase_input_ext Ln)
o_file' <- odir_ify (basename ++ '.':phase_input_ext Ln)
o_file <- osuf_ify o_file'
source_unchanged <-
if not (do_recomp && ( todo == DoLink || todo == StopBefore Ln ))
then return ""
......@@ -1843,7 +1840,7 @@ run_phase Hsc basename suff input_fn output_fn
run_something "Copy stub .c file"
(unwords [
"rm -f", stub_c, "&&",
"echo \'#include \""++stub_h++"\"\' >"++stub_c, " &&",
"echo \'#include \"Stg.h\"\n#include \""++stub_h++"\"\' >"++stub_c, " &&",
"cat", tmp_stub_c, ">> ", stub_c
])
......@@ -1922,9 +1919,6 @@ run_phase cc_phase _basename _suff input_fn output_fn
++ [ verb, "-S", "-Wimplicit", opt_flag ]
++ [ "-D__GLASGOW_HASKELL__="++cProjectVersionInt ]
++ cc_opts
#ifdef mingw32_TARGET_OS
++ [" -mno-cygwin"]
#endif
++ (if excessPrecision then [] else [ "-ffloat-store" ])
++ include_paths
++ pkg_extra_cc_opts
......@@ -2027,10 +2021,15 @@ run_phase SplitAs basename _suff _input_fn _output_fn
-----------------------------------------------------------------------------
-- Linking
GLOBAL_VAR(no_hs_main, False, Bool)
do_link :: [String] -> IO ()
do_link o_files = do
ln <- readIORef pgm_l
verb <- is_verbose
static <- readIORef static
let imp = if static then "" else "_imp"
no_hs_main <- readIORef no_hs_main
o_file <- readIORef output_file
let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
......@@ -2041,7 +2040,7 @@ do_link o_files = do
let lib_path_opts = map ("-L"++) lib_paths
pkg_libs <- getPackageLibraries
let pkg_lib_opts = map (\lib -> "-l"++lib) pkg_libs
let pkg_lib_opts = map (\lib -> "-l" ++ lib ++ imp) pkg_libs
libs <- readIORef cmdline_libraries
let lib_opts = map ("-l"++) (reverse libs)
......@@ -2055,10 +2054,23 @@ do_link o_files = do
-- opts from -optl-<blah>
extra_ld_opts <- getOpts opt_l
rts_pkg <- getPackageDetails ["rts"]
std_pkg <- getPackageDetails ["std"]
#ifdef mingw32_TARGET_OS
let extra_os = if static || no_hs_main
then []
else [ head (library_dirs (head rts_pkg)) ++ "/Main.dll_o",
head (library_dirs (head std_pkg)) ++ "/PrelMain.dll_o" ]
#endif
(md_c_flags, _) <- machdepCCOpts
run_something "Linker"
(unwords
(unwords
([ ln, verb, "-o", output_fn ]
++ md_c_flags
++ o_files
#ifdef mingw32_TARGET_OS
++ extra_os
#endif
++ extra_ld_inputs
++ lib_path_opts
++ lib_opts
......@@ -2066,6 +2078,11 @@ do_link o_files = do
++ pkg_lib_opts
++ pkg_extra_ld_opts
++ extra_ld_opts
#ifdef mingw32_TARGET_OS
++ if static then [ "-u _PrelMain_mainIO_closure" , "-u ___init_PrelMain"] else []
#else
++ [ "-u PrelMain_mainIO_closure" , "-u __init_PrelMain"]
#endif
)
)
......@@ -2095,7 +2112,7 @@ run_something phase_name cmd
hPutStrLn h cmd
hClose h
exit_code <- system ("sh - " ++ tmp) `catchAllIO`
(\e -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
(\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
removeFile tmp
#endif
......@@ -2144,7 +2161,6 @@ driver_opts =
------- ways --------------------------------------------------------
, ( "prof" , NoArg (addNoDups ways WayProf) )
, ( "unreg" , NoArg (addNoDups ways WayUnreg) )
, ( "dll" , NoArg (addNoDups ways WayDll) )
, ( "ticky" , NoArg (addNoDups ways WayTicky) )
, ( "parallel" , NoArg (addNoDups ways WayPar) )
, ( "gransim" , NoArg (addNoDups ways WayGran) )
......@@ -2177,6 +2193,7 @@ driver_opts =
, ( "cpp" , NoArg (updateState (\s -> s{ cpp_flag = True })) )
, ( "#include" , HasArg (addCmdlineHCInclude) )
, ( "no-link-chk" , NoArg (return ()) ) -- ignored for backwards compat
, ( "no-hs-main" , NoArg (writeIORef no_hs_main True) )
------- Output Redirection ------------------------------------------
, ( "odir" , HasArg (writeIORef output_dir . Just) )
......@@ -2254,6 +2271,7 @@ driver_opts =
----- Linker --------------------------------------------------------
, ( "static" , NoArg (writeIORef static True) )
, ( "rdynamic" , NoArg (return ()) ) -- ignored for compat w/ gcc
------ Compiler RTS options -----------------------------------------
, ( "H" , HasArg (newHeapSize . decodeSize) )
......@@ -2434,15 +2452,6 @@ my_prefix_match (p:pat) (r:rest)
| p == r = my_prefix_match pat rest
| otherwise = Nothing
prefixMatch :: Eq a => [a] -> [a] -> Bool
prefixMatch [] _str = True
prefixMatch _pat [] = False
prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
| otherwise = False
postfixMatch :: String -> String -> Bool
postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
later = flip finally
my_catchDyn = flip catchDyn
......
#-----------------------------------------------------------------------------
# $Id: Makefile,v 1.44 2000/09/05 10:16:41 simonmar Exp $
# $Id: Makefile,v 1.45 2000/11/07 10:42:56 simonmar Exp $
#
TOP=..
......@@ -22,8 +22,8 @@ SRC_HC_OPTS += -fglasgow-exts -cpp -syslib concurrent -syslib posix -syslib misc
endif
HS_PROG = ghc-$(ProjectVersion)
HS_SRCS = Config.hs Package.hs GetImports.hs Main.hs
MKDEPENDHS_SRCS = Config.hs Main.hs GetImports.hs PackageSrc.hs
HS_SRCS = Config.hs Package.hs GetImports.hs Main.hs Utils.hs
MKDEPENDHS_SRCS = Config.hs Main.hs GetImports.hs PackageSrc.hs Utils.hs
LINK = ghc
SUBDIRS = mangler split stats
......@@ -58,7 +58,7 @@ Config.hs : $(FPTOOLS_TOP)/mk/config.mk Makefile
@echo "cGHC_SPLIT = \"$(GHC_SPLIT)\"" >> Config.hs
@echo "cGHC_STATS = \"$(GHC_STATS)\"" >> Config.hs
@echo "cGHC_SYSMAN = \"$(GHC_SYSMAN)\"" >> Config.hs
@echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> Config.hs
@echo "cDLLized = \"$(DLLized)\"" >> Config.hs
@echo "cCP = \"$(CP)\"" >> Config.hs
@echo "cRM = \"$(RM)\"" >> Config.hs
@echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> Config.hs
......@@ -95,8 +95,8 @@ CLEAN_FILES += ghc-inplace
all :: package.conf package.conf.inplace
pkgconf : Config.o Package.o PackageSrc.o
$(HC) $(HC_OPTS) $(LD_OPTS) Config.o Package.o PackageSrc.o -o pkgconf
pkgconf : Config.o Package.o PackageSrc.o Utils.o
$(HC) $(HC_OPTS) $(LD_OPTS) Config.o Package.o PackageSrc.o Utils.o -o pkgconf
package.conf.inplace : pkgconf
./pkgconf in-place >$@
......@@ -120,8 +120,12 @@ INSTALL_DATAS += ghc-usage.txt
include $(TOP)/mk/target.mk
# we need the driver for generating dependencies...
boot :: all
# We need the driver for generating dependencies... so build it as
# part of make boot. We need to do this using a recursive invocation
# of $(MAKE), so that dependencies we just generated for the driver
# itself are picked up.
boot ::
$(MAKE) $(MFLAGS) all
# -----------------------------------------------------------------------------
# Create link to from ghc-x.xx to ghc...
......
#include "../includes/config.h"
module Main (main) where
import Utils
import IO
import System
import Config
......@@ -52,37 +56,41 @@ package_details installing =
extra_cc_opts = [],
-- the RTS forward-references to a bunch of stuff in the prelude,
-- so we force it to be included with special options to ld.
extra_ld_opts = [
"-u PrelMain_mainIO_closure"
, "-u PrelBase_Izh_static_info"
, "-u PrelBase_Czh_static_info"
, "-u PrelFloat_Fzh_static_info"
, "-u PrelFloat_Dzh_static_info"
, "-u PrelAddr_Azh_static_info"
, "-u PrelAddr_Wzh_static_info"
, "-u PrelAddr_I64zh_static_info"
, "-u PrelAddr_W64zh_static_info"
, "-u PrelStable_StablePtr_static_info"
, "-u PrelBase_Izh_con_info"
, "-u PrelBase_Czh_con_info"
, "-u PrelFloat_Fzh_con_info"
, "-u PrelFloat_Dzh_con_info"
, "-u PrelAddr_Azh_con_info"
, "-u PrelAddr_Wzh_con_info"
, "-u PrelAddr_I64zh_con_info"
, "-u PrelAddr_W64zh_con_info"
, "-u PrelStable_StablePtr_con_info"
, "-u PrelBase_False_closure"
, "-u PrelBase_True_closure"
, "-u PrelPack_unpackCString_closure"
, "-u PrelIOBase_stackOverflow_closure"
, "-u PrelIOBase_heapOverflow_closure"
, "-u PrelIOBase_NonTermination_closure"
, "-u PrelIOBase_PutFullMVar_closure"
, "-u PrelIOBase_BlockedOnDeadMVar_closure"
, "-u PrelWeak_runFinalizzerBatch_closure"
, "-u __init_Prelude"
, "-u __init_PrelMain"
extra_ld_opts = map (
#ifndef LEADING_UNDERSCORE
"-u "
#else
"-u _"
#endif
++ ) [
"PrelBase_Izh_static_info"
, "PrelBase_Czh_static_info"
, "PrelFloat_Fzh_static_info"
, "PrelFloat_Dzh_static_info"
, "PrelAddr_Azh_static_info"
, "PrelAddr_Wzh_static_info"
, "PrelAddr_I64zh_static_info"
, "PrelAddr_W64zh_static_info"
, "PrelStable_StablePtr_static_info"
, "PrelBase_Izh_con_info"
, "PrelBase_Czh_con_info"
, "PrelFloat_Fzh_con_info"
, "PrelFloat_Dzh_con_info"
, "PrelAddr_Azh_con_info"
, "PrelAddr_Wzh_con_info"
, "PrelAddr_I64zh_con_info"
, "PrelAddr_W64zh_con_info"
, "PrelStable_StablePtr_con_info"
, "PrelBase_False_closure"
, "PrelBase_True_closure"
, "PrelPack_unpackCString_closure"
, "PrelIOBase_stackOverflow_closure"
, "PrelIOBase_heapOverflow_closure"
, "PrelIOBase_NonTermination_closure"
, "PrelIOBase_PutFullMVar_closure"
, "PrelIOBase_BlockedOnDeadMVar_closure"
, "PrelWeak_runFinalizzerBatch_closure"
, "__init_Prelude"
]
},
......@@ -104,7 +112,11 @@ package_details installing =
package_deps = [ "rts" ],
extra_ghc_opts = [],
extra_cc_opts = [],
extra_ld_opts = [ "-lm" ]
extra_ld_opts = [ "-lm"
#ifdef mingw32_TARGET_OS
, "-lwsock32"
#endif
]
},
Package {
......@@ -191,7 +203,7 @@ package_details installing =
package_deps = [ "lang", "text" ],
extra_ghc_opts = [],
extra_cc_opts = [],
extra_ld_opts = if postfixMatch "solaris2" cTARGETPLATFORM
extra_ld_opts = if suffixMatch "solaris2" cTARGETPLATFORM
then [ "-lnsl", "-lsocket" ]
else []
},
......@@ -257,7 +269,11 @@ package_details installing =
then []
else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
c_includes = [ "HsUtil.h" ],
package_deps = [ "lang", "concurrent", "posix" ],
package_deps = [ "lang", "concurrent"
#ifndef mingw32_TARGET_OS
, "posix"
#endif
],
extra_ghc_opts = [],
extra_cc_opts = [],
extra_ld_opts = []
......@@ -322,12 +338,3 @@ package_details installing =
ghc_src_dir :: String -> String
ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path
prefixMatch :: Eq a => [a] -> [a] -> Bool
prefixMatch [] _str = True
prefixMatch _pat [] = False
prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
| otherwise = False
postfixMatch :: String -> String -> Bool
postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
module Utils where
prefixMatch :: Eq a => [a] -> [a] -> Bool
prefixMatch [] _str = True
prefixMatch _pat [] = False
prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
| otherwise = False
suffixMatch :: String -> String -> Bool
suffixMatch pat str = prefixMatch (reverse pat) (reverse str)
......@@ -13,6 +13,18 @@ stuff to do with the C stack.
Any other required tidying up.
\end{itemize}
General note [chak]: Many regexps are very fragile because they rely on white
space being in the right place. This caused trouble with gcc 2.95 (at least
on Linux), where the use of white space in .s files generated by gcc suddenly
changed. To guarantee compatibility across different versions of gcc, make
sure (at least on i386-.*-linux) that regexps tolerate varying amounts of white
space between an assembler statement and its arguments as well as after a the
comma separating multiple arguments.
\emph{For the time being, I have corrected the regexps for i386-.*-linux. I
didn't touch all the regexps for other i386 platforms, as I don't have
a box to test these changes.}
HPPA specific notes:
\begin{itemize}
\item
......@@ -167,9 +179,9 @@ sub init_TARGET_STUFF {
$T_POST_LBL = ':';
$T_X86_PRE_LLBL_PAT = '\.L';
$T_X86_PRE_LLBL = '.L';
$T_X86_BADJMP = '^\tjmp [^\.\*]';
$T_X86_BADJMP = '^\tjmp\s+[^\.\*]';
$T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\t\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
$T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,\s*0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\s*\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
$T_COPY_DIRVS = '\.(globl)';
if ( $TargetPlatform =~ /freebsd|netbsd_elf/ ) {
......@@ -382,15 +394,6 @@ sub mangle_asm {
&init_TARGET_STUFF();
&init_FUNNY_THINGS();
# perl4 on alphas SEGVs when give ${foo} substitutions in patterns.
# To avoid them we declare some locals that allows to avoid using curlies.
local($TUS) = ${T_US};
local($TPOSTLBL) = ${T_POST_LBL};
local($TMOVEDIRVS) = ${T_MOVE_DIRVS};
local($TPREAPP) = ${T_PRE_APP};
local($TCOPYDIRVS) = ${T_COPY_DIRVS};
local($TDOTWORD) = ${T_DOT_WORD};
open(INASM, "< $in_asmf")
|| &tidy_up_and_die(1,"$Pgm: failed to open `$in_asmf' (to read)\n");
open(OUTASM,"> $out_asmf")
......@@ -414,10 +417,10 @@ sub mangle_asm {
$i = 0; $chkcat[0] = 'misc'; $chk[0] = '';
while (<INASM>) {
next if $T_STABBY && /^\.stab.*$TUS[@]?__stg_split_marker/o;
next if $T_STABBY && /^\.stab.*${T_US}__stg_split_marker/o;
next if $T_STABBY && /^\.stab.*ghc.*c_ID/;
next if /^\t\.def.*endef$/;
next if /$TPREAPP(NO_)?APP/o;
next if /${T_PRE_APP}(NO_)?APP/o;
next if /^;/ && $TargetPlatform =~ /^hppa/;
next if /(^$|^\t\.file\t|^ # )/ && $TargetPlatform =~ /^(mips|powerpc|rs6000)-/;
......@@ -457,12 +460,12 @@ sub mangle_asm {
$chkcat[$i] = 'literal';
$chksymb[$i] = $1;
} elsif ( /^$TUS[@]?__stg_split_marker(\d*)$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}__stg_split_marker(\d*)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'splitmarker';
$chksymb[$i] = $1;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_info$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_info${T_POST_LBL}$/o ) {
$symb = $1;
$chk[++$i] = $_;
$chkcat[$i] = 'infotbl';
......@@ -472,50 +475,50 @@ sub mangle_asm {
$infochk{$symb} = $i;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_(entry|ret)$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_(entry|ret)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'slow';
$chksymb[$i] = $1;
$slowchk{$1} = $i;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_fast\d*$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_fast\d*${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'fast';
$chksymb[$i] = $1;
$fastchk{$1} = $i;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_closure$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_closure${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'closure';
$chksymb[$i] = $1;
$closurechk{$1} = $i;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_srt$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_srt${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'srt';
$chksymb[$i] = $1;
$srtchk{$1} = $i;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_ct$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_ct${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'data';
$chksymb[$i] = '';
} elsif ( /^$TUS[@]?ghc.*c_ID$TPOSTLBL/o ) {
} elsif ( /^${T_US}ghc.*c_ID${T_POST_LBL}/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'consist';
} elsif ( /^($TUS[@]?__gnu_compiled_c|gcc2_compiled\.)$TPOSTLBL/o ) {
} elsif ( /^(${T_US}__gnu_compiled_c|gcc2_compiled\.)${T_POST_LBL}/o ) {
; # toss it
} elsif ( /^$TUS[A-Za-z0-9_]+\.\d+$TPOSTLBL[@]?$/o
|| /^$TUS[@]?.*_CAT$TPOSTLBL[@]?$/o # PROF: _entryname_CAT
|| /^$TUS[@]?.*_done$TPOSTLBL[@]?$/o # PROF: _module_done
|| /^$TUS[@]?_module_registered$TPOSTLBL[@]?$/o # PROF: _module_registered
} elsif ( /^${T_US}[A-Za-z0-9_]+\.\d+${T_POST_LBL}$/o
|| /^${T_US}.*_CAT${T_POST_LBL}$/o # PROF: _entryname_CAT
|| /^${T_US}.*_done${T_POST_LBL}$/o # PROF: _module_done
|| /^${T_US}_module_registered${T_POST_LBL}$/o # PROF: _module_registered
) {
$chk[++$i] = $_;
$chkcat[$i] = 'data';
......@@ -531,20 +534,20 @@ sub mangle_asm {
$chkcat[$i] = 'toc';
$chksymb[$i] = $1;
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_cc(s)?$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_cc(s)?${T_POST_LBL}$/o ) {
# all CC_ symbols go in the data section...
$chk[++$i] = $_;
$chkcat[$i] = 'data';
$chksymb[$i] = '';
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_(alt|dflt)$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_(alt|dflt)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
$chksymb[$i] = '';
#$symbtmp = $1;
#$chksymb[$i] = $symbtmp if ($TargetPlatform =~ /^powerpc-|^rs6000-/) ; #rm andre
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_vtbl$TPOSTLBL[@]?$/o ) {
} elsif ( /^${T_US}([A-Za-z0-9_]+)_vtbl${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'vector';
$chksymb[$i] = $1;
......@@ -575,7 +578,7 @@ sub mangle_asm {
$chkcat[$i] = 'toss';
$chksymb[$i] = $1;
} elsif ( /^$TUS[@]?[A-Za-z0-9_]/o
} elsif ( /^${T_US}[A-Za-z0-9_]/o
&& ( $TargetPlatform !~ /^hppa/ # need to avoid local labels in this case
|| ! /^L\$\d+$/ )
&& ( $TargetPlatform !~ /^powerpc|^rs6000/ # ditto
......@@ -584,11 +587,11 @@ sub mangle_asm {
chop($thing = $_);
print "Funny global thing?: $_"
unless $KNOWN_FUNNY_THING{$thing}
|| /^$TUS[@]?stg_.*$TPOSTLBL[@]?$/o # RTS internals
|| /^$TUS[@]__fexp_.*$TPOSTLBL$/o # foreign export
|| /^$TUS[@]?__init.*$TPOSTLBL$/o # __init<module>
|| /^$TUS[@]?.*_btm$TPOSTLBL$/o # large bitmaps
|| /^$TUS[@]?.*_closure_tbl$TPOSTLBL$/o; # closure tables
|| /^${T_US}stg_.*${T_POST_LBL}$/o # RTS internals
|| /^${T_US}__fexp_.*${T_POST_LBL}$/o # foreign export
|| /^${T_US}__init.*${T_POST_LBL}$/o # __init<module>
|| /^${T_US}.*_btm${T_POST_LBL}$/o # large bitmaps
|| /^${T_US}.*_closure_tbl${T_POST_LBL}$/o; # closure tables
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
if ($TargetPlatform =~ /^powerpc-|^rs6000-/)
......@@ -668,11 +671,11 @@ sub mangle_asm {
if (($p, $r) = split(/--- BEGIN ---/, $c)) {
if ($TargetPlatform =~ /^i386-/) {
$p =~ s/^\tpushl \%edi\n//;
$p =~ s/^\tpushl \%esi\n//;
$p =~ s/^\tpushl \%ebx\n//;
$p =~ s/^\tsubl \$\d+,\%esp\n//;
$p =~ s/^\tmovl \$\d+,\%eax\n\tcall __alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/);
$p =~ s/^\tpushl\s+\%edi\n//;
$p =~ s/^\tpushl\s+\%esi\n//;
$p =~ s/^\tpushl\s+\%ebx\n//;
$p =~ s/^\tsubl\s+\$\d+,\s*\%esp\n//;
$p =~ s/^\tmovl\s+\$\d+,\s*\%eax\n\tcall\s+__alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/);
} elsif ($TargetPlatform =~ /^m68k-/) {
$p =~ s/^\tlink a6,#-?\d.*\n//;
$p =~ s/^\tpea a6@\n\tmovel sp,a6\n//;
......@@ -731,12 +734,12 @@ sub mangle_asm {
if (($r, $e) = split(/--- END ---/, $c)) {
if ($TargetPlatform =~ /^i386-/) {
$e =~ s/^\tret\n//;
$e =~ s/^\tpopl \%edi\n//;
$e =~ s/^\tpopl \%esi\n//;
$e =~ s/^\tpopl \%edx\n//;
$e =~ s/^\tpopl \%ecx\n//;
$e =~ s/^\taddl \$\d+,\%esp\n//;
$e =~ s/^\tsubl \$-\d+,\%esp\n//;
$e =~ s/^\tpopl\s+\%edi\n//;
$e =~ s/^\tpopl\s+\%esi\n//;
$e =~ s/^\tpopl\s+\%edx\n//;
$e =~ s/^\tpopl\s+\%ecx\n//;
$e =~ s/^\taddl\s+\$\d+,\s*\%esp\n//;
$e =~ s/^\tsubl\s+\$-\d+,\s*\%esp\n//;
} elsif ($TargetPlatform =~ /^m68k-/) {
$e =~ s/^\tunlk a6\n//;
$e =~ s/^\trts\n//;
......@@ -757,8 +760,15 @@ sub mangle_asm {
# HWL HACK: dont die, just print a warning
#print stderr "HWL: this should die! Epilogue junk?: $e\n" if $e =~ /^\t[^\.]/
# && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
die "Epilogue junk?: $e\n" if $e =~ /^\t[^\.\n]/
&& $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
# ** FIXME: