From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 9F1CE3858D35 for ; Fri, 16 Jun 2023 19:16:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F1CE3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f8fcaa31c7so4791885e9.3 for ; Fri, 16 Jun 2023 12:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686942968; x=1689534968; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LnPz536971KdjfmcWXLStmbhnW+gnFl5Xgd8eeby3KU=; b=cJxBw3RH0f6HLceJilCJyyTm9lhLWhKnDTT1qxUDGf6hF9WYsOMzkcj/5lVo7lxcX9 PWa5Zb6mISskHKPnPPLbNZtquNKmdJ70SL1MD8tnD5i68M7GLTlvIOS6mvRiJwi2lRG1 lZ1zkGYiBhw38N9yh3XAeGVF+Vnn4ieCLf0Er95m5aJVx8d0fRQpf3lRy/um05oHrco2 uQbLM7rWcC7cfqikP+otY+Sn25CcSuvWWItLKT2rMD0Gmgfifoj3Mm3qq3B2Wgo4s/uk So5H5pQzIqVfAcKhD8A5iMSnoxxZCJkZPe3dvAo8SV41MQ9TB3Cmc5hb8/QD//bKeRvv 15QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686942968; x=1689534968; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LnPz536971KdjfmcWXLStmbhnW+gnFl5Xgd8eeby3KU=; b=eNSm/W6iLtgS0OTDIodIfKscE9WOM6uGmVr6ASLsMUFvhM5AFUmnkzEisDZBbCBwJ4 Xxz5Kp2IhUrd0pGhqSwrE5oObGnrE8KzBQXojcr0zqGFE9zZRSS0nnCJ5PiZooqGutwq iMJtHnoC3TkqKip4GdVZMoEUpsX6p8VDD0T0/BS1aU4COfDzGL1BUXbstcX58H8EDPw/ wAFsetE78CvxNYUu4bxxK9QU5r4LYM3M6dd0cQIdcnZLcehY7lcyTZ/V20UEFAtQXmNv HE+jCyas89QPP9Zkun3HWX+xsF3ZoIo4DYDdgTvNdgjqbp+NE/toiRRLr/iw9FxGpoBQ rkSQ== X-Gm-Message-State: AC+VfDziCjRhnFluy1UYOXsx1G1Vmg+N1MTuMC1NuGE+dLuVP+L8A69z /w6ZxlX28bHFNlpJO18CYjsNCtJjLwtAeIjwW1E= X-Google-Smtp-Source: ACHHUZ7xnUv7AbjvV0Arkcga311a3LaeflNdLaUo3YJ3L4dSz+qoTz8OHQAgWfB+grs9P2zUHYZcjeA5t0/697QOZy4= X-Received: by 2002:a5d:4609:0:b0:30f:cc85:23b8 with SMTP id t9-20020a5d4609000000b0030fcc8523b8mr2139536wrq.18.1686942968141; Fri, 16 Jun 2023 12:16:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Fri, 16 Jun 2023 21:15:57 +0200 Message-ID: Subject: Re: Interfacing with external code using libgccjit To: Basile Starynkevitch Cc: David Malcolm , =?UTF-8?Q?Anselm_Sch=C3=BCler?= , jit@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: The simplest way IMO is to write a stub in C with ordinary functions that calls into GMP and MPFR, and then call the C stub from libgccjit code. When you enable LTO, the stub should be optimized away. Am Fr., 16. Juni 2023 um 21:08 Uhr schrieb Basile Starynkevitch : > > > On 6/16/23 19:27, David Malcolm via Jit wrote: > > On Thu, 2023-06-15 at 21:59 +0200, Anselm Sch=C3=BCler wrote: > >> Hi, I=E2=80=99m very new to libgccjit and was hoping to use it to impl= ement 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=E2=80=99m wondering if that=E2=80=99s 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/ >