Bugfix -fm2-whole-program linking.
Linking a project using -fm2-whole-program would fail under the new
linking schema. The bugfixes here fix them. The problem was that the
naming of the dtor/ctor/init/fini functions (for outer modules) must
not get name mangled. Ensure that the special variables exported from
M2LINK are only created once. Subsequent attempts return with the
existing variables. Also fixed an obvious attribute name. Allow
the ZTYPE to be compared to WORD and BYTE without requiring a cast.
Definition for "C" no longer automatically implies export unqualified.
gcc/m2/ChangeLog:
* Make-lang.in (CPP_GM2): Removed. -fpermissive removed.
Ensure that M2LINK.o is linked in to stage1/m2/cc1gm2.
* gm2-compiler/M2Base.mod: Allow the ZTYPE to be compared
to WORD and BYTE without requiring a cast.
* gm2-compiler/M2AsmUtil.mod (SymbolTable): Import list added
identifiers IsExtern, IsMonoName and IsPublic.
(StringToKey): Reformatted. (GetFullScopeAsmName): Rewritten.
* gm2-compiler/M2Base.mod: Allow the ZTYPE to be compared
to WORD and BYTE without requiring a cast.
* gm2-compiler/M2Batch.mod: Improved comment.
* gm2-compiler/M2GCCDeclare.def (DeclareM2linkGlobals):
Add to export list.
* gm2-compiler/M2GCCDeclare.mod: Ensure that
DeclareModuleInit is called when -fm2-whole-program is
employed.
(DoVariableDeclaration) check to see if the special M2LINK
variables require an initial value. (AddEntryM2Link) New
procedure. (GetEntryM2Link) New procedure function.
(DeclareM2linkGlobals) New procedure. (DetectM2LinkInitial)
New procedure. (DeclareVariableWholeProgram) Rewritten.
(InitM2LinkModule) New procedure.
* gm2-compiler/M2GenGCC.mod: Call to DeclareM2linkGlobals
change parameters.
* gm2-compiler/M2Quad.mod (BuildTry): New procedure.
(BuildExcept) New procedure. (BuildM2MainFunction) create
try/catch around _M2_init/_M2_fini providing exceptions
are allowed.
* gm2-compiler/M2Scaffold.mod: Add extra parameter to calls to
PutModuleCtorExtern. Call PutMonoName for all
init/fini/link/main functions. (initialized) New variable.
* gm2-compiler/P1SymBuild.mod: Changed behaviour of
definition for "C" to be consistant and the same as the
bootstrap tool mc. Definition for "C" no longer
automatically implies export unqualified.
* gm2-compiler/P2Build.bnf: Corrected ident comparison
to unused.
* gm2-compiler/SymbolTable.def: New definitions for
IsMonoName and PutMonoName.
* gm2-compiler/SymbolTable.mod: (IsMonoName) New procedure
function. (PutMonoName) New procedure. ctor, init,
fini, dep use MonoName as appropriate.
(PutModuleCtorExtern): Add new parameter.
(MakeProcedure): Initialize IsMonoName.
* gm2-gcc/init.cc: Remove declarations for M2LINK
variables.
* gm2-gcc/m2decl.def (DeclareM2linkForcedModuleInitOrder)
New procedure. (DeclareM2linkStaticInitialization) New
procedure. (BuildPtrToTypeString) New function.
* tools-src/boilerplate.py: Change all double quotes to
single quotes.
* tools-src/def2doc.py: Change all double quotes to
single quotes.
gcc/testsuite/gm2/ChangeLog:
* calling-c/datatypes/unbounded/run/pass/c.def: Add
EXPORT UNQUALIFIED.
* examples/callingC/run/pass/c.def: Add EXPORT
UNQUALIFIED.
* extensions/run/pass/cvararg.def: Add EXPORT
UNQUALIFIED.
* pim/run/pass/minhello.mod: New file.
* switches/check-all/run/fail/tinyrange.mod: New file.
* switches/whole-program/pass/run/hello.mod: New file.
* switches/whole-program/pass/run/hello2.mod: New file.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>