From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 6D39D3858D33 for ; Wed, 25 Jan 2023 12:03:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D39D3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42b.google.com with SMTP id e3so16790415wru.13 for ; Wed, 25 Jan 2023 04:03:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=/dPHFMIwf9akW3RuBT1ZTLICzw2PXoLZwCcd1jX0D4c=; b=IUzLw6+fw9Vh3DM3ELyZyBpdZCfkrB4UWnhOgpigCXkz4S4+4+ni1QmQC1yDTgIVkR WADuwS4sRYtURiQxMU2w4IPQmVmLKaQhi7VcDmWRhfEvnDdiRoktyC1ijYEJAI4FMUyd MTBX7BfoOi+yuzqfaA1+0hQuHGBW+VtgEH+rv/MHRCsg3fZmUjxdXZJOvfOtIMcR5LFo IJL+mRgq2NC4lqO/07D05l6beorN+qesgjFxetua8GjVInPZSQ/xPMO1pqwWWGhDWs8j PApOQOZkCZXEmtYQjWSQZ8tfIh1hCGzplvGIfnHKxnRoJTGdO1YyFnqabVcmwjpqdcO0 e9hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/dPHFMIwf9akW3RuBT1ZTLICzw2PXoLZwCcd1jX0D4c=; b=gNpWPLIpWKb37ur2WSS+S/najhUy5ootMlai+Y/VzaWO1zEGg3EMu1Xk1b3eVU7ybu S+LTFj0ihEJ+ua1TIShn31qv+WZUHgkDbiRmSe6LtN0Gy8FxAS/gR3lRC1G1YmPGUGWY oMjkNkwi2vBicN3VDBZcSyhsrwbBgFhTGlng98TGm29t5Z1j7ZNzGHO3RpYbLHTBho1c XDT7gt6shuLiPXWuis0/6ZKzVip/suTz0q3EFFhaPekrH3lPduVPd4FSSrNE+mxPfmv0 LKBXWTUwuXUE9SjPbVo3QuAygo9lTuo2vxcDWgdxu5zJ0woJQBWLpZisY/vWuuaZVrfx WH6A== X-Gm-Message-State: AFqh2koNpAB0H7Zz6dYxmpgX+NmQtAzelAap07JreQw+xpFkZ6xVjOzM SmKBmEbG+dUtHe8hUDQGLvR3agaD7Io= X-Google-Smtp-Source: AMrXdXui8hBCG48m+mlrLbO8Z/7Ywb5uf09j6ozceXojqnWzVs8y/hAMy5h3CTABM0MfJFLecVCThw== X-Received: by 2002:a5d:6702:0:b0:2bd:e009:79cc with SMTP id o2-20020a5d6702000000b002bde00979ccmr34507969wru.53.1674648214950; Wed, 25 Jan 2023 04:03:34 -0800 (PST) Received: from lancelot ([195.147.220.46]) by smtp.gmail.com with ESMTPSA id q2-20020adfea02000000b002bfae6b17d2sm4126492wrm.55.2023.01.25.04.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 04:03:34 -0800 (PST) Received: from gaius by lancelot with local (Exim 4.94.2) (envelope-from ) id 1pKeUr-008lPj-SU; Wed, 25 Jan 2023 12:03:21 +0000 From: Gaius Mulley To: Iain Sandoe Cc: gcc-patches@gcc.gnu.org, iain@sandoe.co.uk Subject: Re: [PATCH] modula-2: Fixes for preprocessing [PR102343, PR108182] References: <20230125084629.55372-1-iain@sandoe.co.uk> Date: Wed, 25 Jan 2023 12:03:21 +0000 In-Reply-To: <20230125084629.55372-1-iain@sandoe.co.uk> (Iain Sandoe's message of "Wed, 25 Jan 2023 08:46:29 +0000") Message-ID: <874jsen7na.fsf@debian> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Iain Sandoe writes: > Tested on x86_64, powerpc64 - linux-gnu (with 32b multilibs), > i686, powerpc darwin (with 64b multilibs) x86_64 darwin (with and without > 32b multilib). > OK for trunk? > thanks > Iain > > --- 8< --- > > 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 > > 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). Hi Iain, yes LGTM - thanks for the fixes and it is great to have the ability for gm2 to handle preprocessed source regards, Gaius