mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-24 03:14:08 +08:00
PR modula2/107630 Remove M2LINK and remove some cross linking
Remove M2LINK.def. Pass the user forced module initialization string as a parameter to M2RTS.ConstructModules. This patch allows -fm2-whole-program to link successfully using dynamic libraries. gcc/m2/ChangeLog: PR modula2/107630 * Make-lang.in (m2/stage2/cc1gm2$(exeext)): Remove m2/gm2-libs-boot/M2LINK.o. (m2/stage1/cc1gm2$(exeext)): Ditto. (GM2-LIBS-BOOT-DEFS): Remove M2LINK.def. (GM2-LIBS-DEFS): Ditto. (m2/mc-boot/$(SRC_PREFIX)%.o): Replace CXX_FLAGS with CXXFLAGS. (m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto. (m2/mc-boot/main.o): Ditto. (mcflex.o): Add $(CFLAGS). (m2/gm2-libs-boot/M2LINK.o): Remove rule. * gm2-compiler/M2GCCDeclare.def (DeclareM2linkGlobals): Remove. * gm2-compiler/M2GCCDeclare.mod: (M2LinkEntry): Remove. (M2LinkIndex): Remove. (DoVariableDeclaration): Remove initial and call to AddEntryM2Link. (AddEntryM2Link): Remove. (GetEntryM2Link): Remove. (DeclareM2linkGlobals): Remove. (DetectM2LinkInitial): Remove. (InitM2LinkModule): Remove. * gm2-compiler/M2GenGCC.mod (CodeFinallyEnd): Remove call to DeclareM2linkGlobals. * gm2-compiler/M2Quads.mod (BuildM2InitFunction): Add extra parameter containing runtime module override to ConstructModules. * gm2-compiler/M2Scaffold.mod: Update comment describing ConstructModules. * gm2-gcc/m2decl.cc (m2decl_DeclareM2linkForcedModuleInitOrder): Remove. * gm2-libs-iso/M2RTS.def (ConstructModules): Add overrideliborder parameter. * gm2-libs-iso/M2RTS.mod: Add overrideliborder parameter. * gm2-libs/M2Dependent.def (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2Dependent.mod (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2RTS.def (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2RTS.mod (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2LINK.def: Removed. libgm2/ChangeLog: * libm2pim/Makefile.am (M2DEFS): Remove M2LINK.def. * libm2pim/Makefile.in: Rebuild. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
031785270a
commit
573dbd5175
@ -516,13 +516,13 @@ cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
|
||||
|
||||
m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
|
||||
$(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
|
||||
m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) m2/gm2-libs-boot/M2LINK.o
|
||||
m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext)
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
@$(call LINK_PROGRESS,$(INDEX.m2),start)
|
||||
+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
|
||||
attribs.o \
|
||||
$(GM2_LIBS) \
|
||||
$(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \
|
||||
$(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o \
|
||||
$(BACKENDLIBS) $(LIBSTDCXX) -lm
|
||||
@$(call LINK_PROGRESS,$(INDEX.m2),end)
|
||||
|
||||
@ -530,14 +530,13 @@ m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
|
||||
$(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
|
||||
$(GM2_LIBS_BOOT) $(MC_LIBS) \
|
||||
m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \
|
||||
m2/gm2-libs-boot/M2LINK.o \
|
||||
$(m2.prev)
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
@$(call LINK_PROGRESS,$(INDEX.m2),start)
|
||||
+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-boot/m2flex.o \
|
||||
attribs.o \
|
||||
$(GM2_LIBS_BOOT) $(MC_LIBS) \
|
||||
m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \
|
||||
m2/gm2-gcc/rtegraph.o \
|
||||
$(BACKEND) $(LIBS) $(BACKENDLIBS)
|
||||
@$(call LINK_PROGRESS,$(INDEX.m2),end)
|
||||
|
||||
@ -613,7 +612,6 @@ GM2-LIBS-BOOT-DEFS = \
|
||||
Indexing.def \
|
||||
M2Dependent.def \
|
||||
M2EXCEPTION.def \
|
||||
M2LINK.def \
|
||||
M2RTS.def \
|
||||
NumberIO.def \
|
||||
PushBackInput.def \
|
||||
@ -878,7 +876,6 @@ GM2-LIBS-DEFS = \
|
||||
LegacyReal.def \
|
||||
M2Dependent.def \
|
||||
M2EXCEPTION.def \
|
||||
M2LINK.def \
|
||||
M2RTS.def \
|
||||
MathLib0.def \
|
||||
MemUtils.def \
|
||||
@ -1352,23 +1349,23 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
|
||||
|
||||
m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) $(CXX_FLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
|
||||
$(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
|
||||
|
||||
m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) $(CXX_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
|
||||
$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
|
||||
|
||||
m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) $(CXX_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
|
||||
$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
|
||||
|
||||
m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.cc $(srcdir)/m2/init/mcinit
|
||||
$(CXX) $(CXX_FLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@
|
||||
$(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@
|
||||
|
||||
mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h
|
||||
$(CC) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc
|
||||
$(CC) $(CFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc
|
||||
|
||||
mcflex.c: $(srcdir)/m2/mc/mc.flex
|
||||
flex -t $< > $@
|
||||
@ -1404,10 +1401,6 @@ m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SR
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
|
||||
|
||||
m2/gm2-libs-boot/M2LINK.o: $(srcdir)/m2/gm2-libs-ch/M2LINK.c m2/gm2-libs-boot/$(SRC_PREFIX)M2LINK.h m2/gm2-libs/gm2-libs-host.h
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
|
||||
|
||||
m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h
|
||||
-test -d $(@D) || $(mkinstalldirs) $(@D)
|
||||
$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
|
||||
|
@ -26,7 +26,6 @@ DEFINITION MODULE M2GCCDeclare ;
|
||||
Author : Gaius Mulley
|
||||
System : UNIX (gm2)
|
||||
Date : Sat Jul 17 10:28:43 1999
|
||||
Last edit : Sat Jul 17 10:28:43 1999
|
||||
Description: declares Modula-2 types to GCC,
|
||||
only declares a type once all subcomponents are known.
|
||||
*)
|
||||
@ -40,7 +39,6 @@ EXPORT QUALIFIED FoldConstants,
|
||||
InitDeclarations, StartDeclareScope, EndDeclareScope,
|
||||
DeclareModuleVariables, IsProcedureGccNested,
|
||||
DeclareProcedure, PoisonSymbols, DeclareParameters,
|
||||
DeclareM2linkGlobals,
|
||||
CompletelyResolved, MarkExported, PrintSym,
|
||||
ConstantKnownAndUsed,
|
||||
PutToBeSolvedByQuads,
|
||||
@ -145,15 +143,6 @@ PROCEDURE DeclareProcedure (sym: WORD) ;
|
||||
PROCEDURE DeclareModuleVariables (sym: CARDINAL) ;
|
||||
|
||||
|
||||
(*
|
||||
DeclareM2linkGlobals - will create M2LINK.StaticInitialization
|
||||
and M2LINK.ForcedModuleInitOrder providing
|
||||
they have not already been created.
|
||||
*)
|
||||
|
||||
PROCEDURE DeclareM2linkGlobals (tokenno: CARDINAL) ;
|
||||
|
||||
|
||||
(*
|
||||
IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
|
||||
as nested by GCC.
|
||||
|
@ -154,9 +154,9 @@ FROM m2linemap IMPORT location_t, BuiltinsLocation ;
|
||||
FROM m2decl IMPORT BuildIntegerConstant, BuildStringConstant, BuildCStringConstant,
|
||||
BuildStartFunctionDeclaration,
|
||||
BuildParameterDeclaration, BuildEndFunctionDeclaration,
|
||||
DeclareKnownVariable, GetBitsPerBitset, BuildPtrToTypeString,
|
||||
DeclareM2linkStaticInitialization,
|
||||
DeclareM2linkForcedModuleInitOrder ;
|
||||
DeclareKnownVariable, GetBitsPerBitset, BuildPtrToTypeString ;
|
||||
(* DeclareM2linkStaticInitialization,
|
||||
DeclareM2linkForcedModuleInitOrder ; *)
|
||||
|
||||
FROM m2type IMPORT MarkFunctionReferenced, BuildStartRecord, BuildStartVarient, BuildStartFunctionType,
|
||||
BuildStartFieldVarient, BuildStartVarient, BuildStartType, BuildStartArrayType,
|
||||
@ -205,14 +205,6 @@ CONST
|
||||
Progress = FALSE ;
|
||||
EnableSSA = FALSE ;
|
||||
|
||||
TYPE
|
||||
M2LinkEntry = POINTER TO RECORD
|
||||
var : CARDINAL ;
|
||||
gcc : Tree ;
|
||||
varname,
|
||||
modname: Name ;
|
||||
END ;
|
||||
|
||||
VAR
|
||||
ToBeSolvedByQuads, (* constants which must be solved *)
|
||||
(* by processing the quadruples. *)
|
||||
@ -240,7 +232,6 @@ VAR
|
||||
EnumerationIndex : Index ;
|
||||
action : IsAction ;
|
||||
enumDeps : BOOLEAN ;
|
||||
M2LinkIndex : Index ; (* Array of M2LinkEntry. *)
|
||||
|
||||
|
||||
PROCEDURE mystop ; BEGIN END mystop ;
|
||||
@ -3170,9 +3161,9 @@ PROCEDURE DoVariableDeclaration (var, module: CARDINAL; name: ADDRESS;
|
||||
isTemporary, isGlobal: BOOLEAN;
|
||||
scope: Tree) ;
|
||||
VAR
|
||||
type, initial: Tree ;
|
||||
varType : CARDINAL ;
|
||||
location : location_t ;
|
||||
type : Tree ;
|
||||
varType : CARDINAL ;
|
||||
location: location_t ;
|
||||
BEGIN
|
||||
IF IsComponent (var)
|
||||
THEN
|
||||
@ -3209,92 +3200,15 @@ BEGIN
|
||||
END ;
|
||||
location := TokenToLocation (GetDeclaredMod (var)) ;
|
||||
(* The M2LINK module global variables are a special case and have initializers. *)
|
||||
initial := DetectM2LinkInitial (location, var, module) ;
|
||||
PreAddModGcc (var, DeclareKnownVariable (location,
|
||||
name, type,
|
||||
isExported, isImported, isTemporary,
|
||||
isGlobal, scope, initial)) ;
|
||||
IF initial # NIL
|
||||
THEN
|
||||
(* Remember special case has been created. *)
|
||||
AddEntryM2Link (var, module, Mod2Gcc (var))
|
||||
END ;
|
||||
isGlobal, scope, NIL)) ;
|
||||
WatchRemoveList (var, todolist) ;
|
||||
WatchIncludeList (var, fullydeclared)
|
||||
END DoVariableDeclaration ;
|
||||
|
||||
|
||||
(*
|
||||
AddEntryM2Link - remember module_var has been created.
|
||||
*)
|
||||
|
||||
PROCEDURE AddEntryM2Link (var, module: CARDINAL; gcc: Tree) ;
|
||||
VAR
|
||||
entry: M2LinkEntry ;
|
||||
BEGIN
|
||||
IF M2LinkIndex = NIL
|
||||
THEN
|
||||
M2LinkIndex := InitIndex (1)
|
||||
END ;
|
||||
NEW (entry) ;
|
||||
entry^.var := var ;
|
||||
entry^.gcc := gcc ;
|
||||
entry^.varname := GetSymName (var) ;
|
||||
entry^.modname := GetSymName (module) ;
|
||||
IncludeIndiceIntoIndex (M2LinkIndex, entry)
|
||||
END AddEntryM2Link ;
|
||||
|
||||
|
||||
(*
|
||||
GetEntryM2Link - return the gcc tree matching varname modname.
|
||||
*)
|
||||
|
||||
PROCEDURE GetEntryM2Link (varname, modname: Name) : Tree ;
|
||||
VAR
|
||||
entry : M2LinkEntry ;
|
||||
high, i: CARDINAL ;
|
||||
BEGIN
|
||||
IF M2LinkIndex # NIL
|
||||
THEN
|
||||
i := 1 ;
|
||||
high := HighIndice (M2LinkIndex) ;
|
||||
WHILE i <= high DO
|
||||
entry := GetIndice (M2LinkIndex, i) ;
|
||||
IF (entry^.varname = varname) AND (entry^.modname = modname)
|
||||
THEN
|
||||
RETURN entry^.gcc
|
||||
END ;
|
||||
INC (i)
|
||||
END
|
||||
END ;
|
||||
RETURN NIL
|
||||
END GetEntryM2Link ;
|
||||
|
||||
|
||||
(*
|
||||
DeclareM2linkGlobals - will create M2LINK.StaticInitialization
|
||||
and M2LINK.ForcedModuleInitOrder providing
|
||||
they have not already been created.
|
||||
*)
|
||||
|
||||
PROCEDURE DeclareM2linkGlobals (tokenno: CARDINAL) ;
|
||||
VAR
|
||||
m2link: Name ;
|
||||
BEGIN
|
||||
m2link := MakeKey ('M2LINK') ;
|
||||
IF GetEntryM2Link (MakeKey ('StaticInitialization'), m2link) = NIL
|
||||
THEN
|
||||
Assert (DeclareM2linkStaticInitialization (TokenToLocation (tokenno),
|
||||
VAL (INTEGER, ScaffoldStatic)) # NIL)
|
||||
END ;
|
||||
IF GetEntryM2Link (MakeKey ('ForcedModuleInitOrder'), m2link) = NIL
|
||||
THEN
|
||||
Assert (DeclareM2linkForcedModuleInitOrder (TokenToLocation (tokenno),
|
||||
GetRuntimeModuleOverride ()) # NIL)
|
||||
END ;
|
||||
END DeclareM2linkGlobals ;
|
||||
|
||||
|
||||
(*
|
||||
IsGlobal - is the variable not in a procedure scope.
|
||||
*)
|
||||
@ -3343,28 +3257,6 @@ BEGIN
|
||||
END DeclareVariable ;
|
||||
|
||||
|
||||
(*
|
||||
DetectM2LinkInitial -
|
||||
*)
|
||||
|
||||
PROCEDURE DetectM2LinkInitial (location: location_t; variable, decl: CARDINAL) : Tree ;
|
||||
BEGIN
|
||||
IF (decl # NulSym) AND WholeProgram AND (GetSymName (decl) = MakeKey ('M2LINK'))
|
||||
THEN
|
||||
IF GetSymName (variable) = MakeKey ('StaticInitialization')
|
||||
THEN
|
||||
RETURN BuildIntegerConstant (VAL (INTEGER, ScaffoldStatic))
|
||||
ELSIF GetSymName (variable) = MakeKey ('ForcedModuleInitOrder')
|
||||
THEN
|
||||
RETURN BuildPtrToTypeString (location,
|
||||
GetRuntimeModuleOverride (),
|
||||
Mod2Gcc (GetSType (variable)))
|
||||
END
|
||||
END ;
|
||||
RETURN NIL
|
||||
END DetectM2LinkInitial ;
|
||||
|
||||
|
||||
(*
|
||||
DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program.
|
||||
*)
|
||||
@ -6294,16 +6186,6 @@ BEGIN
|
||||
END ConstantKnownAndUsed ;
|
||||
|
||||
|
||||
(*
|
||||
InitM2LinkModule -
|
||||
*)
|
||||
|
||||
PROCEDURE InitM2LinkModule ;
|
||||
BEGIN
|
||||
M2LinkIndex := NIL
|
||||
END InitM2LinkModule ;
|
||||
|
||||
|
||||
(*
|
||||
InitDeclarations - initializes default types and the source filename.
|
||||
*)
|
||||
@ -6329,6 +6211,5 @@ BEGIN
|
||||
EnumerationIndex := InitIndex(1) ;
|
||||
IncludeElementIntoSet(WatchList, 8) ;
|
||||
HaveInitDefaultTypes := FALSE ;
|
||||
recursionCaught := FALSE ;
|
||||
InitM2LinkModule
|
||||
recursionCaught := FALSE
|
||||
END M2GCCDeclare.
|
||||
|
@ -149,8 +149,7 @@ FROM M2GCCDeclare IMPORT WalkAction,
|
||||
CompletelyResolved,
|
||||
PoisonSymbols, GetTypeMin, GetTypeMax,
|
||||
IsProcedureGccNested, DeclareParameters,
|
||||
ConstantKnownAndUsed, PrintSym,
|
||||
DeclareM2linkGlobals ;
|
||||
ConstantKnownAndUsed, PrintSym ;
|
||||
|
||||
FROM M2Range IMPORT CodeRangeCheck, FoldRangeCheck, CodeErrorCheck, GetMinMax ;
|
||||
|
||||
@ -1163,17 +1162,7 @@ BEGIN
|
||||
GetModuleCtors (moduleSym, ctor, init, fini, dep) ;
|
||||
finishFunctionDecl (location, Mod2Gcc (fini)) ;
|
||||
BuildEndFunctionCode (location, Mod2Gcc (fini),
|
||||
IsModuleWithinProcedure (moduleSym)) ;
|
||||
IF ScaffoldMain OR (NOT cflag)
|
||||
THEN
|
||||
IF CompilingMainModule AND
|
||||
(ScaffoldDynamic OR ScaffoldStatic OR ScaffoldMain) AND
|
||||
(moduleSym = GetMainModule ())
|
||||
THEN
|
||||
qprintf0 (" generating scaffold m2link information\n");
|
||||
DeclareM2linkGlobals (tokenpos)
|
||||
END
|
||||
END
|
||||
IsModuleWithinProcedure (moduleSym))
|
||||
END
|
||||
END CodeFinallyEnd ;
|
||||
|
||||
|
@ -209,7 +209,8 @@ FROM M2Options IMPORT NilChecking,
|
||||
GenerateLineDebug, Exceptions,
|
||||
Profiling, Coding, Optimizing,
|
||||
ScaffoldDynamic, ScaffoldStatic, cflag,
|
||||
ScaffoldMain, SharedFlag, WholeProgram ;
|
||||
ScaffoldMain, SharedFlag, WholeProgram,
|
||||
GetRuntimeModuleOverride ;
|
||||
|
||||
FROM M2Pass IMPORT IsPassCodeGeneration, IsNoPass ;
|
||||
|
||||
@ -2531,7 +2532,8 @@ BEGIN
|
||||
(* int
|
||||
_M2_init (int argc, char *argv[], char *envp[])
|
||||
{
|
||||
M2RTS_ConstructModules (module_name, libname, argc, argv, envp);
|
||||
M2RTS_ConstructModules (module_name, libname,
|
||||
overrideliborder, argc, argv, envp);
|
||||
} *)
|
||||
PushT (initFunction) ;
|
||||
BuildProcedureStart ;
|
||||
@ -2566,10 +2568,17 @@ BEGIN
|
||||
PushT(1) ;
|
||||
BuildAdrFunction ;
|
||||
|
||||
PushTF(Adr, Address) ;
|
||||
PushTtok (MakeConstLitString (tok,
|
||||
makekey (GetRuntimeModuleOverride ())),
|
||||
tok) ;
|
||||
PushT(1) ;
|
||||
BuildAdrFunction ;
|
||||
|
||||
PushTtok (SafeRequestSym (tok, MakeKey ("argc")), tok) ;
|
||||
PushTtok (SafeRequestSym (tok, MakeKey ("argv")), tok) ;
|
||||
PushTtok (SafeRequestSym (tok, MakeKey ("envp")), tok) ;
|
||||
PushT (5) ;
|
||||
PushT (6) ;
|
||||
BuildProcedureCall (tok) ;
|
||||
END
|
||||
ELSIF ScaffoldStatic
|
||||
|
@ -87,7 +87,7 @@ VAR
|
||||
|
||||
static void _M2_init (int argc, char *argv[], char *envp[])
|
||||
{
|
||||
M2RTS_ConstructModules (module_name, libname, argc, argv, envp);
|
||||
M2RTS_ConstructModules (module_name, libname, overrideliborder, argc, argv, envp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ extern GTY (()) tree current_function_decl;
|
||||
static GTY (()) tree param_type_list;
|
||||
static GTY (()) tree param_list = NULL_TREE; /* Ready for the next time we
|
||||
call/define a function. */
|
||||
|
||||
#if 0
|
||||
tree
|
||||
m2decl_DeclareM2linkStaticInitialization (location_t location,
|
||||
int ScaffoldStatic)
|
||||
@ -71,6 +71,7 @@ m2decl_DeclareM2linkForcedModuleInitOrder (location_t location,
|
||||
m2block_popGlobalScope ();
|
||||
return forced_order;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* DeclareKnownVariable declares a variable to GCC. */
|
||||
|
@ -34,6 +34,7 @@ TYPE
|
||||
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
|
||||
PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS;
|
||||
|
@ -72,9 +72,11 @@ VAR
|
||||
*)
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
BEGIN
|
||||
M2Dependent.ConstructModules (applicationmodule, libname,
|
||||
overrideliborder,
|
||||
argc, argv, envp)
|
||||
END ConstructModules ;
|
||||
|
||||
|
@ -33,7 +33,8 @@ TYPE
|
||||
ArgCVEnvP = PROCEDURE (INTEGER, ADDRESS, ADDRESS) ;
|
||||
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
PROCEDURE ConstructModules (applicationmodule, libname,
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
|
||||
PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS;
|
||||
|
@ -29,7 +29,7 @@ IMPLEMENTATION MODULE M2Dependent ;
|
||||
|
||||
FROM libc IMPORT abort, exit, write, getenv, printf, snprintf, strncpy ;
|
||||
(* FROM Builtins IMPORT strncmp, strcmp ; not available during bootstrap. *)
|
||||
FROM M2LINK IMPORT ForcedModuleInitOrder, StaticInitialization, PtrToChar ;
|
||||
(* FROM M2LINK IMPORT ForcedModuleInitOrder, StaticInitialization, PtrToChar ; *)
|
||||
FROM ASCII IMPORT nul, nl ;
|
||||
FROM SYSTEM IMPORT ADR, SIZE ;
|
||||
FROM Storage IMPORT ALLOCATE ;
|
||||
@ -39,6 +39,8 @@ IMPORT M2RTS ;
|
||||
|
||||
|
||||
TYPE
|
||||
PtrToChar = POINTER TO CHAR ;
|
||||
|
||||
DependencyState = (unregistered, unordered, started, ordered, user) ;
|
||||
|
||||
DependencyList = RECORD
|
||||
@ -62,7 +64,8 @@ TYPE
|
||||
END ;
|
||||
|
||||
VAR
|
||||
Modules : ARRAY DependencyState OF ModuleChain ;
|
||||
Modules : ARRAY DependencyState OF ModuleChain ;
|
||||
DynamicInitialization,
|
||||
Initialized,
|
||||
WarningTrace,
|
||||
ModuleTrace,
|
||||
@ -70,7 +73,7 @@ VAR
|
||||
DependencyTrace,
|
||||
PreTrace,
|
||||
PostTrace,
|
||||
ForceTrace : BOOLEAN ;
|
||||
ForceTrace : BOOLEAN ;
|
||||
|
||||
|
||||
(*
|
||||
@ -455,18 +458,15 @@ END ResolveDependant ;
|
||||
(*
|
||||
RequestDependant - used to specify that modulename is dependant upon
|
||||
module dependantmodule. It only takes effect
|
||||
if we are not using StaticInitialization.
|
||||
if we are using DynamicInitialization.
|
||||
*)
|
||||
|
||||
PROCEDURE RequestDependant (modulename, libname,
|
||||
dependantmodule, dependantlibname: ADDRESS) ;
|
||||
BEGIN
|
||||
CheckInitialized ;
|
||||
IF NOT StaticInitialization
|
||||
THEN
|
||||
PerformRequestDependant (modulename, libname,
|
||||
dependantmodule, dependantlibname)
|
||||
END
|
||||
PerformRequestDependant (modulename, libname,
|
||||
dependantmodule, dependantlibname)
|
||||
END RequestDependant ;
|
||||
|
||||
|
||||
@ -676,7 +676,7 @@ END ForceModule ;
|
||||
the dynamic ordering with the preference.
|
||||
*)
|
||||
|
||||
PROCEDURE ForceDependencies ;
|
||||
PROCEDURE ForceDependencies (overrideliborder: ADDRESS) ;
|
||||
VAR
|
||||
len,
|
||||
modlen,
|
||||
@ -685,10 +685,10 @@ VAR
|
||||
libname,
|
||||
pc, start: PtrToChar ;
|
||||
BEGIN
|
||||
IF ForcedModuleInitOrder # NIL
|
||||
IF overrideliborder # NIL
|
||||
THEN
|
||||
traceprintf2 (ForceTrace, "user forcing order: %s\n", ForcedModuleInitOrder) ;
|
||||
pc := ForcedModuleInitOrder ;
|
||||
traceprintf2 (ForceTrace, "user forcing order: %s\n", overrideliborder) ;
|
||||
pc := overrideliborder ;
|
||||
start := pc ;
|
||||
len := 0 ;
|
||||
modname := NIL ;
|
||||
@ -762,13 +762,15 @@ END CheckApplication ;
|
||||
module constructor in turn.
|
||||
*)
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
PROCEDURE ConstructModules (applicationmodule, libname,
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
VAR
|
||||
mptr: ModuleChain ;
|
||||
nulp: ArgCVEnvP ;
|
||||
BEGIN
|
||||
CheckInitialized ;
|
||||
DynamicInitialization := TRUE ; (* This procedure is only called if we desire dynamic initialization. *)
|
||||
traceprintf3 (ModuleTrace, "application module: %s [%s]\n",
|
||||
applicationmodule, libname);
|
||||
mptr := LookupModule (unordered, applicationmodule, libname) ;
|
||||
@ -781,7 +783,7 @@ BEGIN
|
||||
ResolveDependencies (applicationmodule, libname) ;
|
||||
traceprintf (PreTrace, "Post resolving dependents\n");
|
||||
DumpModuleData (PostTrace) ;
|
||||
ForceDependencies ;
|
||||
ForceDependencies (overrideliborder) ;
|
||||
traceprintf (ForceTrace, "After user forcing ordering\n");
|
||||
DumpModuleData (ForceTrace) ;
|
||||
CheckApplication ;
|
||||
@ -885,20 +887,17 @@ VAR
|
||||
mptr: ModuleChain ;
|
||||
BEGIN
|
||||
CheckInitialized ;
|
||||
IF NOT StaticInitialization
|
||||
mptr := LookupModule (unordered, modulename, libname) ;
|
||||
IF mptr = NIL
|
||||
THEN
|
||||
mptr := LookupModule (unordered, modulename, libname) ;
|
||||
IF mptr = NIL
|
||||
THEN
|
||||
traceprintf3 (ModuleTrace, "module: %s [%s] registering",
|
||||
modulename, libname);
|
||||
moveTo (unordered,
|
||||
CreateModule (modulename, libname, init, fini, dependencies)) ;
|
||||
traceprintf (ModuleTrace, "\n") ;
|
||||
ELSE
|
||||
warning3 ("module: %s [%s] (ignoring duplicate registration)\n",
|
||||
modulename, libname)
|
||||
END
|
||||
traceprintf3 (ModuleTrace, "module: %s [%s] registering",
|
||||
modulename, libname);
|
||||
moveTo (unordered,
|
||||
CreateModule (modulename, libname, init, fini, dependencies)) ;
|
||||
traceprintf (ModuleTrace, "\n") ;
|
||||
ELSE
|
||||
warning3 ("module: %s [%s] (ignoring duplicate registration)\n",
|
||||
modulename, libname)
|
||||
END
|
||||
END RegisterModule ;
|
||||
|
||||
@ -1001,7 +1000,8 @@ BEGIN
|
||||
SetupDebugFlags ;
|
||||
FOR state := MIN (DependencyState) TO MAX (DependencyState) DO
|
||||
Modules[state] := NIL
|
||||
END
|
||||
END ;
|
||||
DynamicInitialization := FALSE
|
||||
END Init ;
|
||||
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
(* M2LINK.def defines the linking mode used in Modula-2.
|
||||
|
||||
Copyright (C) 2022-2023 Free Software Foundation, Inc.
|
||||
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
|
||||
|
||||
This file is part of GNU Modula-2.
|
||||
|
||||
GNU Modula-2 is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Modula-2 is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. *)
|
||||
|
||||
DEFINITION MODULE FOR "C" M2LINK ;
|
||||
|
||||
|
||||
TYPE
|
||||
PtrToChar = POINTER TO CHAR ;
|
||||
|
||||
(* These variables are set by the compiler in the program module
|
||||
according to linking command line options. *)
|
||||
|
||||
VAR
|
||||
ForcedModuleInitOrder: PtrToChar ;
|
||||
StaticInitialization : BOOLEAN ;
|
||||
|
||||
|
||||
END M2LINK.
|
@ -33,7 +33,8 @@ TYPE
|
||||
ArgCVEnvP = PROCEDURE (INTEGER, ADDRESS, ADDRESS) ;
|
||||
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
PROCEDURE ConstructModules (applicationmodule, libname,
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
|
||||
PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS;
|
||||
|
@ -71,9 +71,11 @@ VAR
|
||||
*)
|
||||
|
||||
PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS;
|
||||
overrideliborder: ADDRESS;
|
||||
argc: INTEGER; argv, envp: ADDRESS) ;
|
||||
BEGIN
|
||||
M2Dependent.ConstructModules (applicationmodule, libname,
|
||||
overrideliborder,
|
||||
argc, argv, envp)
|
||||
END ConstructModules ;
|
||||
|
||||
|
@ -136,7 +136,7 @@ M2DEFS = Args.def ASCII.def \
|
||||
LegacyReal.def libc.def \
|
||||
libm.def LMathLib0.def \
|
||||
M2Dependent.def \
|
||||
M2EXCEPTION.def M2LINK.def \
|
||||
M2EXCEPTION.def \
|
||||
M2RTS.def \
|
||||
MathLib0.def MemUtils.def \
|
||||
NumberIO.def PushBackInput.def \
|
||||
|
@ -504,7 +504,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
@BUILD_PIMLIB_TRUE@ LegacyReal.def libc.def \
|
||||
@BUILD_PIMLIB_TRUE@ libm.def LMathLib0.def \
|
||||
@BUILD_PIMLIB_TRUE@ M2Dependent.def \
|
||||
@BUILD_PIMLIB_TRUE@ M2EXCEPTION.def M2LINK.def \
|
||||
@BUILD_PIMLIB_TRUE@ M2EXCEPTION.def \
|
||||
@BUILD_PIMLIB_TRUE@ M2RTS.def \
|
||||
@BUILD_PIMLIB_TRUE@ MathLib0.def MemUtils.def \
|
||||
@BUILD_PIMLIB_TRUE@ NumberIO.def PushBackInput.def \
|
||||
|
Loading…
Reference in New Issue
Block a user