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.133.124]) by sourceware.org (Postfix) with ESMTPS id 3C0133858288 for ; Tue, 7 Nov 2023 14:32:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C0133858288 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 3C0133858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699367577; cv=none; b=ffsKD/5v/PhGvr7TJrK98hqEgXOtihuSR07MQQ1qCsol0fgcp1aA0nKCrcoPwTL6yLMR4/WJDfQ6g58E/1pcXBnPhe9+h7kyrprLVetaCD/m0eiKv9maA5wNfw1rP7sQcIUCM/6ZQOECrqdxsCzUcfe84MyQQkh1TgsgfqNSR6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699367577; c=relaxed/simple; bh=L+dVnPqvUko8zZYzSMd1tR5twxJjeuoZrzmoLrTXWH4=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=arMQvEgn5/8LpYdHI/aabpqC/+NMsNJcu1VBohk0nQm3wdlF5YyD+l6eEz53kvlpT6X4d2tmFntkXBmznDAL3YsaboDY2daVZjK7OIRMqT0OiSDd+gPOKvgnYykaTZFPiudDwvbaZxaZHQ+c+Iuy7DfI3pEQrDG4qMxl2xJRxN0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699367566; 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=ZeENMQv2vp6nmdlm9d/cFSAWw/9qCyxLAmqfvh2VZNMUiAGobnohJMsDj7tIiUTc+V/e3F AjVfbxKLI1DLwvtQEVnRMYnQCum2cgL2v4Mf0EAmaoEhVl7a31s4A78Y06Eag+LtHUs8wX +5FxzK9wdl5DkIXzns4Udg9uMJjPt+0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-mTOG3su2M3iE7v3ILxtoMA-1; Tue, 07 Nov 2023 09:32:44 -0500 X-MC-Unique: mTOG3su2M3iE7v3ILxtoMA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-77892f2ee51so628386785a.1 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=WaYcdFlIV5BSsigBZA9Z0kWw3QZEtTfdPNH+EIqh4+d/CdRiOIXMJ8dilIkophPdhI SA1AcjE4t0xLlit9T8dfZaVE8ZZIu150j14PngOsoghVL6oIV0QCwbYzn8W82n+Hy8go za+PNmGPP9kGsSAciiAQGZpa8Fhn9OgW4KNTX4tI7hhNOylsXAyvPPlrjaFm4Jp1SWqj AnjMi8zOyJwLOKOAlJ42vvmpPGYJPZeOu/DmRnDtY4XQoQsCHeOsQphEGw5XunNA9Wkc 1C/mgcBmD3who/hpSrfK8WMejAjR/wLuhCiO0rfwwvwo0xJR+VP9lpE9g33db5BJLrJP 1yCw== X-Gm-Message-State: AOJu0Yy7drwP1OKMtD8ytg4k0t5fZvGnQWYrfkEdrCNPxZTC/0diZUJD +bSx51IID47kIphOc8Nj6UlUVq2taUlpFRFcBUKXEPkQBNdRDLIXAIA/knWPkvODgKUUy/pccIM EyWzJ2gqGvfqumFFGIA== X-Received: by 2002:a05:620a:40c2:b0:775:c5bb:1df9 with SMTP id g2-20020a05620a40c200b00775c5bb1df9mr39950195qko.60.1699367563502; 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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 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