Static scaffold fixes, gm2l tidyup.

This patch fixes many static scaffold bugs and contains
a re-implementation of UnixArgs.cc and termios.cc.  gm2l
contains new options --exlude=, --include= and -flibs=.

2022-07-04  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/ChangeLog:

	* doc/gm2.texi (-fscaffold-c): Removed.  (-fscaffold-c++)
	Removed.  (-fmodules) Removed.  (-fonlylink) Removed.

gcc/m2/ChangLog:

	* Make-lang.in (UnixArgs.o): Use UnixArgs.cc.
	(gm2-pge-boot/Gtermsios.o) Use mc-boot-ch/Gtermios.cc.
	* bnf/gm2l.bnf: Partial re-write and introduced
	--include=, --exclude= and -flibs=.  (AddUserInclude)
	New procedure.  (ScanSources) Remove IncludeM2RTS
	filter.  (MakeModule) Return a boolean if a new module
	is seen.  (source) New field userInclude.
	(source) New field userExclude.  (DisplaySources)
	test for userExclude and userInclude and produce
	appropriate diagnostic.  (DisplayUsage) Remove
	--M2RTS.  Add -flibs=, --include-list= and --exclude-list=.
	(PopulateList) New procedure.  (addInclude) New procedure.
	(SetLibs) New procedure.  (SetExclude) New procedure.
	(ScanArgs) Remove IncludeM2RTS.  Remove --M2RTS.
	Add --include=, --exclude= and -flibs=.  Detect if multiple
	source files are given and detect any unrecognized option.
	* bnf/gm2m.bnf (main): Renamed as mainModule.
	* gm2-compiler/M2Options.mod (SetScaffoldDynamic): Ensure that
	ScaffoldStatic is not also set.  (SetScaffoldStatic) Ensure
	that ScaffoldDynamic is not also set.
	* gm2-compiler/M2Quads.mod (BuildM2FiniFunction):
	Add ForeachModuleCallFinish for the static clause.
	(BuildM2InitFunction) Add ForeachModuleCallInit for the
	static clause.
	* gm2-compiler/M2Scaffold.def (ForeachModuleCallInit):
	New procedure.  (ForeachModuleCallFinish) New Procedure.
	* gm2-compiler/M2Scaffold.mod (ForeachModuleCallInit):
	New procedure implemented.  (ForeachModuleCallFinish) New
	Procedure implemented.  (LookupModuleSym) New procedure.
	(ReadModules) Addition parameter tok and populate
	uselistModules.  (DeclareModuleExtern) Renamed from
	DeclareCtorModuleExtern.
	* gm2-compiler/M2Swig.mod (main): Renamed as mainModule.
	* gm2-compiler/SymbolTable.def (PutModuleCtorExtern): Exported
	and declared.  (MakeModuleCtor) Pass extra boolean public true.
	(InitCtorFields) pub new parameter.  (PutProcedureExternPublic)
	New procedure.  (PutCtorExtern) New procedure.
	(PutModuleCtorExtern) New procedure.
	* gm2-gcc/init.cc: Rewritten to pass envp to call init and fini
	functions.
	* gm2-gcc/m2expr.def: FOR "C" removed.
	* gm2-libs-ch/RTcodummy.c: Undo removal of _init and _finish
	functions.
	* gm2-libs-ch/pthdummy.c (Removed).
	* m2/gm2spec.cc (seen_scaffold_static): New boolean.
	(seen_scaffold_dynamic) New boolean.  (scaffold_static)
	New boolean.  (scaffold_dynamic) New boolean.
	(get_libexec) Removed.  (add_exec_dir) Rewritten comment.
	(lang_specific_driver) Check that dynamic scaffold and static
	scaffold are not both enabled.
	* mc-boot-ch/Gpth.c (Removed).
	* mc-boot-ch/Gtermios.c (Removed).
	* mc-boot-ch/Gtermios.cc (Added).  Converted from Gtermios.c.

gm2tools/ChangeLog:

	* gm2l.1 (--M2RTS) Removed.  (-M2RTS) Removed.  (--include=) Added.
	(--exclude=) Added.  (-flibs=) Added.

libgm2/ChangeLog:

	* libm2iso/ErrnoCategory.cc (_finish): Changed to _fini.
	* libm2iso/RTco.cc (_finish): Changed to _fini.
	* libm2pim/SysExceptions.cc (_finish): Changed to _fini.
	* libm2pim/errno.cc (_finish): Changed to _fini.
	* libm2pim/termios.cc (_finish): Changed to _fini.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
26 files changed