diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2023-01-16 14:07:20 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2023-01-25 15:23:32 +0000 |
commit | 80cf2c5e8f496bed9c6facf55f9ae31d0d90fd28 (patch) | |
tree | f02f7767cecade575300675f1fd35e5c3992ed70 /config | |
parent | 9d4c00cdaccc3decd07740e817387ce844ef3ac9 (diff) | |
download | gcc-80cf2c5e8f496bed9c6facf55f9ae31d0d90fd28.zip gcc-80cf2c5e8f496bed9c6facf55f9ae31d0d90fd28.tar.gz gcc-80cf2c5e8f496bed9c6facf55f9ae31d0d90fd28.tar.bz2 |
modula-2: Fixes for preprocessing [PR102343, PR108182].
Modula-2 uses the C preprocessor to implement handling for conditional
code and macros. However, this is not done directly, because the process
is applied recursively to imported definitions and modules.
The cc1gm2 executable records the parameters as a template command line
needed to create a composite 'cc1 -E' for each file to be preprocessed
starting with the main file from the original command line.
This patch fixes the capture of the C preprocessor template to include
the target information needed for correct multilib operation.
In order to match the existing semantics of '-E, -M and -MM' these have
to be handled as a 'pre-processor only' job (i.e. the recursion is omitted
and only the main file is processed).
Whereas C-family front ends always pre-process, Modula-2 only does so
when specifically requested (via the -fcpp option).
'-MD, -MMD and -MQ' also require special handling, since (in principle)
these options can be applied to any command line (with -fcpp) providing
dependency information as a by-product.
TODO: the preprocessor is not able to determine def and mod dependencies
for Modula-2 and so the output of this only shows the object to module
dep. We should be able to append the .def and .mod dependencies.
The patch amends save-temps handling to cater for the preprocessor
recursion and to avoid writing saved files into the source directories.
The patch changes the extension for Modula-2 preprocessed source to .m2i
to avoid clashes with .i.
The main driver code is amended to add default handlers for .mod and .m2i
so that a useful error message will be emitted if the Modula-2 compiler
is not built-in.
The compiler will now also handle code generation from a .m2i preprocessed
source.
TODO: We should not need to pass the '-c' option to the compiler to alter
the processing of init code.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR modula2/102343
PR modula2/108182
gcc/ChangeLog:
* gcc.cc: Provide default specs for Modula-2 so that when the
language is not built-in better diagnostics are emitted for
attempts to use .mod or .m2i file extensions.
gcc/m2/ChangeLog:
* gm2-compiler/M2Comp.mod: Early exit for pre-processor-only jobs.
* gm2-compiler/M2Options.def (SetPPOnly, GetPPOnly, SetMD, GetMD,
SetMMD, GetMMD, SetMQ, GetMQ, SetObj, GetObj, SetDumpDir,
GetDumpDir):New.
* gm2-compiler/M2Options.mod:(SetPPOnly, GetPPOnly, SetMD, GetMD,
SetMMD, GetMMD, SetMQ, GetMQ, SetObj, GetObj, SetDumpDir,
GetDumpDir):New.
* gm2-compiler/M2Preprocess.def (PreprocessModule): Add flag to
indicate the main file.
* gm2-compiler/M2Preprocess.mod: Handle Preprocess-only jobs,
handle MD, MMD and MQ options.
* gm2-gcc/m2options.h (M2Options_SetPPOnly, M2Options_GetPPOnly,
M2Options_SetDumpDir, M2Options_SetMD, M2Options_GetMD,
M2Options_SetMMD, M2Options_GetMMD, M2Options_SetMQ, M2Options_GetMQ,
M2Options_SetObj, M2Options_GetObj): New.
* gm2-gcc/m2type.cc (m2type_InitBaseTypes): Early exit for pre-
processor-only jobs.
* gm2-lang.cc (gm2_langhook_init): Handle preprocess-only commands.
(gm2_langhook_option_lang_mask): Claim C and Driver options so that
we can intercept them for building pre-processor commands.
(gm2_langhook_init_options): Collect the preprocessor line here.
Save options that have different actions for preprocessor and compile
commands.
(gm2_langhook_handle_option): Only handle the modula-2 options here.
(gm2_langhook_post_options): Do not create a back-end for pre-
processor-only jobs.
* gm2spec.cc (lang_specific_driver): Ignore PCH options, append a
scaffold-main for cases where we are building a main module with
-c.
* lang-specs.h: Revise to handle preprocessor-only jobs and to
consume pre-processed files.
* lang.opt: Remove Driver and C options copies (we claim these
separately).
Diffstat (limited to 'config')
0 files changed, 0 insertions, 0 deletions