From patchwork Tue Mar 31 13:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1264758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48s99K4ZV8z9sPJ for ; Wed, 1 Apr 2020 00:27:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30BF7385DC09; Tue, 31 Mar 2020 13:27:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cvs.linux-mips.org (eddie.linux-mips.org [148.251.95.138]) by sourceware.org (Postfix) with ESMTP id 6E473385B836 for ; Tue, 31 Mar 2020 13:27:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E473385B836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=macro@linux-mips.org Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S23990413AbgCaN1A4LYuo (ORCPT ); Tue, 31 Mar 2020 15:27:00 +0200 Date: Tue, 31 Mar 2020 14:27:00 +0100 (BST) From: "Maciej W. Rozycki" To: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] PR lto/94249: Correct endianness detection with the __BYTE_ORDER macro In-Reply-To: Message-ID: References: <20200323103505.GF2156@tucnak> <6313e487-6dbb-ac17-4160-4ac600af40be@suse.cz> <7369b1aa-be0d-92cc-4f81-1612f101e2e8@suse.cz> <3786da05-1530-38c5-e9e2-cd69418cd42a@suse.cz> <5b27738a-9885-9906-0c93-888daf4a066f@suse.cz> <20200324083109.GP2156@tucnak> <20200324091805.GQ2156@tucnak> MIME-Version: 1.0 X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Jakub Jelinek , GCC Patches , binutils@sourceware.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Correct an issue with GCC commit 906b3eb9df6c ("Improve endianess detection.") and fix a typo in the __BYTE_ORDER fallback macro check that causes compilation errors like: .../include/plugin-api.h:162:2: error: #error "Could not detect architecture endianess" on systems that do not provide the __BYTE_ORDER__ macro. include/ PR lto/94249 * plugin-api.h: Fix a typo in the __BYTE_ORDER macro check. --- On Tue, 24 Mar 2020, Martin Liška wrote: > >> +/* Detect endianess based on _BYTE_ORDER. */ > >> +#if _BYTE_ORDER == _LITTLE_ENDIAN > > > > So most likely _BYTE_ORDER and _LITTLE_ENDIAN macros will not be defined. > > Which means this will be handled as #if 0 == 0 and override the > >> +#define PLUGIN_LITTLE_ENDIAN 1 > > > > will define also PLUGIN_LITTLE_ENDIAN. > > Ok, for being sure, I've wrapped all equality comparison with corresponding > check of the LHS is defined. This change, when merged into binutils, caused BFD to fail building in one of my configurations: In file included from .../bfd/elflink.c:31: .../bfd/../include/plugin-api.h:162:2: error: #error "Could not detect architecture endianess" make[4]: *** [elflink.lo] Error 1 This is due to a missing underscore in the: #ifdef _BYTE_ORDER check. OK to apply this hopefully obvious fix to GCC and then merge to binutils? NB if posting as an attachment please try matching the message subject with the change heading as otherwise it takes a lot of effort to track the patch submission corresponding to a given commit. Maciej --- include/plugin-api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) binutils-include-plugin-api-byte-order.diff Index: binutils/include/plugin-api.h =================================================================== --- binutils.orig/include/plugin-api.h +++ binutils/include/plugin-api.h @@ -51,7 +51,7 @@ /* Older GCC releases (<4.6.0) can make detection from glibc macros. */ #if defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__ANDROID__) #include -#ifdef _BYTE_ORDER +#ifdef __BYTE_ORDER #if __BYTE_ORDER == __LITTLE_ENDIAN #define PLUGIN_LITTLE_ENDIAN 1 #elif __BYTE_ORDER == __BIG_ENDIAN