From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 2DDB1385DC00 for ; Wed, 3 Jun 2020 09:24:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DDB1385DC00 Received: by mail-pg1-x536.google.com with SMTP id p30so1334987pgl.11 for ; Wed, 03 Jun 2020 02:24:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=ABjgSc6bevhdWNuN9QqpuHOT1/KXTNkuIqI8N8/7PD0=; b=e/bO08HYtQptvkseQZxaHvGRl/pb/ExsMO9Tu9sTa/NUqcn8VyFGE2EK8CmHVQu7+G JhP9sOtIt38awTMFMU2b9bQCh4n5HpxsThiF0JrI54PQwTQ/Tig6MVQvcollbDCW5NAR SQYO573gx5Klp7apn/Lqwzxhzw1ETbbM5qdEv0qTBjKXkm+TK2kjjqLvRIUpK4BeGJgi FQ/7ICmGA7z/4bM9z7/XGF0rbn8fxsVG1giC1FtRaKzGw9U2uwWZBoyiiIK55NcQVSus t6NdWb97cGUl8KWxLaxwdC1EK2oYqVLkXgP3GqrxXcVchVriLZJKpbzHVPVpqK5vt9+H riKQ== X-Gm-Message-State: AOAM533EGJPTlrKCKwAoQb3LG6J6NvrgpTPsOU9E9k94oEm7l2kR02IH VSNL/T5AinSdal6fzDT8jc5LGlq8uVE= X-Google-Smtp-Source: ABdhPJxni9GseTfqSIAZJ5nohwkk82r0T41mKx3zDfnLW3VcJZvNhlTis4pPAgbl2TfzizMub7SbXw== X-Received: by 2002:a63:2252:: with SMTP id t18mr25308918pgm.450.1591176264835; Wed, 03 Jun 2020 02:24:24 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:8530:e245:4c89:a0c]) by smtp.gmail.com with ESMTPSA id q68sm2048061pjc.30.2020.06.03.02.24.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 02:24:23 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 09C5180699; Wed, 3 Jun 2020 18:54:19 +0930 (ACST) Date: Wed, 3 Jun 2020 18:54:19 +0930 From: Alan Modra To: binutils@sourceware.org Subject: ld -plugin options when plugins are disabled Message-ID: <20200603092419.GI29024@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-9.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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 09:24:40 -0000 This patch makes ld accept and ignore -plugin options when configured with --disable-plugins. The idea is to allow using a linker built without plugin support with a gcc built with plugin support. Quite obviously such a combination won't work if using LTO, but gcc has a habit of passing a bunch of -plugin and -plugin-opt arguments to ld even when not generating or linking LTO objects. Why do I want to do this? Well, it lets me and other binutils developers answer the question as to whether plugin support breaks binutils in some areas, without recompiling gcc or arranging to pass -fno-use-linker-plugin to gcc for testsuite runs. Does anyone know of a project that tests for linker plugin support by looking at ld -help output similarly to check_plugin_api_available below? If so then the patch may need more tweaking. * lexsup.c (ld_options): Accept -plugin and -plugin-opt when !ENABLE_PLUGINS. * testsuite/lib/ld-lib.exp (check_plugin_api_available): Adjust. diff --git a/ld/lexsup.c b/ld/lexsup.c index 412e2e6026..c651a1ccbe 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -185,6 +185,11 @@ static const struct ld_option ld_options[] = { {"flto-partition=", required_argument, NULL, OPTION_IGNORE}, '\0', NULL, N_("Ignored for GCC LTO option compatibility"), ONE_DASH }, +#else + { {"plugin", required_argument, NULL, OPTION_IGNORE}, + '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH }, + { {"plugin-opt", required_argument, NULL, OPTION_IGNORE}, + '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH }, #endif /* ENABLE_PLUGINS */ { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE}, '\0', NULL, N_("Ignored for GCC linker option compatibility"), diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 015eda6eb9..6535881dd1 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -1135,7 +1135,8 @@ proc check_plugin_api_available { } { if {![info exists plugin_api_available_saved]} { # Check if the ld used by gcc supports --plugin. set ld_output [remote_exec host $ld "--help"] - if { [ string first "-plugin PLUGIN" $ld_output ] >= 0 } { + if { [regexp -- "-plugin PLUGIN \[^\n\r\]*" $ld_output line] + && ![regexp "ignored" $line] } { set plugin_api_available_saved 1 } else { set plugin_api_available_saved 0 -- Alan Modra Australia Development Lab, IBM