From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by sourceware.org (Postfix) with ESMTPS id AFBE33858284 for ; Fri, 16 Jun 2023 19:07:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFBE33858284 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=starynkevitch.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=starynkevitch.net X-GND-Sasl: basile@starynkevitch.net X-GND-Sasl: basile@starynkevitch.net X-GND-Sasl: basile@starynkevitch.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 02BA520002; Fri, 16 Jun 2023 19:07:54 +0000 (UTC) Message-ID: Date: Fri, 16 Jun 2023 21:07:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Interfacing with external code using libgccjit Content-Language: en-US To: David Malcolm , =?UTF-8?Q?Anselm_Sch=c3=bcler?= , jit@gcc.gnu.org References: From: Basile Starynkevitch In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 List-Id: On 6/16/23 19:27, David Malcolm via Jit wrote: > On Thu, 2023-06-15 at 21:59 +0200, Anselm Schüler wrote: >> Hi, I’m very new to libgccjit and was hoping to use it to implement a >> DSL that abstracts over some high-precision mathematics. > Hi! > >> However, to do that, I need to interface with a high-precision >> library >> such as GMP or MPFR. >> I’m wondering if that’s possible. > It ought to be possible, but you need some way to express the > declarations from the library's headers via the ligccjit API; we don't > yet have a convenient way to take a header and express it in libgccjit > form. As you note, doing it "by hand" is laborious; sorry that we > don't yet have an automated way of doing this. Possible approaches > would be to use a library that can parse C headers, such as: > https://github.com/vnmakarov/mir > or perhaps using libabigail to work with the ABI representation: > https://sourceware.org/libabigail/ > (which would be parsing the debug data) > Another possible approach might be to use some GCC plugin (perhaps inspired by some code from https://github.com/bstarynk/bismon ...) to parse the GMP or MPFR header files, and later inject some constants (describing the external code, such as GMP or MPFR) into libgccjit Maybe future GCC support for C++ 2x modules could be also relevant Cheers -- Basile Starynkevitch (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/