From patchwork Thu Jan 26 20:27:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 63760 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 25B3C385AC29 for ; Thu, 26 Jan 2023 20:28:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25B3C385AC29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674764899; bh=nRSGDy8yIQPgq2846FHKysW/i8G3BEejoly/o5mGPyI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BB1PnRFxKuSHmgTjk9h6BXsC3XYyEtoiZOa83puPyPVuAvkA1diriSRB/LR+DQ8YG W7x4vVf7zQwv2vqLHCXcDU9sKgUTnef92ymK+XInOKeIKR+LEK6Z2wzE70ZHdwKkn7 yk9qsnzNbkbSw+HsCb4DesjJVN/ZD6UVsP5SFFk0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id F23723858D28 for ; Thu, 26 Jan 2023 20:27:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F23723858D28 Received: by mail-wr1-x42c.google.com with SMTP id y1so3040061wru.2 for ; Thu, 26 Jan 2023 12:27:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nRSGDy8yIQPgq2846FHKysW/i8G3BEejoly/o5mGPyI=; b=hiSRqR4kG/McZuQ467AGfEDdUj6QZvNy4JbIMLUFD5+GvgsCs/zbxTNJXyUr44XPOZ HDpnpt6AgeDtEYQ/5Xd6BJ5Bgwhc2T4awUxwgbV420/Vz0kQnH1JoitUnbISAVNtEfCh pbolP74p9RqtVJExGERBYimCANnIn38U+ESL/ZMVZvPxlWMlX/5rrZLOKR8DJXFC7899 6u4r64evjd5wTn18V7Z4sexhBLsNd/jYExik0RgfIIe0cLifl2BhovwJVp30S8QwOlZV adf6f7VljjV6PVSGXlzu9xpxQjnGV8xrkIuw7z7Kg7VQP1rkuPU367DmUgk+U38khBkH j1JA== X-Gm-Message-State: AFqh2kqb4MAJ+6gp0Gt9wASBJi5g25WuvT0tSMgBd+Dj5Fkh2NrpVNBF jsgjDWl995ABwZnvzpxvZaRurCvOO/k= X-Google-Smtp-Source: AMrXdXulsnWlY7VgQWnLVm7B03bhd+xttnCvF3/hWmVnL1ia3AT8ufbWktpyw3J8Hew/iOCtMsT2Og== X-Received: by 2002:a5d:6186:0:b0:2bd:dc24:cade with SMTP id j6-20020a5d6186000000b002bddc24cademr26756136wru.16.1674764867579; Thu, 26 Jan 2023 12:27:47 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id t4-20020a05600001c400b002bdcce37d31sm2478862wrx.99.2023.01.26.12.27.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Jan 2023 12:27:46 -0800 (PST) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH] Modula-2: Add claimed command line options to lang.opt [PR108555]. Date: Thu, 26 Jan 2023 20:27:45 +0000 Message-Id: <20230126202745.49379-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe , gaiusmod2@gmail.com, rguenther@suse.de Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This has been retested on x86_64, powerpc64 linux-gnu (with 32b multilibs) on i686, powerpc darwin (with 64b multilibs), x86_64 darwin with and without 32b multilibs, OK for trunk? thanks Iain --- 8< --- This is a partial reversion of the changes in r13-5373-g80cf2c5e8f496b. As observed in the PR, handling the C and Driver options in the Modula-2 lang-specific code could be difficult to emulate; This reverts to adding the required options to the language-specific .opt file. Signed-off-by: Iain Sandoe PR modula2/108555 PR modula2/108182 PR modula2/102343 gcc/m2/ChangeLog: * gm2-lang.cc (gm2_langhook_option_lang_mask): Do not claim CL_C or CL_DRIVER. (gm2_langhook_init_options): Handle options that we want to pass to the preprocessor. * lang-specs.h: Pass -B and -save-temps to regular compile lines. * lang.opt: Add C and Driver options that Modula-2 intercepts for internal use. Reorder options into two sections and to collate. --- gcc/m2/gm2-lang.cc | 53 ++++++------- gcc/m2/lang-specs.h | 5 +- gcc/m2/lang.opt | 185 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 177 insertions(+), 66 deletions(-) diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc index a30e626620c..999c57c1cfa 100644 --- a/gcc/m2/gm2-lang.cc +++ b/gcc/m2/gm2-lang.cc @@ -137,9 +137,7 @@ gm2_langhook_init (void) static unsigned int gm2_langhook_option_lang_mask (void) { - /* We need to process some driver options and pass through some C - ones to build our preprocessing lines. */ - return CL_ModulaX2 | CL_C | CL_DRIVER; + return CL_ModulaX2; } /* Initialize the options structure. */ @@ -262,21 +260,22 @@ gm2_langhook_init_options (unsigned int decoded_options_count, For now skip all plugins to avoid fails with the m2 one. */ break; - /* Preprocessor arguments with a following filename. */ + /* Preprocessor arguments with a following filename, we add these + back to the main file preprocess line, but not to dependents + TODO Handle MF. */ case OPT_MD: + M2Options_SetMD (arg); + break; case OPT_MMD: - /* Save the filename associated with the MD/MMD which will also - mark the option as used. FIXME: maybe we should diagnose a - missing filename here, rather than assert. */ - gcc_checking_assert (i+1 < decoded_options_count); - gcc_checking_assert (decoded_options[i+1].opt_index - == OPT_SPECIAL_input_file); - /* Pick up the following filename. */ - arg = decoded_options[i+1].arg; - if (code == OPT_MD) - M2Options_SetMD (arg); - else - M2Options_SetMMD (arg); + M2Options_SetMMD (arg); + break; + + /* Modula 2 claimed options we pass to the preprocessor. */ + case OPT_ansi: + case OPT_traditional_cpp: + if (building_cpp_command) + M2Options_CppArg (opt, arg, (option->flags & CL_JOINED) + && !(option->flags & CL_SEPARATE)); break; /* Options we act on and also pass to the preprocessor. */ @@ -286,6 +285,12 @@ gm2_langhook_init_options (unsigned int decoded_options_count, M2Options_CppArg (opt, arg, (option->flags & CL_JOINED) && !(option->flags & CL_SEPARATE)); break; + case OPT_quiet: + M2Options_SetQuiet (value); + if (building_cpp_command) + M2Options_CppArg (opt, arg, (option->flags & CL_JOINED) + && !(option->flags & CL_SEPARATE)); + break; case OPT_v: M2Options_SetVerbose (value); /* FALLTHROUGH */ @@ -533,9 +538,6 @@ gm2_langhook_handle_option ( /* Otherwise, ignored, at least for now. */ return 1; break; - case OPT_quiet: - M2Options_SetQuiet (value); - return 1; case OPT_fm2_whole_program: M2Options_SetWholeProgram (value); return 1; @@ -557,20 +559,19 @@ gm2_langhook_handle_option ( } else return 0; - case OPT_o: - /* Options we ignore, always. */ - return 1; default: if (insideCppArgs) - /* Already handled. */ + /* Handled in gm2_langhook_init_options (). */ return 1; else if (option->flags & CL_DRIVER) - /* Ignore driver options we do not specifically use. */ + /* Driver options (unless specifically claimed above) should be handled + in gm2_langhook_init_options (). */ return 1; else if (option->flags & CL_C) - /* Ignore C options we do not specifically use. */ + /* C options (unless specifically claimed above) should be handled + in gm2_langhook_init_options (). */ return 1; - return 0; + break; } return 0; } diff --git a/gcc/m2/lang-specs.h b/gcc/m2/lang-specs.h index 6228c3c5dad..65004e1cabd 100644 --- a/gcc/m2/lang-specs.h +++ b/gcc/m2/lang-specs.h @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see "%{E|M|MM|fcpp: %{E} -fcpp-begin " \ " %{!E:-E} %(cpp_unique_options) -traditional-cpp -ansi " \ " -fcpp-end %{B*} %{save-temps*} ; \ - : %{v} %I } " + : %{v} %I %{B*} %{save-temps*} } " /* We have three modes: 1. When the preprocessing step is explict and there is no following @@ -44,7 +44,8 @@ along with GCC; see the file COPYING3. If not see cc1gm2 " M2CPP " %{!fcpp:-fcpp;:%{fcpp}} %{I*} %i } \ %{!E:%{!M:%{!MM:\ cc1gm2 " M2CPP " %(cc1_options) %{I*} %i %{c} \ - %{MF*:%eto generate dependencies you must specify either '-M' or '-MM'} \ + %{!fcpp:%{MD|MMD|MF*: \ + %eto generate dependencies you must specify '-fcpp' }} \ %{!fsyntax-only:%(invoke_as)} \ }}}", 0, 0, 0}, {".m2i", "@modula-2-cpp-output", 0, 0, 0}, diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt index 43d6ba56767..ab4ea5547eb 100644 --- a/gcc/m2/lang.opt +++ b/gcc/m2/lang.opt @@ -21,19 +21,15 @@ ; See the GCC internals manual for a description of this file's format. +; There are two sections: +; 1. Options specific to Modula-2 +; 2. Options shared with C or the Driver. +; Please keep any new additions for either case in the relevant section. ; Please try to keep this file in ASCII collating order. Language Modula-2 -Wall -Modula-2 -; Documented in c.opt - -Wpedantic -Modula-2 -; Documented in common.opt - Wpedantic-param-names Modula-2 compiler checks to force definition module procedure parameter names with their implementation module counterpart @@ -50,18 +46,6 @@ Wstyle Modula-2 extra compile time semantic checking, typically tries to catch poor programming style -Wunused-variable -Modula-2 -; Documented in c.opt - -Wunused-parameter -Modula-2 -; Documented in c.opt - -c -Modula-2 -; Documented in c.opt - fauto-init Modula-2 automatically initializes all pointers to NIL @@ -74,10 +58,6 @@ fcase Modula-2 turns on runtime checking to check whether a CASE statement requires an ELSE clause when on was not specified -fobjc-std=objc1 -Modula-2 -; Documented in c.opt - fcpp Modula-2 use cpp to preprocess the module @@ -118,10 +98,6 @@ fdump-system-exports Modula-2 display all inbuilt system items -fexceptions -Modula-2 -; Documented in common.opt - fextended-opaque Modula-2 allows opaque types to be implemented as any type (a GNU Modula-2 extension) @@ -202,10 +178,6 @@ fpositive-mod-floor-div Modula-2 force positive result from MOD and DIV result floor -fpreprocessed -Modula-2 -; Documented in c.opt - fpthread Modula-2 link against the pthread library (default on) @@ -282,16 +254,153 @@ fwholevalue Modula-2 turns on runtime checking to check whether a whole number is about to exceed range -;fworking-directory -;Modula-2 +static-libgm2 +Driver +Link the standard Modula-2 libraries statically in the compilation. + +; Here are C options that we also recognise, either within the compiler +; or to build the preprocessor command lines. + +Wall +Modula-2 ; Documented in c.opt -lang-asm +Wpedantic +Modula-2 +; Documented in common.opt + +Wunused-variable Modula-2 ; Documented in c.opt -static-libgm2 -Driver -Link the standard Modula-2 libraries statically in the compilation. +Wunused-parameter +Modula-2 +; Documented in c.opt + +B +Modula-2 +; Documented in c.opt + +D +Modula-2 +; Documented in c.opt + +E +Modula-2 +; Documented in c.opt + +I +Modula-2 Joined Separate +; Documented in c.opt + +L +Modula-2 Joined Separate +; Not documented + +M +Modula-2 +; Documented in c.opt + +MD +Modula-2 +; Documented in c.opt + +MF +Modula-2 +; Documented in c.opt + +MG +Modula-2 +; Documented in c.opt + +MM +Modula-2 +; Documented in c.opt + +MMD +Modula-2 +; Documented in c.opt + +Mmodules +Modula-2 +; Documented in c.opt + +Mno-modules +Modula-2 +; Documented in c.opt + +MP +Modula-2 +; Documented in c.opt + +MQ +Modula-2 +; Documented in c.opt + +MT +Modula-2 +; Documented in c.opt + +P +Modula-2 +; Documented in c.opt + +ansi +Modula-2 +; Documented in c.opt + +c +Modula-2 +; Documented in c.opt + +fexceptions +Modula-2 +; Documented in common.opt + +fobjc-std=objc1 +Modula-2 +; Documented in c.opt + +fpreprocessed +Modula-2 +; Documented in c.opt + +fworking-directory +Modula-2 +; Documented in c.opt + +iprefix +Modula-2 +; Documented in c.opt + +iquote +Modula-2 +; Documented in c.opt + +isystem +Modula-2 +; Documented in c.opt + +idirafter +Modula-2 +; Documented in c.opt + +imultilib +Modula-2 + +-save-temps +Modula-2 Alias(save-temps) + +save-temps +Modula-2 +save temporary preprocessed files + +save-temps= +Modula-2 Joined +save temporary preprocessed files + +traditional-cpp +Modula-2 +; Documented in c.opt ; This comment is to ensure we retain the blank line above.