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')
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
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 ())
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)
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
BEGIN
curBeginTok := propageteTokenPosition (curStartTok, curBeginTok) ;
curFinallyTok := propageteTokenPosition (tokno, curFinallyTok) ;
+ Assert (curModuleSym # NulSym) ;
MakeModuleCtor (curStartTok, curBeginTok, curFinallyTok,
curModuleSym) ;
PopBlock
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 ;
{
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:
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:
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;
#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
void
lang_register_spec_functions (void)
{
+ fe_add_spec_function ("exec_prefix", add_exec_dir);
}
/* 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",
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
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
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.
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.
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.
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.
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"]
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.
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
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]] {
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.
gm2_init_log
-gm2_link_with "-lm2log -lm2pim -lm2iso -lpthread"
+gm2_link_with "-lm2log"
foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
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.
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.
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.
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
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.
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.
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.
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.
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"]
--- /dev/null
+/* 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));