From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by sourceware.org (Postfix) with ESMTPS id 729963834696 for ; Thu, 21 Apr 2022 18:08:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 729963834696 Received: by mail-qv1-xf29.google.com with SMTP id b17so4262044qvp.6 for ; Thu, 21 Apr 2022 11:08:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=zIqLZTVMTZM04KnCG7HFwLMOGTDj0zG3iTrV+H8mPMM=; b=4t/H8KW1VKkcUGvXVnkhSI3qWq/6/c2QV/PRVXwkKzF5HG+u0Ak6HL+fb+skl0McTG O7MkpIaJuCsAMN7XoNThgUL2R/a5gHDPCMu/08AakiTsJ6CEJjrWj5LHiYOYyhcRY6GK gnl7FHY+cPx/y6SBzc4jkmehdouDDEJkRrlzNrf5DgdxsrFARgBdyHwdNtUXYMqyfhY6 37VHro8wtP0949wjgoGvfEOv11D8Qt2CDLUkSPsZrCAnL7r+m220PFBM/QBT3Cn/Cq/O iBvKGbE0tISU06Ey7cajnyR9BY1DrPD07GXEDNFpHum6lZgxkvkBiYlD1NrJTguawoMv q99A== X-Gm-Message-State: AOAM531SCnJ8PQXRyeztqAnAgYrCujTW3moc2AtWsFLVNE8v0itZqb2G MGjc/gjQaXZ4kWizLwqCFzVPjv45FczMWRtZ X-Google-Smtp-Source: ABdhPJywfXXT/LdxtA/5pGmO8Azdfh6eSHh+A/hxHrE3IsRkLmcMrLB0/4hpBhx/e45ie2sA+alVKw== X-Received: by 2002:a0c:a942:0:b0:443:a395:cc1f with SMTP id z2-20020a0ca942000000b00443a395cc1fmr851842qva.68.1650564484831; Thu, 21 Apr 2022 11:08:04 -0700 (PDT) Received: from localhost (cpe-142-105-146-128.nycap.res.rr.com. [142.105.146.128]) by smtp.gmail.com with ESMTPSA id u129-20020a376087000000b0067e401d7177sm3378508qkb.3.2022.04.21.11.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 11:08:04 -0700 (PDT) Date: Thu, 21 Apr 2022 14:08:47 -0400 From: Ben Boeckel To: Iain Sandoe Cc: Boris Kolpackov , gcc@gcc.gnu.org Subject: Re: [modules] Preprocessing requires compiled header unit modules Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.1.5 (2021-12-30) X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 18:08:06 -0000 On Thu, Apr 21, 2022 at 18:59:56 +0100, Iain Sandoe wrote: > Hi Ben, > > > On 21 Apr 2022, at 13:05, Ben Boeckel via Gcc wrote: > > > > On Thu, Apr 21, 2022 at 06:05:52 +0200, Boris Kolpackov wrote: > >> I don't think it is. A header unit (unlike a named module) may export > >> macros which could affect further dependencies. Consider: > >> > >> import "header-unit.hpp"; // May or may not export macro FOO. > > 1. If you know how this was built, then you could do an -E -fdirectives-only build (both > GCC and clang support this now) to obtain the macros. My understanding is that how it gets used determines how it should be made for Clang (because the consumer's `-D`, `-W`, etc. flags matter). I do not yet know how I am to support this in CMake. > 2. I suppose we could invent a tool (or FE mode) to dump the macros exported by a HU *** Fun considerations: - are `-D` flags exported? `-U`? - how about this if `value` is the same as or different from the at-start expansion: ```c++ #undef SOME_MACRO #define SOME_MACRO value ``` - how about `#undef FOO`? > >> #ifdef FOO > >> import "header-unit2.hpp" > >> #endif > > > > I agree that the header needs to be *found*, but scanning cannot require > > a pre-existing BMI for that header. A new mode likely needs to be laid > > down to get the information necessary (instead of just piggy-backing on > > `-E` behavior to get what I want). > > perhaps that means (2)? Can't it just read the header as if it wasn't imported? AFAIU, that's what GCC did in Jan 2019. I understand that CPP state is probably not easy, but something to consider. > *** it’s kinda frustrating that this is hard infomation to get as a developer, so > perhaps we can anticipate users wanting such output. I think cacheing and distributed build tools are the most likely consumers of such information. --Ben