From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 2FE843858C51 for ; Mon, 20 Jun 2022 09:23:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FE843858C51 Received: by mail-qk1-x730.google.com with SMTP id d23so7405091qke.0 for ; Mon, 20 Jun 2022 02:23:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=wQsiUa8v2BzyghC1ju7uDJ8tMDyJJjjTMGfYxBtgG/g=; b=mUxsn1zWeukk5XQRkClWNwZmVe09fqb/NPz9hL1EoJBsTh3LppQqHhna+ZC7oT089k zL3jl8sVvADIZ5FGEa/20Y71uh4Qfp/iWr4v5JfY4pE1pyxgXvw7Lmf9uuzZUNp/9FFu clboLnx6eo1+TeA/MHpoWTwFA5e0Sh76smLnQhlGgPnjR58t7TlS6NpsuQl9R5D6bT88 rrde//MkpOg9xOXZ8/XcIuBG6vntstI0oLkowi1DvSLSl77PG23hUOtfdUC8ch/OoNxq seQ70Qm2MbpSDcey7bw75pYsjhjOtOeQ0PPpqZlavbIg4oho0/bg73CFMNCwlcdnnG0d O9/A== X-Gm-Message-State: AJIora8l1YG/7TSECryLU8HaHYtvUJ/7NCdIajG0b+K9fuS58jVf+ug0 PvRC+ZVgYIh773zDZOIybgTaSRhOFHQ9aaurNDI= X-Google-Smtp-Source: AGRyM1tv5g5me+SIibYSn2bTY5mrLZBcVZCHjn1VG2VBdrmqVbpO4Xbn2fLezexTrkt8fLp6yQoL4kcQes9jSJnTYmc= X-Received: by 2002:a05:620a:4116:b0:6a6:fd52:19dd with SMTP id j22-20020a05620a411600b006a6fd5219ddmr15536282qko.4.1655717030331; Mon, 20 Jun 2022 02:23:50 -0700 (PDT) MIME-Version: 1.0 References: <803a0290-3909-b9c5-2461-b1740a00c63a@suse.cz> <53ccccfd-875d-8651-4e1e-283794b32ae7@suse.cz> In-Reply-To: <53ccccfd-875d-8651-4e1e-283794b32ae7@suse.cz> From: Richard Biener Date: Mon, 20 Jun 2022 11:23:38 +0200 Message-ID: Subject: Re: [PATCH 1/3] lto-plugin: support LDPT_GET_SYMBOLS_V3 To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Mon, 20 Jun 2022 09:23:52 -0000 On Thu, Jun 16, 2022 at 9:00 AM Martin Li=C5=A1ka wrote: > > That supports skipping of an object file (LDPS_NO_SYMS). OK. Thanks, Richard. > lto-plugin/ChangeLog: > > * lto-plugin.c (struct plugin_file_info): Add skip_file flag. > (write_resolution): Write resolution only if get_symbols !=3D LDP= S_NO_SYMS. > (all_symbols_read_handler): Ignore file if skip_file is true. > (onload): Handle LDPT_GET_SYMBOLS_V3. > --- > lto-plugin/lto-plugin.c | 42 ++++++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c > index 47378435612..00b760636dc 100644 > --- a/lto-plugin/lto-plugin.c > +++ b/lto-plugin/lto-plugin.c > @@ -136,6 +136,7 @@ struct plugin_file_info > void *handle; > struct plugin_symtab symtab; > struct plugin_symtab conflicts; > + bool skip_file; > }; > > /* List item with name of the file with offloading. */ > @@ -159,7 +160,7 @@ enum symbol_style > static char *arguments_file_name; > static ld_plugin_register_claim_file register_claim_file; > static ld_plugin_register_all_symbols_read register_all_symbols_read; > -static ld_plugin_get_symbols get_symbols, get_symbols_v2; > +static ld_plugin_get_symbols get_symbols, get_symbols_v2, get_symbols_v3= ; > static ld_plugin_register_cleanup register_cleanup; > static ld_plugin_add_input_file add_input_file; > static ld_plugin_add_input_library add_input_library; > @@ -547,15 +548,13 @@ free_symtab (struct plugin_symtab *symtab) > static void > write_resolution (void) > { > - unsigned int i; > + unsigned int i, included_files =3D 0; > FILE *f; > > check (resolution_file, LDPL_FATAL, "resolution file not specified"); > f =3D fopen (resolution_file, "w"); > check (f, LDPL_FATAL, "could not open file"); > > - fprintf (f, "%d\n", num_claimed_files); > - > for (i =3D 0; i < num_claimed_files; i++) > { > struct plugin_file_info *info =3D &claimed_files[i]; > @@ -563,13 +562,38 @@ write_resolution (void) > struct ld_plugin_symbol *syms =3D symtab->syms; > > /* Version 2 of API supports IRONLY_EXP resolution that is > - accepted by GCC-4.7 and newer. */ > - if (get_symbols_v2) > + accepted by GCC-4.7 and newer. > + Version 3 can return LDPS_NO_SYMS that means the object > + will not be used at all. */ > + if (get_symbols_v3) > + { > + enum ld_plugin_status status > + =3D get_symbols_v3 (info->handle, symtab->nsyms, syms); > + if (status =3D=3D LDPS_NO_SYMS) > + { > + info->skip_file =3D true; > + continue; > + } > + } > + else if (get_symbols_v2) > get_symbols_v2 (info->handle, symtab->nsyms, syms); > else > get_symbols (info->handle, symtab->nsyms, syms); > > + ++included_files; > + > finish_conflict_resolution (symtab, &info->conflicts); > + } > + > + fprintf (f, "%d\n", included_files); > + > + for (i =3D 0; i < num_claimed_files; i++) > + { > + struct plugin_file_info *info =3D &claimed_files[i]; > + struct plugin_symtab *symtab =3D &info->symtab; > + > + if (info->skip_file) > + continue; > > fprintf (f, "%s %d\n", info->name, symtab->nsyms + info->conflicts= .nsyms); > dump_symtab (f, symtab); > @@ -833,7 +857,8 @@ all_symbols_read_handler (void) > { > struct plugin_file_info *info =3D &claimed_files[i]; > > - *lto_arg_ptr++ =3D info->name; > + if (!info->skip_file) > + *lto_arg_ptr++ =3D info->name; > } > > *lto_arg_ptr++ =3D NULL; > @@ -1410,6 +1435,9 @@ onload (struct ld_plugin_tv *tv) > case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK: > register_all_symbols_read =3D p->tv_u.tv_register_all_symbols_r= ead; > break; > + case LDPT_GET_SYMBOLS_V3: > + get_symbols_v3 =3D p->tv_u.tv_get_symbols; > + break; > case LDPT_GET_SYMBOLS_V2: > get_symbols_v2 =3D p->tv_u.tv_get_symbols; > break; > -- > 2.36.1 > >