From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8001 invoked by alias); 8 Jan 2019 21:16:16 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 7873 invoked by uid 89); 8 Jan 2019 21:16:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=France, france, noticed X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: relay6-d.mail.gandi.net Received: from relay6-d.mail.gandi.net (HELO relay6-d.mail.gandi.net) (217.70.183.198) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 21:16:02 +0000 X-Originating-IP: 193.248.54.187 Received: from [192.168.1.2] (lstlambert-656-1-266-187.w193-248.abo.wanadoo.fr [193.248.54.187]) (Authenticated sender: basile@starynkevitch.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 1452EC0004; Tue, 8 Jan 2019 21:15:59 +0000 (UTC) Subject: Re: about header file parsing To: akrl@sdf.org, jit@gcc.gnu.org References: <0511991f924b445cad0467ad28fc8f45.squirrel@mx.sdf.org> From: Basile Starynkevitch Message-ID: Date: Tue, 01 Jan 2019 00:00:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <0511991f924b445cad0467ad28fc8f45.squirrel@mx.sdf.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-IsSubscribed: yes X-SW-Source: 2019-q1/txt/msg00012.txt.bz2 On 1/8/19 11:50 AM, akrl@sdf.org wrote: > Hi all, > I have a basic question. > Is there a way to ask libgccjit to parse a conventional .h file? I have asked a very similar question in https://gcc.gnu.org/ml/jit/2015-q2/msg00093.html > Or alternatively is there a way to have an header file parsed and > converted in the equivalent libgccjit api calls? > I ask this because I noticed that, if you jit some code that have to > inter-operate with non jitted code, maintaining two duplicated definitions > of all data structures can be quite painful if these are not trivial. > Alternatively what's the suggested work flow? I am not sure there is one yet, in practice. A possible work-around (not entirely trivial) might be to do the "opposite": use GCC itself to parse the header file, and write your GCC plugin extracting all the relevant information for your particular usage of libgccjit. I have no idea how easy that can be for you. I am not even sure if all the features of C (including some common extensions accepted by GCC) are usable from libgccjit. Perhaps bit fields and computed gotos like `goto *ptr` and statement expressions like `({int x=0; while (y>0) x+=f(y--); x;})` are not easily achievable in libgccjit. Still another thing could be to use LTO: you'll compile your C file with GCC using -flto, you'll do LIBGCCJIT things, and the final executable sould be compiled and linked with -flto. Cheers. -- Basile STARYNKEVITCH == http://starynkevitch.net/Basile opinions are mine only - les opinions sont seulement miennes Bourg La Reine, France