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 1948C3858418 for ; Fri, 4 Aug 2023 15:39:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1948C3858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691163566; 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=RayNGe5XK/5CKfC3nvuMOJAvJH3IhD8p7zBRhsHHgKQ=; b=amwsMGb40x+QnBXbopyTAzn9vUXcpvhIKGWLkTZYmnce+zKlBIYXhCjs3BtInvRJqtckH3 NB4CZKfbe21HAyRL+3EH10WeflH6rxfgRy9K+y/IrIAwstdtwv3OnqkSiEvsw2Qn2ZtwT6 G25voAfVp5l8Ys3+KKVPJ6VNM36qC1c= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-Fus1lv2TNYax6ZmH0MLEdw-1; Fri, 04 Aug 2023 11:39:25 -0400 X-MC-Unique: Fus1lv2TNYax6ZmH0MLEdw-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-565893ef956so2831136eaf.0 for ; Fri, 04 Aug 2023 08:39:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691163564; x=1691768364; 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=RayNGe5XK/5CKfC3nvuMOJAvJH3IhD8p7zBRhsHHgKQ=; b=I4HykVlYCcamhLyWG3tgQeswutz9fE8w8qYelHv7JL7tOGeCyTcq+nqWj9X5fPToX1 9cqoruE3CaxHxRcKyXKe+YS6NYLt1a6wn+LlUMXVGAxO0XCko+3ZsPTcFDH1Cfsgd1dC pvwJJuz3mpaar6zLM0xQd5qoxFdQ+Be0vL1KqTNnOe0r6we0odgvJh5GDwdR0HOeCNCi LXUi8iyRsUVNPec66oQfHcR8MR63UvCj0NlH64ty2KEGQTFTdB1aXFHSJFpCwUPDhZIX 0Yw9Tdt+tokFTcSeCzDYImJplLzlzgCxyvgTJ1gIaHVxsFG7cUqjii032Yw04dKTNL7h gtOw== X-Gm-Message-State: AOJu0YzvHAyDVOu9OycK6ZlmysoNUBbmU+Ok9fZ9v5/Zd+bvQqex7kW/ /Uu2t3UH5U4m/BKOfu8Yn4TQ5+CsYxBcqHA4AxA/9+h3dt3vfF+JSmhWcHxP/yP+veOYWj4GnEC bceKc0aA= X-Received: by 2002:a05:6358:2607:b0:12b:e47a:8191 with SMTP id l7-20020a056358260700b0012be47a8191mr1001891rwc.16.1691163564516; Fri, 04 Aug 2023 08:39:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGI3lmq38guOKTafRZAwox3NTs3a9SD0aR4T7PrtHBBlyNAdXD5/psfLQAvSIpOHVp0UcMVEw== X-Received: by 2002:a05:6358:2607:b0:12b:e47a:8191 with SMTP id l7-20020a056358260700b0012be47a8191mr1001870rwc.16.1691163564142; Fri, 04 Aug 2023 08:39:24 -0700 (PDT) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id a10-20020a0ce38a000000b00636291d04adsm742051qvl.47.2023.08.04.08.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:39:23 -0700 (PDT) Message-ID: <38828e8aa3d0905c2c006ff635534953e88ad91f.camel@redhat.com> Subject: Re: Update and Questions on CPython Extension Module -fanalyzer plugin development From: David Malcolm To: Eric Feng Cc: gcc@gcc.gnu.org Date: Fri, 04 Aug 2023 11:39:22 -0400 In-Reply-To: References: <969057b59e5cf472b73e8e1dedcc4a46630b31a0.camel@redhat.com> <6050a30719fed76a5bdb36c00620f4cb44e00aad.camel@redhat.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=-5.2 required=5.0 tests=BAYES_00,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 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 Fri, 2023-08-04 at 11:02 -0400, Eric Feng wrote: > Hi Dave, >=20 > Tests related to our plugin which depend on Python-specific > definitions have been run by including /* { dg-options "-fanalyzer > -I/usr/include/python3.9" } */. This is undoubtedly not ideal; is it > best to approach this problem by adapting a subset of relevant > definitions like in gil.h? That might be acceptable in the very short-term, but to create a plugin that's useful to end-user (authors of CPython extension modules) we want to be testing against real Python headers. As I understand it, https://peps.python.org/pep-0394/ allows for distributors of Python to symlink "python3-config" in the PATH to a python3.X-config script (for some X). So on such systems running: python3-config --includes should emit the correct -I option. On my box it emits: -I/usr/include/python3.8 -I/usr/include/python3.8 It's more complicated, but I believe: python3-config --cflags should emit the build flags that C/C++ extensions ought to use when building. On my box this emits: -I/usr/include/python3.8 -I/usr/include/python3.8 -Wno-unused-result - Wsign-compare -O2 -g -pipe -Wall -Werror=3Dformat-security -Wp,- D_FORTIFY_SOURCE=3D2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack- protector-strong -grecord-gcc-switches -m64 -mtune=3Dgeneric - fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection - D_GNU_SOURCE -fPIC -fwrapv -DDYNAMIC_ANNOTATIONS_ENABLED=3D1 -DNDEBUG - O2 -g -pipe -Wall -Werror=3Dformat-security -Wp,-D_FORTIFY_SOURCE=3D2 -Wp,- D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord- gcc-switches -m64 -mtune=3Dgeneric -fasynchronous-unwind-tables - fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv and it's likely going to vary from distribution to distribution. Some of those options *are* going to affect the gimple that -fanalyzer "sees". Does your installation of Python have such a script? So in the short term you could hack in a minimal subset of the decls/defns from Python.h, but I'd prefer it if target-supports.exp gained a DejaGnu directive that invokes python3-config, captures the result (or fails with UNSUPPORTED for systems without python3 development headers), and then adds the result to the build flags of the file being tested. The .exp files are implemented in Tcl, alas; let me know if you want help with that. Dave >=20 > Best, > Eric >=20 > On Tue, Aug 1, 2023 at 1:06=E2=80=AFPM David Malcolm > wrote: > >=20 > > On Tue, 2023-08-01 at 09:57 -0400, Eric Feng wrote: > > > >=20 > > > > My guess is that you were trying to do it from the > > > > PLUGIN_ANALYZER_INIT > > > > hook rather than from the plugin_init function, but it's hard > > > > to be > > > > sure without seeing the code. > > > >=20 > > >=20 > > > Thanks Dave, you are entirely right =E2=80=94 I made the mistake of > > > trying to > > > do it from PLUGIN_ANALYZER_INIT hook and not from the plugin_init > > > function. After following your suggestion, the callbacks are > > > getting > > > registered as expected. > >=20 > > Ah, good. > >=20 > > > I submitted a patch to review for this feature > > > on gcc-patches; please let me know if it looks OK. > >=20 > > Thanks Eric; I've posted a reply to your email there, so let's > > discuss > > the details there. > >=20 > > Dave > >=20 >=20