aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaius Mulley <gaius.mulley@southwales.ac.uk>2022-06-26 13:50:27 +0100
committerGaius Mulley <gaius.mulley@southwales.ac.uk>2022-06-26 13:50:27 +0100
commit60bd34a45bfed0da9605606a5596b96d8f13e5cb (patch)
treef3e35cfecd6dbfef351b56a16b07243a8a0d1756
parent6c02f7ca5c93f4ea57fb7701b5daebc9e5cd3e94 (diff)
Fixes to allow -fcpp and regression test link changes.
This patch fixes (re-introduces) the -fcpp option and it migrates more testsuite tcl files to use the new linking mechanism. 2022-06-26 Gaius Mulley <gaius.mulley@southwales.ac.uk> gcc/m2/ChangeLog: * bnf/gm2l.bnf (ScanArgs): -fcppbegin changed to -fcpp-begin. * gm2-compiler/M2DriverOptions.mod (ScanCppArgs): -fcppbegin changed to -fcpp-begin, -fcppend changed to -fcpp-end. * gm2-compiler/M2GenGCC.mod (CodeFinallyEnd): Check we are compiling the main module before generating the scaffold. * gm2-compiler/M2Options.mod (CppRemember): -fcppbegin changed to -fcpp-begin. (CppArg) -fcppbegin changed to -fcpp-begin, -fcppend changed to -fcpp-end. -fcppprog changed to -fcpp-prog. * gm2-compiler/P2SymBuild.mod (BlockEnd): Added assert. (PopBlock) bug fix, curModuleSym is popped in correct sequence. * gm2-lang.cc (gm2_langhook_init_options): -fcppbegin changed to -fcpp-begin. -fcppend changed to -fcpp-end. -fcppprog changed to -fcpp-prog. * gm2spec.cc (get_libexec): New function. (gen_gm2_libexec) New function. (add_exec_dir) New function. (lang_register_spec_functions) add exec_prefix. * lang-specs.h: -fcppbegin changed to -fcpp-begin. -fcppend changed to -fcpp-end. * lang.opt: Uniform internal switch statement used where necessary. -fcppbegin changed to -fcpp-begin. -fcppend changed to -fcpp-end. -fcppprog= changed to -fcpp-prog=. libgm2/Changelog: * libm2iso/m2rts.h: (New file). Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
-rw-r--r--gcc/m2/bnf/gm2l.bnf2
-rw-r--r--gcc/m2/gm2-compiler/M2DriverOptions.mod4
-rw-r--r--gcc/m2/gm2-compiler/M2GenGCC.mod4
-rw-r--r--gcc/m2/gm2-compiler/M2Options.mod6
-rw-r--r--gcc/m2/gm2-compiler/P2SymBuild.mod5
-rw-r--r--gcc/m2/gm2-lang.cc10
-rw-r--r--gcc/m2/gm2spec.cc69
-rw-r--r--gcc/m2/lang-specs.h4
-rw-r--r--gcc/m2/lang.opt14
-rw-r--r--gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/exceptions/run/pass/exceptions-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/extensions/run/fail/extensions-run-fail.exp1
-rw-r--r--gcc/testsuite/gm2/extensions/run/pass/extensions-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/pimcoroutines/run/pass/pimcoroutines-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/pimlib/run/pass/pimlib-run-pass.exp2
-rw-r--r--gcc/testsuite/gm2/quads/run/pass/quads-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/sets/run/pass/sets-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/switches/check-all/run/fail/switches-check-all-run-fail.exp1
-rw-r--r--gcc/testsuite/gm2/switches/check-all/run/pass/switches-check-all-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/switches/iso/run/pass/switches-iso-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/switches/makeall/pass/switches-makeall-pass.exp1
-rw-r--r--gcc/testsuite/gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp1
-rw-r--r--gcc/testsuite/gm2/types/run/pass/types-run-pass.exp2
-rw-r--r--libgm2/libm2iso/m2rts.h41
28 files changed, 145 insertions, 40 deletions
diff --git a/gcc/m2/bnf/gm2l.bnf b/gcc/m2/bnf/gm2l.bnf
index 5d1fb880a3f..88cbb1ddc62 100644
--- a/gcc/m2/bnf/gm2l.bnf
+++ b/gcc/m2/bnf/gm2l.bnf
@@ -867,7 +867,7 @@ BEGIN
ELSIF EqualArray(Mark (Slice (s, 0, 6)), '-fmod=')
THEN
SetModExtension (Slice (s, 6, 0))
- ELSIF EqualArray (s, '-fcppbegin')
+ ELSIF EqualArray (s, '-fcpp-begin')
THEN
i := ScanCppArgs (i)
ELSIF EqualArray (s, '--M2RTS') OR EqualArray (s, '-M2RTS')
diff --git a/gcc/m2/gm2-compiler/M2DriverOptions.mod b/gcc/m2/gm2-compiler/M2DriverOptions.mod
index e27dd72146e..e3971e6b29e 100644
--- a/gcc/m2/gm2-compiler/M2DriverOptions.mod
+++ b/gcc/m2/gm2-compiler/M2DriverOptions.mod
@@ -70,11 +70,11 @@ PROCEDURE ScanCppArgs (i: CARDINAL) : CARDINAL ;
VAR
option: String ;
BEGIN
- IF GetArg (option, i) AND EqualArray (option, '-fcppbegin')
+ IF GetArg (option, i) AND EqualArray (option, '-fcpp-begin')
THEN
INC (i) ;
WHILE GetArg (option, i) DO
- IF EqualArray (option, '-fcppend')
+ IF EqualArray (option, '-fcpp-end')
THEN
RETURN i
ELSE
diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod
index 570713c4126..fd7d7fb75bb 100644
--- a/gcc/m2/gm2-compiler/M2GenGCC.mod
+++ b/gcc/m2/gm2-compiler/M2GenGCC.mod
@@ -1156,7 +1156,9 @@ BEGIN
IsModuleWithinProcedure (moduleSym)) ;
IF ScaffoldMain OR (NOT cflag)
THEN
- IF CompilingMainModule AND (ScaffoldDynamic OR ScaffoldStatic OR ScaffoldMain)
+ IF CompilingMainModule AND
+ (ScaffoldDynamic OR ScaffoldStatic OR ScaffoldMain) AND
+ (moduleSym = GetMainModule ())
THEN
qprintf0 ("generating scaffold m2link information\n");
DeclareM2linkGlobals (location, VAL (INTEGER, ScaffoldStatic), GetRuntimeModuleOverride ())
diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod
index 00df4ddde94..450c08a25ed 100644
--- a/gcc/m2/gm2-compiler/M2Options.mod
+++ b/gcc/m2/gm2-compiler/M2Options.mod
@@ -175,10 +175,10 @@ VAR
s: String ;
BEGIN
s := InitStringCharStar(opt) ;
- IF EqualArray(s, '-fcppbegin') OR EqualArray(s, '-fcppend')
+ IF EqualArray(s, '-fcpp-begin') OR EqualArray(s, '-fcpp-end')
THEN
(* do nothing *)
- ELSIF EqualArray(s, '-fcppprog=')
+ ELSIF EqualArray(s, '-fcpp-prog=')
THEN
CppProgram := KillString(CppProgram) ;
CppProgram := InitStringCharStar(arg)
@@ -208,7 +208,7 @@ END CppArg ;
PROCEDURE CppRemember (s: String) ;
BEGIN
- IF EqualArray(Mark(Slice(s, 0, 10)), '-fcppprog=')
+ IF EqualArray(Mark(Slice(s, 0, 10)), '-fcpp-prog=')
THEN
CppProg(string(Mark(Slice(s, 10, 0))))
ELSE
diff --git a/gcc/m2/gm2-compiler/P2SymBuild.mod b/gcc/m2/gm2-compiler/P2SymBuild.mod
index 97aeb8de0eb..d5c8d249963 100644
--- a/gcc/m2/gm2-compiler/P2SymBuild.mod
+++ b/gcc/m2/gm2-compiler/P2SymBuild.mod
@@ -199,6 +199,7 @@ PROCEDURE BlockEnd (tokno: CARDINAL) ;
BEGIN
curBeginTok := propageteTokenPosition (curStartTok, curBeginTok) ;
curFinallyTok := propageteTokenPosition (tokno, curFinallyTok) ;
+ Assert (curModuleSym # NulSym) ;
MakeModuleCtor (curStartTok, curBeginTok, curFinallyTok,
curModuleSym) ;
PopBlock
@@ -250,11 +251,11 @@ END PushBlock ;
PROCEDURE PopBlock ;
BEGIN
+ curModuleSym := PopWord (BlockStack) ;
curFinallyTok := PopWord (BlockStack) ;
curEndTok := PopWord (BlockStack) ;
curBeginTok := PopWord (BlockStack) ;
- curStartTok := PopWord (BlockStack) ;
- curModuleSym := PopWord (BlockStack)
+ curStartTok := PopWord (BlockStack)
END PopBlock ;
diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
index fd03d9c5387..5b1021b7950 100644
--- a/gcc/m2/gm2-lang.cc
+++ b/gcc/m2/gm2-lang.cc
@@ -167,10 +167,10 @@ gm2_langhook_init_options (unsigned int decoded_options_count,
{
switch (decoded_options[i].opt_index)
{
- case OPT_fcppbegin:
+ case OPT_fcpp_begin:
in_cpp_args = true;
break;
- case OPT_fcppend:
+ case OPT_fcpp_end:
in_cpp_args = false;
break;
case OPT_SPECIAL_input_file:
@@ -343,13 +343,13 @@ gm2_langhook_handle_option (
case OPT_fcpp:
M2Options_SetCpp (value);
return 1;
- case OPT_fcppbegin:
+ case OPT_fcpp_begin:
insideCppArgs = TRUE;
return 1;
- case OPT_fcppend:
+ case OPT_fcpp_end:
insideCppArgs = FALSE;
return 1;
- case OPT_fcppprog_:
+ case OPT_fcpp_prog_:
M2Options_CppProg (arg);
return 1;
case OPT_fq:
diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
index 8d834252eef..1305d9ceb53 100644
--- a/gcc/m2/gm2spec.cc
+++ b/gcc/m2/gm2spec.cc
@@ -117,6 +117,9 @@ static void insert_option (unsigned int *in_decoded_options_count,
struct cl_decoded_option **in_decoded_options,
unsigned int position);
static const char *gen_link_path (const char *libpath, const char *dialect);
+static const char *add_exec_dir (int argc, const char *argv[]);
+static const char *gen_gm2_libexec (const char *path);
+static const char *get_libexec (void);
static bool seen_B = false;
static const char *B_path = NULL;
@@ -130,6 +133,71 @@ static const char *multilib_dir = NULL;
#endif
+static const char *
+get_libexec (void)
+{
+ const char *libexec = getenv (GM2_LIBEXEC_ENV);
+
+ if (libexec == NULL || (strcmp (libexec, "") == 0))
+ return STANDARD_LIBEXEC_PREFIX;
+ else
+ return libexec;
+}
+
+/* gen_gm2_libexec, return a libexec string. */
+
+static const char *
+gen_gm2_libexec (const char *libexec)
+{
+ int l = strlen (libexec) + 1 + strlen (DEFAULT_TARGET_MACHINE) + 1
+ + strlen (DEFAULT_TARGET_VERSION) + 1;
+ char *s = (char *)xmalloc (l);
+ char dir_sep[2];
+
+ dir_sep[0] = DIR_SEPARATOR;
+ dir_sep[1] = (char)0;
+
+ strcpy (s, libexec);
+ strcat (s, dir_sep);
+ strcat (s, DEFAULT_TARGET_MACHINE);
+ strcat (s, dir_sep);
+ strcat (s, DEFAULT_TARGET_VERSION);
+ return s;
+}
+
+/* add_exec_dir prepends the exec path to the given executable filename. */
+
+static const char *
+add_exec_dir (int argc, const char *argv[])
+{
+ if (argc == 1 && argv[0] != NULL)
+ {
+ const char *path;
+
+ if (seen_B)
+ path = xstrdup (B_path);
+ else
+ path = gen_gm2_libexec (get_libexec ());
+
+ if (path != NULL)
+ {
+ char *opt = (char *)xmalloc (strlen ("-fcpp-prog=") + strlen (path)
+ + 1 + strlen (argv[0]) + 1);
+ char *sep = (char *)alloca (2);
+
+ sep[0] = DIR_SEPARATOR;
+ sep[1] = (char)0;
+
+ strcpy (opt, "-fcpp-prog=");
+ strcat (opt, path);
+ strcat (opt, sep);
+ strcat (opt, argv[0]);
+ return opt;
+ }
+ }
+ return "-fcpp-prog=none";
+}
+
/* fe_generate_option wrap up arg and pass it to fe_save_switch. */
static void
@@ -793,4 +861,5 @@ lang_specific_pre_link (void)
void
lang_register_spec_functions (void)
{
+ fe_add_spec_function ("exec_prefix", add_exec_dir);
}
diff --git a/gcc/m2/lang-specs.h b/gcc/m2/lang-specs.h
index d7f1e696e8d..c5b2fbfca83 100644
--- a/gcc/m2/lang-specs.h
+++ b/gcc/m2/lang-specs.h
@@ -24,9 +24,9 @@ along with GCC; see the file COPYING3. If not see
/* Pass the preprocessor options on the command line together with
the exec prefix. */
-#define M2CPP "%{fcpp:-fcppbegin %:exec_prefix(cc1)" \
+#define M2CPP "%{fcpp:-fcpp-begin %:exec_prefix(cc1)" \
" -E -lang-asm -traditional-cpp " \
- " %(cpp_unique_options) -fcppend}"
+ " %(cpp_unique_options) -fcpp-end}"
{".mod", "@modula-2", 0, 0, 0},
{"@modula-2",
diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
index 01f6a9ad188..14176fa6039 100644
--- a/gcc/m2/lang.opt
+++ b/gcc/m2/lang.opt
@@ -80,7 +80,7 @@ automatically initializes all pointers to NIL
flocation=
Modula-2 Joined
-set all location values to a specific value (internal)
+set all location values to a specific value (internal switch)
fbounds
Modula-2
@@ -326,17 +326,17 @@ fobjc-std=objc1
Modula-2
; Documented in c.opt
-fcppend
+fcpp-end
Modula-2
-passed to the preprocessor if -fcpp is used
+passed to the preprocessor if -fcpp is used (internal switch)
-fcppbegin
+fcpp-begin
Modula-2
-passed to the preprocessor if -fcpp is used
+passed to the preprocessor if -fcpp is used (internal switch)
-fcppprog=
+fcpp-prog=
Modula-2 Joined
-passed to the preprocessor if -fcpp is used
+passed to the preprocessor if -fcpp is used (internal switch)
E
Modula-2
diff --git a/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp b/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
index 4d7076bf6cc..ec2483bbc60 100644
--- a/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
+++ b/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
@@ -28,7 +28,7 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../gm2
gm2_init_cor
-gm2_link_with "-lm2cor -lm2pim -lm2iso -lpthread"
+gm2_link_with "-lm2cor"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/exceptions/run/pass/exceptions-run-pass.exp b/gcc/testsuite/gm2/exceptions/run/pass/exceptions-run-pass.exp
index 729c63f2d38..9616ff11c06 100644
--- a/gcc/testsuite/gm2/exceptions/run/pass/exceptions-run-pass.exp
+++ b/gcc/testsuite/gm2/exceptions/run/pass/exceptions-run-pass.exp
@@ -29,7 +29,6 @@ load_lib gm2-torture.exp
set output [target_compile $srcdir/$subdir/cpp.cpp cpp.o object "-g"]
-set output [target_compile $srcdir/$subdir/mycpp.cpp mycpp.o object "-g"]
#
# notice this uses PIM libraries with exceptions - this is a useful test.
@@ -39,6 +38,7 @@ set output [target_compile $srcdir/$subdir/mycpp.cpp mycpp.o object "-g"]
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/exceptions/run/pass"
+gm2_link_with "cpp.o"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/extensions/run/fail/extensions-run-fail.exp b/gcc/testsuite/gm2/extensions/run/fail/extensions-run-fail.exp
index 224ebb252ec..ede8efb40a7 100644
--- a/gcc/testsuite/gm2/extensions/run/fail/extensions-run-fail.exp
+++ b/gcc/testsuite/gm2/extensions/run/fail/extensions-run-fail.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/extensions/run/fail" -fsoft-check-all -fno-m2-plugin
-gm2_link_with "-lm2pim -lm2iso -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/extensions/run/pass/extensions-run-pass.exp b/gcc/testsuite/gm2/extensions/run/pass/extensions-run-pass.exp
index 04227121000..40d40fb6e50 100644
--- a/gcc/testsuite/gm2/extensions/run/pass/extensions-run-pass.exp
+++ b/gcc/testsuite/gm2/extensions/run/pass/extensions-run-pass.exp
@@ -28,7 +28,7 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/extensions/run/pass" -fsoft-check-all
-gm2_link_with "cvararg.o -lm2pim -lm2iso -lpthread"
+gm2_link_with "cvararg.o"
set output [target_compile $srcdir/$subdir/cvararg.c cvararg.o object "-g"]
diff --git a/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp b/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
index ba6ebc6dc79..7f284ec4a99 100644
--- a/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
+++ b/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
@@ -25,6 +25,7 @@ if $tracelevel then {
load_lib gm2-torture.exp
gm2_init_iso "${srcdir}/gm2/iso/run/pass" -fsoft-check-all
+gm2_link_with fileio.o
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp b/gcc/testsuite/gm2/pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp
index 28deba3ce48..746cb5f296b 100644
--- a/gcc/testsuite/gm2/pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp
+++ b/gcc/testsuite/gm2/pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp
@@ -82,7 +82,7 @@ proc gm2_target_compile_options_optimize { source dest type options } {
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/pim/options/optimize/run/pass"
-gm2_link_with "-lm2pim -lm2iso -lpthread"
+# gm2_link_with "-lm2pim -lm2iso -lpthread"
#
# compile library file
diff --git a/gcc/testsuite/gm2/pimcoroutines/run/pass/pimcoroutines-run-pass.exp b/gcc/testsuite/gm2/pimcoroutines/run/pass/pimcoroutines-run-pass.exp
index a224ce80892..a6157d0233a 100644
--- a/gcc/testsuite/gm2/pimcoroutines/run/pass/pimcoroutines-run-pass.exp
+++ b/gcc/testsuite/gm2/pimcoroutines/run/pass/pimcoroutines-run-pass.exp
@@ -27,7 +27,7 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_cor "${srcdir}/gm2/pim/run/pass"
-gm2_link_with "-lm2cor -lm2pim -lm2iso -lpthread"
+gm2_link_with "-lm2cor"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
diff --git a/gcc/testsuite/gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp b/gcc/testsuite/gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp
index 447b16d7796..ba0d677b931 100644
--- a/gcc/testsuite/gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp
+++ b/gcc/testsuite/gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/pimlib/base/run/pass"
-gm2_link_with "-lm2pim -lm2iso -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp b/gcc/testsuite/gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp
index 77afa0aa354..1a10a77cd72 100644
--- a/gcc/testsuite/gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp
+++ b/gcc/testsuite/gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp
@@ -29,7 +29,7 @@ set gm2src ${srcdir}/../m2
gm2_init_log
-gm2_link_with "-lm2log -lm2pim -lm2iso -lpthread"
+gm2_link_with "-lm2log"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
diff --git a/gcc/testsuite/gm2/pimlib/run/pass/pimlib-run-pass.exp b/gcc/testsuite/gm2/pimlib/run/pass/pimlib-run-pass.exp
index a04c33308a3..b2078c62d05 100644
--- a/gcc/testsuite/gm2/pimlib/run/pass/pimlib-run-pass.exp
+++ b/gcc/testsuite/gm2/pimlib/run/pass/pimlib-run-pass.exp
@@ -29,7 +29,7 @@ set gm2src ${srcdir}/../m2
gm2_init_log
-gm2_link_with "-lm2pim -lm2log -lm2iso -lpthread"
+gm2_link_with "-lm2log"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/quads/run/pass/quads-run-pass.exp b/gcc/testsuite/gm2/quads/run/pass/quads-run-pass.exp
index 06dfd44c8e4..01d40d29d9f 100644
--- a/gcc/testsuite/gm2/quads/run/pass/quads-run-pass.exp
+++ b/gcc/testsuite/gm2/quads/run/pass/quads-run-pass.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${gm2src}/gm2-compiler"
-gm2_link_with "-lm2pim -lm2iso -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/sets/run/pass/sets-run-pass.exp b/gcc/testsuite/gm2/sets/run/pass/sets-run-pass.exp
index b90725df293..96670450fc9 100644
--- a/gcc/testsuite/gm2/sets/run/pass/sets-run-pass.exp
+++ b/gcc/testsuite/gm2/sets/run/pass/sets-run-pass.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_iso "${srcdir}/gm2/sets/run/pass/"
-gm2_link_with "-lm2iso -lm2pim -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/switches/check-all/run/fail/switches-check-all-run-fail.exp b/gcc/testsuite/gm2/switches/check-all/run/fail/switches-check-all-run-fail.exp
index 076f90a531b..38acb74db8c 100644
--- a/gcc/testsuite/gm2/switches/check-all/run/fail/switches-check-all-run-fail.exp
+++ b/gcc/testsuite/gm2/switches/check-all/run/fail/switches-check-all-run-fail.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/switches/check-all/run/fail" -fsoft-check-all -fno-m2-plugin
-gm2_link_with "-lm2pim -lm2iso -lpthread"
#
# compile the support module
diff --git a/gcc/testsuite/gm2/switches/check-all/run/pass/switches-check-all-run-pass.exp b/gcc/testsuite/gm2/switches/check-all/run/pass/switches-check-all-run-pass.exp
index 1ee2f3ff38e..a6eb4669615 100644
--- a/gcc/testsuite/gm2/switches/check-all/run/pass/switches-check-all-run-pass.exp
+++ b/gcc/testsuite/gm2/switches/check-all/run/pass/switches-check-all-run-pass.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_iso "${srcdir}/gm2/switches/check-all/run/pass" -fsoft-check-all
-gm2_link_with "-lm2iso -lm2pim -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/switches/iso/run/pass/switches-iso-run-pass.exp b/gcc/testsuite/gm2/switches/iso/run/pass/switches-iso-run-pass.exp
index e7a36c9ac85..114f5f8a92b 100644
--- a/gcc/testsuite/gm2/switches/iso/run/pass/switches-iso-run-pass.exp
+++ b/gcc/testsuite/gm2/switches/iso/run/pass/switches-iso-run-pass.exp
@@ -27,7 +27,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_iso "${srcdir}/gm2/switches/iso/run/pass"
-gm2_link_with "-lm2iso -lm2pim -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/switches/makeall/pass/switches-makeall-pass.exp b/gcc/testsuite/gm2/switches/makeall/pass/switches-makeall-pass.exp
index 9c43b98edbb..82d057430c5 100644
--- a/gcc/testsuite/gm2/switches/makeall/pass/switches-makeall-pass.exp
+++ b/gcc/testsuite/gm2/switches/makeall/pass/switches-makeall-pass.exp
@@ -26,7 +26,6 @@ load_lib gm2-torture.exp
gm2_init "-I${srcdir}/gm2/switches/makeall/pass" -fmakeall
gm2_init_pim4 "${srcdir}/gm2/switches/makeall/pass"
-gm2_link_with "-lm2pim -lm2iso -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp b/gcc/testsuite/gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp
index 6e915e96191..9444780b5ee 100644
--- a/gcc/testsuite/gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp
+++ b/gcc/testsuite/gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp
@@ -28,7 +28,6 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim2
-gm2_link_with "-lm2pim -lm2iso -lpthread"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
# If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/gm2/types/run/pass/types-run-pass.exp b/gcc/testsuite/gm2/types/run/pass/types-run-pass.exp
index 50903547367..375c7012e7d 100644
--- a/gcc/testsuite/gm2/types/run/pass/types-run-pass.exp
+++ b/gcc/testsuite/gm2/types/run/pass/types-run-pass.exp
@@ -28,7 +28,7 @@ load_lib gm2-torture.exp
set gm2src ${srcdir}/../m2
gm2_init_pim "${srcdir}/gm2/types/run/pass"
-gm2_link_with "d.o -lm2pim -lm2iso -lpthread"
+gm2_link_with "d.o"
set output [target_compile $srcdir/$subdir/d.c d.o object "-g"]
diff --git a/libgm2/libm2iso/m2rts.h b/libgm2/libm2iso/m2rts.h
new file mode 100644
index 00000000000..57e6e90d94d
--- /dev/null
+++ b/libgm2/libm2iso/m2rts.h
@@ -0,0 +1,41 @@
+/* m2rts.h provides a C interface to M2RTS.mod.
+
+Copyright (C) 2019-2022 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/>. */
+
+
+typedef void (*proc_con) (int, char **, char **);
+typedef void (*proc_dep) (void);
+
+extern "C" void M2RTS_RequestDependant (const char *modulename, const char *dependancy);
+extern "C" void M2RTS_RegisterModule (const char *modulename,
+ proc_con init, proc_con fini, proc_dep dependencies);
+extern "C" void _M2_M2RTS_init (void);
+
+extern "C" void M2RTS_ConstructModules (const char *,
+ int argc, char *argv[], char *envp[]);
+extern "C" void M2RTS_Terminate (void);
+extern "C" void M2RTS_DeconstructModules (void);
+
+extern "C" void M2RTS_Halt (const char *, int, const char *, const char *) __attribute__ ((noreturn));