From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2B3DD3857707 for ; Tue, 7 Nov 2023 14:32:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B3DD3857707 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2B3DD3857707 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699367579; cv=none; b=xpLTlA0ThbZeLdgwSqoLM4zA1ubIVxJkalN+dWgymJB6+9cNTBRUxkTFAbEa5rnJ7U4GrnFVTfCIrqAwwi0Yw2rWQwKzUrlFlglfqevRZLfrJtGNIDLGqI6Z664EpyJ9OyzANJKWipc6eu7xuihi7EHSkgpDOTvcLkP6s/3fvUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699367579; c=relaxed/simple; bh=L+dVnPqvUko8zZYzSMd1tR5twxJjeuoZrzmoLrTXWH4=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=T52/BS9jEJqA+Q0szXlA/ZFHPW/XzmLVxXvC9ANkUYUe+i/Rs5E9HTUhZdoUSedh0I+m2yUhGZpH0P4XV4QyfuVV20zImdbSTIgpsthlo5wrULtbHjvIWbBd9sGae9C+o0U97SStfVtYkhTrsQbEhPtXFmtZUjy/wbGiL54n7Xk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699367568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mHDPrMiRIs3emTY0A49Mm6/uIF2NWt3x8qrF6H3KDE0=; b=QPX4Kpk7FjUS8jtR6SoTcBTbSgHgwa/QB+y7g/FSsQ8IFspilCcwpCTFb40afCFFaRxbOE 3Y3gVTkXvt3H5VOlDNaJwtel9WdHiy/Rtwuaf1JDNduLd/3pj/koth+8l60ofKoPUp4rzQ voZ/hMZdHzhAKKymMSzIzV9EmeHs4EE= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-Gauv6H7vO0O5mRc7Xj35lg-1; Tue, 07 Nov 2023 09:32:44 -0500 X-MC-Unique: Gauv6H7vO0O5mRc7Xj35lg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-778a2e84830so624645085a.3 for ; Tue, 07 Nov 2023 06:32:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699367563; x=1699972363; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mHDPrMiRIs3emTY0A49Mm6/uIF2NWt3x8qrF6H3KDE0=; b=DRrsVgR1V9N4t7VxzGk6sKzyUdStUjfh1X+QDDrEpsPCscbgP5truJbX8Y0SKtdi6L H4AG2RP2mWYrmzchQ8u5Pv0FzhLLLKUXOtm3ZaP3q5MbqfoOP0DGBLrDppm5T01O0Kzi ia5isL5qMkgucrSUSQrnghZ9lIneZcOT/5ISyac2DJQY+bhjQuObpSU93N5miXT+d9FD fRAT7Pzd7xpGppYPbF8tVSY1KIp94VY0bxBubccaDzUXRP3dq2MkMag2kKje/Gv7lSop JoDmFalHumtIahji2e84FThUigXonGwImDzNgQOd8oF07OVoxrOdWNwvHfExlyq5GQNl t+rQ== X-Gm-Message-State: AOJu0YxuxcV6sC/Z2pBnmTVK/IX/wL2zDHeKvd0SO90r1ecyCM9RHRt+ 9J7ovnIzeIbWqxJCi89POYuHSWc5O4n5zmIP4qRRmUXyslDtyjGd/U0BH6thjhK32+gEwhFEJkZ 8TyGGrzRhBc8b9TevTg== X-Received: by 2002:a05:620a:40c2:b0:775:c5bb:1df9 with SMTP id g2-20020a05620a40c200b00775c5bb1df9mr39950200qko.60.1699367563513; Tue, 07 Nov 2023 06:32:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIEbEF77RunGmkQomlLrfB4nDSkvwGQjq/sr0nYv/kW5stdscYaQx/hCQt1tEZThg8zNs+KQ== X-Received: by 2002:a05:620a:40c2:b0:775:c5bb:1df9 with SMTP id g2-20020a05620a40c200b00775c5bb1df9mr39950176qko.60.1699367563210; Tue, 07 Nov 2023 06:32:43 -0800 (PST) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id bl3-20020a05620a1a8300b0076ee973b9a7sm4222821qkb.27.2023.11.07.06.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 06:32:42 -0800 (PST) Message-ID: Subject: Re: [PATCH] binutils: experimental use of libdiagnostics in gas From: David Malcolm To: Jan Beulich Cc: Nick Clifton , Simon Sobisch , gcc-patches@gcc.gnu.org, binutils@sourceware.org Date: Tue, 07 Nov 2023 09:32:41 -0500 In-Reply-To: <4994bf91-8cd8-833b-80c4-9e4890d67840@suse.com> References: <20231106222959.2707741-1-dmalcolm@redhat.com> <20231106222959.2707741-4-dmalcolm@redhat.com> <4994bf91-8cd8-833b-80c4-9e4890d67840@suse.com> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 2023-11-07 at 11:03 +0100, Jan Beulich wrote: > On 06.11.2023 23:29, David Malcolm wrote: > > Here's a patch for gas in binutils that makes it use libdiagnostics > > (with some nasty hardcoded paths to specific places on my hard > > drive > > to make it easier to develop the API). > >=20 > > For now this hardcodes adding two sinks: a text sink on stderr, and > > also a SARIF output to stderr (which happens after all regular > > output). > >=20 > > For example, without this patch: > >=20 > > =C2=A0=C2=A0 gas testsuite/gas/all/warn-1.s > >=20 > > emits: > > VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV > > VVVVVVVVV > > testsuite/gas/all/warn-1.s: Assembler messages: > > testsuite/gas/all/warn-1.s:3: Warning: a warning message > > testsuite/gas/all/warn-1.s:4: Error: .warning argument must be a > > string > > testsuite/gas/all/warn-1.s:5: Warning: .warning directive invoked > > in source file > > testsuite/gas/all/warn-1.s:6: Warning: .warning directive invoked > > in source file > > testsuite/gas/all/warn-1.s:7: Warning: > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ^^^^^^^^^ > >=20 > > whereas with this patch: > > =C2=A0 LD_LIBRARY_PATH=3D/home/david/coding-3/gcc-newgit-canvas- > > 2023/build/gcc ./as-new testsuite/gas/all/warn-1.s > > emits: > >=20 > > VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV > > VVVVVVVVV > > testsuite/gas/all/warn-1.s:3: warning: a warning message > > =C2=A0=C2=A0=C2=A0 3 |=C2=A0 .warning "a warning message"=C2=A0=C2=A0 ;= # { dg-warning "Warning: a > > warning message" } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > > testsuite/gas/all/warn-1.s:4: error: .warning argument must be a > > string > > =C2=A0=C2=A0=C2=A0 4 |=C2=A0 .warning a warning message=C2=A0=C2=A0=C2= =A0=C2=A0 ;# { dg-error "Error: > > .warning argument must be a string" } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > > testsuite/gas/all/warn-1.s:5: warning: .warning directive invoked > > in source file > > =C2=A0=C2=A0=C2=A0 5 |=C2=A0 .warning=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 ;# { dg-warning "Warning: > > .warning directive invoked in source file" } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > > testsuite/gas/all/warn-1.s:6: warning: .warning directive invoked > > in source file > > =C2=A0=C2=A0=C2=A0 6 |=C2=A0 .warning ".warning directive invoked in so= urce file"=C2=A0=C2=A0 ;# > > { dg-warning "Warning: .warning directive invoked in source file" } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > > testsuite/gas/all/warn-1.s:7: warning: > > =C2=A0=C2=A0=C2=A0 7 |=C2=A0 .warning ""=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 ;# { dg-warning "Warning: " > > } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | [...snip...] > > which I see: > > - drops the leading "Assembler messages" warning, > > - changes the capitalization of the "Warning" -> "warning" etc > > - quotes the pertinent line in the .s file > >=20 > > All of the locations are just lines; does gas do column numbers at > > all? > > (or ranges?) >=20 > It currently doesn't, which is primarily related to the scrubbing > done > before lines are actually processed. How complicated/desirable would it be to track locations in .s files at the column level? I confess I didn't look at the parsing code at all. >=20 > I take it that the lack of column information is why there are lines > of > this form >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | >=20 > in the example output above.=C2=A0 Yes: those lines are for annotation information such as underlining specific columns. > Them uniformly not carrying any information > would make it desirable for them to be suppressed. In GCC we typically have column information, so I'd never noticed this behavior, but it ought to be fixable, to simply not display these if there's no column info. >=20 > > @@ -172,16 +203,34 @@ as_tsktsk (const char *format, ...) > > =C2=A0static void > > =C2=A0as_warn_internal (const char *file, unsigned int line, char > > *buffer) > > =C2=A0{ > > +#if !USE_LIBDIAGNOSTICS > > =C2=A0=C2=A0 bool context =3D false; > > +#endif > > =C2=A0 > > =C2=A0=C2=A0 ++warning_count; > > =C2=A0 > > =C2=A0=C2=A0 if (file =3D=3D NULL) > > =C2=A0=C2=A0=C2=A0=C2=A0 { > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 file =3D as_where_top (&line); > > +#if !USE_LIBDIAGNOSTICS > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context =3D true; > > +#endif >=20 > I can't spot how this context information would be replaced. It works > for macros only right now, but the hope is to eventually extend it > also to .include files. I confess I hacked this up, and I didn't check what this code does. I see now that it calls as_report_context, which iterates over macro expansions calling as_info_where with successively larger "indent" values. I could extend the patch to cover that. More ambitiously, GCC's location tracking supports recording macro expansions and include files, and the diagnostics subsystem has a way of printing this information. So potentially libdiagnostics could provide API support for this - but I haven't yet looked at the feasibility. >=20 > > @@ -199,6 +248,7 @@ as_warn_internal (const char *file, unsigned > > int line, char *buffer) > > =C2=A0#ifndef NO_LISTING > > =C2=A0=C2=A0 listing_warning (buffer); > > =C2=A0#endif > > +#endif /* #else clause of #if USE_LIBDIAGNOSTICS */ >=20 > This listing integration of course needs to remain irrespective of > which way of emitting diagnostics is used. Likewise; I think I just put the #endif in the wrong place above. Thanks for the feedback; hope this is constructive. Dave