From patchwork Wed Dec 1 10:25:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 48336 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A10D3858406 for ; Wed, 1 Dec 2021 10:37:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A10D3858406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638355079; bh=h+IS6WuktGsZ7W4dENTh0KvPvaHQV/yW9ngWJ4rirws=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=pD/K4peltXpUvRZ336cThwasija8zt/4bldE1jjPX3v94YpuhcAcwoZ5vH67bKupd QL2OLrnKM+JM5dM6WG362+muVG9AYlNNgZ5NaMfRe5XOJLOm1N3vgJkOfXh/W24xkY v2771m1uhphM1x4v78kHfwj7HhK+5wfcmBHCuHsk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Create object file for ignored ghost compilation unit Message-ID: <20211201102540.GA1635280@adacore.com> MIME-Version: 1.0 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Richard Kenner Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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.