From patchwork Sat Oct 12 20:00:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1175757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510851-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HQmwmI6C"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46rG0j4s38z9sNx for ; Sun, 13 Oct 2019 07:01:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; q=dns; s=default; b=WDI1aLdFJSgjxZnoXrKOKvJ ZXXICTZwMBMmPFen68dfW0XfN0MOPL7iK0CHr7iwkg9u0Y21XLjdAu9djzEzlxL7 OZCcJJnbZcwu8Rm5L4hlhxqOZhtWyQjjZyVYPh0euk0h7fgyiZXiwYPaybW08pFY awgLZUheBa+iLN1hesn8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=default; bh=9Nib/gUM946j8Wz1qyTaBQR20SU=; b= HQmwmI6C/AAsXuI6upJnvQ+dgu8QisFCTB7XjO82YbBD3PWYANIBiCcl35KpQiiC 3ksPLy9dYaLtIw9EfX/QjObxvmdMVCZ7YZ7HbDvRe3FJY7GnjW3VFc8NpktVLsuS 0wJSVZyIPkTLhFVdup2mnwSXINkYYHJyfPS7uuGEN48= Received: (qmail 124273 invoked by alias); 12 Oct 2019 20:00:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 124248 invoked by uid 89); 12 Oct 2019 20:00:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=sk:destruc, H*F:D*uk, HX-Spam-Relays-External:ESMTPA X-HELO: smtp1.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp1.wavenetuk.net) (195.26.36.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Oct 2019 20:00:55 +0000 Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id 8B1E5120059A for ; Sat, 12 Oct 2019 21:00:51 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [Darwin, committed] Suppress emitting empty ctor/dtor sections. Message-Id: <23002353-E54E-40C2-A8FA-026589F8C06D@sandoe.co.uk> Date: Sat, 12 Oct 2019 21:00:48 +0100 To: GCC-patches Older versions of GCC emit empty .constructor/.destructor sections whenever building for C++. In fact, these sections are only used for kernel mode code - so don't emit them unless that's what we're building. tested on x86_64-darwin16, powerpc-darwin9, applied to mainline thanks Iain gcc/ChangeLog: 2019-10-12 Iain Sandoe * config/darwin.c (darwin_file_end): Only emit empty CTOR/DTOR sections when building kernel extension code. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 539ef759d3..ddce9f8c8b 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2931,8 +2931,9 @@ darwin_file_end (void) } machopic_finish (asm_out_file); - if (lang_GNU_CXX ()) + if (flag_apple_kext) { + /* These sections are only used for kernel code. */ switch_to_section (darwin_sections[constructor_section]); switch_to_section (darwin_sections[destructor_section]); ASM_OUTPUT_ALIGN (asm_out_file, 1);