From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 7591D3858025 for ; Wed, 1 Dec 2021 10:25:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7591D3858025 Received: by mail-wm1-x32a.google.com with SMTP id p27-20020a05600c1d9b00b0033bf8532855so745979wms.3 for ; Wed, 01 Dec 2021 02:25:43 -0800 (PST) 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:mime-version :content-disposition; bh=h+IS6WuktGsZ7W4dENTh0KvPvaHQV/yW9ngWJ4rirws=; b=vH2MOkGCn0fBJxVBlm90/9sLAJl3z4Vf69D8Zyl5y8r3oPg5o6EQWf/ykL345THLZC 6cm0IpsMEJ/YPOvJu4CSDI+yjIVERSKbBhl+laFRIV9nDSaoj2BaDP/yoJTGJpm1/ftf EL0fDcP6xcHodGweCTAT/lfRUjRa7moFYCkLTgIyBWBfsT3bKI5z3GhND6mZauwtI5XZ 14gH5IA4hiXAao/lwmNAKQyWs+FySsQe2ROtn9RBauUWRNvK4SNqoskRZEKlrfVowAXP 7qLUeRCwEYVkLy5fRluWDUj6rkJGlbYNgVulRBWAUMs0KhHb6n/2HZJnzCrQH5NHo6WE +o2w== X-Gm-Message-State: AOAM5311nSlD2d3oP6XaFeS8dxf7cJkGLDLIoyLh+AwL1iVCHferySaZ hrgT+m5n09QKh6qpeF3y9Ve899O/rB7123y4 X-Google-Smtp-Source: ABdhPJy5t8aib6I+sTvDIqavj8/U5z7V16t05Km9R4TyWsHKBW3PKap6GJwW43u/0einBr95qHv+gA== X-Received: by 2002:a7b:ca55:: with SMTP id m21mr5774695wml.178.1638354342317; Wed, 01 Dec 2021 02:25:42 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id g5sm25034609wri.45.2021.12.01.02.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 02:25:41 -0800 (PST) Date: Wed, 1 Dec 2021 10:25:40 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Richard Kenner Subject: [Ada] Create object file for ignored ghost compilation unit Message-ID: <20211201102540.GA1635280@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Dec 2021 10:25:45 -0000 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline If the compilation unit we're compiling is an ignored ghost, we need to ensure that an object file is generated. This happens automatically for the GCC backend since it always generates the .o file, but for GNAT LLVM, the backend isn't called. So we need to be sure that we explicitly generate the file. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat1drv.adb (Gnat1drv): Force generation of object file if compilation unit is an ignored ghost. --YiEDa0DAkWCtVeE4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -1415,18 +1415,19 @@ begin if Back_End_Mode = Skip then - -- An ignored Ghost unit is rewritten into a null statement because - -- it must not produce an ALI or object file. Do not emit any errors - -- related to code generation because the unit does not exist. + -- An ignored Ghost unit is rewritten into a null statement. Do + -- not emit any errors related to code generation because the + -- unit does not exist. if Is_Ignored_Ghost_Unit (Main_Unit_Node) then -- Exit the gnat driver with success, otherwise external builders -- such as gnatmake and gprbuild will treat the compilation of an - -- ignored Ghost unit as a failure. Note that this will produce - -- an empty object file for the unit. + -- ignored Ghost unit as a failure. Be sure we produce an empty + -- object file for the unit. Ecode := E_Success; + Back_End.Gen_Or_Update_Object_File; -- Otherwise the unit is missing a crucial piece that prevents code -- generation. --YiEDa0DAkWCtVeE4--