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 50C6C3858C20 for ; Thu, 8 Jun 2023 14:54:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50C6C3858C20 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=1686236065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Guo+r6OQhrnIHelgzCcYNyuqkarXqats3b49LSj+R5E=; b=WbHENOOOxjIsihzpmsk96EoujLzRPsovKWb1B/G1e9B0LAYHjlOHqUOgEx8aXqQfSMkKsl IunxDB/3tfJjzlglXUMTlNBKbhes7aPreTKW3XqPJGNGmhXk4QNnL2kKDhnhumqD9C2hlQ TbGr1FVdciVFfpqPLWTCA2dUaC5ycOc= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-BvgTEugJO1yDswu_e4xJNQ-1; Thu, 08 Jun 2023 10:54:24 -0400 X-MC-Unique: BvgTEugJO1yDswu_e4xJNQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6238c3bf768so9431506d6.0 for ; Thu, 08 Jun 2023 07:54:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686236064; x=1688828064; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Guo+r6OQhrnIHelgzCcYNyuqkarXqats3b49LSj+R5E=; b=ARWabb7xeUOP/9GMqdJemVu2ph7UPmUI7E2XFei7Ay38CbCORFVkwnD5X70K6nrBRP JbpgG5qV+nITcGGwiRZjfzD0BWeMYjg8c5wa522I3xM7JB7M7rMLSiq8a/nUIwn/hO2W 5mH/65L202on8fNBpN6tjB5RqVS5OfqP57hjNcTaq3FlZCpqzlOM7MZx0EUpgCsNscHD Bqdnsp665fSJ9/EwZi/8bfm6CVithdb+qmQGhI+10wa9c4SFGYOIjtF1sGWSJ05V5UyI P+VfY6OSjWXJm1Tum5J1cY10MSNnKK2ef4+Ya2pBOpbyPa5LI+xCPtkUHpcdNDrliHNO B/YQ== X-Gm-Message-State: AC+VfDyUuvV3ye1HIW2V6dXFzH3G1bwUukf3touGamxTclJVTrK3odW+ 02CNbZMwxK9m/AQcPk7cVTKDU4eTwfxstW01ed/cFsvIRJL6lKY1UfKDCLQ/vgRqrYp8BI3kQGh laHZqIBPeqJlB1bs= X-Received: by 2002:a05:6214:20ea:b0:626:31ad:f873 with SMTP id 10-20020a05621420ea00b0062631adf873mr1827817qvk.24.1686236063845; Thu, 08 Jun 2023 07:54:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hT56RCN029s5J4mlVVV4xKdWOVkmIc2NlxT6Z0W46RJXkNpv71ZZ7b0UB9W+TR0csZ+Gh6A== X-Received: by 2002:a05:6214:20ea:b0:626:31ad:f873 with SMTP id 10-20020a05621420ea00b0062631adf873mr1827806qvk.24.1686236063582; Thu, 08 Jun 2023 07:54:23 -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 w16-20020a0cdf90000000b00626204ad6fcsm434717qvl.103.2023.06.08.07.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 07:54:23 -0700 (PDT) Message-ID: <3765620ca62b16090873a01e16be1e27a7f42043.camel@redhat.com> Subject: Re: __attribute__((cleanup)) support in libgccjit? From: David Malcolm To: Eric Wong , jit@gcc.gnu.org Date: Thu, 08 Jun 2023 10:54:22 -0400 In-Reply-To: <20230608134626.M184090@dcvr> References: <20230608134626.M184090@dcvr> 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,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 Thu, 2023-06-08 at 13:46 +0000, Eric Wong via Jit wrote: > Hi, I'm considering libgccjit for use in a new GPL3+ scripting > language and I am wondering if declaring locals with > __attribute__((cleanup)) is supported by libgccjit. >=20 > I find gcc_jit_lvalue_set_alignment in libgccjit.h, but not > many other attributes for locals.. It varies attribute by attribute. I took a look at this, and unfortunately it would need extra work on libgccjit to make it support __attribute__((cleanup)). Specifically, when the C and C++ frontends are building the "generic/tree" representation of functions and see a local variable with the attribute they add extra code to handle the cleanup: C: in gcc/c/c-decl.c: finish_decl C++: in gcc/cp/decl.c: cxx_maybe_build_cleanup We'd need to implement something similar to the above in gcc/jit/jit- playback.cc (and I'm already overtasked with analyzer work, alas). Note that libgccjit doesn't have fine-grained scopes like C/C++ do; locals exist at the level of a function frame. >=20 > I'll likely use libgccjit regardless since it seems like it could > make libffi redundant (or maybe I'm wrong on that bit...). >=20 > I might steal LuaJIT's C parser to deal with parsing headers and > structs; not sure if gcc exposes a C parser as a stable API... Yeah, unfortunately we don't export C parsing as an API. If you need to parse a header you'll need to either use a different C parser or write a plugin to the GCC C frontend. Hope this is helpful Dave